Author |
Message
|
scravr |
Posted: Mon May 21, 2012 6:41 am Post subject: c plugin |
|
|
 Partisan
Joined: 03 Apr 2003 Posts: 391 Location: NY NY USA 10021
|
HI to All,
In c pluging I am trying read a file and return 1 rec at a time.
Trying to read next record where left file-pointer on prev call to function, and avoid re-open file every time.
In "evaluate" do I need to keep
static FILE *FilePtr;
or save the pointer in NODE_CONTEXT ?
How do I caonvert file pointer to CNI_TYPE_?????
Thanks,
MA |
|
Back to top |
|
 |
Vitor |
Posted: Mon May 21, 2012 6:55 am Post subject: Re: c plugin |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
scravr wrote: |
In c pluging I am trying read a file and return 1 rec at a time. |
And you can't use the inbuilt file nodes because....?
scravr wrote: |
Trying to read next record where left file-pointer on prev call to function, and avoid re-open file every time. |
I'm unconvinced you can. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
scravr |
Posted: Mon May 21, 2012 6:59 am Post subject: |
|
|
 Partisan
Joined: 03 Apr 2003 Posts: 391 Location: NY NY USA 10021
|
1. Will "static FILE *fp" be kept between c-plugin node iterations?
2. How can I convert *fp and keep in "NODE_CONTEXT????" |
|
Back to top |
|
 |
mqjeff |
Posted: Mon May 21, 2012 7:02 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
Why, exactly, are you using the C APIs to do this? |
|
Back to top |
|
 |
scravr |
Posted: Mon May 21, 2012 7:08 am Post subject: |
|
|
 Partisan
Joined: 03 Apr 2003 Posts: 391 Location: NY NY USA 10021
|
trying to get better performance.
File-Read node is very slow. |
|
Back to top |
|
 |
Vitor |
Posted: Mon May 21, 2012 7:26 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
scravr wrote: |
File-Read node is very slow. |
No it isn't. Especially as it's doing what you're trying to code (or will end up coding).
Also if you're repeatedly reading the same file why not use the FileInput node? FileRead is intended to pick a single record out of a file rather than do repeated reads (which may be why you're finding it slow). _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
Vitor |
Posted: Mon May 21, 2012 7:28 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
scravr wrote: |
1. Will "static FILE *fp" be kept between c-plugin node iterations? |
I don't believe so. I'd certainly hate to rely on it
scravr wrote: |
2. How can I convert *fp and keep in "NODE_CONTEXT????" |
I don't believe you can.
Others with more plugin experience may wish to correct me. I'd use the built-ins for this. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
mqjeff |
Posted: Mon May 21, 2012 7:32 am Post subject: |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 17447
|
It's going to be relatively easier to code this in Java than in C.
The C node API does run in a C++ context, so you can indeed create your own C++ object to hold all the things you need, but you still need to be aware of which instance of your object is tied to which instance of the message flow that's being invoked from the evaluate().
The C++ implementation will indeed run faster than java, but unless you're trying to process millions of records a second, it's not likely you'll see a measurable gain using C++. If you are trying to process millions of records a second, you shouldn't be writing them to a file in the first place. |
|
Back to top |
|
 |
scravr |
Posted: Mon May 21, 2012 8:02 am Post subject: |
|
|
 Partisan
Joined: 03 Apr 2003 Posts: 391 Location: NY NY USA 10021
|
Dose anyone have a sample of how to get & set values to/from env.var. elaments passed from ESQL? |
|
Back to top |
|
 |
scravr |
Posted: Mon May 21, 2012 8:19 am Post subject: |
|
|
 Partisan
Joined: 03 Apr 2003 Posts: 391 Location: NY NY USA 10021
|
does c has similare function to JAVA's getFirstElementByPath ? |
|
Back to top |
|
 |
|