use of org.neo4j.values.virtual.NodeValue in project neo4j by neo4j.
the class CypherFunctions method asPoint.
private static Value asPoint(DbAccess access, VirtualNodeValue nodeValue, NodeCursor nodeCursor, PropertyCursor propertyCursor) {
MapValueBuilder builder = new MapValueBuilder();
for (String key : POINT_KEYS) {
Value value = access.nodeProperty(nodeValue.id(), access.propertyKey(key), nodeCursor, propertyCursor, true);
if (value == NO_VALUE) {
continue;
}
builder.add(key, value);
}
return PointValue.fromMap(builder.build());
}
use of org.neo4j.values.virtual.NodeValue in project neo4j by neo4j.
the class SchemaProcedureIT method testLabelIndex.
@Test
void testLabelIndex() throws Throwable {
KernelTransaction transaction = newTransaction(AnonymousContext.writeToken());
long nbrIndexesOnStartup = Iterators.count(transaction.schemaRead().indexesGetAll());
// Given there is label with index and a constraint
long nodeId = transaction.dataWrite().nodeCreate();
int labelId = transaction.tokenWrite().labelGetOrCreateForName("Person");
transaction.dataWrite().nodeAddLabel(nodeId, labelId);
int propertyIdName = transaction.tokenWrite().propertyKeyGetOrCreateForName("name");
int propertyIdAge = transaction.tokenWrite().propertyKeyGetOrCreateForName("age");
transaction.dataWrite().nodeSetProperty(nodeId, propertyIdName, Values.of("Emil"));
commit();
SchemaWrite schemaOps = schemaWriteInNewTransaction();
schemaOps.indexCreate(forLabel(labelId, propertyIdName), "my index");
schemaOps.uniquePropertyConstraintCreate(uniqueForSchema(forLabel(labelId, propertyIdAge)).withName("constraint name"));
commit();
// When
RawIterator<AnyValue[], ProcedureException> stream = procs().procedureCallRead(procs().procedureGet(procedureName("db", "schema", "visualization")).id(), new AnyValue[0], ProcedureCallContext.EMPTY);
// Then
while (stream.hasNext()) {
AnyValue[] next = stream.next();
assertEquals(2, next.length);
ListValue nodes = (ListValue) next[0];
assertEquals(1, nodes.size());
NodeValue node = (NodeValue) nodes.value(0);
assertThat(node.labels()).isEqualTo(Values.stringArray("Person"));
assertEquals(stringValue("Person"), node.properties().get("name"));
assertEquals(VirtualValues.list(stringValue("name")), node.properties().get("indexes"));
assertEquals(VirtualValues.list(stringValue("Constraint( id=" + (3 + nbrIndexesOnStartup) + ", name='constraint name', type='UNIQUENESS', schema=(:Person {age}), " + "ownedIndex=" + (2 + nbrIndexesOnStartup) + " )")), node.properties().get("constraints"));
}
}
use of org.neo4j.values.virtual.NodeValue in project neo4j by neo4j.
the class PathWrappingPathValue method nodes.
@Override
public NodeValue[] nodes() {
int length = path.length() + 1;
NodeValue[] values = new NodeValue[length];
int i = 0;
for (Node node : path.nodes()) {
values[i++] = ValueUtils.fromNodeEntity(node);
}
return values;
}
use of org.neo4j.values.virtual.NodeValue in project neo4j by neo4j.
the class BoltRequestMessageV3Test method shouldSerializeNode.
// "B1 71 91 B3 4E 0C 92 |84 55 73 65 72 | 86 42 61 6E\n61 6E 61 A284 6E 61 6D 65 83 42 6F 62 83 61 67\n65 0E"
// "B1 71 91 B3 4E 0C 92 |86 42 61 6E 61 6E 61| 84 55\n73 65 72 A2 84 6E 61 6D 65 83 42 6F 62 83 61 67\n65 0E
@Test
void shouldSerializeNode() throws Throwable {
NodeValue nodeValue = nodeValue(12L, stringArray("User", "Banana"), map(new String[] { "name", "age" }, new AnyValue[] { stringValue("Bob"), intValue(14) }));
assertThat(serialized(nodeValue)).isEqualTo("B1 71 91 B3 4E 0C 92 84 55 73 65 72 86 42 61 6E" + lineSeparator() + "61 6E 61 A2 84 6E 61 6D 65 83 42 6F 62 83 61 67" + lineSeparator() + "65 0E");
}
use of org.neo4j.values.virtual.NodeValue in project neo4j by neo4j.
the class PathValueBuilderTest method shouldHandleSingleNode.
@Test
void shouldHandleSingleNode() {
// Given
NodeValue node = node(42);
PathValueBuilder builder = builder(node);
// When
builder.addNode(node);
// Then
assertEquals(path(node), builder.build());
}
Aggregations