Search in sources :

Example 11 with DynamicRecord

use of org.neo4j.kernel.impl.nioneo.store.DynamicRecord in project graphdb by neo4j-attic.

the class WriteTransaction method createPropertyIndex.

void createPropertyIndex(int id, String key) {
    PropertyIndexRecord record = new PropertyIndexRecord(id);
    record.setInUse(true);
    record.setCreated();
    PropertyIndexStore propIndexStore = getPropertyStore().getIndexStore();
    int keyBlockId = propIndexStore.nextKeyBlockId();
    record.setKeyBlockId(keyBlockId);
    int length = key.length();
    char[] chars = new char[length];
    key.getChars(0, length, chars, 0);
    Collection<DynamicRecord> keyRecords = propIndexStore.allocateKeyRecords(keyBlockId, chars);
    for (DynamicRecord keyRecord : keyRecords) {
        record.addKeyRecord(keyRecord);
    }
    addPropertyIndexRecord(record);
}
Also used : DynamicRecord(org.neo4j.kernel.impl.nioneo.store.DynamicRecord) PropertyIndexRecord(org.neo4j.kernel.impl.nioneo.store.PropertyIndexRecord) PropertyIndexStore(org.neo4j.kernel.impl.nioneo.store.PropertyIndexStore)

Example 12 with DynamicRecord

use of org.neo4j.kernel.impl.nioneo.store.DynamicRecord 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 13 with DynamicRecord

use of org.neo4j.kernel.impl.nioneo.store.DynamicRecord 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 14 with DynamicRecord

use of org.neo4j.kernel.impl.nioneo.store.DynamicRecord in project graphdb by neo4j-attic.

the class DumpLogicalLog method readDynamicRecord.

static DynamicRecord readDynamicRecord(ReadableByteChannel byteChannel, ByteBuffer buffer) throws IOException {
    // id+type+in_use(byte)+prev_block(long)+nr_of_bytes(int)+next_block(long)
    buffer.clear();
    buffer.limit(13);
    if (byteChannel.read(buffer) != buffer.limit()) {
        return null;
    }
    buffer.flip();
    long id = buffer.getLong();
    int type = buffer.getInt();
    byte inUseFlag = buffer.get();
    boolean inUse = false;
    if (inUseFlag == Record.IN_USE.byteValue()) {
        inUse = true;
        buffer.clear();
        buffer.limit(20);
        if (byteChannel.read(buffer) != buffer.limit()) {
            return null;
        }
        buffer.flip();
    } else if (inUseFlag != Record.NOT_IN_USE.byteValue()) {
        throw new IOException("Illegal in use flag: " + inUseFlag);
    }
    DynamicRecord record = new DynamicRecord(id);
    record.setInUse(inUse, type);
    if (inUse) {
        record.setPrevBlock(buffer.getLong());
        int nrOfBytes = buffer.getInt();
        record.setNextBlock(buffer.getLong());
        buffer.clear();
        buffer.limit(nrOfBytes);
        if (byteChannel.read(buffer) != buffer.limit()) {
            return null;
        }
        buffer.flip();
        byte[] data = new byte[nrOfBytes];
        buffer.get(data);
        record.setData(data);
    }
    return record;
}
Also used : DynamicRecord(org.neo4j.kernel.impl.nioneo.store.DynamicRecord) IOException(java.io.IOException)

Example 15 with DynamicRecord

use of org.neo4j.kernel.impl.nioneo.store.DynamicRecord in project neo4j-mobile-android by neo4j-contrib.

the class BatchInserterImpl method deletePropertyChain.

private void deletePropertyChain(long nextProp) {
    PropertyStore propStore = getPropertyStore();
    while (nextProp != Record.NO_NEXT_PROPERTY.intValue()) {
        PropertyRecord propRecord = propStore.getRecord(nextProp);
        for (PropertyBlock propBlock : propRecord.getPropertyBlocks()) {
            propStore.makeHeavy(propBlock);
            for (DynamicRecord rec : propBlock.getValueRecords()) {
                rec.setInUse(false);
                propRecord.addDeletedRecord(rec);
            }
        }
        propRecord.setInUse(false);
        nextProp = propRecord.getNextProp();
        propStore.updateRecord(propRecord);
    }
}
Also used : DynamicRecord(org.neo4j.kernel.impl.nioneo.store.DynamicRecord) PropertyRecord(org.neo4j.kernel.impl.nioneo.store.PropertyRecord) PropertyBlock(org.neo4j.kernel.impl.nioneo.store.PropertyBlock) PropertyStore(org.neo4j.kernel.impl.nioneo.store.PropertyStore)

Aggregations

DynamicRecord (org.neo4j.kernel.impl.nioneo.store.DynamicRecord)30 PropertyRecord (org.neo4j.kernel.impl.nioneo.store.PropertyRecord)15 PropertyBlock (org.neo4j.kernel.impl.nioneo.store.PropertyBlock)7 PropertyIndexRecord (org.neo4j.kernel.impl.nioneo.store.PropertyIndexRecord)7 RelationshipTypeRecord (org.neo4j.kernel.impl.nioneo.store.RelationshipTypeRecord)7 NodeRecord (org.neo4j.kernel.impl.nioneo.store.NodeRecord)6 RelationshipRecord (org.neo4j.kernel.impl.nioneo.store.RelationshipRecord)6 IOException (java.io.IOException)5 PropertyIndexStore (org.neo4j.kernel.impl.nioneo.store.PropertyIndexStore)4 PropertyData (org.neo4j.kernel.impl.nioneo.store.PropertyData)3 XaCommand (org.neo4j.kernel.impl.transaction.xaframework.XaCommand)3 ArrayMap (org.neo4j.kernel.impl.util.ArrayMap)3 XAException (javax.transaction.xa.XAException)2 InvalidRecordException (org.neo4j.kernel.impl.nioneo.store.InvalidRecordException)2 PropertyStore (org.neo4j.kernel.impl.nioneo.store.PropertyStore)2 RelationshipTypeStore (org.neo4j.kernel.impl.nioneo.store.RelationshipTypeStore)2 PropertyType (org.neo4j.kernel.impl.nioneo.store.PropertyType)1