use of org.neo4j.values.virtual.MapValue in project neo4j by neo4j.
the class SnapshotExecutionEngine method executeQuery.
@Override
public Result executeQuery(String query, MapValue parameters, TransactionalContext context, boolean prePopulate) throws QueryExecutionKernelException {
QueryExecutor queryExecutor = querySubscriber -> super.executeQuery(query, parameters, context, prePopulate, querySubscriber);
ResultSubscriber resultSubscriber = new ResultSubscriber(context);
MaterialisedResult materialisedResult = executeWithRetries(query, context, queryExecutor);
QueryExecution queryExecution = materialisedResult.stream(resultSubscriber);
resultSubscriber.init(queryExecution);
return resultSubscriber;
}
use of org.neo4j.values.virtual.MapValue in project neo4j by neo4j.
the class DateValue method truncate.
public static DateValue truncate(TemporalUnit unit, TemporalValue input, MapValue fields, Supplier<ZoneId> defaultZone) {
LocalDate localDate = input.getDatePart();
DateValue truncated = date(truncateTo(localDate, unit));
if (fields.size() == 0) {
return truncated;
} else {
MapValue updatedFields = fields.updatedWith("date", truncated);
return build(updatedFields, defaultZone);
}
}
use of org.neo4j.values.virtual.MapValue in project neo4j by neo4j.
the class DbIndexesFailureMessageIT method assertMapsEqual.
private void assertMapsEqual(Map<String, Value> expected, MapValue actual) {
assertEquals(expected.size(), actual.size());
expected.forEach((k, v) -> {
final AnyValue value = actual.get(k);
assertNotNull(value);
assertEquals(v, value);
});
actual.foreach((k, v) -> {
final Value value = expected.get(k);
assertNotNull(value);
assertEquals(v, value);
});
}
use of org.neo4j.values.virtual.MapValue in project neo4j by neo4j.
the class ValueUtilsTest method shouldHandleMaps.
@Test
void shouldHandleMaps() {
// Given
Map<String, Object> map = MapUtil.map("a", Arrays.asList("foo", 42));
// When
AnyValue anyValue = ValueUtils.of(map);
// Then
assertThat(anyValue).isInstanceOf(MapValue.class);
MapValue mapValue = (MapValue) anyValue;
assertThat(mapValue.get("a")).isEqualTo(VirtualValues.list(stringValue("foo"), intValue(42)));
assertThat(mapValue.size()).isEqualTo(1);
}
use of org.neo4j.values.virtual.MapValue in project neo4j by neo4j.
the class TemporalValue method updateFieldMapWithConflictingSubseconds.
static <TEMP extends Temporal, VALUE> VALUE updateFieldMapWithConflictingSubseconds(MapValue fields, TemporalUnit unit, TEMP temporal, BiFunction<MapValue, TEMP, VALUE> mapFunction) {
boolean conflictingMilliSeconds = unit == ChronoUnit.MILLIS && (fields.containsKey("microsecond") || fields.containsKey("nanosecond"));
boolean conflictingMicroSeconds = unit == ChronoUnit.MICROS && fields.containsKey("nanosecond");
if (conflictingMilliSeconds) {
AnyValue millis = Values.intValue(temporal.get(ChronoField.MILLI_OF_SECOND));
AnyValue micros = fields.get("microsecond");
AnyValue nanos = fields.get("nanosecond");
int newNanos = validNano(millis, micros, nanos);
TEMP newTemporal = (TEMP) temporal.with(ChronoField.NANO_OF_SECOND, newNanos);
MapValue filtered = fields.filter((k, ignore) -> !k.equals("microsecond") && !k.equals("nanosecond"));
return mapFunction.apply(filtered, newTemporal);
} else if (conflictingMicroSeconds) {
AnyValue micros = Values.intValue(temporal.get(ChronoField.MICRO_OF_SECOND));
AnyValue nanos = fields.get("nanosecond");
int newNanos = validNano(null, micros, nanos);
TEMP newTemporal = (TEMP) temporal.with(ChronoField.NANO_OF_SECOND, newNanos);
MapValue filtered = fields.filter((k, ignore) -> !k.equals("nanosecond"));
return mapFunction.apply(filtered, newTemporal);
} else {
return mapFunction.apply(fields, temporal);
}
}
Aggregations