Search in sources :

Example 56 with DynamicRecord

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

the class PhysicalLogCommandReaderV2_2_10 method visitLabelTokenCommand.

private Command visitLabelTokenCommand(ReadableChannel channel) throws IOException {
    // id+in_use(byte)+type_blockId(int)+nr_type_records(int)
    int id = channel.getInt();
    byte inUseFlag = channel.get();
    boolean inUse = false;
    if ((inUseFlag & Record.IN_USE.byteValue()) == Record.IN_USE.byteValue()) {
        inUse = true;
    } else if (inUseFlag != Record.NOT_IN_USE.byteValue()) {
        throw new IOException("Illegal in use flag: " + inUseFlag);
    }
    LabelTokenRecord record = new LabelTokenRecord(id);
    record.setInUse(inUse);
    record.setNameId(channel.getInt());
    int nrTypeRecords = channel.getInt();
    for (int i = 0; i < nrTypeRecords; i++) {
        DynamicRecord dr = readDynamicRecord(channel);
        if (dr == null) {
            return null;
        }
        record.addNameRecord(dr);
    }
    return new Command.LabelTokenCommand(null, record);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) IOException(java.io.IOException) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord)

Example 57 with DynamicRecord

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

the class PhysicalLogCommandReaderV2_2_4 method visitLabelTokenCommand.

private Command visitLabelTokenCommand(ReadableChannel channel) throws IOException {
    // id+in_use(byte)+type_blockId(int)+nr_type_records(int)
    int id = channel.getInt();
    byte inUseFlag = channel.get();
    boolean inUse = false;
    if ((inUseFlag & Record.IN_USE.byteValue()) == Record.IN_USE.byteValue()) {
        inUse = true;
    } else if (inUseFlag != Record.NOT_IN_USE.byteValue()) {
        throw new IOException("Illegal in use flag: " + inUseFlag);
    }
    LabelTokenRecord record = new LabelTokenRecord(id);
    record.setInUse(inUse);
    record.setNameId(channel.getInt());
    int nrTypeRecords = channel.getInt();
    for (int i = 0; i < nrTypeRecords; i++) {
        DynamicRecord dr = readDynamicRecord(channel);
        if (dr == null) {
            return null;
        }
        record.addNameRecord(dr);
    }
    return new Command.LabelTokenCommand(null, record);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) IOException(java.io.IOException) LabelTokenRecord(org.neo4j.kernel.impl.store.record.LabelTokenRecord)

Example 58 with DynamicRecord

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

the class PhysicalLogCommandReaderV2_2_4 method readNodeRecord.

private NodeRecord readNodeRecord(long id, ReadableChannel channel) throws IOException {
    byte inUseFlag = channel.get();
    boolean inUse = false;
    if (inUseFlag == Record.IN_USE.byteValue()) {
        inUse = true;
    } else if (inUseFlag != Record.NOT_IN_USE.byteValue()) {
        throw new IOException("Illegal in use flag: " + inUseFlag);
    }
    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();
    } 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) IOException(java.io.IOException)

Example 59 with DynamicRecord

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

the class PhysicalLogCommandReaderV2_2_4 method visitRelationshipTypeTokenCommand.

private Command visitRelationshipTypeTokenCommand(ReadableChannel channel) throws IOException {
    // id+in_use(byte)+type_blockId(int)+nr_type_records(int)
    int id = channel.getInt();
    byte inUseFlag = channel.get();
    boolean inUse = false;
    if ((inUseFlag & Record.IN_USE.byteValue()) == Record.IN_USE.byteValue()) {
        inUse = true;
    } else if (inUseFlag != Record.NOT_IN_USE.byteValue()) {
        throw new IOException("Illegal in use flag: " + inUseFlag);
    }
    RelationshipTypeTokenRecord record = new RelationshipTypeTokenRecord(id);
    record.setInUse(inUse);
    record.setNameId(channel.getInt());
    int nrTypeRecords = channel.getInt();
    for (int i = 0; i < nrTypeRecords; i++) {
        DynamicRecord dr = readDynamicRecord(channel);
        if (dr == null) {
            return null;
        }
        record.addNameRecord(dr);
    }
    return new Command.RelationshipTypeTokenCommand(null, record);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) RelationshipTypeTokenRecord(org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord) IOException(java.io.IOException)

Example 60 with DynamicRecord

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

the class PhysicalLogCommandReaderV2_2_4 method readDynamicRecord.

private DynamicRecord readDynamicRecord(ReadableChannel channel) throws IOException {
    // id+type+in_use(byte)+nr_of_bytes(int)+next_block(long)
    long id = channel.getLong();
    assert id >= 0 && id <= (1L << 36) - 1 : id + " is not a valid dynamic record id";
    int type = channel.getInt();
    byte inUseFlag = channel.get();
    boolean inUse = (inUseFlag & Record.IN_USE.byteValue()) != 0;
    DynamicRecord record = new DynamicRecord(id);
    record.setInUse(inUse, type);
    if (inUse) {
        record.setStartRecord((inUseFlag & Record.FIRST_IN_CHAIN.byteValue()) != 0);
        int nrOfBytes = channel.getInt();
        assert nrOfBytes >= 0 && nrOfBytes < ((1 << 24) - 1) : nrOfBytes + " is not valid for a number of bytes field of " + "a dynamic record";
        long nextBlock = channel.getLong();
        assert (nextBlock >= 0 && nextBlock <= (1L << 36 - 1)) || (nextBlock == Record.NO_NEXT_BLOCK.intValue()) : nextBlock + " is not valid for a next record field of " + "a dynamic record";
        record.setNextBlock(nextBlock);
        byte[] data = new byte[nrOfBytes];
        channel.get(data, nrOfBytes);
        record.setData(data);
    }
    return record;
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord)

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