use of org.neo4j.values.virtual.MapValueBuilder in project neo4j by neo4j.
the class ExecutionPlanConverter method convert.
public static MapValue convert(ExecutionPlanDescription plan) {
boolean hasProfilerStatistics = plan.hasProfilerStatistics();
int size = hasProfilerStatistics ? 10 : 4;
MapValueBuilder out = new MapValueBuilder(size);
out.add("operatorType", utf8Value(plan.getName()));
out.add("args", ValueUtils.asMapValue(plan.getArguments()));
out.add("identifiers", ValueUtils.asListValue(plan.getIdentifiers()));
out.add("children", children(plan));
if (hasProfilerStatistics) {
ExecutionPlanDescription.ProfilerStatistics profile = plan.getProfilerStatistics();
if (profile.hasDbHits()) {
out.add("dbHits", longValue(profile.getDbHits()));
}
if (profile.hasPageCacheStats()) {
out.add("pageCacheHits", longValue(profile.getPageCacheHits()));
out.add("pageCacheMisses", longValue(profile.getPageCacheMisses()));
out.add("pageCacheHitRatio", doubleValue(profile.getPageCacheHitRatio()));
}
if (profile.hasRows()) {
out.add("rows", longValue(profile.getRows()));
}
if (profile.hasTime()) {
out.add("time", longValue(profile.getTime()));
}
}
return out.build();
}
use of org.neo4j.values.virtual.MapValueBuilder in project neo4j by neo4j.
the class CypherFunctions method asPoint.
private static Value asPoint(DbAccess access, VirtualNodeValue nodeValue, NodeCursor nodeCursor, PropertyCursor propertyCursor) {
MapValueBuilder builder = new MapValueBuilder();
for (String key : POINT_KEYS) {
Value value = access.nodeProperty(nodeValue.id(), access.propertyKey(key), nodeCursor, propertyCursor, true);
if (value == NO_VALUE) {
continue;
}
builder.add(key, value);
}
return PointValue.fromMap(builder.build());
}
use of org.neo4j.values.virtual.MapValueBuilder in project neo4j by neo4j.
the class JmxQueryProcedure method toNeo4jValue.
private MapValue toNeo4jValue(ObjectName name, MBeanAttributeInfo attribute) throws JMException {
AnyValue value;
try {
value = toNeo4jValue(jmxServer.getAttribute(name, attribute.getName()));
} catch (RuntimeMBeanException e) {
if (e.getCause() != null && e.getCause() instanceof UnsupportedOperationException) {
// We include the name and description of this attribute still - but the value of it is
// unknown. We do this rather than rethrow the exception, because several MBeans built into
// the JVM will throw exception on attribute access depending on their runtime state, even
// if the attribute is marked as readable. Notably the GC beans do this.
value = NO_VALUE;
} else {
throw e;
}
}
MapValueBuilder builder = new MapValueBuilder(2);
builder.add("description", stringValue(attribute.getDescription()));
builder.add("value", value);
return builder.build();
}
use of org.neo4j.values.virtual.MapValueBuilder in project neo4j by neo4j.
the class JmxQueryProcedure method toNeo4jValue.
private MapValue toNeo4jValue(Map<?, ?> attributeValue) {
// Build a new map with the same keys, but each value passed
// through `toNeo4jValue`
MapValueBuilder builder = new MapValueBuilder();
attributeValue.forEach((key, value) -> builder.add(key.toString(), toNeo4jValue(value)));
return builder.build();
}
use of org.neo4j.values.virtual.MapValueBuilder in project neo4j by neo4j.
the class ValueMapperTest method valueOf.
private static AnyValue valueOf(Object obj) {
if (obj instanceof MappedGraphType) {
return ((MappedGraphType) obj).value;
}
Value value = Values.unsafeOf(obj, true);
if (value != null) {
return value;
}
if (obj instanceof List<?>) {
return ((List<?>) obj).stream().map(ValueMapperTest::valueOf).collect(ListValueBuilder.collector());
}
if (obj instanceof Map<?, ?>) {
@SuppressWarnings("unchecked") Map<String, ?> map = (Map<String, ?>) obj;
int size = map.size();
if (size == 0) {
return EMPTY_MAP;
}
MapValueBuilder builder = new MapValueBuilder(size);
for (Map.Entry<String, ?> entry : map.entrySet()) {
builder.add(entry.getKey(), valueOf(entry.getValue()));
}
return builder.build();
}
throw new AssertionError("cannot convert: " + obj + " (a " + obj.getClass().getName() + ")");
}
Aggregations