use of org.neo4j.kernel.impl.transaction.state.PropertyCreator in project neo4j by neo4j.
the class PropertyEncoderStep method process.
@Override
protected void process(Batch<INPUT, RECORD> batch, BatchSender sender) {
RelativeIdRecordAllocator stringAllocator = new RelativeIdRecordAllocator(stringDataSize);
RelativeIdRecordAllocator arrayAllocator = new RelativeIdRecordAllocator(arrayDataSize);
PropertyCreator propertyCreator = new PropertyCreator(stringAllocator, arrayAllocator, null, null);
int blockCountGuess = (int) averageBlocksPerBatch.average();
PropertyBlock[] propertyBlocks = new PropertyBlock[blockCountGuess == 0 ? batch.input.length : blockCountGuess + batch.input.length / 20];
int blockCursor = 0;
int[] lengths = new int[batch.input.length];
for (int i = 0; i < batch.input.length; i++) {
stringAllocator.initialize();
arrayAllocator.initialize();
INPUT input = batch.input[i];
if (!input.hasFirstPropertyId()) {
// Encode the properties and attach the blocks to the BatchEntity.
// Dynamic records for each entity will start from 0, they will be reassigned later anyway
int count = input.properties().length >> 1;
if (blockCursor + count > propertyBlocks.length) {
propertyBlocks = copyOf(propertyBlocks, max(propertyBlocks.length << 1, blockCursor + count));
}
propertyKeyHolder.propertyKeysAndValues(propertyBlocks, blockCursor, input.properties(), propertyCreator);
lengths[i] = count;
blockCursor += count;
}
}
batch.propertyBlocks = propertyBlocks;
batch.propertyBlocksLengths = lengths;
averageBlocksPerBatch.add(blockCursor);
sender.send(batch);
}
Aggregations