Re: String conversion to Int, float double

2016-03-30 Thread Madhukar Thota
Thanks Joe. I updated my config and not seeing the issue anymore.

On Wed, Mar 30, 2016 at 1:18 PM, Joe Witt <joe.w...@gmail.com> wrote:

> Hello
>
> From your screenshot it shows you have both success and failure
> looping back to Kafka.  Do not loop success and you should be fine.
>
> Thanks
> Joe
>
> On Wed, Mar 30, 2016 at 11:16 AM, Madhukar Thota
> <madhukar.th...@gmail.com> wrote:
> > I was able to construct the Json with right data type output from
> > ExecuteScript and sending to Kafka directly. The problem i am seeing is
> if i
> > send one record to kafka, kafka processor is writing the message again
> and
> > again and not ending the loop. How can i send exactly once message? Any
> > help.
> >
> > Here is what i am doing in my script:
> >
> > import simplejson as json
> > from org.apache.nifi.processor.io import StreamCallback
> > from user_agents import parse
> >
> >
> > def num(s):
> > try:
> > return int(s)
> > except ValueError:
> > try:
> > return float(s)
> > except ValueError:
> > raise ValueError('argument is not a string of number')
> >
> >
> > class PyStreamCallback(StreamCallback):
> > def __init__(self):
> > pass
> >
> > def process(self, inputStream, outputStream):
> > obj = {'browser':
> > str(parse(flowFile.getAttribute('useragent')).browser.family),
> >'browser_version':
> > str(parse(flowFile.getAttribute('useragent')).browser.version_string),
> >'os':
> > str(parse(flowFile.getAttribute('useragent')).os.family),
> >'os_version':
> > str(parse(flowFile.getAttribute('useragent')).os.version_string),
> >'client_ip': flowFile.getAttribute('clientip')}
> >   if flowFile.getAttribute('http.param.t_resp') and
> > flowFile.getAttribute('http.param.t_page') and
> > flowFile.getAttribute('http.param.t_done'):
> > obj['rt_firstbyte'] =
> > num(flowFile.getAttribute('http.param.t_resp'))
> > obj['rt_lastbyte'] =
> > num(flowFile.getAttribute('http.param.t_page'))
> > obj['rt_loadtime'] =
> > num(flowFile.getAttribute('http.param.t_done'))
> >  outputStream.write(bytearray(json.dumps(obj,
> > indent=4).encode('utf-8')))
> >
> >
> > flowFile = session.get()
> > if (flowFile != None):
> > flowFile = session.write(flowFile, PyStreamCallback())
> > session.transfer(flowFile, REL_SUCCESS)
> >
> >
> > Thanks
> >
> > On Tue, Mar 29, 2016 at 2:30 AM, Conrad Crampton
> > <conrad.cramp...@secdata.com> wrote:
> >>
> >> Hi,
> >> Depending on the final destination of the data (json) you could use the
> >> JsonToAvro -> ConvertAvroSchema -> AvroToJson, with the
> ConvertAvroSchema
> >> doing the type conversion. I had to do this as I came across this
> behaviour
> >> previously. I use the Avro directly (after the conversion) as that was
> my
> >> final data format requirement, but I don’t see any reason if you want
> Json
> >> back that this wouldn’t work. I haven’t tried this by the way, but the
> type
> >> conversion certainly works for the final attributes in the Avro
> documents.
> >> Conrad
> >>
> >> From: Madhukar Thota <madhukar.th...@gmail.com>
> >> Reply-To: "users@nifi.apache.org" <users@nifi.apache.org>
> >> Date: Friday, 25 March 2016 at 14:01
> >> To: "users@nifi.apache.org" <users@nifi.apache.org>
> >> Subject: Re: String conversion to Int, float double
> >>
> >> Any Other ways to achieve this?
> >>
> >> On Thu, Mar 24, 2016 at 4:48 PM, Bryan Bende <bbe...@gmail.com> wrote:
> >>>
> >>> I think the problem is that all attributes are actually Strings
> >>> internally, even after calling toNumber() that is only temporary while
> the
> >>> expression language is executing.
> >>>
> >>> So by the time it gets to AttributesToJson it doesn't have any
> >>> information about the type of each attribute and they all end up as
> Strings.
> >>> I think we would have to come up with a way to pass some type
> information
> >>> along to AttributesToJson in order to get something other than Strings.
> >>>
> >>> -Bryan
> >>>
> >>>
> >>> On Thu, Mar 24, 2016 at 3:30 PM, Madhuk

Re: String conversion to Int, float double

2016-03-30 Thread Joe Witt
Hello

>From your screenshot it shows you have both success and failure
looping back to Kafka.  Do not loop success and you should be fine.

Thanks
Joe

