|
From Emmanuel Bernard in PR #501:
For the record, here is an idea that would potentially limit pressure on memory.
Create an Operations object that stores the necessary data representing applied operations in a (set of) array.
class Operations implements Iterable<GridDialectOperation> { Object[] state = new Object[100]; //todo make it a set of arrays to scale on big lists int index = 0; int numberOfOperations = 0; applyOperation(OperationType operationType, Object... operationState) { // todo use the Slf4J trick with overloaded methods (OT) (OT, O), (OT, O,O), (OT, O,O, O...) state[index++] = operationType; for(Object object : operationState)
Unknown macro: { state[index++] = object; }
numberOfOperations++; }
int getNumberOfOperations()
Unknown macro: { return numberOfOperations; }
// todo iterable / iterator implementation
private GridDialectOperation getOperation(index startOfState) { OperationType operationType = (OperationType) state[startOfState++]; if ( operationType == INSERT_OR_UPDATE_TUPLE)
Unknown macro: { return new InsertOrUpdateTupleImpl(state, startOfState); }
// todo other operationType
}
We would only instantiate the applied operation objects when the user needs them.
|