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);
}
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;
}
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);
}
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);
}
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;
}
Aggregations