public static Consumer<NodeRecord> nextRel( long nextRelId ) { return n -> n.setNextRel( nextRelId ); }
@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; }
public static Consumer<NodeRecord> group( long groupId ) { return n -> { n.setDense( true ); n.setNextRel( groupId ); }; }
@Override public NodeRecord answer( InvocationOnMock invocation ) { if ( ((Number) invocation.getArgument( 0 )).longValue() == 0L && invocation.getArgument( 1 ) == null && invocation.getArgument( 2 ) == null ) { return null; } NodeRecord record = invocation.getArgument( 1 ); record.setId( ((Number) invocation.getArgument( 0 )).longValue() ); record.setInUse( true ); record.setDense( dense ); record.setNextRel( nextRel ); record.setNextProp( nextProp ); return record; } }
private void convertNodeToDenseNode( NodeRecord node, RelationshipRecord firstRel, RecordAccess<RelationshipRecord, Void> relRecords, RecordAccess<RelationshipGroupRecord, Integer> relGroupRecords, ResourceLocker locks ) { node.setDense( true ); node.setNextRel( Record.NO_NEXT_RELATIONSHIP.intValue() ); long relId = firstRel.getId(); RelationshipRecord relRecord = firstRel; while ( relId != Record.NO_NEXT_RELATIONSHIP.intValue() ) { // Get the next relationship id before connecting it (where linkage is overwritten) relId = relChain( relRecord, node.getId() ).get( relRecord ); connectRelationshipToDenseNode( node, relRecord, relRecords, relGroupRecords, locks ); if ( relId != Record.NO_NEXT_RELATIONSHIP.intValue() ) { // Lock and load the next relationship in the chain locks.acquireExclusive( LockTracer.NONE, ResourceTypes.RELATIONSHIP, relId ); relRecord = relRecords.getOrLoad( relId, null ).forChangingLinkage(); } } }
private void deleteGroup( RecordProxy<NodeRecord, Void> nodeChange, RelationshipGroupRecord group, RecordAccess<RelationshipGroupRecord, Integer> relGroupRecords ) { long previous = group.getPrev(); long next = group.getNext(); if ( previous == Record.NO_NEXT_RELATIONSHIP.intValue() ) { // This is the first one, just point the node to the next group nodeChange.forChangingLinkage().setNextRel( next ); } else { // There are others before it, point the previous to the next group RelationshipGroupRecord previousRecord = relGroupRecords.getOrLoad( previous, null ).forChangingLinkage(); previousRecord.setNext( next ); } if ( next != Record.NO_NEXT_RELATIONSHIP.intValue() ) { // There are groups after this one, point that next group to the previous of the group to be deleted RelationshipGroupRecord nextRecord = relGroupRecords.getOrLoad( next, null ).forChangingLinkage(); nextRecord.setPrev( previous ); } group.setInUse( false ); }
@Override protected void process( RelationshipGroupRecord[] batch, BatchSender sender ) { for ( RelationshipGroupRecord group : batch ) { if ( !group.inUse() ) { continue; } long nodeId = group.getOwningNode(); if ( cache.getByte( nodeId, 0 ) == 0 ) { cache.setByte( nodeId, 0, (byte) 1 ); NodeRecord nodeRecord = nodeStore.newRecord(); nodeStore.getRecordByCursor( nodeId, nodeRecord, NORMAL, nodeCursor ); nodeRecord.setNextRel( group.getId() ); nodeRecord.setDense( true ); current[cursor++] = nodeRecord; if ( cursor == batchSize ) { sender.send( current ); newBatch(); } } } control.recycle( batch ); }
@Override public void checkConsistency( RelationshipRecord relationship, CheckerEngine<RelationshipRecord, ConsistencyReport.RelationshipConsistencyReport> engine, RecordAccess records ) { if ( valueFrom( relationship ) < 0 ) { illegalNode( engine.report() ); } else { // build the node record from cached values with only valid fields as id, inUse, and nextRel. NodeRecord node = new NodeRecord( valueFrom( relationship ) ); CacheAccess.Client client = records.cacheAccess().client(); node.setInUse( client.getFromCache( node.getId(), SLOT_SOURCE_OR_TARGET ) != RelationshipLink.SOURCE ); node.setNextRel( client.getFromCache( node.getId(), SLOT_RELATIONSHIP_ID ) ); // We use "created" flag here. Consistency checking code revolves around records and so // even in scenarios where records are built from other sources, f.ex half-and-purpose-built from cache, // this flag is used to signal that the real record needs to be read in order to be used as a general // purpose record. node.setCreated(); if ( records.shouldCheck( node.getId(), MultiPassStore.NODES ) ) { engine.comparativeCheck( new DirectRecordReference<>( node, records ), this ); } } }
firstNode.setNextRel( rel.getId() ); secondNode.setNextRel( rel.getId() );
previousFirstRecord.setPrev( id ); node.setNextRel( id );
startNode.setNextRel( rel.getFirstNextRel() ); endNode.setNextRel( rel.getSecondNextRel() );
@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; }
private void convertNodeToDenseNode( NodeRecord node, RelationshipRecord firstRel, RecordAccess<RelationshipRecord, Void> relRecords, RecordAccess<RelationshipGroupRecord, Integer> relGroupRecords, ResourceLocker locks ) { node.setDense( true ); node.setNextRel( Record.NO_NEXT_RELATIONSHIP.intValue() ); long relId = firstRel.getId(); RelationshipRecord relRecord = firstRel; while ( relId != Record.NO_NEXT_RELATIONSHIP.intValue() ) { // Get the next relationship id before connecting it (where linkage is overwritten) relId = relChain( relRecord, node.getId() ).get( relRecord ); connectRelationshipToDenseNode( node, relRecord, relRecords, relGroupRecords, locks ); if ( relId != Record.NO_NEXT_RELATIONSHIP.intValue() ) { // Lock and load the next relationship in the chain locks.acquireExclusive( LockTracer.NONE, ResourceTypes.RELATIONSHIP, relId ); relRecord = relRecords.getOrLoad( relId, null ).forChangingLinkage(); } } }
@Override protected void process( RelationshipGroupRecord[] batch, BatchSender sender ) { for ( RelationshipGroupRecord group : batch ) { if ( !group.inUse() ) { continue; } long nodeId = group.getOwningNode(); if ( cache.getByte( nodeId, 0 ) == 0 ) { cache.setByte( nodeId, 0, (byte) 1 ); NodeRecord nodeRecord = nodeStore.newRecord(); nodeStore.getRecordByCursor( nodeId, nodeRecord, NORMAL, nodeCursor ); nodeRecord.setNextRel( group.getId() ); nodeRecord.setDense( true ); current[cursor++] = nodeRecord; if ( cursor == batchSize ) { sender.send( current ); newBatch(); } } } control.recycle( batch ); }
private void deleteGroup( RecordProxy<NodeRecord, Void> nodeChange, RelationshipGroupRecord group, RecordAccess<RelationshipGroupRecord, Integer> relGroupRecords ) { long previous = group.getPrev(); long next = group.getNext(); if ( previous == Record.NO_NEXT_RELATIONSHIP.intValue() ) { // This is the first one, just point the node to the next group nodeChange.forChangingLinkage().setNextRel( next ); } else { // There are others before it, point the previous to the next group RelationshipGroupRecord previousRecord = relGroupRecords.getOrLoad( previous, null ).forChangingLinkage(); previousRecord.setNext( next ); } if ( next != Record.NO_NEXT_RELATIONSHIP.intValue() ) { // There are groups after this one, point that next group to the previous of the group to be deleted RelationshipGroupRecord nextRecord = relGroupRecords.getOrLoad( next, null ).forChangingLinkage(); nextRecord.setPrev( previous ); } group.setInUse( false ); }
firstNode.setNextRel( rel.getId() ); secondNode.setNextRel( rel.getId() );
oldNode1.setNextRel( oldRel.getId() ); oldNode2.setNextRel( oldRel.getId() ); newNode1.setNextRel( newRel.getId() ); newNode2.setNextRel( newRel.getId() );
previousFirstRecord.setPrev( id ); node.setNextRel( id );
startNode.setNextRel( rel.getFirstNextRel() ); endNode.setNextRel( rel.getSecondNextRel() );