Results 1 to 5 of 5

Thread: Multiple Input Reader Java Node

  1. #1

    Question Multiple Input Reader Java Node

    How to read two input in Java Node?
    The example that are referenced shows how to read data by RecordMetadata for single input.
    In reference the processAll(), to read all the data input, we iterate by calling numInputs().
    How can I differentiate the two input in my Java Node?

  2. #2
    Lavastorm Employee
    Join Date
    Aug 2009



    The example in the Java Node Getting started Guide shows a case where you keep reading data until the data from all inputs is complete using:

    for (int i=0; i<numInputs();i++) { 
    Record record = read(i);
    This is just incrementing an index (i) and reading data from the input at that index.

    So from this you can see to read from the ith input (0-indexed), you use read(i).
    If you wanted to read a record from the first input, this would be read(0);
    If you wanted to read a record from the second input, this would be read(1);

    All of the input based operations are done using the 0-based index of the input.
    In order to get the RecordInput object itself - from which you can get the metadata etc - you can use input(inputIndex)

    Section 4 "Handling Node Input" of the Java Node Getting Started guide talks about different input operations that can be performed using the Java Node API.

    As mentioned in section 4.2, if you want to locate the index of an input based on the name of the input:

    ...the index of an input or output can be found using the findInput and findOutput methods respectively as defined on the Node interface.
    The API documentation is also available in javadoc format in your client installation under docs\laeJavaApi\


  3. #3


    It worked.
    Thanks Tim.

    How to reset the Record after I reach the EOF? I want to read the file for every iteration.
    I don't want to start a new thread.
    Please check the code below

    			allDone = true;
    			Record searchRecord = read(0);
    			if (searchRecord != RecordInput.EOF) {
    				allDone = false;					
    				String searchData = searchRecord.field(0).toString();
    				logger().warn("F --"+searchData);    //Print for checking data
    				boolean checkDone = false;
    					checkDone = true;
    					Record sr = read(1);
    						checkDone = false;
    						for(int i = 0; i<inSecondRecMeta.numFields();i++){
    							logger().warn("V - "+sampleRecord.field(i).toString());  //For checking the data
    How to reset the sampleRecord for nested loop, because it is already at the EOF, for the next of the loop?

  4. #4
    Lavastorm Employee
    Join Date
    Aug 2009



    There isn't anyway to reset the input to read the data from the first record again.
    The reason for this is that while the node API obscures this, the data coming in the input doesn't need to be from a file or from something that is complete at the time of reading.
    Rather, if you are running the LAE using the external controller (or with a BRX/LXA) and using streaming mode, the data could be coming directly from an upstream node as that node is processing records.
    In the current implementation of that streaming mechanism, the upstream node would communicate via a socket connection to the downstream node, so it needs the downstream node to consume the data before it continues. There would also be no way to reset the streamed data and tell the upstream node to start sending records again.

    There are ideas about enhancing this to allow for a multi-pass input or something similar which would further mask the streaming behavior, meaning that you could reset and start reading from the first record again (or "mark" the input, and reset to the marked position) - however that is not currently available.

    Instead, you would need to save off the records you have processed to a temporary file.
    In order to do this you should look at section 9.1.3 of the Java Node Getting Started Guide - "Writing to External BRD Files" - which will allow you to construct a record output.
    You can then use the RecordOutput to write the records to a temp directory location (look at the information on the fileManager in section 9.1) you could then construct a RecordInput over that location to be able to reprocess the records when you need to reset.

    Hope this helps somewhat.


  5. #5


    Thanks Tim,
    Storing it in temporary location and reusing it worked

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts