use of org.neo4j.storageengine.api.NodeItem in project neo4j by neo4j.
the class StorageLayerPropertyTest method should_get_all_node_properties.
@Test
public void should_get_all_node_properties() throws Exception {
// GIVEN
String longString = "AlalalalalongAlalalalalongAlalalalalongAlalalalalongAlalalalalongAlalalalalongAlalalalalongAlalalalalong";
Object[] properties = { longString, createNew(String.class), createNew(long.class), createNew(int.class), createNew(byte.class), createNew(short.class), createNew(boolean.class), createNew(char.class), createNew(float.class), createNew(double.class), array(0, String.class), array(0, long.class), array(0, int.class), array(0, byte.class), array(0, short.class), array(0, boolean.class), array(0, char.class), array(0, float.class), array(0, double.class), array(1, String.class), array(1, long.class), array(1, int.class), array(1, byte.class), array(1, short.class), array(1, boolean.class), array(1, char.class), array(1, float.class), array(1, double.class), array(256, String.class), array(256, long.class), array(256, int.class), array(256, byte.class), array(256, short.class), array(256, boolean.class), array(256, char.class), array(256, float.class), array(256, double.class) };
int propKey = disk.propertyKeyGetOrCreateForName("prop");
StorageStatement statement = state.getStoreStatement();
for (Object value : properties) {
// given
long nodeId = createLabeledNode(db, singletonMap("prop", value), label1).getId();
// when
try (Cursor<NodeItem> node = statement.acquireSingleNodeCursor(nodeId)) {
node.next();
Lock lock = node.get().lock();
try (Cursor<PropertyItem> props = statement.acquireSinglePropertyCursor(node.get().nextPropertyId(), propKey, lock)) {
if (props.next()) {
Object propVal = props.get().value();
//then
assertTrue(propVal + ".valueEquals(" + value + ")", Property.property(propKey, propVal).valueEquals(value));
} else {
fail();
}
}
}
}
}
use of org.neo4j.storageengine.api.NodeItem in project neo4j by neo4j.
the class StateOperationsAutoIndexingTest method shouldSignalNodePropertyRemovedToAutoIndex.
@Test
public void shouldSignalNodePropertyRemovedToAutoIndex() throws Exception {
// Given
PropertyItem existingProperty = mock(PropertyItem.class);
when(existingProperty.propertyKeyId()).thenReturn(1);
when(existingProperty.value()).thenReturn("Goodbye!");
int propertyKeyId = existingProperty.propertyKeyId();
NodeItem node = mock(NodeItem.class);
when(storeLayer.nodeGetProperty(eq(storeStmt), any(NodeItem.class), eq(propertyKeyId))).thenReturn(cursor(existingProperty));
when(node.labels()).thenReturn(PrimitiveIntCollections.emptySet());
when(storeStmt.acquireSingleNodeCursor(1337)).thenReturn(cursor(node));
// When
context.nodeRemoveProperty(stmt, 1337, propertyKeyId);
// Then
verify(nodeOps).propertyRemoved(writeOps, 1337L, propertyKeyId);
}
use of org.neo4j.storageengine.api.NodeItem in project neo4j by neo4j.
the class StateOperationsAutoIndexingTest method shouldSignalNodePropertyAddedToAutoIndex.
@Test
public void shouldSignalNodePropertyAddedToAutoIndex() throws Exception {
// Given
DefinedProperty property = property(1, "Hello!");
NodeItem node = mock(NodeItem.class);
when(node.labels()).thenReturn(PrimitiveIntCollections.emptySet());
when(storeStmt.acquireSingleNodeCursor(1337)).thenReturn(cursor(node));
when(storeLayer.nodeGetProperty(eq(storeStmt), any(NodeItem.class), eq(property.propertyKeyId()))).thenReturn(cursor());
// When
context.nodeSetProperty(stmt, 1337, property);
// Then
verify(nodeOps).propertyAdded(writeOps, 1337, property);
}
use of org.neo4j.storageengine.api.NodeItem in project neo4j by neo4j.
the class NeoStoresTest method deleteRelationships.
private void deleteRelationships(long nodeId) throws Exception {
try (KernelStatement statement = (KernelStatement) tx.acquireStatement();
Cursor<NodeItem> nodeCursor = statement.getStoreStatement().acquireSingleNodeCursor(nodeId)) {
assertTrue(nodeCursor.next());
NodeItem nodeItem = nodeCursor.get();
statement.getStoreStatement().acquireNodeRelationshipCursor(nodeItem.isDense(), nodeItem.id(), nodeItem.nextRelationshipId(), BOTH, ALWAYS_TRUE_INT).forAll(rel -> relDelete(rel.id()));
}
}
use of org.neo4j.storageengine.api.NodeItem in project neo4j by neo4j.
the class NeoStoresTest method assertHasRelationships.
private void assertHasRelationships(long node) {
try (KernelStatement statement = (KernelStatement) tx.acquireStatement();
Cursor<NodeItem> nodeCursor = statement.getStoreStatement().acquireSingleNodeCursor(node)) {
nodeCursor.next();
NodeItem nodeItem = nodeCursor.get();
try (Cursor<RelationshipItem> relationships = statement.getStoreStatement().acquireNodeRelationshipCursor(nodeItem.isDense(), nodeItem.id(), nodeItem.nextRelationshipId(), BOTH, ALWAYS_TRUE_INT)) {
assertTrue(relationships.next());
}
}
}
Aggregations