Search in sources :

Example 1 with XaCommand

use of org.neo4j.kernel.impl.transaction.xaframework.XaCommand in project graphdb by neo4j-attic.

the class DumpLogicalLog method readPropertyIndexCommand.

static XaCommand readPropertyIndexCommand(ReadableByteChannel byteChannel, ByteBuffer buffer) throws IOException {
    // id+in_use(byte)+count(int)+key_blockId(int)+nr_key_records(int)
    buffer.clear();
    buffer.limit(17);
    if (byteChannel.read(buffer) != buffer.limit()) {
        return null;
    }
    buffer.flip();
    int id = buffer.getInt();
    byte inUseFlag = buffer.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);
    }
    PropertyIndexRecord record = new PropertyIndexRecord(id);
    record.setInUse(inUse);
    record.setPropertyCount(buffer.getInt());
    record.setKeyBlockId(buffer.getInt());
    int nrKeyRecords = buffer.getInt();
    for (int i = 0; i < nrKeyRecords; i++) {
        DynamicRecord dr = readDynamicRecord(byteChannel, buffer);
        if (dr == null) {
            return null;
        }
        record.addKeyRecord(dr);
    }
    return new Command(record);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.nioneo.store.DynamicRecord) XaCommand(org.neo4j.kernel.impl.transaction.xaframework.XaCommand) PropertyIndexRecord(org.neo4j.kernel.impl.nioneo.store.PropertyIndexRecord) IOException(java.io.IOException)

Example 2 with XaCommand

use of org.neo4j.kernel.impl.transaction.xaframework.XaCommand in project graphdb by neo4j-attic.

the class DumpLogicalLog method readRelationshipCommand.

static XaCommand readRelationshipCommand(ReadableByteChannel byteChannel, ByteBuffer buffer) throws IOException {
    buffer.clear();
    buffer.limit(9);
    if (byteChannel.read(buffer) != buffer.limit()) {
        return null;
    }
    buffer.flip();
    long id = buffer.getLong();
    byte inUseFlag = buffer.get();
    boolean inUse = false;
    if ((inUseFlag & Record.IN_USE.byteValue()) == Record.IN_USE.byteValue()) {
        inUse = true;
    } else if ((inUseFlag & Record.IN_USE.byteValue()) != Record.NOT_IN_USE.byteValue()) {
        throw new IOException("Illegal in use flag: " + inUseFlag);
    }
    RelationshipRecord record;
    if (inUse) {
        buffer.clear();
        buffer.limit(52);
        if (byteChannel.read(buffer) != buffer.limit()) {
            return null;
        }
        buffer.flip();
        record = new RelationshipRecord(id, buffer.getInt(), buffer.getInt(), buffer.getInt());
        record.setInUse(inUse);
        record.setFirstPrevRel(buffer.getLong());
        record.setFirstNextRel(buffer.getLong());
        record.setSecondPrevRel(buffer.getLong());
        record.setSecondNextRel(buffer.getLong());
        record.setNextProp(buffer.getLong());
    } else {
        record = new RelationshipRecord(id, -1, -1, -1);
        record.setInUse(false);
    }
    return new Command(record);
}
Also used : XaCommand(org.neo4j.kernel.impl.transaction.xaframework.XaCommand) RelationshipRecord(org.neo4j.kernel.impl.nioneo.store.RelationshipRecord) IOException(java.io.IOException)

Example 3 with XaCommand

use of org.neo4j.kernel.impl.transaction.xaframework.XaCommand in project graphdb by neo4j-attic.

the class DumpLogicalLog method readRelationshipTypeCommand.

static XaCommand readRelationshipTypeCommand(ReadableByteChannel byteChannel, ByteBuffer buffer) throws IOException {
    // id+in_use(byte)+type_blockId(int)+nr_type_records(int)
    buffer.clear();
    buffer.limit(13);
    if (byteChannel.read(buffer) != buffer.limit()) {
        return null;
    }
    buffer.flip();
    int id = buffer.getInt();
    byte inUseFlag = buffer.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);
    }
    RelationshipTypeRecord record = new RelationshipTypeRecord(id);
    record.setInUse(inUse);
    record.setTypeBlock(buffer.getInt());
    int nrTypeRecords = buffer.getInt();
    for (int i = 0; i < nrTypeRecords; i++) {
        DynamicRecord dr = readDynamicRecord(byteChannel, buffer);
        if (dr == null) {
            return null;
        }
        record.addTypeRecord(dr);
    }
    return new Command(record);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.nioneo.store.DynamicRecord) XaCommand(org.neo4j.kernel.impl.transaction.xaframework.XaCommand) IOException(java.io.IOException) RelationshipTypeRecord(org.neo4j.kernel.impl.nioneo.store.RelationshipTypeRecord)

