Search in sources :

Example 1 with PropertyIndexRecord

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

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

the class WriteTransaction method getPropertyIndex.

String getPropertyIndex(int id) {
    PropertyIndexStore indexStore = getPropertyStore().getIndexStore();
    PropertyIndexRecord index = getPropertyIndexRecord(id);
    if (index == null) {
        index = indexStore.getRecord(id);
    }
    if (index.isLight()) {
        indexStore.makeHeavy(index);
    }
    return indexStore.getStringFor(index);
}
Also used : PropertyIndexRecord(org.neo4j.kernel.impl.nioneo.store.PropertyIndexRecord) PropertyIndexStore(org.neo4j.kernel.impl.nioneo.store.PropertyIndexStore)

Example 3 with PropertyIndexRecord

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

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

the class WriteTransaction method doPrepare.

@Override
protected void doPrepare() throws XAException {
    if (committed) {
        throw new XAException("Cannot prepare committed transaction[" + getIdentifier() + "]");
    }
    if (prepared) {
        throw new XAException("Cannot prepare prepared transaction[" + getIdentifier() + "]");
    }
    // generate records then write to logical log via addCommand method
    prepared = true;
    for (RelationshipTypeRecord record : relTypeRecords.values()) {
        Command.RelationshipTypeCommand command = new Command.RelationshipTypeCommand(neoStore.getRelationshipTypeStore(), record);
        relTypeCommands.add(command);
        addCommand(command);
    }
    for (NodeRecord record : nodeRecords.values()) {
        if (!record.inUse() && record.getNextRel() != Record.NO_NEXT_RELATIONSHIP.intValue()) {
            throw new InvalidRecordException("Node record " + record + " still has relationships");
        }
        Command.NodeCommand command = new Command.NodeCommand(neoStore.getNodeStore(), record);
        nodeCommands.add(command);
        if (!record.inUse()) {
            removeNodeFromCache(record.getId());
        }
        addCommand(command);
    }
    for (RelationshipRecord record : relRecords.values()) {
        Command.RelationshipCommand command = new Command.RelationshipCommand(neoStore.getRelationshipStore(), record);
        relCommands.add(command);
        if (!record.inUse()) {
            removeRelationshipFromCache(record.getId());
        }
        addCommand(command);
    }
    for (PropertyIndexRecord record : propIndexRecords.values()) {
        Command.PropertyIndexCommand command = new Command.PropertyIndexCommand(neoStore.getPropertyStore().getIndexStore(), record);
        propIndexCommands.add(command);
        addCommand(command);
    }
    for (PropertyRecord record : propertyRecords.values()) {
        Command.PropertyCommand command = new Command.PropertyCommand(neoStore.getPropertyStore(), record);
        propCommands.add(command);
        addCommand(command);
    }
}
Also used : XAException(javax.transaction.xa.XAException) RelationshipRecord(org.neo4j.kernel.impl.nioneo.store.RelationshipRecord) PropertyIndexRecord(org.neo4j.kernel.impl.nioneo.store.PropertyIndexRecord) RelationshipTypeRecord(org.neo4j.kernel.impl.nioneo.store.RelationshipTypeRecord) PropertyCommand(org.neo4j.kernel.impl.nioneo.xa.Command.PropertyCommand) NodeRecord(org.neo4j.kernel.impl.nioneo.store.NodeRecord) PropertyRecord(org.neo4j.kernel.impl.nioneo.store.PropertyRecord) PropertyCommand(org.neo4j.kernel.impl.nioneo.xa.Command.PropertyCommand) XaCommand(org.neo4j.kernel.impl.transaction.xaframework.XaCommand) PropertyCommand(org.neo4j.kernel.impl.nioneo.xa.Command.PropertyCommand) InvalidRecordException(org.neo4j.kernel.impl.nioneo.store.InvalidRecordException)

Example 5 with PropertyIndexRecord

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

the class BatchInserterImpl method createNewPropertyIndex.

private int createNewPropertyIndex(String stringKey) {
    PropertyIndexStore idxStore = getPropertyIndexStore();
    int keyId = (int) idxStore.nextId();
    PropertyIndexRecord record = new PropertyIndexRecord(keyId);
    record.setInUse(true);
    record.setCreated();
    int keyBlockId = idxStore.nextKeyBlockId();
    record.setKeyBlockId(keyBlockId);
    Collection<DynamicRecord> keyRecords = idxStore.allocateKeyRecords(keyBlockId, encodeString(stringKey));
    for (DynamicRecord keyRecord : keyRecords) {
        record.addKeyRecord(keyRecord);
    }
    idxStore.updateRecord(record);
    indexHolder.addPropertyIndex(stringKey, keyId);
    return keyId;
}
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)

Aggregations

PropertyIndexRecord (org.neo4j.kernel.impl.nioneo.store.PropertyIndexRecord)14 PropertyIndexStore (org.neo4j.kernel.impl.nioneo.store.PropertyIndexStore)8 DynamicRecord (org.neo4j.kernel.impl.nioneo.store.DynamicRecord)7 XAException (javax.transaction.xa.XAException)4 InvalidRecordException (org.neo4j.kernel.impl.nioneo.store.InvalidRecordException)4 NodeRecord (org.neo4j.kernel.impl.nioneo.store.NodeRecord)4 PropertyRecord (org.neo4j.kernel.impl.nioneo.store.PropertyRecord)4 RelationshipRecord (org.neo4j.kernel.impl.nioneo.store.RelationshipRecord)4 RelationshipTypeRecord (org.neo4j.kernel.impl.nioneo.store.RelationshipTypeRecord)4 XaCommand (org.neo4j.kernel.impl.transaction.xaframework.XaCommand)3 PropertyCommand (org.neo4j.kernel.impl.nioneo.xa.Command.PropertyCommand)2 IOException (java.io.IOException)1 RandomAccessFile (java.io.RandomAccessFile)1 ByteBuffer (java.nio.ByteBuffer)1 FileChannel (java.nio.channels.FileChannel)1 LinkedList (java.util.LinkedList)1 PropertyBlock (org.neo4j.kernel.impl.nioneo.store.PropertyBlock)1