Search in sources :

Example 61 with DynamicRecord

use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.

the class PhysicalLogCommandReaderV2_2_4 method visitSchemaRuleCommand.

private Command visitSchemaRuleCommand(ReadableChannel channel) throws IOException {
    Collection<DynamicRecord> recordsBefore = new ArrayList<>();
    readDynamicRecords(channel, recordsBefore, COLLECTION_DYNAMIC_RECORD_ADDER);
    Collection<DynamicRecord> recordsAfter = new ArrayList<>();
    readDynamicRecords(channel, recordsAfter, COLLECTION_DYNAMIC_RECORD_ADDER);
    byte isCreated = channel.get();
    if (1 == isCreated) {
        for (DynamicRecord record : recordsAfter) {
            record.setCreated();
        }
    }
    SchemaRule rule = Iterables.first(recordsAfter).inUse() ? readSchemaRule(recordsAfter) : readSchemaRule(recordsBefore);
    return new Command.SchemaRuleCommand(recordsBefore, recordsAfter, rule);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) ArrayList(java.util.ArrayList) SchemaRule(org.neo4j.storageengine.api.schema.SchemaRule)

Example 62 with DynamicRecord

use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.

the class PhysicalLogCommandReaderV3_0 method visitSchemaRuleCommand.

private Command visitSchemaRuleCommand(ReadableChannel channel) throws IOException {
    Collection<DynamicRecord> recordsBefore = new ArrayList<>();
    readDynamicRecords(channel, recordsBefore, COLLECTION_DYNAMIC_RECORD_ADDER);
    Collection<DynamicRecord> recordsAfter = new ArrayList<>();
    readDynamicRecords(channel, recordsAfter, COLLECTION_DYNAMIC_RECORD_ADDER);
    byte isCreated = channel.get();
    if (1 == isCreated) {
        for (DynamicRecord record : recordsAfter) {
            record.setCreated();
        }
    }
    SchemaRule rule = Iterables.first(recordsAfter).inUse() ? readSchemaRule(recordsAfter) : readSchemaRule(recordsBefore);
    return new Command.SchemaRuleCommand(recordsBefore, recordsAfter, rule);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) ArrayList(java.util.ArrayList) SchemaRule(org.neo4j.storageengine.api.schema.SchemaRule)

Example 63 with DynamicRecord

use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.

the class PhysicalLogCommandReaderV3_0 method readNodeRecord.

private NodeRecord readNodeRecord(long id, ReadableChannel channel) throws IOException {
    byte flags = channel.get();
    boolean inUse = bitFlag(flags, Record.IN_USE.byteValue());
    boolean requiresSecondaryUnit = bitFlag(flags, Record.REQUIRE_SECONDARY_UNIT);
    boolean hasSecondaryUnit = bitFlag(flags, Record.HAS_SECONDARY_UNIT);
    NodeRecord record;
    Collection<DynamicRecord> dynamicLabelRecords = new ArrayList<>();
    long labelField = Record.NO_LABELS_FIELD.intValue();
    if (inUse) {
        boolean dense = channel.get() == 1;
        record = new NodeRecord(id, dense, channel.getLong(), channel.getLong());
        // labels
        labelField = channel.getLong();
        record.setRequiresSecondaryUnit(requiresSecondaryUnit);
        if (hasSecondaryUnit) {
            record.setSecondaryUnitId(channel.getLong());
        }
    } else {
        record = new NodeRecord(id);
    }
    readDynamicRecords(channel, dynamicLabelRecords, COLLECTION_DYNAMIC_RECORD_ADDER);
    record.setLabelField(labelField, dynamicLabelRecords);
    record.setInUse(inUse);
    return record;
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) ArrayList(java.util.ArrayList)

Example 64 with DynamicRecord

use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.

the class PhysicalLogCommandReaderV3_0 method readDynamicRecords.

private <T> int readDynamicRecords(ReadableChannel channel, T target, DynamicRecordAdder<T> adder) throws IOException {
    int numberOfRecords = channel.getInt();
    assert numberOfRecords >= 0;
    while (numberOfRecords > 0) {
        DynamicRecord read = readDynamicRecord(channel);
        if (read == null) {
            return -1;
        }
        adder.add(target, read);
        numberOfRecords--;
    }
    return numberOfRecords;
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord)

Example 65 with DynamicRecord

use of org.neo4j.kernel.impl.store.record.DynamicRecord in project neo4j by neo4j.

the class NodeStoreTest method shouldMarkRecordHeavyWhenSettingLabelFieldWithDynamicRecords.

@Test
public void shouldMarkRecordHeavyWhenSettingLabelFieldWithDynamicRecords() throws Exception {
    // GIVEN
    NodeRecord record = new NodeRecord(0, false, NO_NEXT_RELATIONSHIP.intValue(), NO_NEXT_PROPERTY.intValue());
    // WHEN
    DynamicRecord dynamicRecord = new DynamicRecord(1);
    record.setLabelField(0x8000000001L, asList(dynamicRecord));
    // THEN
    assertFalse(record.isLight());
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) NodeRecord(org.neo4j.kernel.impl.store.record.NodeRecord) Test(org.junit.Test)

Aggregations

DynamicRecord (org.neo4j.kernel.impl.store.record.DynamicRecord)225 Test (org.junit.Test)117 ConsistencyReport (org.neo4j.consistency.report.ConsistencyReport)51 NodeRecord (org.neo4j.kernel.impl.store.record.NodeRecord)38 ArrayList (java.util.ArrayList)32 PropertyKeyTokenRecord (org.neo4j.kernel.impl.store.record.PropertyKeyTokenRecord)28 LabelTokenRecord (org.neo4j.kernel.impl.store.record.LabelTokenRecord)23 IndexRule (org.neo4j.kernel.impl.store.record.IndexRule)21 PropertyRecord (org.neo4j.kernel.impl.store.record.PropertyRecord)21 IOException (java.io.IOException)20 RecordAccessStub (org.neo4j.consistency.store.RecordAccessStub)16 ReusableRecordsAllocator (org.neo4j.kernel.impl.store.allocator.ReusableRecordsAllocator)16 ConstraintRule (org.neo4j.kernel.impl.store.record.ConstraintRule)16 PropertyBlock (org.neo4j.kernel.impl.store.record.PropertyBlock)16 GraphStoreFixture (org.neo4j.consistency.checking.GraphStoreFixture)15 IdGenerator (org.neo4j.consistency.checking.GraphStoreFixture.IdGenerator)15 TransactionDataBuilder (org.neo4j.consistency.checking.GraphStoreFixture.TransactionDataBuilder)15 SchemaIndexProvider (org.neo4j.kernel.api.index.SchemaIndexProvider)15 ConsistencySummaryStatistics (org.neo4j.consistency.report.ConsistencySummaryStatistics)14 RelationshipTypeTokenRecord (org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord)14