On Wed, Mar 30, 2016 at 11:16 AM, Madhukar Thota
<madhukar.th...@gmail.com> wrote:
> I was able to construct the Json with right data type output from
> ExecuteScript and sending to Kafka directly. The problem i am seeing is if i
> send one record to kafka, kafka processor is writing the message again and
> again and not ending the loop. How can i send exactly once message? Any
> help.
>
> Here is what i am doing in my script:
>
> import simplejson as json
> from org.apache.nifi.processor.io import StreamCallback
> from user_agents import parse
>
>
> def num(s):
> try:
> return int(s)
> except ValueError:
> try:
> return float(s)
> except ValueError:
> raise ValueError('argument is not a string of number')
>
>
> class PyStreamCallback(StreamCallback):
> def __init__(self):
> pass
>
> def process(self, inputStream, outputStream):
> obj = {'browser':
> str(parse(flowFile.getAttribute('useragent')).browser.family),
>'browser_version':
> str(parse(flowFile.getAttribute('useragent')).browser.version_string),
>'os':
> str(parse(flowFile.getAttribute('useragent')).os.family),
>'os_version':
> str(parse(flowFile.getAttribute('useragent')).os.version_string),
>'client_ip': flowFile.getAttribute('clientip')}
>   if flowFile.getAttribute('http.param.t_resp') and
> flowFile.getAttribute('http.param.t_page') and
> flowFile.getAttribute('http.param.t_done'):
> obj['rt_firstbyte'] =
> num(flowFile.getAttribute('http.param.t_resp'))
> obj['rt_lastbyte'] =
> num(flowFile.getAttribute('http.param.t_page'))
> obj['rt_loadtime'] =
> num(flowFile.getAttribute('http.param.t_done'))
>  outputStream.write(bytearray(json.dumps(obj,
> indent=4).encode('utf-8')))
>
>
> flowFile = session.get()
> if (flowFile != None):
> flowFile = session.write(flowFile, PyStreamCallback())
> session.transfer(flowFile, REL_SUCCESS)
>
>
> Thanks
>
> On Tue, Mar 29, 2016 at 2:30 AM, Conrad Crampton
> <conrad.cramp...@secdata.com> wrote:
>>
>> Hi,
>> Depending on the final destination of the data (json) you could use the
>> JsonToAvro -> ConvertAvroSchema -> AvroToJson, with the ConvertAvroSchema
>> doing the type conversion. I had to do this as I came across this behaviour
>> previously. I use the Avro directly (after the conversion) as that was my
>> final data format requirement, but I don’t see any reason if you want Json
>> back that this wouldn’t work. I haven’t tried this by the way, but the type
>> conversion certainly works for the final attributes in the Avro documents.
>> Conrad
>>
>> From: Madhukar Thota <madhukar.th...@gmail.com>
>> Reply-To: "users@nifi.apache.org" <users@nifi.apache.org>
>> Date: Friday, 25 March 2016 at 14:01
>> To: "users@nifi.apache.org" <users@nifi.apache.org>
>> Subject: Re: String conversion to Int, float double
>>
>> Any Other ways to achieve this?
>>
>> On Thu, Mar 24, 2016 at 4:48 PM, Bryan Bende <bbe...@gmail.com> wrote:
>>>
>>> I think the problem is that all attributes are actually Strings
>>> internally, even after calling toNumber() that is only temporary while the
>>> expression language is executing.
>>>
>>> So by the time it gets to AttributesToJson it doesn't have any
>>> information about the type of each attribute and they all end up as Strings.
>>> I think we would have to come up with a way to pass some type information
>>> along to AttributesToJson in order to get something other than Strings.
>>>
>>> -Bryan
>>>
>>>
>>> On Thu, Mar 24, 2016 at 3:30 PM, Madhukar Thota
>>> <madhukar.th...@gmail.com> wrote:
>>>>
>>>> Hi i am trying to convert string value to integer in UpdateAtrributes
>>>> using toNumber like this
>>>>
>>>>
>>>> ${http.param.t_resp:toNumber()}  where http.param.t_resp = "132"
>>>>
>>>> but when the fileattribute pushed to Attributetojson processor , i am
>>>> stilling seeing it as string. Am i am doing something wrong? and also how
>>>> can i convert string to float?
>>>>
>>>>
>>>>
>>>>
>>>
>>
>>
>>
>> ***This email originated 

Re: String conversion to Int, float double

2016-03-30 Thread Madhukar Thota
I was able to construct the Json with right data type output from
ExecuteScript and sending to Kafka directly. The problem i am seeing is if
i send one record to kafka, kafka processor is writing the message again
and again and not ending the loop. How can i send exactly once message? Any
help.

Here is what i am doing in my script:

import simplejson as json
from org.apache.nifi.processor.io import StreamCallback
from user_agents import parse


def num(s):
try:
return int(s)
except ValueError:
try:
return float(s)
except ValueError:
raise ValueError('argument is not a string of number')


class PyStreamCallback(StreamCallback):
def __init__(self):
pass

