Search in sources :

Example 11 with MapValueBuilder

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

the class ValueUtils method asMapValue.

public static MapValue asMapValue(Map<String, ?> map) {
    int size = map.size();
    if (size == 0) {
        return VirtualValues.EMPTY_MAP;
    }
    MapValueBuilder builder = new MapValueBuilder(size);
    for (Map.Entry<String, ?> entry : map.entrySet()) {
        builder.add(entry.getKey(), ValueUtils.of(entry.getValue()));
    }
    return builder.build();
}
Also used : MapValueBuilder(org.neo4j.values.virtual.MapValueBuilder) Map(java.util.Map) Point(org.neo4j.graphdb.spatial.Point)

Example 12 with MapValueBuilder

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

the class TruncatedQuerySnapshot method truncateParameters.

private static MapValue truncateParameters(MapValue parameters) {
    int size = parameters.size();
    if (size == 0) {
        return VirtualValues.EMPTY_MAP;
    }
    MapValueBuilder mapValueBuilder = new MapValueBuilder(size);
    parameters.foreach((key, value) -> {
        mapValueBuilder.add(key.length() <= MAX_PARAMETER_KEY_LENGTH ? key : key.substring(0, MAX_PARAMETER_KEY_LENGTH), value.map(VALUE_TRUNCATER));
    });
    return mapValueBuilder.build();
}
Also used : MapValueBuilder(org.neo4j.values.virtual.MapValueBuilder)

Example 13 with MapValueBuilder

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

the class AbstractCypherAdapterStream method systemQueryStats.

private MapValue systemQueryStats(QueryStatistics queryStatistics) {
    MapValueBuilder builder = new MapValueBuilder();
    addIfNonZero(builder, "system-updates", queryStatistics.getSystemUpdates());
    return builder.build();
}
Also used : MapValueBuilder(org.neo4j.values.virtual.MapValueBuilder)

Example 14 with MapValueBuilder

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

the class AbstractCypherAdapterStream method convertNotifications.

private static AnyValue convertNotifications(Iterable<Notification> notifications) {
    ListValueBuilder listValueBuilder = ListValueBuilder.newListBuilder();
    for (Notification notification : notifications) {
        // position is optional
        InputPosition pos = notification.getPosition();
        boolean includePosition = !pos.equals(InputPosition.empty);
        int size = includePosition ? 5 : 4;
        MapValueBuilder builder = new MapValueBuilder(size);
        builder.add("code", utf8Value(notification.getCode()));
        builder.add("title", utf8Value(notification.getTitle()));
        builder.add("description", utf8Value(notification.getDescription()));
        builder.add("severity", utf8Value(notification.getSeverity().toString()));
        if (includePosition) {
            // only add the position if it is not empty
            builder.add("position", VirtualValues.map(new String[] { "offset", "line", "column" }, new AnyValue[] { intValue(pos.getOffset()), intValue(pos.getLine()), intValue(pos.getColumn()) }));
        }
        listValueBuilder.add(builder.build());
    }
    return listValueBuilder.build();
}
Also used : MapValueBuilder(org.neo4j.values.virtual.MapValueBuilder) InputPosition(org.neo4j.graphdb.InputPosition) AnyValue(org.neo4j.values.AnyValue) Notification(org.neo4j.graphdb.Notification) ListValueBuilder(org.neo4j.values.virtual.ListValueBuilder)

Example 15 with MapValueBuilder

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

the class ValueUtils method asParameterMapValue.

public static MapValue asParameterMapValue(Map<String, Object> map) {
    int size = map.size();
    if (size == 0) {
        return VirtualValues.EMPTY_MAP;
    }
    MapValueBuilder builder = new MapValueBuilder(size);
    for (Map.Entry<String, Object> entry : map.entrySet()) {
        try {
            builder.add(entry.getKey(), ValueUtils.of(entry.getValue()));
        } catch (IllegalArgumentException e) {
            builder.add(entry.getKey(), VirtualValues.error(e));
        }
    }
    return builder.build();
}
Also used : MapValueBuilder(org.neo4j.values.virtual.MapValueBuilder) Map(java.util.Map) Point(org.neo4j.graphdb.spatial.Point)

Aggregations

MapValueBuilder (org.neo4j.values.virtual.MapValueBuilder)22 AnyValue (org.neo4j.values.AnyValue)6 SocketAddress (org.neo4j.configuration.helpers.SocketAddress)5 AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)5 Map (java.util.Map)4 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 EnumSource (org.junit.jupiter.params.provider.EnumSource)4 Point (org.neo4j.graphdb.spatial.Point)3 HostnamePort (org.neo4j.internal.helpers.HostnamePort)3 LongValue (org.neo4j.values.storable.LongValue)3 Value (org.neo4j.values.storable.Value)3 Values.doubleValue (org.neo4j.values.storable.Values.doubleValue)3 Values.longValue (org.neo4j.values.storable.Values.longValue)3 Values.stringValue (org.neo4j.values.storable.Values.stringValue)3 NodeValue (org.neo4j.values.virtual.NodeValue)3 PathValue (org.neo4j.values.virtual.PathValue)3 RelationshipValue (org.neo4j.values.virtual.RelationshipValue)3 VirtualNodeValue (org.neo4j.values.virtual.VirtualNodeValue)3 VirtualRelationshipValue (org.neo4j.values.virtual.VirtualRelationshipValue)3 SequenceValue (org.neo4j.values.SequenceValue)2