use of org.neo4j.internal.kernel.api.PropertyCursor in project neo4j by neo4j.
the class DefaultPooledCursorsTestBase method shouldReusePropertyCursor.
@Test
void shouldReusePropertyCursor() {
NodeCursor node = cursors.allocateNodeCursor(NULL);
PropertyCursor c1 = cursors.allocatePropertyCursor(NULL, INSTANCE);
read.singleNode(propNode, node);
node.next();
node.properties(c1);
node.close();
c1.close();
PropertyCursor c2 = cursors.allocatePropertyCursor(NULL, INSTANCE);
assertThat(c1).isSameAs(c2);
c2.close();
}
use of org.neo4j.internal.kernel.api.PropertyCursor in project neo4j by neo4j.
the class NodeTransactionStateTestBase method hasPropertiesShouldSeeNewlyCreatedProperties.
@Test
void hasPropertiesShouldSeeNewlyCreatedProperties() throws Exception {
// Given
long node;
try (KernelTransaction tx = beginTransaction()) {
node = tx.dataWrite().nodeCreate();
tx.commit();
}
// Then
try (KernelTransaction tx = beginTransaction()) {
try (NodeCursor cursor = tx.cursors().allocateNodeCursor(tx.cursorContext());
PropertyCursor props = tx.cursors().allocatePropertyCursor(tx.cursorContext(), tx.memoryTracker())) {
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));
}
}
}
use of org.neo4j.internal.kernel.api.PropertyCursor in project neo4j by neo4j.
the class NodeTransactionStateTestBase method shouldSeeRemovedThenAddedPropertyInTransaction.
@Test
void shouldSeeRemovedThenAddedPropertyInTransaction() throws Exception {
// Given
long nodeId;
String propKey = "prop1";
int propToken;
try (KernelTransaction tx = beginTransaction()) {
nodeId = tx.dataWrite().nodeCreate();
propToken = tx.token().propertyKeyGetOrCreateForName(propKey);
assertEquals(NO_VALUE, tx.dataWrite().nodeSetProperty(nodeId, propToken, stringValue("hello")));
tx.commit();
}
// When/Then
try (KernelTransaction tx = beginTransaction()) {
assertEquals(tx.dataWrite().nodeRemoveProperty(nodeId, propToken), stringValue("hello"));
assertEquals(NO_VALUE, tx.dataWrite().nodeSetProperty(nodeId, propToken, stringValue("world")));
try (NodeCursor node = tx.cursors().allocateNodeCursor(tx.cursorContext());
PropertyCursor property = tx.cursors().allocatePropertyCursor(tx.cursorContext(), tx.memoryTracker())) {
tx.dataRead().singleNode(nodeId, node);
assertTrue(node.next(), "should access node");
node.properties(property);
assertTrue(property.next());
assertEquals(propToken, property.propertyKey());
assertEquals(property.propertyValue(), stringValue("world"));
assertFalse(property.next(), "should not find any properties");
assertFalse(node.next(), "should only find one node");
}
tx.commit();
}
try (org.neo4j.graphdb.Transaction tx = graphDb.beginTx()) {
assertThat(tx.getNodeById(nodeId).getProperty(propKey)).isEqualTo("world");
}
}
use of org.neo4j.internal.kernel.api.PropertyCursor in project neo4j by neo4j.
the class ManagedTestCursors method allocateFullAccessPropertyCursor.
@Override
public PropertyCursor allocateFullAccessPropertyCursor(CursorContext cursorContext, MemoryTracker memoryTracker) {
PropertyCursor n = cursors.allocateFullAccessPropertyCursor(cursorContext, memoryTracker);
allCursors.add(n);
return n;
}
use of org.neo4j.internal.kernel.api.PropertyCursor in project neo4j by neo4j.
the class ManagedTestCursors method allocatePropertyCursor.
@Override
public PropertyCursor allocatePropertyCursor(CursorContext cursorContext, MemoryTracker memoryTracker) {
PropertyCursor n = cursors.allocatePropertyCursor(cursorContext, memoryTracker);
allCursors.add(n);
return n;
}
Aggregations