def process(self, inputStream, outputStream):
obj = {'browser':
str(parse(flowFile.getAttribute('useragent')).browser.family),
   'browser_version':
str(parse(flowFile.getAttribute('useragent')).browser.version_string),
   'os':
str(parse(flowFile.getAttribute('useragent')).os.family),
   'os_version':
str(parse(flowFile.getAttribute('useragent')).os.version_string),
   'client_ip': flowFile.getAttribute('clientip')}
  if flowFile.getAttribute('http.param.t_resp') and
flowFile.getAttribute('http.param.t_page') and
flowFile.getAttribute('http.param.t_done'):
obj['rt_firstbyte'] =
num(flowFile.getAttribute('http.param.t_resp'))
obj['rt_lastbyte'] =
num(flowFile.getAttribute('http.param.t_page'))
obj['rt_loadtime'] =
num(flowFile.getAttribute('http.param.t_done'))
 outputStream.write(bytearray(json.dumps(obj,
indent=4).encode('utf-8')))


flowFile = session.get()
if (flowFile != None):
flowFile = session.write(flowFile, PyStreamCallback())
session.transfer(flowFile, REL_SUCCESS)


Thanks

On Tue, Mar 29, 2016 at 2:30 AM, Conrad Crampton <
conrad.cramp...@secdata.com> wrote:

> Hi,
> Depending on the final destination of the data (json) you could use the
> JsonToAvro -> ConvertAvroSchema -> AvroToJson, with the ConvertAvroSchema
> doing the type conversion. I had to do this as I came across this behaviour
> previously. I use the Avro directly (after the conversion) as that was my
> final data format requirement, but I don’t see any reason if you want Json
> back that this wouldn’t work. I haven’t tried this by the way, but the type
> conversion certainly works for the final attributes in the Avro documents.
> Conrad
>
> From: Madhukar Thota <madhukar.th...@gmail.com>
> Reply-To: "users@nifi.apache.org" <users@nifi.apache.org>
> Date: Friday, 25 March 2016 at 14:01
> To: "users@nifi.apache.org" <users@nifi.apache.org>
> Subject: Re: String conversion to Int, float double
>
> Any Other ways to achieve this?
>
> On Thu, Mar 24, 2016 at 4:48 PM, Bryan Bende <bbe...@gmail.com> wrote:
>
>> I think the problem is that all attributes are actually Strings
>> internally, even after calling toNumber() that is only temporary while the
>> expression language is executing.
>>
>> So by the time it gets to AttributesToJson it doesn't have any
>> information about the type of each attribute and they all end up as
>> Strings. I think we would have to come up with a way to pass some type
>> information along to AttributesToJson in order to get something other than
>> Strings.
>>
>> -Bryan
>>
>>
>> On Thu, Mar 24, 2016 at 3:30 PM, Madhukar Thota <madhukar.th...@gmail.com
>> > wrote:
>>
>>> Hi i am trying to convert string value to integer in UpdateAtrributes
>>> using toNumber like this
>>>
>>>
>>> ${http.param.t_resp:toNumber()}  where http.param.t_resp = "132"
>>>
>>> but when the fileattribute pushed to Attributetojson processor , i am
>>> stilling seeing it as string. Am i am doing something wrong? and also how
>>> can i convert string to float?
>>>
>>>
>>>
>>>
>>>
>>
>
>
> ***This email originated outside SecureData***
>
> Click here <https://www.mailcontrol.com/sr/MZbqvYs5QwJvpeaetUwhCQ==> to
> report this email as spam.
>
>
> SecureData, combating cyber threats
>
> --
>
> The information contained in this message or any of its attachments may be
> privileged and confidential and intended for the exclusive use of the
> intended recipient. If you are not the intended recipient any disclosure,
> reproduction, distribution or other dissemination or use of this
> communications is strictly prohibited. The views expressed in this email
> are those of the individual and not necessarily of SecureData Europe Ltd.
> Any prices quoted are only valid if followed up by a formal written quote.
>
> SecureData Europe Limited. Registered in England & Wales 04365896.
> Registered Address: SecureData House, Hermitage Court, Hermitage Lane,
> Maidstone, Kent, ME16 9NT
>


Re: String conversion to Int, float double

2016-03-28 Thread Matt Burgess
Sounds good to me. I presume the processor would still put all attributes in 
the JSON content, but would use any dynamic properties solely for type 
coercion? Anything not listed would be treated like a String as it is now (to 
preserve current behavior).

We'd need to document the possible values and/or offer a PropertyDescriptor in 
getSupportedDynamicPropertyDescriptors()for a drop-down of valid values.


