public BatchedQuery deriveForMultiBatch(int valueBlock) { if (getBatchSize() != 1) { throw new IllegalStateException("Only the original decorator can be derived."); } if (valueBlock == 1) { return this; } int index = Integer.numberOfTrailingZeros(valueBlock) - 1; if (valueBlock > 128 || valueBlock != (1 << (index + 1))) { throw new IllegalArgumentException( "Expected value block should be a power of 2 smaller or equal to 128. Actual block is " + valueBlock); } if (blocks == null) { blocks = new BatchedQuery[7]; } BatchedQuery bq = blocks[index]; if (bq == null) { bq = new BatchedQuery(this, valueBlock); blocks[index] = bq; } return bq; }
@Override public String toString(ParameterList params) { if (getBatchSize() < 2) { return super.toString(params); } return buildNativeSql(params); }
final int bindCount = originalQuery.getBindCount(); final int highestBlockCount = 128; final int maxValueBlocks = bindCount == 0 ? 1024 /* if no binds, use 1024 rows */ BatchedQuery bq = originalQuery.deriveForMultiBatch(valueBlock); ParameterList newPl = bq.createParameterList(); for (int j = 0; j < valueBlock; j++) { ParameterList pl = batchParameters.get(offset++);
int batchSize = getBatchSize(); if (batchSize < 2) { sql = nativeSql; int[] bindPositions = getNativeQuery().bindPositions; int[] chunkStart = new int[1 + bindPositions.length]; int[] chunkEnd = new int[1 + bindPositions.length];
/** * Method to return the sql based on number of batches. Skipping the initial * batch. */ @Override public String getNativeSql() { if (sql != null) { return sql; } sql = buildNativeSql(null); return sql; }
int valuesBraceClosePosition = firstQuery.getCommand().getBatchRewriteValuesBraceClosePosition(); return new BatchedQuery(firstQuery, this, valuesBraceOpenPosition, valuesBraceClosePosition, isColumnSanitiserDisabled()); } else {