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();
}
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();
}
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();
}
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();
}
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();
}
Aggregations