> On Mar 28, 2016, at 2:23 PM, Joe Witt  wrote:
> 
> Madhu
> 
> No i do not believe that it does.  I am proposing we make this change
> so that you can handle this case.  Just looking for feedback on
> whether people like that approach or have a better method.
> 
> Thanks
> Joe
> 
> On Mon, Mar 28, 2016 at 11:36 AM, Madhukar Thota
>  wrote:
>> Hi Joe,
>> 
>> is this dynamic Property works today with AttributesToJSON today?
>> 
>> property name: rt_firstbyte
>>  property value: Integer
>> 
>> -Madhu
>> 
>>> On Sat, Mar 26, 2016 at 1:13 PM, Joe Witt  wrote:
>>> 
>>> What Madhukar is trying to do seems totally reasonable.  As an
>>> alternative to Bryan's proposal what do you all think about updating
>>> the behavior of AttributesToJSON to allow the user to suggest the type
>>> information they would like for a given attribute?  It's default
>>> behavior is as is which is it will encode it as a string but I'm
>>> suggesting the user be able to list certain attribute names as dynamic
>>> properties and their desired serialized type as the value of that
>>> property.  So for instance he could add a dynamic property to
>>> AttributesToJSON which would be
>>> 
>>>  property name: rt_firstbyte
>>>  property value: Integer
>>> 
>>> If any of the supplied type hints result in conversion failures then
>>> we route to failure.
>>> 
>>> Thanks
>>> Joe
>>> 
 On Fri, Mar 25, 2016 at 12:59 PM, Bryan Bende  wrote:
 Depending how many attributes you are dealing with, a possible work
 around
 could be to construct the JSON with a ReplaceText text processor.
 
 If you have ReplaceText after your UpdateAttribute, you could set the
 Replacement Value to a String like:
 
 { "rt_firstbyte" : ${http.param.t_resp},  "rt_lastbyte" :
 ${http.param.t_page}, "rt_loadtime" :  ${http.param.t_done} }
 
 In the long-term, maybe AttributesToJson could follow a convention where
 it
 looks for optional attributes that have the same name as another
 attribute,
 but end with have ".type" ?
 
 So in your example there would be:
 
 rt_firstbyte ${http.param.t_resp}
 rt_firstbyte.type int
 
 If it doesn't find a type attribute then it defaults to String as it
 does
 today.
 Just an idea of how we can provide type information, I'm sure there are
 other options too.
 
 -Bryan
 
 On Fri, Mar 25, 2016 at 12:07 PM, Madhukar Thota
 
 wrote:
> 
> Joe,
> 
> I attached the screenshot for UpdateAttributes and AttributesToJson.
> Please let me know if this is not something your are looking for.
> 
>> On Fri, Mar 25, 2016 at 11:58 AM, Joe Witt  wrote:
>> 
>> Ok and can you share the config settings you have in Attributes to
>> JSON  at this time?  We do need to make changes for this probably but
>> want to understand what will be a good path forward.
>> 
>> On Fri, Mar 25, 2016 at 9:49 AM, Madhukar Thota
>>  wrote:
>>> Hi Joe,
>>> 
>>> In my UpdateAtrribute, i am converting the  string values to Number
>>> like
>>> this:
>>> 
>>> rt_firstbyte ${http.param.t_resp:toNumber()}
>>> rt_lastbyte  ${http.param.t_page:toNumber()}
>>> rt_loadtime  ${http.param.t_done:toNumber()}
>>> 
>>> when i pass this attribute to AttributeToJson processor, the type
>>> should be
>>> properly serialized but here is what i am getting from
>>> AttributeToJson
>>> processor
>>> 
>>> 
>>> 
>>> {"rt_loadtime":"260","rt_firstbyte":"20","referrer":"http://localhost:63342/Beacon/test.html","rt_lastbyte":"240"}
>>> 
>>> This what i expect
>>> 
>>> 
>>> 
>>> {"rt_loadtime":260,"rt_firstbyte":20,"referrer":"http://localhost:63342/Beacon/test.html","rt_lastbyte":240}
>>> 
>>> Thanks
>>> 
>>> On Fri, Mar 25, 2016 at 10:47 AM, Joe Witt 
>>> wrote:
 
 Chase,
 
 To unsubscribe send an e-mail here
 users-unsubscr...@nifi.apache.org
 
 Madhukar,
 
 As Bryan mentioned attributes are always serialized as Strings.
 Their
 type is really a function of when they are being evaluated/used.
 Can
 you describe a bit more about what you'd like AttributesToJson to
 do
 with a given attribute that is of type 

Re: String conversion to Int, float double

2016-03-28 Thread Joe Witt
Madhu

No i do not believe that it does.  I am proposing we make this change
so that you can handle this case.  Just looking for feedback on
whether people like that approach or have a better method.

Thanks
Joe

On Mon, Mar 28, 2016 at 11:36 AM, Madhukar Thota
 wrote:
