Search in sources :

Example 16 with NodeRecord

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

the class WriteTransaction method nodeCreate.

void nodeCreate(long nodeId) {
    NodeRecord nodeRecord = new NodeRecord(nodeId);
    nodeRecord.setInUse(true);
    nodeRecord.setCreated();
    addNodeRecord(nodeRecord);
}
Also used : NodeRecord(org.neo4j.kernel.impl.nioneo.store.NodeRecord)

Example 17 with NodeRecord

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

the class WriteTransaction method nodeGetProperties.

ArrayMap<Integer, PropertyData> nodeGetProperties(long nodeId, boolean light) {
    ArrayMap<Integer, PropertyData> propertyMap = new ArrayMap<Integer, PropertyData>(9, false, true);
    NodeRecord nodeRecord = getNodeRecord(nodeId);
    if (nodeRecord != null && nodeRecord.isCreated()) {
        return propertyMap;
    }
    if (nodeRecord != null) {
        if (!nodeRecord.inUse() && !light) {
            throw new IllegalStateException("Node[" + nodeId + "] has been deleted in this tx");
        }
    }
    nodeRecord = getNodeStore().getRecord(nodeId);
    if (!nodeRecord.inUse()) {
        throw new InvalidRecordException("Node[" + nodeId + "] not in use");
    }
    long nextProp = nodeRecord.getNextProp();
    while (nextProp != Record.NO_NEXT_PROPERTY.intValue()) {
        PropertyRecord propRecord = getPropertyStore().getLightRecord(nextProp);
        propertyMap.put(propRecord.getKeyIndexId(), new PropertyData(propRecord.getId(), propertyGetValueOrNull(propRecord)));
        nextProp = propRecord.getNextProp();
    }
    return propertyMap;
}
Also used : NodeRecord(org.neo4j.kernel.impl.nioneo.store.NodeRecord) PropertyData(org.neo4j.kernel.impl.nioneo.store.PropertyData) PropertyRecord(org.neo4j.kernel.impl.nioneo.store.PropertyRecord) ArrayMap(org.neo4j.kernel.impl.util.ArrayMap) InvalidRecordException(org.neo4j.kernel.impl.nioneo.store.InvalidRecordException)

Example 18 with NodeRecord

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

the class WriteTransaction method relationshipCreate.

void relationshipCreate(long id, long firstNodeId, long secondNodeId, int type) {
    NodeRecord firstNode = getNodeRecord(firstNodeId);
    if (firstNode == null) {
        firstNode = getNodeStore().getRecord(firstNodeId);
        addNodeRecord(firstNode);
    }
    if (!firstNode.inUse()) {
        throw new IllegalStateException("First node[" + firstNodeId + "] is deleted and cannot be used to create a relationship");
    }
    NodeRecord secondNode = getNodeRecord(secondNodeId);
    if (secondNode == null) {
        secondNode = getNodeStore().getRecord(secondNodeId);
        addNodeRecord(secondNode);
    }
    if (!secondNode.inUse()) {
        throw new IllegalStateException("Second node[" + secondNodeId + "] is deleted and cannot be used to create a relationship");
    }
    RelationshipRecord record = new RelationshipRecord(id, firstNodeId, secondNodeId, type);
    record.setInUse(true);
    record.setCreated();
    addRelationshipRecord(record);
    connectRelationship(firstNode, secondNode, record);
}
Also used : NodeRecord(org.neo4j.kernel.impl.nioneo.store.NodeRecord) RelationshipRecord(org.neo4j.kernel.impl.nioneo.store.RelationshipRecord)

Example 19 with NodeRecord

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

Example 20 with NodeRecord

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

the class BatchInserterImpl method getRelationshipIds.

public Iterable<Long> getRelationshipIds(long nodeId) {
    NodeRecord nodeRecord = getNodeRecord(nodeId);
    long nextRel = nodeRecord.getNextRel();
    List<Long> ids = new ArrayList<Long>();
    while (nextRel != Record.NO_NEXT_RELATIONSHIP.intValue()) {
        RelationshipRecord relRecord = getRelationshipRecord(nextRel);
        ids.add(relRecord.getId());
        long firstNode = relRecord.getFirstNode();
        long secondNode = relRecord.getSecondNode();
        if (firstNode == nodeId) {
            nextRel = relRecord.getFirstNextRel();
        } else if (secondNode == nodeId) {
            nextRel = relRecord.getSecondNextRel();
        } else {
            throw new InvalidRecordException("Node[" + nodeId + "] not part of firstNode[" + firstNode + "] or secondNode[" + secondNode + "]");
        }
    }
    return ids;
}
Also used : NodeRecord(org.neo4j.kernel.impl.nioneo.store.NodeRecord) ArrayList(java.util.ArrayList) RelationshipRecord(org.neo4j.kernel.impl.nioneo.store.RelationshipRecord) InvalidRecordException(org.neo4j.kernel.impl.nioneo.store.InvalidRecordException)

Aggregations

NodeRecord (org.neo4j.kernel.impl.nioneo.store.NodeRecord)36 PropertyRecord (org.neo4j.kernel.impl.nioneo.store.PropertyRecord)12 RelationshipRecord (org.neo4j.kernel.impl.nioneo.store.RelationshipRecord)12 InvalidRecordException (org.neo4j.kernel.impl.nioneo.store.InvalidRecordException)10 DynamicRecord (org.neo4j.kernel.impl.nioneo.store.DynamicRecord)6 ArrayList (java.util.ArrayList)4 XAException (javax.transaction.xa.XAException)4 PropertyData (org.neo4j.kernel.impl.nioneo.store.PropertyData)4 PropertyIndexRecord (org.neo4j.kernel.impl.nioneo.store.PropertyIndexRecord)4 RelationshipTypeRecord (org.neo4j.kernel.impl.nioneo.store.RelationshipTypeRecord)4 PropertyBlock (org.neo4j.kernel.impl.nioneo.store.PropertyBlock)3 XaCommand (org.neo4j.kernel.impl.transaction.xaframework.XaCommand)3 ArrayMap (org.neo4j.kernel.impl.util.ArrayMap)3 IOException (java.io.IOException)2 RelationshipType (org.neo4j.graphdb.RelationshipType)2 NodeStore (org.neo4j.kernel.impl.nioneo.store.NodeStore)2 RelationshipChainPosition (org.neo4j.kernel.impl.nioneo.store.RelationshipChainPosition)2 PropertyCommand (org.neo4j.kernel.impl.nioneo.xa.Command.PropertyCommand)2 ByteBuffer (java.nio.ByteBuffer)1 PrefetchingIterator (org.neo4j.helpers.collection.PrefetchingIterator)1