@Override public void onMetadata( String key, AnyValue value ) { metadata.add( key, value ); }
private void addIfNonZero( MapValueBuilder builder, String name, int count ) { if ( count > 0 ) { builder.add( name, intValue( count ) ); } }
@Override public void addMetadata( String key, AnyValue value ) { meta.add( key, value ); } } );
public static MapValue asMapValue( Map<String,Object> map ) { MapValueBuilder builder = new MapValueBuilder( map.size() ); for ( Map.Entry<String,Object> entry : map.entrySet() ) { builder.add( entry.getKey(), ValueUtils.of( entry.getValue() ) ); } return builder.build(); }
public static MapValue asParameterMapValue( Map<String,Object> map ) { MapValueBuilder builder = new MapValueBuilder( map.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(); }
public static MapValue convert( ExecutionPlanDescription plan ) { boolean hasProfilerStatistics = plan.hasProfilerStatistics(); int size = hasProfilerStatistics ? 9 : 4; MapValueBuilder out = new MapValueBuilder( size ); out.add( "operatorType", stringValue( 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(); out.add( "dbHits", longValue( profile.getDbHits() ) ); out.add( "pageCacheHits", longValue( profile.getPageCacheHits() ) ); out.add( "pageCacheMisses", longValue( profile.getPageCacheMisses() ) ); out.add( "pageCacheHitRatio", doubleValue( profile.getPageCacheHitRatio() ) ); out.add( "rows", longValue( profile.getRows() ) ); } return out.build(); }
@Override public AnyValue mapMap( MapValue value ) { MapValueBuilder builder = new MapValueBuilder(); value.foreach( ( k, v ) -> builder.add( k, v.map( this ) ) ); return builder.build(); }
private MapValue mapValues( Object... values ) { int i = 0; MapValueBuilder builder = new MapValueBuilder(); while ( i < values.length ) { builder.add( (String) values[i++], (AnyValue) values[i++] ); } return builder.build(); }
public static AnyValue convert( Iterable<Notification> notifications ) { List<AnyValue> out = new ArrayList<>(); for ( Notification notification : notifications ) { InputPosition pos = notification.getPosition(); // position is optional boolean includePosition = !pos.equals( InputPosition.empty ); int size = includePosition ? 5 : 4; MapValueBuilder builder = new MapValueBuilder( size ); builder.add( "code", stringValue( notification.getCode() ) ); builder.add( "title", stringValue( notification.getTitle() ) ); builder.add( "description", stringValue( notification.getDescription() ) ); builder.add( "severity", stringValue( 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() ) } ) ); } out.add( builder.build() ); } return VirtualValues.fromList( out ); } }
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 fromList( ((List<?>) obj).stream().map( ValueMapperTest::valueOf ).collect( toList() ) ); } if ( obj instanceof Map<?,?> ) { @SuppressWarnings( "unchecked" ) Map<String,?> map = (Map<String,?>) obj; MapValueBuilder builder = new MapValueBuilder( map.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() + ")" ); }
private static Value asPoint( DbAccess access, VirtualRelationshipValue relationshipValue ) { MapValueBuilder builder = new MapValueBuilder(); for ( String key : POINT_KEYS ) { Value value = access.relationshipProperty( relationshipValue.id(), access.propertyKey( key ) ); if ( value == NO_VALUE ) { continue; } builder.add( key, value ); } return PointValue.fromMap( builder.build() ); }
private static Value asPoint( DbAccess access, VirtualNodeValue nodeValue ) { MapValueBuilder builder = new MapValueBuilder(); for ( String key : POINT_KEYS ) { Value value = access.nodeProperty( nodeValue.id(), access.propertyKey( key ) ); if ( value == NO_VALUE ) { continue; } builder.add( key, value ); } return PointValue.fromMap( builder.build() ); }
for ( Map.Entry<String,?> entry : incoming.entrySet() ) builder.add( entry.getKey(), materializeAnyResult( proxySpi, entry.getValue() ) );
@Override public void onMetadata( String key, AnyValue value ) { metadata.add( key, value ); }
private void addIfNonZero( MapValueBuilder builder, String name, int count ) { if ( count > 0 ) { builder.add( name, intValue( count ) ); } }
public static MapValue asMapValue( Map<String,Object> map ) { MapValueBuilder builder = new MapValueBuilder( map.size() ); for ( Map.Entry<String,Object> entry : map.entrySet() ) { builder.add( entry.getKey(), ValueUtils.of( entry.getValue() ) ); } return builder.build(); }
@Override public AnyValue mapMap( MapValue value ) { MapValueBuilder builder = new MapValueBuilder(); value.foreach( ( k, v ) -> builder.add( k, v.map( this ) ) ); return builder.build(); }
private static Value asPoint( DbAccess access, VirtualNodeValue nodeValue ) { MapValueBuilder builder = new MapValueBuilder(); for ( String key : POINT_KEYS ) { Value value = access.nodeProperty( nodeValue.id(), access.propertyKey( key ) ); if ( value == NO_VALUE ) { continue; } builder.add( key, value ); } return PointValue.fromMap( builder.build() ); }