> Hi Joe,
>
> is this dynamic Property works today with AttributesToJSON today?
>
>  property name: rt_firstbyte
>   property value: Integer
>
> -Madhu
>
> On Sat, Mar 26, 2016 at 1:13 PM, Joe Witt  wrote:
>>
>> What Madhukar is trying to do seems totally reasonable.  As an
>> alternative to Bryan's proposal what do you all think about updating
>> the behavior of AttributesToJSON to allow the user to suggest the type
>> information they would like for a given attribute?  It's default
>> behavior is as is which is it will encode it as a string but I'm
>> suggesting the user be able to list certain attribute names as dynamic
>> properties and their desired serialized type as the value of that
>> property.  So for instance he could add a dynamic property to
>> AttributesToJSON which would be
>>
>>   property name: rt_firstbyte
>>   property value: Integer
>>
>> If any of the supplied type hints result in conversion failures then
>> we route to failure.
>>
>> Thanks
>> Joe
>>
>> On Fri, Mar 25, 2016 at 12:59 PM, Bryan Bende  wrote:
>> > Depending how many attributes you are dealing with, a possible work
>> > around
>> > could be to construct the JSON with a ReplaceText text processor.
>> >
>> > If you have ReplaceText after your UpdateAttribute, you could set the
>> > Replacement Value to a String like:
>> >
>> > { "rt_firstbyte" : ${http.param.t_resp},  "rt_lastbyte" :
>> > ${http.param.t_page}, "rt_loadtime" :  ${http.param.t_done} }
>> >
>> > In the long-term, maybe AttributesToJson could follow a convention where
>> > it
>> > looks for optional attributes that have the same name as another
>> > attribute,
>> > but end with have ".type" ?
>> >
>> > So in your example there would be:
>> >
>> > rt_firstbyte ${http.param.t_resp}
>> > rt_firstbyte.type int
>> >
>> > If it doesn't find a type attribute then it defaults to String as it
>> > does
>> > today.
>> > Just an idea of how we can provide type information, I'm sure there are
>> > other options too.
>> >
>> > -Bryan
>> >
>> > On Fri, Mar 25, 2016 at 12:07 PM, Madhukar Thota
>> > 
>> > wrote:
>> >>
>> >> Joe,
>> >>
>> >> I attached the screenshot for UpdateAttributes and AttributesToJson.
>> >> Please let me know if this is not something your are looking for.
>> >>
>> >> On Fri, Mar 25, 2016 at 11:58 AM, Joe Witt  wrote:
>> >>>
>> >>> Ok and can you share the config settings you have in Attributes to
>> >>> JSON  at this time?  We do need to make changes for this probably but
>> >>> want to understand what will be a good path forward.
>> >>>
>> >>> On Fri, Mar 25, 2016 at 9:49 AM, Madhukar Thota
>> >>>  wrote:
>> >>> > Hi Joe,
>> >>> >
>> >>> > In my UpdateAtrribute, i am converting the  string values to Number
>> >>> > like
>> >>> > this:
>> >>> >
>> >>> > rt_firstbyte ${http.param.t_resp:toNumber()}
>> >>> > rt_lastbyte  ${http.param.t_page:toNumber()}
>> >>> > rt_loadtime  ${http.param.t_done:toNumber()}
>> >>> >
>> >>> > when i pass this attribute to AttributeToJson processor, the type
>> >>> > should be
>> >>> > properly serialized but here is what i am getting from
>> >>> > AttributeToJson
>> >>> > processor
>> >>> >
>> >>> >
>> >>> >
>> >>> > {"rt_loadtime":"260","rt_firstbyte":"20","referrer":"http://localhost:63342/Beacon/test.html","rt_lastbyte":"240"}
>> >>> >
>> >>> > This what i expect
>> >>> >
>> >>> >
>> >>> >
>> >>> > {"rt_loadtime":260,"rt_firstbyte":20,"referrer":"http://localhost:63342/Beacon/test.html","rt_lastbyte":240}
>> >>> >
>> >>> > Thanks
>> >>> >
>> >>> > On Fri, Mar 25, 2016 at 10:47 AM, Joe Witt 
>> >>> > wrote:
>> >>> >>
>> >>> >> Chase,
>> >>> >>
>> >>> >> To unsubscribe send an e-mail here
>> >>> >> users-unsubscr...@nifi.apache.org
>> >>> >>
>> >>> >> Madhukar,
>> >>> >>
>> >>> >> As Bryan mentioned attributes are always serialized as Strings.
>> >>> >> Their
>> >>> >> type is really a function of when they are being evaluated/used.
>> >>> >> Can
>> >>> >> you describe a bit more about what you'd like AttributesToJson to
>> >>> >> do
>> >>> >> with a given attribute that is of type Int/Long/etc..?
>> >>> >>
>> >>> >> Thanks
>> >>> >> Joe
>> >>> >>
>> >>> >>
>> >>> >>
>> >>> >> On Fri, Mar 25, 2016 at 8:01 AM, Chase Cunningham
>> >>> >> 
>> >>> >> wrote:
>> >>> >> > unsubscribe
>> >>> >> >
>> >>> >> >
>> >>> >> > On 3/25/16 9:01 AM, Madhukar Thota wrote:
>> >>> >> >
>> >>> >> > Any Other ways to achieve this?
>> >>> >> >
>> >>> >> > On Thu, Mar 24, 2016 at 4:48 PM, Bryan Bende 
>> >>> >> > wrote:
>> >>> >> >>
>> >>> >> >> I think the problem is that all attributes are 

