OwningNode( NodeRecord record ) { this.id = record.getId(); }
@Override public long getKey() { return record.getId(); }
public static DirectionWrapper wrapDirection( RelationshipRecord rel, NodeRecord startNode ) { boolean isOut = rel.getFirstNode() == startNode.getId(); boolean isIn = rel.getSecondNode() == startNode.getId(); assert isOut | isIn; if ( isOut & isIn ) { return DirectionWrapper.BOTH; } return isOut ? DirectionWrapper.OUTGOING : DirectionWrapper.INCOMING; } }
@Override public void setIdTo( PropertyRecord property ) { property.setNodeId( getId() ); }
public static NodeField select( RelationshipRecord relationship, NodeRecord node ) { return select( relationship, node.getId() ); }
private void connect( NodeRecord node, RelationshipRecord rel, RecordAccess<RelationshipRecord, Void> relRecords, ResourceLocker locks ) { connect( node.getId(), node.getNextRel(), rel, relRecords, locks ); }
@Override public boolean process( NodeRecord node ) { long nodeId = node.getId(); long firstRel = cache.getFirstRel( nodeId, NodeRelationshipCache.NO_GROUP_VISITOR ); if ( firstRel != -1 ) { node.setNextRel( firstRel ); } return true; }
@Override public String toString() { String denseInfo = (dense ? "group" : "rel") + "=" + nextRel; String lightHeavyInfo = isLight ? "light" : dynamicLabelRecords.isEmpty() ? "heavy" : "heavy,dynlabels=" + dynamicLabelRecords; return "Node[" + getId() + ",used=" + inUse() + "," + denseInfo + ",prop=" + getNextProp() + ",labels=" + parseLabelsField( this ) + "," + lightHeavyInfo + ",secondaryUnitId=" + getSecondaryUnitId() + "]"; }
public void validateNodeRecord( NodeRecord record ) throws TransactionFailureException { if ( !record.inUse() && record.getNextRel() != Record.NO_NEXT_RELATIONSHIP.intValue() ) { throw new ConstraintViolationTransactionFailureException( "Cannot delete node<" + record.getId() + ">, because it still has relationships. " + "To delete this node, you must first delete its relationships." ); } }
@Override public void serialize( WritableChannel channel ) throws IOException { channel.put( NeoCommandType.NODE_COMMAND ); channel.putLong( after.getId() ); writeNodeRecord( channel, before ); writeNodeRecord( channel, after ); }
@Override protected void process( NodeRecord[] batch, BatchSender sender ) throws Throwable { for ( NodeRecord node : batch ) { if ( node.inUse() ) { writer.write( labelChanges( node.getId(), EMPTY_LONG_ARRAY, get( node, nodeStore ) ) ); } } sender.send( batch ); }
private void connectRelationshipToDenseNode( NodeRecord node, RelationshipRecord rel, RecordAccess<RelationshipRecord, Void> relRecords, RecordAccess<RelationshipGroupRecord, Integer> relGroupRecords, ResourceLocker locks ) { RelationshipGroupRecord group = relGroupGetter.getOrCreateRelationshipGroup( node, rel.getType(), relGroupRecords ).forChangingData(); DirectionWrapper dir = DirectionIdentifier.wrapDirection( rel, node ); long nextRel = dir.getNextRel( group ); setCorrectNextRel( node, rel, nextRel ); connect( node.getId(), nextRel, rel, relRecords, locks ); dir.setNextRel( group, rel.getId() ); }
private NodeRecord nodeRecordWithDynamicLabels( long nodeId, NodeStore nodeStore, long... labels ) { NodeRecord node = new NodeRecord( nodeId, false, 0, 0 ); Collection<DynamicRecord> initialRecords = allocateAndApply( nodeStore, node.getId(), labels ); node.setLabelField( dynamicLabelsLongRepresentation( initialRecords ), initialRecords ); return node; }
public void create( NodeRecord node ) { node.setCreated(); update( new NodeRecord( node.getId(), false, NO_PREV_RELATIONSHIP.intValue(), NO_NEXT_PROPERTY.intValue() ), node ); }
public void delete( NodeRecord node ) { node.setInUse( false ); add( node, new NodeRecord( node.getId(), false, NO_PREV_RELATIONSHIP.intValue(), NO_NEXT_PROPERTY.intValue() ) ); }
@Override public Collection<DynamicRecord> add( long labelId, NodeStore nodeStore, DynamicRecordAllocator allocator ) { nodeStore.ensureHeavy( node, firstDynamicLabelRecordId( node.getLabelField() ) ); long[] existingLabelIds = getDynamicLabelsArray( node.getUsedDynamicLabelRecords(), nodeStore.getDynamicLabelStore() ); long[] newLabelIds = LabelIdArray.concatAndSort( existingLabelIds, labelId ); Collection<DynamicRecord> existingRecords = node.getDynamicLabelRecords(); Collection<DynamicRecord> changedDynamicRecords = allocateRecordsForDynamicLabels( node.getId(), newLabelIds, new ReusableRecordsCompositeAllocator( existingRecords, allocator ) ); node.setLabelField( dynamicPointer( changedDynamicRecords ), changedDynamicRecords ); return changedDynamicRecords; }
private String diff( NodeRecord expected, NodeRecord actual ) { if ( actual.getId() == expected.getId() && actual.getNextRel() == expected.getNextRel() && actual.getLabelField() == expected.getLabelField() && actual.getNextProp() == expected.getNextProp() && actual.isDense() == expected.isDense() && actual.isLight() == expected.isLight() ) { return null; } return describeDiff( expected.toString(), actual.toString() ); }
@Override protected void transactionData( GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next ) { NodeRecord nodeRecord = new NodeRecord( next.node(), false, -1, -1 ); DynamicRecord record = inUse( new DynamicRecord( next.nodeLabel() ) ); Collection<DynamicRecord> newRecords = new ArrayList<>(); allocateFromNumbers( newRecords, prependNodeId( nodeRecord.getId(), new long[]{42L} ), new ReusableRecordsAllocator( 60, record ) ); nodeRecord.setLabelField( dynamicPointer( newRecords ), newRecords ); tx.create( nodeRecord ); } } );
@Override protected void transactionData( GraphStoreFixture.TransactionDataBuilder tx, GraphStoreFixture.IdGenerator next ) { NodeRecord nodeRecord = new NodeRecord( next.node(), false, -1, -1 ); DynamicRecord record1 = inUse( new DynamicRecord( next.nodeLabel() ) ); DynamicRecord record2 = inUse( new DynamicRecord( next.nodeLabel() ) ); DynamicRecord record3 = inUse( new DynamicRecord( next.nodeLabel() ) ); labels[0] = nodeRecord.getId(); // the first id should not be a label id, but the id of the node ReusableRecordsAllocator allocator = new ReusableRecordsAllocator( 60, record1, record2, record3 ); allocateFromNumbers( chain, labels, allocator ); nodeRecord.setLabelField( dynamicPointer( chain ), chain ); tx.create( nodeRecord ); } } );