private ResourceIterator<Node> getNodesByLabelAndPropertyWithoutIndex( Statement statement, int labelId, IndexQuery... queries ) { KernelTransaction transaction = statementContext.getKernelTransactionBoundToThisThread( true ); NodeLabelIndexCursor nodeLabelCursor = transaction.cursors().allocateNodeLabelIndexCursor(); NodeCursor nodeCursor = transaction.cursors().allocateNodeCursor(); PropertyCursor propertyCursor = transaction.cursors().allocatePropertyCursor(); transaction.dataRead().nodeLabelScan( labelId, nodeLabelCursor ); return new NodeLabelPropertyIterator( transaction.dataRead(), nodeLabelCursor, nodeCursor, propertyCursor, statement, this::newNodeProxy, queries ); }
@Override public NodeValueIndexCursor allocateNodeValueIndexCursor() { NodeValueIndexCursor n = cursors.allocateNodeValueIndexCursor(); allCursors.add( n ); return n; }
private void updateReader( KernelTransactionImplementation kti ) throws Exception { modifiedEntityIdsInThisTransaction.clear(); // Clear this so we don't filter out entities who have had their changes reversed since last time. writer.resetWriterState(); AllStoreHolder read = (AllStoreHolder) kti.dataRead(); TransactionState transactionState = kti.txState(); try ( NodeCursor nodeCursor = visitingNodes ? kti.cursors().allocateNodeCursor() : null; RelationshipScanCursor relationshipCursor = visitingNodes ? null : kti.cursors().allocateRelationshipScanCursor(); PropertyCursor propertyCursor = kti.cursors().allocatePropertyCursor() ) { transactionState.accept( txStateVisitor.init( read, nodeCursor, relationshipCursor, propertyCursor ) ); } FulltextIndexReader baseReader = (FulltextIndexReader) read.indexReader( descriptor, false ); FulltextIndexReader nearRealTimeReader = writer.getNearRealTimeReader(); currentReader = new TransactionStateFulltextIndexReader( baseReader, nearRealTimeReader, modifiedEntityIdsInThisTransaction ); lastUpdateRevision = kti.getTransactionDataRevision(); }
private static void setupAllDense( RelationshipDenseSelection denseSelection, CursorFactory cursors, NodeCursor node, int[] types ) { RelationshipGroupCursor groupCursor = cursors.allocateRelationshipGroupCursor(); RelationshipTraversalCursor traversalCursor = cursors.allocateRelationshipTraversalCursor(); try { node.relationships( groupCursor ); denseSelection.all( groupCursor, traversalCursor, types ); } catch ( Throwable t ) { groupCursor.close(); traversalCursor.close(); throw t; } }
long newRelationship = write.relationshipCreate( start, type, write.nodeCreate() ); try ( NodeCursor node = tx.cursors().allocateNodeCursor(); RelationshipTraversalCursor traversal = tx.cursors().allocateRelationshipTraversalCursor(); RelationshipGroupCursor group = tx.cursors().allocateRelationshipGroupCursor() )
@Test public void propertyTypeShouldBeTxStateAware() throws Exception { // Given long node; try ( Transaction tx = beginTransaction() ) { node = tx.dataWrite().nodeCreate(); tx.success(); } // Then try ( Transaction tx = beginTransaction() ) { try ( NodeCursor nodes = tx.cursors().allocateNodeCursor(); PropertyCursor properties = tx.cursors().allocatePropertyCursor() ) { tx.dataRead().singleNode( node, nodes ); assertTrue( nodes.next() ); assertFalse( hasProperties( nodes, properties ) ); int prop = tx.tokenWrite().propertyKeyGetOrCreateForName( "prop" ); tx.dataWrite().nodeSetProperty( node, prop, stringValue( "foo" ) ); nodes.properties( properties ); assertTrue( properties.next() ); assertThat( properties.propertyType(), equalTo( ValueGroup.TEXT ) ); } } }
Value relationshipGetProperty( Transaction transaction, long relationship, int property ) { try ( RelationshipScanCursor cursor = transaction.cursors().allocateRelationshipScanCursor(); PropertyCursor properties = transaction.cursors().allocatePropertyCursor() ) { transaction.dataRead().singleRelationship( relationship, cursor ); if ( !cursor.next() ) { return NO_VALUE; } else { cursor.properties( properties ); while ( properties.next() ) { if ( properties.propertyKey() == property ) { return properties.propertyValue(); } } return NO_VALUE; } } }
private void traverseWithoutGroups( RelationshipTestSupport.StartNode start, boolean detached ) throws Exception { try ( Transaction tx = beginTransaction() ) { Map<String,Integer> expectedCounts = modifyStartNodeRelationships( start, tx ); // given try ( NodeCursor node = tx.cursors().allocateNodeCursor(); RelationshipTraversalCursor relationship = tx.cursors().allocateRelationshipTraversalCursor() ) { // when tx.dataRead().singleNode( start.id, node ); assertTrue( "access node", node.next() ); if ( detached ) { tx.dataRead().relationships( start.id, node.allRelationshipsReference(), relationship ); } else { node.allRelationships( relationship ); } Map<String,Integer> counts = count( tx, relationship ); // then assertCounts( expectedCounts, counts ); } tx.failure(); } }
@Override public NodeCursor allocateNodeCursor() { NodeCursor n = cursors.allocateNodeCursor(); allCursors.add( n ); return n; }
@Override public NodeLabelIndexCursor allocateNodeLabelIndexCursor() { NodeLabelIndexCursor n = cursors.allocateNodeLabelIndexCursor(); allCursors.add( n ); return n; }
@Override public RelationshipScanCursor allocateRelationshipScanCursor() { RelationshipScanCursor n = cursors.allocateRelationshipScanCursor(); allCursors.add( n ); return n; }
try ( NodeCursor node = tx.cursors().allocateNodeCursor(); RelationshipGroupCursor group = tx.cursors().allocateRelationshipGroupCursor() )
@Override public PropertyCursor allocatePropertyCursor() { PropertyCursor n = cursors.allocatePropertyCursor(); allCursors.add( n ); return n; }
@Override public RelationshipTraversalCursor allocateRelationshipTraversalCursor() { RelationshipTraversalCursor n = cursors.allocateRelationshipTraversalCursor(); allCursors.add( n ); return n; }
@Override public NodeExplicitIndexCursor allocateNodeExplicitIndexCursor() { NodeExplicitIndexCursor n = cursors.allocateNodeExplicitIndexCursor(); allCursors.add( n ); return n; }
@Override public RelationshipGroupCursor allocateRelationshipGroupCursor() { RelationshipGroupCursor n = cursors.allocateRelationshipGroupCursor(); allCursors.add( n ); return n; }
long newRelationship = write.relationshipCreate( start, type, write.nodeCreate() ); try ( NodeCursor node = tx.cursors().allocateNodeCursor(); RelationshipTraversalCursor traversal = tx.cursors().allocateRelationshipTraversalCursor(); RelationshipGroupCursor group = tx.cursors().allocateRelationshipGroupCursor() )
@Test public void hasPropertiesShouldSeeNewlyCreatedPropertiesOnNewlyCreatedNode() throws Exception { try ( Transaction tx = beginTransaction() ) { long node = tx.dataWrite().nodeCreate(); try ( NodeCursor cursor = tx.cursors().allocateNodeCursor(); PropertyCursor props = tx.cursors().allocatePropertyCursor() ) { tx.dataRead().singleNode( node, cursor ); assertTrue( cursor.next() ); assertFalse( hasProperties( cursor, props ) ); tx.dataWrite().nodeSetProperty( node, tx.tokenWrite().propertyKeyGetOrCreateForName( "prop" ), stringValue( "foo" ) ); assertTrue( hasProperties( cursor, props ) ); } } }
private static void setupIncomingDense( RelationshipDenseSelection denseSelection, CursorFactory cursors, NodeCursor node, int[] types ) { RelationshipGroupCursor groupCursor = cursors.allocateRelationshipGroupCursor(); RelationshipTraversalCursor traversalCursor = cursors.allocateRelationshipTraversalCursor(); try { node.relationships( groupCursor ); denseSelection.incoming( groupCursor, traversalCursor, types ); } catch ( Throwable t ) { groupCursor.close(); traversalCursor.close(); throw t; } }
@Test public void propertyTypeShouldBeTxStateAware() throws Exception { // Given long relationship; try ( Transaction tx = beginTransaction() ) { Write write = tx.dataWrite(); int token = tx.tokenWrite().relationshipTypeGetOrCreateForName( "R" ); relationship = write.relationshipCreate( write.nodeCreate(), token, write.nodeCreate() ); tx.success(); } // Then try ( Transaction tx = beginTransaction() ) { try ( RelationshipScanCursor relationships = tx.cursors().allocateRelationshipScanCursor(); PropertyCursor properties = tx.cursors().allocatePropertyCursor() ) { tx.dataRead().singleRelationship( relationship, relationships ); assertTrue( relationships.next() ); assertFalse( hasProperties( relationships, tx ) ); int prop = tx.tokenWrite().propertyKeyGetOrCreateForName( "prop" ); tx.dataWrite().relationshipSetProperty( relationship, prop, stringValue( "foo" ) ); relationships.properties( properties ); assertTrue( properties.next() ); assertThat( properties.propertyType(), equalTo( ValueGroup.TEXT ) ); } } }