Joss, you were right. Look at these numbers:
BEFORE: Processed 608K of EDI data in 50.811 sec (717K/min)
AFTER: Processed 608K of EDI data in 29.441 sec (1.23MB/min)
Your Vector approach saved 21.37 sec – 42% less time to execute the same transaction!
Here is the code that I am now using:
[begin code for Java Service “buildVector”]
boolean isFound = false;
// pipeline
IDataHashCursor pipelineCursor = pipeline.getHashCursor();
pipelineCursor.first( “vectorECS” );
Vector vECS = (Vector) pipelineCursor.getValue();
pipelineCursor.first( “vectorCC” );
Vector vCC = (Vector) pipelineCursor.getValue();
pipelineCursor.first( “currencyCode” );
//This is the currency code of the EDI segment in this iteration over the loop of EDIValues
String currencyCode = (String) pipelineCursor.getValue();
pipelineCursor.first( “string” );
//This is the entire EDI segment in this iteration over the loop of EDIValues
String string = (String) pipelineCursor.getValue();
ListIterator vCCIterator = vCC.listIterator();
int i = 0;
loop: while ( vCCIterator.hasNext() ) {
if ( vCCIterator.next().equals(currencyCode) ) {
StringBuffer s = new StringBuffer( (vECS.get(i).toString() ) );
s.append(string);
vECS.set(i, s);
isFound = true;
break loop;
}
i++;
}
if (isFound == false) {
vECS.addElement(string);
vCC.addElement(currencyCode);
}
// pipeline
pipelineCursor.last();
pipelineCursor.insertAfter(“vectorECS”, vECS );
pipelineCursor.last();
pipelineCursor.insertAfter(“vectorCC”, vCC );
pipelineCursor.destroy();
[end code for Java Service “buildVector”]
Later, I build a String object from the Vector for EDI use. That code looks like this:
[begin code for Java service “buildStringFromVector”]
// pipeline
IDataHashCursor pipelineCursor = pipeline.getHashCursor();
pipelineCursor.first( “vectorECS” );
Vector vECS = (Vector) pipelineCursor.getValue();
pipelineCursor.destroy();
ListIterator vECSIterator = vECS.listIterator();
int j= 0;
StringBuffer sbECS = new StringBuffer ();
while ( vECSIterator.hasNext() ) {
vECSIterator.next();
sbECS.append (vECS.get(j).toString() );
j++;
}
String stringECS = sbECS.toString();
// pipeline
IDataHashCursor pipelineCursor_1 = pipeline.getHashCursor();
pipelineCursor_1.last();
pipelineCursor_1.insertAfter( “stringECS”, stringECS );
pipelineCursor_1.destroy();
[end code for Java service “buildStringFromVector”]
Thanks so much for your help.