@Override public PropertyCursor allocatePropertyCursor() { PropertyCursor n = cursors.allocatePropertyCursor(); allCursors.add( n ); return n; }
private boolean hasProperties( RelationshipScanCursor cursor, Transaction tx ) { try ( PropertyCursor propertyCursor = tx.cursors().allocatePropertyCursor() ) { cursor.properties( propertyCursor ); return propertyCursor.next(); } }
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 ); }
@Test public void shouldSeeNewGraphPropertyInTransaction() throws Exception { try ( Transaction tx = beginTransaction(); PropertyCursor cursor = tx.cursors().allocatePropertyCursor() ) { int prop = tx.tokenWrite().propertyKeyGetOrCreateForName( "prop" ); assertThat( tx.dataWrite().graphSetProperty( prop, stringValue( "hello" ) ), equalTo( NO_VALUE ) ); tx.dataRead().graphProperties( cursor ); assertTrue( cursor.next() ); assertThat( cursor.propertyKey(), equalTo( prop ) ); assertThat( cursor.propertyValue(), equalTo( stringValue( "hello" ) ) ); } }
@Test public void shouldSeeUpdatedGraphPropertyInTransaction() throws Exception { int prop; try ( Transaction tx = beginTransaction() ) { prop = tx.tokenWrite().propertyKeyGetOrCreateForName( "prop" ); assertThat( tx.dataWrite().graphSetProperty( prop, stringValue( "hello" ) ), equalTo( NO_VALUE ) ); tx.success(); } try ( Transaction tx = beginTransaction(); PropertyCursor cursor = tx.cursors().allocatePropertyCursor() ) { assertThat( tx.dataWrite().graphSetProperty( prop, stringValue( "good bye" ) ), equalTo( stringValue( "hello" ) ) ); tx.dataRead().graphProperties( cursor ); assertTrue( cursor.next() ); assertThat( cursor.propertyKey(), equalTo( prop ) ); assertThat( cursor.propertyValue(), equalTo( stringValue( "good bye" ) ) ); assertFalse( cursor.next() ); } }
@Test public void shouldNotSeeRemovedGraphPropertyInTransaction() throws Exception { int prop; try ( Transaction tx = beginTransaction() ) { prop = tx.tokenWrite().propertyKeyGetOrCreateForName( "prop" ); assertThat( tx.dataWrite().graphSetProperty( prop, stringValue( "hello" ) ), equalTo( NO_VALUE ) ); tx.success(); } try ( Transaction tx = beginTransaction(); PropertyCursor cursor = tx.cursors().allocatePropertyCursor() ) { assertThat( tx.dataWrite().graphRemoveProperty( prop ), equalTo( stringValue( "hello" ) ) ); tx.dataRead().graphProperties( cursor ); assertFalse( cursor.next() ); } }
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(); }
@Test public void shouldBeAbleToReadExistingGraphProperties() throws Exception { int prop1, prop2, prop3; try ( Transaction tx = beginTransaction() ) { prop1 = tx.tokenWrite().propertyKeyGetOrCreateForName( "prop1" ); prop2 = tx.tokenWrite().propertyKeyGetOrCreateForName( "prop2" ); prop3 = tx.tokenWrite().propertyKeyGetOrCreateForName( "prop3" ); tx.dataWrite().graphSetProperty( prop1, stringValue( "hello" ) ); tx.dataWrite().graphSetProperty( prop2, stringValue( "world" ) ); tx.dataWrite().graphSetProperty( prop3, stringValue( "etc" ) ); tx.success(); } try ( Transaction tx = beginTransaction(); PropertyCursor cursor = tx.cursors().allocatePropertyCursor() ) { tx.dataRead().graphProperties( cursor ); assertTrue( cursor.next() ); assertThat( cursor.propertyKey(), equalTo( prop1 ) ); assertThat( cursor.propertyValue(), equalTo( stringValue( "hello" ) ) ); assertTrue( cursor.next() ); assertThat( cursor.propertyKey(), equalTo( prop2 ) ); assertThat( cursor.propertyValue(), equalTo( stringValue( "world" ) ) ); assertTrue( cursor.next() ); assertThat( cursor.propertyKey(), equalTo( prop3 ) ); assertThat( cursor.propertyValue(), equalTo( stringValue( "etc" ) ) ); assertFalse( cursor.next() ); } }
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; } } }
@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 ) ); } } }
@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 ) ); } } }
@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 ) ); } } }
@Test public void hasPropertiesShouldSeeNewlyCreatedProperties() throws Exception { // Given long node; try ( Transaction tx = beginTransaction() ) { node = tx.dataWrite().nodeCreate(); tx.success(); } // Then try ( Transaction tx = beginTransaction() ) { 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 ) ); } } }
stringValue( "hello" ) ); try ( NodeCursor node = tx.cursors().allocateNodeCursor(); PropertyCursor property = tx.cursors().allocatePropertyCursor() )
PropertyCursor property = tx.cursors().allocatePropertyCursor() )
assertEquals( tx.dataWrite().nodeSetProperty( nodeId, propToken, stringValue( "world" ) ), NO_VALUE ); try ( NodeCursor node = tx.cursors().allocateNodeCursor(); PropertyCursor property = tx.cursors().allocatePropertyCursor() )
PropertyCursor property = tx.cursors().allocatePropertyCursor() )
PropertyCursor props = tx.cursors().allocatePropertyCursor() )
PropertyCursor property = tx.cursors().allocatePropertyCursor() )
PropertyCursor property = tx.cursors().allocatePropertyCursor() )