use of org.neo4j.values.virtual.ListValue in project neo4j by neo4j.
the class InCacheTest method shouldTrackMemory.
@Test
void shouldTrackMemory() {
// given
InCache cache = new InCache();
ListValue list = list(stringValue("a"), stringValue("b"), stringValue("c"));
// when
MemoryTracker memoryTracker = mock(MemoryTracker.class);
cache.check(stringValue("a"), list, memoryTracker);
// then
ArgumentCaptor<Long> arg = ArgumentCaptor.forClass(Long.class);
verify(memoryTracker).allocateHeap(arg.capture());
assertThat(arg.getValue()).isGreaterThan(0);
}
use of org.neo4j.values.virtual.ListValue in project neo4j by neo4j.
the class CypherFunctions method toSlice.
public static ListValue toSlice(AnyValue collection, AnyValue toValue) {
assert collection != NO_VALUE && toValue != NO_VALUE : "NO_VALUE checks need to happen outside this call";
int from = asInt(toValue);
ListValue list = asList(collection);
if (from >= 0) {
return list.take(from);
} else {
return list.take(list.size() + from);
}
}
use of org.neo4j.values.virtual.ListValue in project neo4j by neo4j.
the class PathValueBuilder method addMultipleUndirected.
/**
* Adds multiple undirected relationships to the path
*
* @param relationships the undirected relationships to add
*/
@CalledFromGeneratedCode
public void addMultipleUndirected(ListValue relationships) {
if (relationships.isEmpty()) {
// nothing to add
return;
}
long previous = nodes.get(nodes.size() - 1).id();
RelationshipValue first = (RelationshipValue) relationships.head();
boolean correctDirection = startNode(first, dbAccess, cursor).id() == previous || endNode(first, dbAccess, cursor).id() == previous;
if (correctDirection) {
for (AnyValue value : relationships) {
if (notNoValue(value)) {
addUndirectedWhenRelationshipsAreFullyLoaded((RelationshipValue) value);
}
}
} else {
ListValue reversed = relationships.reverse();
for (AnyValue rel : reversed) {
if (notNoValue(rel)) {
addUndirectedWhenRelationshipsAreFullyLoaded((RelationshipValue) rel);
}
}
}
}
Aggregations