use of org.neo4j.kernel.impl.store.allocator.ReusableRecordsCompositeAllocator in project neo4j by neo4j.
the class DynamicNodeLabels method putSorted.
public static Collection<DynamicRecord> putSorted(NodeRecord node, long[] labelIds, NodeStore nodeStore, DynamicRecordAllocator allocator) {
long existingLabelsField = node.getLabelField();
long existingLabelsBits = parseLabelsBody(existingLabelsField);
Collection<DynamicRecord> changedDynamicRecords = node.getDynamicLabelRecords();
long labelField = node.getLabelField();
if (fieldPointsToDynamicRecordOfLabels(labelField)) {
// There are existing dynamic label records, get them
nodeStore.ensureHeavy(node, existingLabelsBits);
changedDynamicRecords = node.getDynamicLabelRecords();
setNotInUse(changedDynamicRecords);
}
if (!InlineNodeLabels.tryInlineInNodeRecord(node, labelIds, changedDynamicRecords)) {
Iterator<DynamicRecord> recycledRecords = changedDynamicRecords.iterator();
Collection<DynamicRecord> allocatedRecords = allocateRecordsForDynamicLabels(node.getId(), labelIds, new ReusableRecordsCompositeAllocator(recycledRecords, allocator));
// Set the rest of the previously set dynamic records as !inUse
while (recycledRecords.hasNext()) {
DynamicRecord removedRecord = recycledRecords.next();
removedRecord.setInUse(false);
allocatedRecords.add(removedRecord);
}
node.setLabelField(dynamicPointer(allocatedRecords), allocatedRecords);
changedDynamicRecords = allocatedRecords;
}
return changedDynamicRecords;
}
use of org.neo4j.kernel.impl.store.allocator.ReusableRecordsCompositeAllocator in project neo4j by neo4j.
the class SchemaStore35Test method allocateFrom.
public List<DynamicRecord> allocateFrom(SchemaRule rule, CursorContext cursorContext) {
List<DynamicRecord> records = new ArrayList<>();
DynamicRecord record = store.getRecord(rule.getId(), store.newRecord(), CHECK, cursorContext);
DynamicRecordAllocator recordAllocator = new ReusableRecordsCompositeAllocator(singleton(record), store);
allocateRecordsFromBytes(records, SchemaRuleSerialization35.serialize(rule, INSTANCE), recordAllocator, cursorContext, INSTANCE);
return records;
}
use of org.neo4j.kernel.impl.store.allocator.ReusableRecordsCompositeAllocator in project neo4j by neo4j.
the class DynamicNodeLabels method add.
@Override
public Collection<DynamicRecord> add(long labelId, NodeStore nodeStore, DynamicRecordAllocator allocator, CursorContext cursorContext, MemoryTracker memoryTracker) {
nodeStore.ensureHeavy(node, firstDynamicLabelRecordId(node.getLabelField()), cursorContext);
long[] existingLabelIds = getDynamicLabelsArray(node.getUsedDynamicLabelRecords(), nodeStore.getDynamicLabelStore(), cursorContext);
long[] newLabelIds = LabelIdArray.concatAndSort(existingLabelIds, labelId);
Collection<DynamicRecord> existingRecords = node.getDynamicLabelRecords();
Collection<DynamicRecord> changedDynamicRecords = allocateRecordsForDynamicLabels(node.getId(), newLabelIds, new ReusableRecordsCompositeAllocator(existingRecords, allocator), cursorContext, memoryTracker);
node.setLabelField(dynamicPointer(changedDynamicRecords), changedDynamicRecords);
return changedDynamicRecords;
}
use of org.neo4j.kernel.impl.store.allocator.ReusableRecordsCompositeAllocator in project neo4j by neo4j.
the class DynamicNodeLabels method putSorted.
static Collection<DynamicRecord> putSorted(NodeRecord node, long[] labelIds, NodeStore nodeStore, DynamicRecordAllocator allocator, CursorContext cursorContext, MemoryTracker memoryTracker) {
long existingLabelsField = node.getLabelField();
long existingLabelsBits = parseLabelsBody(existingLabelsField);
Collection<DynamicRecord> changedDynamicRecords = node.getDynamicLabelRecords();
long labelField = node.getLabelField();
if (fieldPointsToDynamicRecordOfLabels(labelField)) {
// There are existing dynamic label records, get them
nodeStore.ensureHeavy(node, existingLabelsBits, cursorContext);
changedDynamicRecords = node.getDynamicLabelRecords();
setNotInUse(changedDynamicRecords);
}
if (!InlineNodeLabels.tryInlineInNodeRecord(node, labelIds, changedDynamicRecords)) {
Iterator<DynamicRecord> recycledRecords = changedDynamicRecords.iterator();
Collection<DynamicRecord> allocatedRecords = allocateRecordsForDynamicLabels(node.getId(), labelIds, new ReusableRecordsCompositeAllocator(recycledRecords, allocator), cursorContext, memoryTracker);
// Set the rest of the previously set dynamic records as !inUse
while (recycledRecords.hasNext()) {
DynamicRecord removedRecord = recycledRecords.next();
removedRecord.setInUse(false);
allocatedRecords.add(removedRecord);
}
node.setLabelField(dynamicPointer(allocatedRecords), allocatedRecords);
changedDynamicRecords = allocatedRecords;
}
return changedDynamicRecords;
}
use of org.neo4j.kernel.impl.store.allocator.ReusableRecordsCompositeAllocator in project neo4j by neo4j.
the class DynamicNodeLabels method add.
@Override
public Collection<DynamicRecord> add(long labelId, NodeStore nodeStore, DynamicRecordAllocator allocator) {
nodeStore.ensureHeavy(node, firstDynamicLabelRecordId(node.getLabelField()));
long[] existingLabelIds = getDynamicLabelsArray(node.getUsedDynamicLabelRecords(), nodeStore.getDynamicLabelStore());
long[] newLabelIds = LabelIdArray.concatAndSort(existingLabelIds, labelId);
Collection<DynamicRecord> existingRecords = node.getDynamicLabelRecords();
Collection<DynamicRecord> changedDynamicRecords = allocateRecordsForDynamicLabels(node.getId(), newLabelIds, new ReusableRecordsCompositeAllocator(existingRecords, allocator));
node.setLabelField(dynamicPointer(changedDynamicRecords), changedDynamicRecords);
return changedDynamicRecords;
}
Aggregations