Search in sources :

Example 51 with DynamicRecord

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

the class PhysicalLogCommandReaderV3_0_2 method readRelationshipTypeTokenRecord.

private RelationshipTypeTokenRecord readRelationshipTypeTokenRecord(int id, ReadableChannel channel) throws IOException {
    // in_use(byte)+type_blockId(int)+nr_type_records(int)
    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 record;
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) RelationshipTypeTokenRecord(org.neo4j.kernel.impl.store.record.RelationshipTypeTokenRecord) IOException(java.io.IOException)

Example 52 with DynamicRecord

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

the class PhysicalLogCommandReaderV2_2 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 53 with DynamicRecord

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

the class PhysicalLogCommandReaderV2_2_10 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)

Example 54 with DynamicRecord

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

the class PhysicalLogCommandReaderV2_2_10 method readPropertyRecord.

private PropertyRecord readPropertyRecord(long id, ReadableChannel channel) throws IOException {
    // in_use(byte)+type(int)+key_indexId(int)+prop_blockId(long)+
    // prev_prop_id(long)+next_prop_id(long)
    PropertyRecord record = new PropertyRecord(id);
    // 1
    byte inUseFlag = channel.get();
    // 8
    long nextProp = channel.getLong();
    // 8
    long prevProp = channel.getLong();
    record.setNextProp(nextProp);
    record.setPrevProp(prevProp);
    boolean inUse = false;
    if ((inUseFlag & Record.IN_USE.byteValue()) == Record.IN_USE.byteValue()) {
        inUse = true;
    }
    boolean nodeProperty = true;
    if ((inUseFlag & Record.REL_PROPERTY.byteValue()) == Record.REL_PROPERTY.byteValue()) {
        nodeProperty = false;
    }
    // 8
    long primitiveId = channel.getLong();
    if (primitiveId != -1 && nodeProperty) {
        record.setNodeId(primitiveId);
    } else if (primitiveId != -1) {
        record.setRelId(primitiveId);
    }
    int nrPropBlocks = channel.get();
    assert nrPropBlocks >= 0;
    if (nrPropBlocks > 0) {
        record.setInUse(true);
    }
    while (nrPropBlocks-- > 0) {
        PropertyBlock block = readPropertyBlock(channel);
        if (block == null) {
            return null;
        }
        record.addPropertyBlock(block);
    }
    int deletedRecords = readDynamicRecords(channel, record, PROPERTY_DELETED_DYNAMIC_RECORD_ADDER);
    if (deletedRecords == -1) {
        return null;
    }
    assert deletedRecords >= 0;
    while (deletedRecords-- > 0) {
        DynamicRecord read = readDynamicRecord(channel);
        if (read == null) {
            return null;
        }
        record.addDeletedRecord(read);
    }
    if ((inUse && !record.inUse()) || (!inUse && record.inUse())) {
        throw new IllegalStateException("Weird, inUse was read in as " + inUse + " but the record is " + record);
    }
    return record;
}
Also used : DynamicRecord(org.neo4j.kernel.impl.store.record.DynamicRecord) PropertyRecord(org.neo4j.kernel.impl.store.record.PropertyRecord) PropertyBlock(org.neo4j.kernel.impl.store.record.PropertyBlock)

Example 55 with DynamicRecord

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

the class PhysicalLogCommandReaderV2_2_10 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)

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