Author |
Message
|
dinu7102 |
Posted: Sun May 14, 2017 10:53 pm Post subject: each message from one single file |
|
|
Newbie
Joined: 14 May 2017 Posts: 8
|
Hi Friends,
I need your help one below requirement.
I need total count from one single file that how many messages are there in it.For each message the message start with "{" and end with "-}".I need the logic in Esql.
EX : total message count : 3(for below sample)
file format :
{
A1
B1
C1
-}
{
A2
B2
C3
-}
{
A3
B3
C3
-}
thank you |
|
Back to top |
|
 |
Vitor |
Posted: Mon May 15, 2017 4:20 am Post subject: Re: each message from one single file |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
dinu7102 wrote: |
For each message the message start with "{" and end with "-}".I need the logic in Esql. |
Model the message in DFDL. Read the message count provided by the FileInput node using ESQL. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
dinu7102 |
Posted: Mon May 15, 2017 6:22 am Post subject: |
|
|
Newbie
Joined: 14 May 2017 Posts: 8
|
Hi Vitor,
Thank you.
I need to write the code only in compute node because we are not using filenode. |
|
Back to top |
|
 |
Vitor |
Posted: Mon May 15, 2017 6:32 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
dinu7102 wrote: |
I need to write the code only in compute node because we are not using filenode. |
My bad - I was confused by this comment:
dinu7102 wrote: |
I need total count from one single file |
which I misunderstood to mean you were using a file.
If you're not, then you'll need to model the message in DFDL and obtain the cardinality in ESQL. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
dinu7102 |
Posted: Mon May 15, 2017 9:15 am Post subject: |
|
|
Newbie
Joined: 14 May 2017 Posts: 8
|
Thanks Vitor.
already its existing interface.I will try with cardinality.
In casse u know any other logic pls let me know. |
|
Back to top |
|
 |
Vitor |
Posted: Mon May 15, 2017 9:33 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
dinu7102 wrote: |
already its existing interface. |
So you don't need to model it then, do you?
dinu7102 wrote: |
I will try with cardinality. |
"Try"? You think the ESQL function has a bug in it and it might not work?
dinu7102 wrote: |
In casse u know any other logic pls let me know. |
Other than doing it the best way you mean?
Given that you've a) just now said it's an existing interface and b) given no details about how this interface presents the data then it's really hard for me to do your job for you as you ask.
You could probably build some kind of hash map to determine instances. Probably. Depending on how the data's being presented you might have to think carefully about where you're storing it. You of course couldn't use any of the inbuilt facilities for hash maps that Java possesses because you're determined in the face of all sense and reason to do this in ESQL rather than any other way which (glup!) might change an existing interface.
Which you are of course changing by adding logic to count records in a node which is specifically designed to change record content and will require this existing interface to be as fully tested as if you're done this properly. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
dinu7102 |
Posted: Mon May 15, 2017 9:51 am Post subject: |
|
|
Newbie
Joined: 14 May 2017 Posts: 8
|
|
Back to top |
|
 |
dinu7102 |
Posted: Thu May 18, 2017 7:27 am Post subject: |
|
|
Newbie
Joined: 14 May 2017 Posts: 8
|
Hi Vitor,
I had used length and replacing.
DECLARE LENGTH1,LENGTH2 INTEGER;
SET LENGTH1= LENGTH(REPLACE(Orginalmessage, '{ ', ','));
SET LENGTH2 = LENGTH(Orginalmessage)-LENGTH1; |
|
Back to top |
|
 |
Vitor |
Posted: Thu May 18, 2017 7:38 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
dinu7102 wrote: |
I had used length and replacing.
DECLARE LENGTH1,LENGTH2 INTEGER;
SET LENGTH1= LENGTH(REPLACE(Orginalmessage, '{ ', ','));
SET LENGTH2 = LENGTH(Orginalmessage)-LENGTH1; |
Awesome. A massively inefficient way of doing with hand written code to do what IIB will do for you.
(String handling is the most resource expensive part of IIB).
But it's your site, your requirement and go in peace with your solution. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
|