Search in sources :

Example 46 with MapValue

use of org.neo4j.values.virtual.MapValue in project neo4j by neo4j.

the class RoutingResultFormat method parseRows.

private static Map<Role, List<SocketAddress>> parseRows(ListValue rows) {
    Map<Role, List<SocketAddress>> endpoints = new HashMap<>();
    for (AnyValue single : rows) {
        MapValue row = (MapValue) single;
        Role role = Role.valueOf(((TextValue) row.get("role")).stringValue());
        List<SocketAddress> addresses = parseEndpoints((ListValue) row.get("addresses"));
        endpoints.put(role, addresses);
    }
    Arrays.stream(Role.values()).forEach(r -> endpoints.putIfAbsent(r, Collections.emptyList()));
    return endpoints;
}
Also used : HashMap(java.util.HashMap) AnyValue(org.neo4j.values.AnyValue) ArrayList(java.util.ArrayList) List(java.util.List) MapValue(org.neo4j.values.virtual.MapValue) SocketAddress(org.neo4j.configuration.helpers.SocketAddress)

Example 47 with MapValue

use of org.neo4j.values.virtual.MapValue in project neo4j by neo4j.

the class BoltConnectionIT method createLocalIrisData.

private String createLocalIrisData(BoltStateMachine machine) throws Exception {
    for (String className : IRIS_CLASS_NAMES) {
        MapValue params = map("className", className);
        runAndPull(machine, "CREATE (c:Class {name: $className}) RETURN c", params);
    }
    return env.putTmpFile("iris", ".csv", IRIS_DATA).toExternalForm();
}
Also used : MapValue(org.neo4j.values.virtual.MapValue)

Example 48 with MapValue

use of org.neo4j.values.virtual.MapValue in project neo4j by neo4j.

the class BoltV3TransportIT method shouldSetTxMetadata.

@ParameterizedTest(name = "{0}")
@MethodSource("argumentsProvider")
public void shouldSetTxMetadata(Class<? extends TransportConnection> connectionClass) throws Exception {
    init(connectionClass);
    // Given
    negotiateBoltV3();
    Map<String, Object> txMetadata = map("who-is-your-boss", "Molly-mostly-white");
    Map<String, Object> msgMetadata = map("tx_metadata", txMetadata);
    MapValue meta = asMapValue(msgMetadata);
    connection.send(util.chunk(new BeginMessage(meta, List.of(), null, AccessMode.WRITE, txMetadata), new RunMessage("RETURN 1"), PullAllMessage.INSTANCE));
    // When
    assertThat(connection).satisfies(util.eventuallyReceives(msgSuccess(), msgSuccess(), msgRecord(eqRecord(longEquals(1L))), msgSuccess()));
    // Then
    GraphDatabaseAPI gdb = (GraphDatabaseAPI) server.graphDatabaseService();
    Set<KernelTransactionHandle> txHandles = gdb.getDependencyResolver().resolveDependency(KernelTransactions.class).activeTransactions();
    assertThat(txHandles.size()).isEqualTo(1);
    for (KernelTransactionHandle txHandle : txHandles) {
        assertThat(txHandle.getMetaData()).isEqualTo(txMetadata);
    }
    connection.send(util.chunk(ROLLBACK_MESSAGE));
}
Also used : BeginMessage(org.neo4j.bolt.v3.messaging.request.BeginMessage) GraphDatabaseAPI(org.neo4j.kernel.internal.GraphDatabaseAPI) KernelTransactions(org.neo4j.kernel.impl.api.KernelTransactions) ValueUtils.asMapValue(org.neo4j.kernel.impl.util.ValueUtils.asMapValue) MapValue(org.neo4j.values.virtual.MapValue) RunMessage(org.neo4j.bolt.v3.messaging.request.RunMessage) KernelTransactionHandle(org.neo4j.kernel.api.KernelTransactionHandle) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

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