Re: String conversion to Int, float double

2016-03-28 Thread Madhukar Thota
Hi Joe,

is this dynamic Property works today with AttributesToJSON today?

 property name: rt_firstbyte
  property value: Integer

-Madhu

On Sat, Mar 26, 2016 at 1:13 PM, Joe Witt  wrote:

> What Madhukar is trying to do seems totally reasonable.  As an
> alternative to Bryan's proposal what do you all think about updating
> the behavior of AttributesToJSON to allow the user to suggest the type
> information they would like for a given attribute?  It's default
> behavior is as is which is it will encode it as a string but I'm
> suggesting the user be able to list certain attribute names as dynamic
> properties and their desired serialized type as the value of that
> property.  So for instance he could add a dynamic property to
> AttributesToJSON which would be
>
>   property name: rt_firstbyte
>   property value: Integer
>
> If any of the supplied type hints result in conversion failures then
> we route to failure.
>
> Thanks
> Joe
>
> On Fri, Mar 25, 2016 at 12:59 PM, Bryan Bende  wrote:
> > Depending how many attributes you are dealing with, a possible work
> around
> > could be to construct the JSON with a ReplaceText text processor.
> >
> > If you have ReplaceText after your UpdateAttribute, you could set the
> > Replacement Value to a String like:
> >
> > { "rt_firstbyte" : ${http.param.t_resp},  "rt_lastbyte" :
> > ${http.param.t_page}, "rt_loadtime" :  ${http.param.t_done} }
> >
> > In the long-term, maybe AttributesToJson could follow a convention where
> it
> > looks for optional attributes that have the same name as another
> attribute,
> > but end with have ".type" ?
> >
> > So in your example there would be:
> >
> > rt_firstbyte ${http.param.t_resp}
> > rt_firstbyte.type int
> >
> > If it doesn't find a type attribute then it defaults to String as it does
> > today.
> > Just an idea of how we can provide type information, I'm sure there are
> > other options too.
> >
> > -Bryan
> >
> > On Fri, Mar 25, 2016 at 12:07 PM, Madhukar Thota <
> madhukar.th...@gmail.com>
> > wrote:
> >>
> >> Joe,
> >>
> >> I attached the screenshot for UpdateAttributes and AttributesToJson.
> >> Please let me know if this is not something your are looking for.
> >>
> >> On Fri, Mar 25, 2016 at 11:58 AM, Joe Witt  wrote:
> >>>
> >>> Ok and can you share the config settings you have in Attributes to
> >>> JSON  at this time?  We do need to make changes for this probably but
> >>> want to understand what will be a good path forward.
> >>>
> >>> On Fri, Mar 25, 2016 at 9:49 AM, Madhukar Thota
> >>>  wrote:
> >>> > Hi Joe,
> >>> >
> >>> > In my UpdateAtrribute, i am converting the  string values to Number
> >>> > like
> >>> > this:
> >>> >
> >>> > rt_firstbyte ${http.param.t_resp:toNumber()}
> >>> > rt_lastbyte  ${http.param.t_page:toNumber()}
> >>> > rt_loadtime  ${http.param.t_done:toNumber()}
> >>> >
> >>> > when i pass this attribute to AttributeToJson processor, the type
> >>> > should be
> >>> > properly serialized but here is what i am getting from
> AttributeToJson
> >>> > processor
> >>> >
> >>> >
> >>> > {"rt_loadtime":"260","rt_firstbyte":"20","referrer":"
> http://localhost:63342/Beacon/test.html","rt_lastbyte":"240"}
> >>> >
> >>> > This what i expect
> >>> >
> >>> >
> >>> > {"rt_loadtime":260,"rt_firstbyte":20,"referrer":"
> http://localhost:63342/Beacon/test.html","rt_lastbyte":240}
> >>> >
> >>> > Thanks
> >>> >
> >>> > On Fri, Mar 25, 2016 at 10:47 AM, Joe Witt 
> wrote:
> >>> >>
> >>> >> Chase,
> >>> >>
> >>> >> To unsubscribe send an e-mail here
> users-unsubscr...@nifi.apache.org
> >>> >>
> >>> >> Madhukar,
> >>> >>
> >>> >> As Bryan mentioned attributes are always serialized as Strings.
> Their
> >>> >> type is really a function of when they are being evaluated/used.
> Can
> >>> >> you describe a bit more about what you'd like AttributesToJson to do
> >>> >> with a given attribute that is of type Int/Long/etc..?
> >>> >>
> >>> >> Thanks
> >>> >> Joe
> >>> >>
> >>> >>
> >>> >>
> >>> >> On Fri, Mar 25, 2016 at 8:01 AM, Chase Cunningham <
> ch...@thecynja.com>
> >>> >> wrote:
> >>> >> > unsubscribe
> >>> >> >
> >>> >> >
> >>> >> > On 3/25/16 9:01 AM, Madhukar Thota wrote:
> >>> >> >
> >>> >> > Any Other ways to achieve this?
> >>> >> >
> >>> >> > On Thu, Mar 24, 2016 at 4:48 PM, Bryan Bende 
> >>> >> > wrote:
> >>> >> >>
> >>> >> >> I think the problem is that all attributes are actually Strings
> >>> >> >> internally, even after calling toNumber() that is only temporary
> >>> >> >> while
> >>> >> >> the
> >>> >> >> expression language is executing.
> >>> >> >>
> >>> >> >> So by the time it gets to AttributesToJson it doesn't have any
> >>> >> >> information
> >>> >> >> about the type of each attribute and they all end up as Strings.
> I
> >>> >> >> think we
> >>> >> >> would have to come up with a way to pass some type information
> >>> >> >> along to
> >>> >> >> AttributesToJson in 

Re: String conversion to Int, float double

2016-03-25 Thread Madhukar Thota
Hi Joe,

In my UpdateAtrribute, i am converting the  string values to Number like
this:

rt_firstbyte ${http.param.t_resp:toNumber()}
rt_lastbyte  ${http.param.t_page:toNumber()}
rt_loadtime  ${http.param.t_done:toNumber()}

when i pass this attribute to AttributeToJson processor, the type should be
properly serialized but here is what i am getting from  AttributeToJson
processor

{"rt_loadtime":"260","rt_firstbyte":"20","referrer":"
http://localhost:63342/Beacon/test.html","rt_lastbyte":"240"}

This what i expect

{"rt_loadtime":*260*,"rt_firstbyte":*20*,"referrer":"
http://localhost:63342/Beacon/test.html","rt_lastbyte":*240*}

Thanks

On Fri, Mar 25, 2016 at 10:47 AM, Joe Witt  wrote:

> Chase,
>
> To unsubscribe send an e-mail here users-unsubscr...@nifi.apache.org
>
> Madhukar,
>
> As Bryan mentioned attributes are always serialized as Strings.  Their
> type is really a function of when they are being evaluated/used.  Can
> you describe a bit more about what you'd like AttributesToJson to do
> with a given attribute that is of type Int/Long/etc..?
>
> Thanks
> Joe
>
>
>
> On Fri, Mar 25, 2016 at 8:01 AM, Chase Cunningham 
> wrote:
> > unsubscribe
> >
> >
> > On 3/25/16 9:01 AM, Madhukar Thota wrote:
> >
> > Any Other ways to achieve this?
> >
> > On Thu, Mar 24, 2016 at 4:48 PM, Bryan Bende  wrote:
> >>
> >> I think the problem is that all attributes are actually Strings
> >> internally, even after calling toNumber() that is only temporary while
> the
> >> expression language is executing.
> >>
> >> So by the time it gets to AttributesToJson it doesn't have any
> information
> >> about the type of each attribute and they all end up as Strings. I
> think we
> >> would have to come up with a way to pass some type information along to
> >> AttributesToJson in order to get something other than Strings.
> >>
> >> -Bryan
> >>
> >>
> >> On Thu, Mar 24, 2016 at 3:30 PM, Madhukar Thota <
> madhukar.th...@gmail.com>
> >> wrote:
> >>>
> >>> Hi i am trying to convert string value to integer in UpdateAtrributes
> >>> using toNumber like this
> >>>
> >>>
> >>> ${http.param.t_resp:toNumber()}  where http.param.t_resp = "132"
> >>>
> >>> but when the fileattribute pushed to Attributetojson processor , i am
> >>> stilling seeing it as string. Am i am doing something wrong? and also
> how
> >>> can i convert string to float?
> >>>
> >>>
> >>>
> >>>
> >>
> >
> >
> > --
> > Dr. Chase C Cunningham
> > CTRC (SW) USN Ret.
> > The Cynja LLC Proprietary Business and Technical Information
> > CONFIDENTIAL TREATMENT REQUIRED
>


Re: String conversion to Int, float double

2016-03-25 Thread Joe Witt
Chase,

To unsubscribe send an e-mail here users-unsubscr...@nifi.apache.org

Madhukar,

As Bryan mentioned attributes are always serialized as Strings.  Their
type is really a function of when they are being evaluated/used.  Can
you describe a bit more about what you'd like AttributesToJson to do
with a given attribute that is of type Int/Long/etc..?

Thanks
Joe



On Fri, Mar 25, 2016 at 8:01 AM, Chase Cunningham  wrote:
> unsubscribe
>
>
> On 3/25/16 9:01 AM, Madhukar Thota wrote:
>
> Any Other ways to achieve this?
>
> On Thu, Mar 24, 2016 at 4:48 PM, Bryan Bende  wrote:
>>
>> I think the problem is that all attributes are actually Strings
>> internally, even after calling toNumber() that is only temporary while the
>> expression language is executing.
>>
>> So by the time it gets to AttributesToJson it doesn't have any information
>> about the type of each attribute and they all end up as Strings. I think we
>> would have to come up with a way to pass some type information along to
>> AttributesToJson in order to get something other than Strings.
>>
>> -Bryan
>>
>>
>> On Thu, Mar 24, 2016 at 3:30 PM, Madhukar Thota 
>> wrote:
>>>
>>> Hi i am trying to convert string value to integer in UpdateAtrributes
>>> using toNumber like this
>>>
>>>
>>> ${http.param.t_resp:toNumber()}  where http.param.t_resp = "132"
>>>
>>> but when the fileattribute pushed to Attributetojson processor , i am
>>> stilling seeing it as string. Am i am doing something wrong? and also how
>>> can i convert string to float?
>>>
>>>
>>>
>>>
>>
>
>
> --
> Dr. Chase C Cunningham
> CTRC (SW) USN Ret.
> The Cynja LLC Proprietary Business and Technical Information
> CONFIDENTIAL TREATMENT REQUIRED


Re: String conversion to Int, float double

2016-03-25 Thread Chase Cunningham

unsubscribe

On 3/25/16 9:01 AM, Madhukar Thota wrote:

Any Other ways to achieve this?

On Thu, Mar 24, 2016 at 4:48 PM, Bryan Bende > wrote:


I think the problem is that all attributes are actually Strings
internally, even after calling toNumber() that is only temporary
while the expression language is executing.

So by the time it gets to AttributesToJson it doesn't have any
information about the type of each attribute and they all end up
as Strings. I think we would have to come up with a way to pass
some type information along to AttributesToJson in order to get
something other than Strings.

-Bryan


On Thu, Mar 24, 2016 at 3:30 PM, Madhukar Thota
> wrote:

Hi i am trying to convert string value to integer in
UpdateAtrributes using toNumber like this


${http.param.t_resp:toNumber()}  where http.param.t_resp = "132"

but when the fileattribute pushed to Attributetojson processor
, i am stilling seeing it as string. Am i am doing something
wrong? and also how can i convert string to float?








--
Dr. Chase C Cunningham
CTRC (SW) USN Ret.
The Cynja LLC Proprietary Business and Technical Information
CONFIDENTIAL TREATMENT REQUIRED



Re: String conversion to Int, float double

2016-03-25 Thread Madhukar Thota
Any Other ways to achieve this?

On Thu, Mar 24, 2016 at 4:48 PM, Bryan Bende  wrote:

> I think the problem is that all attributes are actually Strings
> internally, even after calling toNumber() that is only temporary while the
> expression language is executing.
>
> So by the time it gets to AttributesToJson it doesn't have any information
> about the type of each attribute and they all end up as Strings. I think we
> would have to come up with a way to pass some type information along to
> AttributesToJson in order to get something other than Strings.
>
> -Bryan
>
>
> On Thu, Mar 24, 2016 at 3:30 PM, Madhukar Thota 
> wrote:
>
>> Hi i am trying to convert string value to integer in UpdateAtrributes
>> using toNumber like this
>>
>>
>> ${http.param.t_resp:toNumber()}  where http.param.t_resp = "132"
>>
>> but when the fileattribute pushed to Attributetojson processor , i am
>> stilling seeing it as string. Am i am doing something wrong? and also how
>> can i convert string to float?
>>
>>
>>
>>
>>
>


Re: String conversion to Int, float double

2016-03-24 Thread Bryan Bende
I think the problem is that all attributes are actually Strings internally,
even after calling toNumber() that is only temporary while the expression
language is executing.

So by the time it gets to AttributesToJson it doesn't have any information
about the type of each attribute and they all end up as Strings. I think we
would have to come up with a way to pass some type information along to
AttributesToJson in order to get something other than Strings.

-Bryan


On Thu, Mar 24, 2016 at 3:30 PM, Madhukar Thota 
wrote:

> Hi i am trying to convert string value to integer in UpdateAtrributes
> using toNumber like this
>
>
> ${http.param.t_resp:toNumber()}  where http.param.t_resp = "132"
>
> but when the fileattribute pushed to Attributetojson processor , i am
> stilling seeing it as string. Am i am doing something wrong? and also how
> can i convert string to float?
>
>
>
>
>


String conversion to Int, float double

2016-03-24 Thread Madhukar Thota
Hi i am trying to convert string value to integer in UpdateAtrributes using
toNumber like this


${http.param.t_resp:toNumber()}  where http.param.t_resp = "132"

but when the fileattribute pushed to Attributetojson processor , i am
stilling seeing it as string. Am i am doing something wrong? and also how
can i convert string to float?