@Override public long nodeReference() { return storeCursor.entityReference(); }
@Override public boolean process( StorageNodeCursor cursor ) throws FAILURE { long[] labels = cursor.labels(); if ( labels.length == 0 && labelIds.length != 0 ) { // This node has no labels at all return false; } if ( labelUpdateVisitor != null ) { // Notify the label update visitor labelUpdateVisitor.visit( labelChanges( cursor.entityReference(), EMPTY_LONG_ARRAY, labels ) ); } if ( propertyUpdatesVisitor != null && containsAnyEntityToken( labelIds, labels ) ) { // Notify the property update visitor EntityUpdates.Builder updates = EntityUpdates.forEntity( cursor.entityReference() ).withTokens( labels ); if ( hasRelevantProperty( cursor, updates ) ) { return propertyUpdatesVisitor.visit( updates.build() ); } } return false; } }
@Override public LabelSet labels() { if ( hasChanges() ) { TransactionState txState = read.txState(); if ( txState.nodeIsAddedInThisTx( storeCursor.entityReference() ) ) { //Node just added, no reason to go down to store and check return Labels.from( txState.nodeStateLabelDiffSets( storeCursor.entityReference() ).getAdded() ); } else { //Get labels from store and put in intSet, unfortunately we get longs back long[] longs = storeCursor.labels(); final MutableLongSet labels = new LongHashSet(); for ( long labelToken : longs ) { labels.add( labelToken ); } //Augment what was found in store with what we have in tx state return Labels.from( txState.augmentLabels( labels, txState.getNodeState( storeCursor.entityReference() ) ) ); } } else { //Nothing in tx state, just read the data. return Labels.from( storeCursor.labels() ); } }
private StorageRelationshipTraversalCursor allocateRelationshipTraversalCursor( StorageNodeCursor node ) { StorageRelationshipTraversalCursor relationships = storageReader.allocateRelationshipTraversalCursor(); relationships.init( node.entityReference(), node.allRelationshipsReference() ); return relationships; }
private Set<TestRelType> relTypes( StorageNodeCursor cursor ) { Set<TestRelType> types = new HashSet<>(); try ( StorageRelationshipGroupCursor groups = storageReader.allocateRelationshipGroupCursor() ) { groups.init( cursor.entityReference(), cursor.relationshipGroupReference() ); while ( groups.next() ) { types.add( relTypeForId( groups.type() ) ); } } return types; }
private void visitDegrees( StorageNodeCursor node, DegreeVisitor visitor ) { groupCursor.init( node.entityReference(), node.relationshipGroupReference() ); while ( groupCursor.next() ) { int loopCount = groupCursor.loopCount(); visitor.visitDegree( groupCursor.type(), groupCursor.outgoingCount() + loopCount, groupCursor.incomingCount() + loopCount ); } }
@Override public boolean next() { // Check tx state boolean hasChanges = hasChanges(); if ( hasChanges && addedNodes.hasNext() ) { storeCursor.setCurrent( addedNodes.next() ); return true; } while ( storeCursor.next() ) { if ( !hasChanges || !read.txState().nodeIsDeletedInThisTx( storeCursor.entityReference() ) ) { return true; } } return false; }
@Override public void receive( StorageNodeCursor node ) { if ( node.entityReference() == 7 ) { indexPopulator.queueUpdate( IndexEntryUpdate.change( 8L, index, Values.of( "a" ), Values.of( "b" ) ) ); } } }
@Override public boolean hasLabel( int label ) { if ( hasChanges() ) { TransactionState txState = read.txState(); LongDiffSets diffSets = txState.nodeStateLabelDiffSets( storeCursor.entityReference() ); if ( diffSets.getAdded().contains( label ) ) { return true; } if ( diffSets.getRemoved().contains( label ) ) { return false; } } //Get labels from store and put in intSet, unfortunately we get longs back return storeCursor.hasLabel( label ); }
private Set<TestDegreeItem> degrees( StorageNodeCursor nodeCursor ) { Set<TestDegreeItem> degrees = new HashSet<>(); try ( StorageRelationshipGroupCursor groups = storageReader.allocateRelationshipGroupCursor() ) { groups.init( nodeCursor.entityReference(), nodeCursor.relationshipGroupReference() ); while ( groups.next() ) { degrees.add( new TestDegreeItem( groups.type(), groups.outgoingCount() + groups.loopCount(), groups.incomingCount() + groups.loopCount() ) ); } } return degrees; }
private int degreeForDirectionAndType( StorageNodeCursor cursor, RelationshipDirection direction, int relType ) { int degree = 0; try ( StorageRelationshipGroupCursor groups = storageReader.allocateRelationshipGroupCursor() ) { groups.init( cursor.entityReference(), cursor.relationshipGroupReference() ); while ( groups.next() ) { if ( relType == ANY_RELATIONSHIP_TYPE || relType == groups.type() ) { switch ( direction ) { case OUTGOING: degree += groups.outgoingCount() + groups.loopCount(); break; case INCOMING: degree += groups.incomingCount() + groups.loopCount(); break; case LOOP: degree += groups.outgoingCount() + groups.incomingCount() + groups.loopCount(); break; default: throw new IllegalArgumentException( direction.name() ); } } } } return degree; }
@Override public long nodeReference() { return storeCursor.entityReference(); }
@Override public boolean process( StorageNodeCursor cursor ) throws FAILURE { long[] labels = cursor.labels(); if ( labels.length == 0 && labelIds.length != 0 ) { // This node has no labels at all return false; } if ( labelUpdateVisitor != null ) { // Notify the label update visitor labelUpdateVisitor.visit( labelChanges( cursor.entityReference(), EMPTY_LONG_ARRAY, labels ) ); } if ( propertyUpdatesVisitor != null && containsAnyEntityToken( labelIds, labels ) ) { // Notify the property update visitor EntityUpdates.Builder updates = EntityUpdates.forEntity( cursor.entityReference() ).withTokens( labels ); if ( hasRelevantProperty( cursor, updates ) ) { return propertyUpdatesVisitor.visit( updates.build() ); } } return false; } }
@Override public LabelSet labels() { if ( hasChanges() ) { TransactionState txState = read.txState(); if ( txState.nodeIsAddedInThisTx( storeCursor.entityReference() ) ) { //Node just added, no reason to go down to store and check return Labels.from( txState.nodeStateLabelDiffSets( storeCursor.entityReference() ).getAdded() ); } else { //Get labels from store and put in intSet, unfortunately we get longs back long[] longs = storeCursor.labels(); final MutableLongSet labels = new LongHashSet(); for ( long labelToken : longs ) { labels.add( labelToken ); } //Augment what was found in store with what we have in tx state return Labels.from( txState.augmentLabels( labels, txState.getNodeState( storeCursor.entityReference() ) ) ); } } else { //Nothing in tx state, just read the data. return Labels.from( storeCursor.labels() ); } }
private void visitDegrees( StorageNodeCursor node, DegreeVisitor visitor ) { groupCursor.init( node.entityReference(), node.relationshipGroupReference() ); while ( groupCursor.next() ) { int loopCount = groupCursor.loopCount(); visitor.visitDegree( groupCursor.type(), groupCursor.outgoingCount() + loopCount, groupCursor.incomingCount() + loopCount ); } }
@Override public boolean next() { // Check tx state boolean hasChanges = hasChanges(); if ( hasChanges && addedNodes.hasNext() ) { storeCursor.setCurrent( addedNodes.next() ); return true; } while ( storeCursor.next() ) { if ( !hasChanges || !read.txState().nodeIsDeletedInThisTx( storeCursor.entityReference() ) ) { return true; } } return false; }
@Override public boolean hasLabel( int label ) { if ( hasChanges() ) { TransactionState txState = read.txState(); LongDiffSets diffSets = txState.nodeStateLabelDiffSets( storeCursor.entityReference() ); if ( diffSets.getAdded().contains( label ) ) { return true; } if ( diffSets.getRemoved().contains( label ) ) { return false; } } //Get labels from store and put in intSet, unfortunately we get longs back return storeCursor.hasLabel( label ); }