if (buffer == null) {
buffer = getBufferManager().createTupleBuffer(intoElements, getConnectionID(), TupleSourceType.PROCESSOR);
}
buffer.addTupleBatch(currentBatch, true);
if (currentBatch.getTerminationFlag() && (buffer.getRowCount() != 0 || intoGroup.isImplicitTempGroupSymbol())) {
Insert insert = new Insert(intoGroup, intoElements, null);
buffer.close();
insert.setTupleSource(buffer.createIndexedTupleSource(true));
// Register insert command against source
registerRequest(insert);
} else {
requests = 0;
}
break;
case BULK:
//convert to multivalued parameter
List<Constant> parameters = new ArrayList<Constant>(intoElements.size());
for (int i = 0; i < intoElements.size(); i++) {
Constant value = new Constant(null, ((ElementSymbol)intoElements.get(i)).getType());
value.setMultiValued(new ArrayList<Object>(currentBatch.getTuples().size()));
parameters.add(value);
}
for (List row : currentBatch.getTuples()) {
for (int i = 0; i < row.size(); i++) {
((List<Object>)parameters.get(i).getValue()).add(row.get(i));
}
}
// Create a bulk insert command batching all rows in the current batch.
Insert insert = new Insert(intoGroup, intoElements, parameters);
// Register insert command against source
registerRequest(insert);
break;
case BATCH:
// Register batched update command against source
int endRow = currentBatch.getEndRow();
List rows = new ArrayList(endRow-batchRow);
for(int rowNum = batchRow; rowNum <= endRow; rowNum++) {
insert = new Insert( intoGroup,
intoElements,
convertValuesToConstants(currentBatch.getTuple(rowNum), intoElements));
rows.add( insert );
}
registerRequest(new BatchedUpdateCommand( rows ));
break;
case SINGLE:
batchSize = 1;
// Register insert command against source
// Defect 16036 - submit a new INSERT command to the DataManager.
registerRequest(new Insert(intoGroup, intoElements, convertValuesToConstants(currentBatch.getTuple(batchRow), intoElements)));
}
this.batchRow += batchSize;
if (batchRow > currentBatch.getEndRow()) {
currentBatch = null;