Example 4 with XaCommand

use of org.neo4j.kernel.impl.transaction.xaframework.XaCommand in project graphdb by neo4j-attic.

the class DumpLogicalLog method readPropertyCommand.

static XaCommand readPropertyCommand(ReadableByteChannel byteChannel, ByteBuffer buffer) throws IOException {
    // id+in_use(byte)+type(int)+key_indexId(int)+prop_blockId(long)+
    // prev_prop_id(long)+next_prop_id(long)+nr_value_records(int)
    buffer.clear();
    buffer.limit(9);
    if (byteChannel.read(buffer) != buffer.limit()) {
        return null;
    }
    buffer.flip();
    int id = buffer.getInt();
    byte inUseFlag = buffer.get();
    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;
    }
    int primitiveId = buffer.getInt();
    PropertyRecord record = new PropertyRecord(id);
    if (primitiveId != -1 && nodeProperty) {
        record.setNodeId(primitiveId);
    } else if (primitiveId != -1) {
        record.setRelId(primitiveId);
    }
    if (inUse) {
        buffer.clear();
        buffer.limit(32);
        if (byteChannel.read(buffer) != buffer.limit()) {
            return null;
        }
        buffer.flip();
        PropertyType type = getType(buffer.getInt());
        if (type == null) {
            return null;
        }
        record.setType(type);
        record.setInUse(inUse);
        record.setKeyIndexId(buffer.getInt());
        record.setPropBlock(buffer.getLong());
        record.setPrevProp(buffer.getLong());
        record.setNextProp(buffer.getLong());
    }
    buffer.clear();
    buffer.limit(4);
    if (byteChannel.read(buffer) != buffer.limit()) {
        return null;
    }
    buffer.flip();
    int nrValueRecords = buffer.getInt();
    for (int i = 0; i < nrValueRecords; i++) {
        DynamicRecord dr = readDynamicRecord(byteChannel, buffer);
        if (dr == null) {
            return null;
        }
        record.addValueRecord(dr);
    }
    return new Command(record);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.nioneo.store.DynamicRecord) PropertyRecord(org.neo4j.kernel.impl.nioneo.store.PropertyRecord) XaCommand(org.neo4j.kernel.impl.transaction.xaframework.XaCommand) PropertyType(org.neo4j.kernel.impl.nioneo.store.PropertyType)

Example 5 with XaCommand

use of org.neo4j.kernel.impl.transaction.xaframework.XaCommand in project graphdb by neo4j-attic.

the class DumpLogicalLog method readNodeCommand.

static XaCommand readNodeCommand(ReadableByteChannel byteChannel, ByteBuffer buffer) throws IOException {
    buffer.clear();
    buffer.limit(9);
    if (byteChannel.read(buffer) != buffer.limit()) {
        return null;
    }
    buffer.flip();
    long id = buffer.getLong();
    byte inUseFlag = buffer.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 = new NodeRecord(id);
    record.setInUse(inUse);
    if (inUse) {
        buffer.clear();
        buffer.limit(16);
        if (byteChannel.read(buffer) != buffer.limit()) {
            return null;
        }
        buffer.flip();
        record.setNextRel(buffer.getLong());
        record.setNextProp(buffer.getLong());
    }
    return new Command(record);
}
Also used : NodeRecord(org.neo4j.kernel.impl.nioneo.store.NodeRecord) XaCommand(org.neo4j.kernel.impl.transaction.xaframework.XaCommand) IOException(java.io.IOException)

Aggregations

XaCommand (org.neo4j.kernel.impl.transaction.xaframework.XaCommand)5 IOException (java.io.IOException)4 DynamicRecord (org.neo4j.kernel.impl.nioneo.store.DynamicRecord)3 NodeRecord (org.neo4j.kernel.impl.nioneo.store.NodeRecord)1 PropertyIndexRecord (org.neo4j.kernel.impl.nioneo.store.PropertyIndexRecord)1 PropertyRecord (org.neo4j.kernel.impl.nioneo.store.PropertyRecord)1 PropertyType (org.neo4j.kernel.impl.nioneo.store.PropertyType)1 RelationshipRecord (org.neo4j.kernel.impl.nioneo.store.RelationshipRecord)1 RelationshipTypeRecord (org.neo4j.kernel.impl.nioneo.store.RelationshipTypeRecord)1