Search in sources :

Example 6 with MapValue

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;
}
Also used : VersionContext(org.neo4j.io.pagecache.context.VersionContext) FullyParsedQuery(org.neo4j.cypher.internal.FullyParsedQuery) Result(org.neo4j.graphdb.Result) TransactionalContext(org.neo4j.kernel.impl.query.TransactionalContext) LogProvider(org.neo4j.logging.LogProvider) Config(org.neo4j.configuration.Config) QueryExecutionKernelException(org.neo4j.kernel.impl.query.QueryExecutionKernelException) GraphDatabaseQueryService(org.neo4j.kernel.GraphDatabaseQueryService) QueryExecutionMonitor(org.neo4j.kernel.impl.query.QueryExecutionMonitor) CompilerFactory(org.neo4j.cypher.internal.CompilerFactory) InputDataStream(org.neo4j.cypher.internal.runtime.InputDataStream) GraphDatabaseInternalSettings(org.neo4j.configuration.GraphDatabaseInternalSettings) QuerySubscriber(org.neo4j.kernel.impl.query.QuerySubscriber) MapValue(org.neo4j.values.virtual.MapValue) CaffeineCacheFactory(org.neo4j.cypher.internal.cache.CaffeineCacheFactory) QueryExecution(org.neo4j.kernel.impl.query.QueryExecution) QueryExecution(org.neo4j.kernel.impl.query.QueryExecution)

Example 7 with MapValue

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);
    }
}
Also used : MapValue(org.neo4j.values.virtual.MapValue) LocalDate(java.time.LocalDate)

Example 8 with MapValue

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);
    });
}
Also used : AnyValue(org.neo4j.values.AnyValue) AnyValue(org.neo4j.values.AnyValue) Values.doubleValue(org.neo4j.values.storable.Values.doubleValue) Value(org.neo4j.values.storable.Value) Values.longValue(org.neo4j.values.storable.Values.longValue) MapValue(org.neo4j.values.virtual.MapValue) TextValue(org.neo4j.values.storable.TextValue) Values.stringValue(org.neo4j.values.storable.Values.stringValue)

Example 9 with MapValue

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);
}
Also used : AnyValue(org.neo4j.values.AnyValue) MapValue(org.neo4j.values.virtual.MapValue) Test(org.junit.jupiter.api.Test)

Example 10 with MapValue

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);
    }
}
Also used : ChronoField(java.time.temporal.ChronoField) AnyValue(org.neo4j.values.AnyValue) DateTimeValue.parseZoneName(org.neo4j.values.storable.DateTimeValue.parseZoneName) ZonedDateTime(java.time.ZonedDateTime) TemporalUnit(java.time.temporal.TemporalUnit) BiFunction(java.util.function.BiFunction) LocalDateTime(java.time.LocalDateTime) TemporalQuery(java.time.temporal.TemporalQuery) HashMap(java.util.HashMap) Function(java.util.function.Function) Supplier(java.util.function.Supplier) ValueRange(java.time.temporal.ValueRange) Matcher(java.util.regex.Matcher) TemporalParseException(org.neo4j.exceptions.TemporalParseException) Map(java.util.Map) LocalTime(java.time.LocalTime) TemporalAmount(java.time.temporal.TemporalAmount) MapValue(org.neo4j.values.virtual.MapValue) ZoneOffset(java.time.ZoneOffset) StructureBuilder(org.neo4j.values.StructureBuilder) IntegralValue.safeCastIntegral(org.neo4j.values.storable.IntegralValue.safeCastIntegral) LocalDateTimeValue.localDateTime(org.neo4j.values.storable.LocalDateTimeValue.localDateTime) HashFunction(org.neo4j.hashing.HashFunction) DateTimeException(java.time.DateTimeException) OffsetTime(java.time.OffsetTime) EnumMap(java.util.EnumMap) UnsupportedTemporalUnitException(org.neo4j.exceptions.UnsupportedTemporalUnitException) TemporalField(java.time.temporal.TemporalField) Set(java.util.Set) DateTimeValue.datetime(org.neo4j.values.storable.DateTimeValue.datetime) TimeValue.time(org.neo4j.values.storable.TimeValue.time) UnsupportedTemporalTypeException(java.time.temporal.UnsupportedTemporalTypeException) ZoneId(java.time.ZoneId) InvalidArgumentException(org.neo4j.exceptions.InvalidArgumentException) NO_NUMBER(org.neo4j.values.storable.NumberType.NO_NUMBER) Objects(java.util.Objects) ChronoZonedDateTime(java.time.chrono.ChronoZonedDateTime) ChronoUnit(java.time.temporal.ChronoUnit) IsoFields(java.time.temporal.IsoFields) LocalDate(java.time.LocalDate) Pattern(java.util.regex.Pattern) Pair(org.neo4j.internal.helpers.collection.Pair) Temporal(java.time.temporal.Temporal) TemporalAdjuster(java.time.temporal.TemporalAdjuster) ArithmeticException(org.neo4j.exceptions.ArithmeticException) AnyValue(org.neo4j.values.AnyValue) MapValue(org.neo4j.values.virtual.MapValue)

Aggregations

MapValue (org.neo4j.values.virtual.MapValue)48 Test (org.junit.jupiter.api.Test)30 AnyValue (org.neo4j.values.AnyValue)7 BoltIOException (org.neo4j.bolt.messaging.BoltIOException)6 QueryExecution (org.neo4j.kernel.impl.query.QueryExecution)6 BoltAdapterSubscriber (org.neo4j.bolt.runtime.statemachine.impl.BoltAdapterSubscriber)5 QueryStatistics (org.neo4j.graphdb.QueryStatistics)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)3 RunMessage (org.neo4j.bolt.v3.messaging.request.RunMessage)3 ValueUtils.asMapValue (org.neo4j.kernel.impl.util.ValueUtils.asMapValue)3 Clock (java.time.Clock)2 LocalDate (java.time.LocalDate)2 HashMap (java.util.HashMap)2 SuccessMessage (org.neo4j.bolt.v3.messaging.response.SuccessMessage)2 NotFoundException (org.neo4j.graphdb.NotFoundException)2 RelationshipEntity (org.neo4j.kernel.impl.core.RelationshipEntity)2 EmbeddedChannel (io.netty.channel.embedded.EmbeddedChannel)1 IOException (java.io.IOException)1 UncheckedIOException (java.io.UncheckedIOException)1 DateTimeException (java.time.DateTimeException)1