Search in sources :

Example 6 with ReusableRecordsCompositeAllocator

use of org.neo4j.kernel.impl.store.allocator.ReusableRecordsCompositeAllocator in project neo4j by neo4j.

the class DynamicNodeLabels method remove.

@Override
public Collection<DynamicRecord> remove(long labelId, NodeStore nodeStore) {
    nodeStore.ensureHeavy(node, firstDynamicLabelRecordId(node.getLabelField()));
    long[] existingLabelIds = getDynamicLabelsArray(node.getUsedDynamicLabelRecords(), nodeStore.getDynamicLabelStore());
    long[] newLabelIds = filter(existingLabelIds, labelId);
    Collection<DynamicRecord> existingRecords = node.getDynamicLabelRecords();
    if (InlineNodeLabels.tryInlineInNodeRecord(node, newLabelIds, existingRecords)) {
        setNotInUse(existingRecords);
    } else {
        Collection<DynamicRecord> newRecords = allocateRecordsForDynamicLabels(node.getId(), newLabelIds, new ReusableRecordsCompositeAllocator(existingRecords, nodeStore.getDynamicLabelStore()));
        node.setLabelField(dynamicPointer(newRecords), existingRecords);
        if (!newRecords.equals(existingRecords)) {
            // One less dynamic record, mark that one as not in use
            for (DynamicRecord record : existingRecords) {
                if (!newRecords.contains(record)) {
                    record.setInUse(false);
                }
            }
        }
    }
    return existingRecords;
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) ReusableRecordsCompositeAllocator(org.neo4j.kernel.impl.store.allocator.ReusableRecordsCompositeAllocator)

Example 7 with ReusableRecordsCompositeAllocator

use of org.neo4j.kernel.impl.store.allocator.ReusableRecordsCompositeAllocator in project neo4j by neo4j.

the class SchemaStore method allocateFrom.

public List<DynamicRecord> allocateFrom(SchemaRule rule) {
    List<DynamicRecord> records = new ArrayList<>();
    DynamicRecord record = getRecord(rule.getId(), nextRecord(), CHECK);
    DynamicRecordAllocator recordAllocator = new ReusableRecordsCompositeAllocator(singleton(record), this);
    allocateRecordsFromBytes(records, rule.serialize(), recordAllocator);
    return records;
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) ReusableRecordsCompositeAllocator(org.neo4j.kernel.impl.store.allocator.ReusableRecordsCompositeAllocator) ArrayList(java.util.ArrayList)

Example 8 with ReusableRecordsCompositeAllocator

use of org.neo4j.kernel.impl.store.allocator.ReusableRecordsCompositeAllocator in project neo4j by neo4j.

the class DynamicNodeLabels method remove.

@Override
public Collection<DynamicRecord> remove(long labelId, NodeStore nodeStore, CursorContext cursorContext, MemoryTracker memoryTracker) {
    nodeStore.ensureHeavy(node, firstDynamicLabelRecordId(node.getLabelField()), cursorContext);
    long[] existingLabelIds = getDynamicLabelsArray(node.getUsedDynamicLabelRecords(), nodeStore.getDynamicLabelStore(), cursorContext);
    long[] newLabelIds = filter(existingLabelIds, labelId);
    Collection<DynamicRecord> existingRecords = node.getDynamicLabelRecords();
    if (InlineNodeLabels.tryInlineInNodeRecord(node, newLabelIds, existingRecords)) {
        setNotInUse(existingRecords);
    } else {
        Collection<DynamicRecord> newRecords = allocateRecordsForDynamicLabels(node.getId(), newLabelIds, new ReusableRecordsCompositeAllocator(existingRecords, nodeStore.getDynamicLabelStore()), cursorContext, memoryTracker);
        node.setLabelField(dynamicPointer(newRecords), existingRecords);
        if (!newRecords.equals(existingRecords)) {
            // One less dynamic record, mark that one as not in use
            for (DynamicRecord record : existingRecords) {
                if (!newRecords.contains(record)) {
                    record.setInUse(false);
                }
            }
        }
    }
    return existingRecords;
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) ReusableRecordsCompositeAllocator(org.neo4j.kernel.impl.store.allocator.ReusableRecordsCompositeAllocator)

Example 9 with ReusableRecordsCompositeAllocator

use of org.neo4j.kernel.impl.store.allocator.ReusableRecordsCompositeAllocator in project neo4j by neo4j.

the class RecordStorageMigratorIT method allocateFrom.

public static List<DynamicRecord> allocateFrom(SchemaStore35 schemaStore35, SchemaRule rule, CursorContext cursorContext) {
    List<DynamicRecord> records = new ArrayList<>();
    DynamicRecord record = schemaStore35.getRecord(rule.getId(), schemaStore35.newRecord(), CHECK, cursorContext);
    DynamicRecordAllocator recordAllocator = new ReusableRecordsCompositeAllocator(singleton(record), schemaStore35);
    allocateRecordsFromBytes(records, SchemaRuleSerialization35.serialize(rule, INSTANCE), recordAllocator, cursorContext, INSTANCE);
    return records;
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) DynamicRecordAllocator(org.neo4j.kernel.impl.store.DynamicRecordAllocator) ReusableRecordsCompositeAllocator(org.neo4j.kernel.impl.store.allocator.ReusableRecordsCompositeAllocator) ArrayList(java.util.ArrayList)

Aggregations

ReusableRecordsCompositeAllocator (org.neo4j.kernel.impl.store.allocator.ReusableRecordsCompositeAllocator)9 DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)9 ArrayList (java.util.ArrayList)3 DynamicRecordAllocator (org.neo4j.kernel.impl.store.DynamicRecordAllocator)2