public static String pathString(final Path path) { return PATH + L_BRACKET + String.join(", ", IteratorUtils.map(path, Object::toString)) + R_BRACKET; } }
public DetachedVertex(final Object id, final String label, final Map<String, Object> properties) { super(id, label); if (properties != null && !properties.isEmpty()) { this.properties = new HashMap<>(); properties.entrySet().iterator().forEachRemaining(entry -> this.properties.put(entry.getKey(), IteratorUtils.<Property>list(IteratorUtils.map(((List<Object>) entry.getValue()).iterator(), m -> VertexProperty.class.isAssignableFrom(m.getClass()) ? (VertexProperty) m : new DetachedVertexProperty<>(((Map) m).get(ID), entry.getKey(), ((Map) m).get(VALUE), (Map<String, Object>) ((Map) m).getOrDefault(PROPERTIES, new HashMap<>()), this))))); } }
@Override public <V> Iterator<Property<V>> properties(final String... propertyKeys) { return IteratorUtils.map(super.properties(propertyKeys), property -> new ComputerProperty(property)); }
/** * Get the values of properties as an {@link Iterator}. */ public default <V> Iterator<V> values(final String... propertyKeys) { return IteratorUtils.map(this.<V>properties(propertyKeys), property -> property.value()); }
@Override public <U> Iterator<Property<U>> properties(final String... propertyKeys) { return IteratorUtils.map(super.properties(propertyKeys), property -> new ComputerProperty(property)); }
@Override public void reduce(final ObjectWritable key, final Iterable<ObjectWritable> values, final Reducer<ObjectWritable, ObjectWritable, ObjectWritable, ObjectWritable>.Context context) throws IOException, InterruptedException { this.reduceEmitter.setContext(context); this.mapReduce.reduce(key.get(), IteratorUtils.map(values.iterator(), ObjectWritable::get), this.reduceEmitter); }
@Override public void reduce(final ObjectWritable key, final Iterable<ObjectWritable> values, final Reducer<ObjectWritable, ObjectWritable, ObjectWritable, ObjectWritable>.Context context) throws IOException, InterruptedException { this.combineEmitter.setContext(context); this.mapReduce.combine(key.get(), IteratorUtils.map(values.iterator(), ObjectWritable::get), this.combineEmitter); }
@Override public Iterator<String> head(final String location, final int totalLines) { return IteratorUtils.map(Spark.getRDD(location).toJavaRDD().take(totalLines).iterator(), Object::toString); }
@Override public Iterator<Vertex> vertices(final Direction direction, final String... edgeLabels) { return TinkerHelper.inComputerMode(this.graph) ? direction.equals(Direction.BOTH) ? IteratorUtils.concat( IteratorUtils.map(this.edges(Direction.OUT, edgeLabels), Edge::inVertex), IteratorUtils.map(this.edges(Direction.IN, edgeLabels), Edge::outVertex)) : IteratorUtils.map(this.edges(direction, edgeLabels), edge -> edge.vertices(direction.opposite()).next()) : (Iterator) TinkerHelper.getVertices(this, direction, edgeLabels); }
@Override public <V> Iterator<Property<V>> properties(final String... propertyKeys) { return IteratorUtils.<Property<V>, Property<V>>map(this.getBaseEdge().properties(propertyKeys), property -> new HadoopProperty<>(property, HadoopEdge.this)); } }
@Override public <U> Iterator<Property<U>> properties(final String... propertyKeys) { return IteratorUtils.<Property<U>, Property<U>>map(this.getBaseVertexProperty().properties(propertyKeys), property -> new HadoopProperty<>(property, HadoopVertexProperty.this)); } }
public Builder statusAttributeException(final Throwable ex) { statusAttribute(Tokens.STATUS_ATTRIBUTE_EXCEPTIONS, IteratorUtils.asList( IteratorUtils.map(ExceptionUtils.getThrowableList(ex), t -> t.getClass().getName()))); statusAttribute(Tokens.STATUS_ATTRIBUTE_STACK_TRACE, ExceptionUtils.getFullStackTrace(ex)); return this; }
@Override public <V> Iterator<VertexProperty<V>> properties(final String... propertyKeys) { return IteratorUtils.<VertexProperty<V>, VertexProperty<V>>map(this.getBaseVertex().properties(propertyKeys), property -> new HadoopVertexProperty<>(property, HadoopVertex.this)); } }
@Override public Iterator iterator() { return IteratorUtils.map(this.getKeys(), k -> new Pair<>(k, this.getProperty(k))); } }
@Override public Iterator<Vertex> vertices(final Direction direction, final String... edgeLabels) { return IteratorUtils.map(this.getBaseVertex().vertices(direction, edgeLabels), vertex -> HadoopVertex.this.graph.vertices(vertex.id()).next()); }
@Override public Iterator<Vertex> vertices(final Direction direction, final String... edgeLabels) { if (direction.equals(Direction.OUT)) return IteratorUtils.map(this.edges(direction, edgeLabels), Edge::inVertex); else if (direction.equals(Direction.IN)) return IteratorUtils.map(this.edges(direction, edgeLabels), Edge::outVertex); else return IteratorUtils.concat(this.vertices(Direction.IN, edgeLabels), this.vertices(Direction.OUT, edgeLabels)); }
@Override public Iterator<Vertex> vertices(final Direction direction, final String... edgeLabels) { if (state.equals(State.MAP_REDUCE)) throw GraphComputer.Exceptions.incidentAndAdjacentElementsCanNotBeAccessedInMapReduce(); return IteratorUtils.map(this.getBaseVertex().vertices(direction, edgeLabels), v -> v.equals(starVertex) ? starVertex : new ComputerAdjacentVertex(v)); }
@Override public Iterator<Edge> edges(final Direction direction, final String... edgeLabels) { if (state.equals(State.MAP_REDUCE)) throw GraphComputer.Exceptions.incidentAndAdjacentElementsCanNotBeAccessedInMapReduce(); return IteratorUtils.map(this.getBaseVertex().edges(direction, edgeLabels), ComputerEdge::new); }
@Override public <V> Iterator<Property<V>> properties(final String... propertyKeys) { this.graph.tx().readWrite(); Iterable<String> keys = this.baseElement.getKeys(); Iterator<String> filter = IteratorUtils.filter(keys.iterator(), key -> ElementHelper.keyExists(key, propertyKeys)); return IteratorUtils.map(filter, key -> new Neo4jProperty<>(this, key, (V) this.baseElement.getProperty(key))); }
public Iterator<Traverser.Admin<S>> attach(final Iterator<Traverser.Admin<S>> iterator, final Graph graph) { return IteratorUtils.map(iterator, traverser -> { traverser.setSideEffects(this.getTraversal().getSideEffects()); // necessary to ensure no NPE if (this.attachElements && (traverser.get() instanceof Attachable) && !(traverser.get() instanceof Property)) traverser.set((S) ((Attachable<Element>) traverser.get()).attach(Attachable.Method.get(graph))); return traverser; }); }