use of org.neo4j.values.AnyValue in project neo4j by neo4j.
the class HeapTrackingListValueBuilderTest method streamAndCollectElements.
@Test
void streamAndCollectElements() {
int iterations = rnd.nextInt(10, 1000);
ArrayList<LongValue> list = new ArrayList<>(iterations);
for (int i = 0; i < iterations; i++) {
list.add(Values.longValue(i));
}
var collector = HeapTrackingListValueBuilder.collector(memoryTracker);
ListValue listValue = list.stream().collect(collector);
// Validate value size
long memoryTrackerActualSize = meter.measureDeep(memoryTracker);
long actualValueSize = meter.measureDeep(listValue) - memoryTrackerActualSize;
long estimatedValueSize = listValue.estimatedHeapUsage();
assertEquals(actualValueSize, estimatedValueSize);
// Validate items
Iterator<AnyValue> iterator = listValue.iterator();
for (int i = 0; i < iterations; i++) {
assertTrue(iterator.hasNext());
assertEquals(i, ((LongValue) iterator.next()).longValue());
}
assertFalse(iterator.hasNext());
}
use of org.neo4j.values.AnyValue in project neo4j by neo4j.
the class BuiltInProceduresIT method dbIndexesResult.
private static AnyValue[] dbIndexesResult(long id, String name, String state, Double populationPercent, String uniqueness, String type, String entityType, List<String> labelsOrTypes, List<String> properties, String provider) {
ListValue labelsOrTypesList = VirtualValues.list(labelsOrTypes.stream().map(Values::stringValue).toArray(AnyValue[]::new));
ListValue propertiesList = VirtualValues.list(properties.stream().map(Values::stringValue).toArray(AnyValue[]::new));
return new AnyValue[] { longValue(id), stringValue(name), stringValue(state), doubleValue(populationPercent), stringValue(uniqueness), stringValue(type), stringValue(entityType), labelsOrTypesList, propertiesList, stringValue(provider) };
}
use of org.neo4j.values.AnyValue 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.AnyValue in project neo4j by neo4j.
the class BoltResponseMessageWriterV3Test method shouldWriteRecordMessage.
@Test
void shouldWriteRecordMessage() throws Exception {
PackOutput output = mock(PackOutput.class);
Neo4jPack.Packer packer = mock(Neo4jPack.Packer.class);
var writer = newWriter(output, packer);
writer.write(new RecordMessage(new AnyValue[] { longValue(42), stringValue("42") }));
InOrder inOrder = inOrder(output, packer);
inOrder.verify(output).beginMessage();
inOrder.verify(packer).pack(longValue(42));
inOrder.verify(packer).pack(stringValue("42"));
inOrder.verify(output).messageSucceeded();
}
use of org.neo4j.values.AnyValue in project neo4j by neo4j.
the class TruncatedQuerySnapshotTest method shouldTruncateNode.
@Test
void shouldTruncateNode() {
// when
TruncatedQuerySnapshot x = new TruncatedQuerySnapshot(null, "", null, map("n", NODE), -1L, -1L, -1L, 100);
// then
AnyValue truncatedNode = x.queryParameters.get("n");
assertTrue(truncatedNode instanceof NodeReference);
assertEquals(NODE.id(), ((NodeReference) truncatedNode).id());
}
Aggregations