本文整理汇总了Java中org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils.map方法的典型用法代码示例。如果您正苦于以下问题:Java IteratorUtils.map方法的具体用法?Java IteratorUtils.map怎么用?Java IteratorUtils.map使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils
的用法示例。
在下文中一共展示了IteratorUtils.map方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: head
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; //导入方法依赖的package包/类
@Override
public <K, V> Iterator<KeyValue<K, V>> head(final String location, final String memoryKey, final Class readerClass, final int totalLines) {
final Configuration configuration = new BaseConfiguration();
configuration.setProperty(Constants.GREMLIN_HADOOP_INPUT_LOCATION, location);
configuration.setProperty(Constants.GREMLIN_HADOOP_GRAPH_READER, readerClass.getCanonicalName());
try {
if (InputRDD.class.isAssignableFrom(readerClass)) {
return IteratorUtils.map(((InputRDD) readerClass.getConstructor().newInstance()).readMemoryRDD(configuration, memoryKey, new JavaSparkContext(Spark.getContext())).take(totalLines).iterator(), tuple -> new KeyValue(tuple._1(), tuple._2()));
} else if (InputFormat.class.isAssignableFrom(readerClass)) {
return IteratorUtils.map(new InputFormatRDD().readMemoryRDD(configuration, memoryKey, new JavaSparkContext(Spark.getContext())).take(totalLines).iterator(), tuple -> new KeyValue(tuple._1(), tuple._2()));
}
} catch (final Exception e) {
throw new IllegalArgumentException(e.getMessage(), e);
}
throw new IllegalArgumentException("The provided parserClass must be an " + InputFormat.class.getCanonicalName() + " or an " + InputRDD.class.getCanonicalName() + ": " + readerClass.getCanonicalName());
}
示例2: vertices
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; //导入方法依赖的package包/类
@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);
}
示例3: vertices
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; //导入方法依赖的package包/类
@Override
public Iterator<Vertex> vertices(final Direction direction, final String... edgeLabels) {
Iterator<Edge> edges = specificEdges(direction, edgeLabels);
if (direction == Direction.IN) {
return IteratorUtils.map(edges, Edge::outVertex);
} else if (direction == Direction.OUT) {
return IteratorUtils.map(edges, Edge::inVertex);
} else if (direction == Direction.BOTH) {
return IteratorUtils.flatMap(edges, Edge::bothVertices);
} else {
return Collections.emptyIterator();
}
}
示例4: properties
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; //导入方法依赖的package包/类
@Override
public <V> Iterator<Property<V>> properties(final String... propertyKeys) {
Iterable<String> keys = getPropertyKeys();
Iterator<String> filter = IteratorUtils.filter(keys.iterator(),
key -> ElementHelper.keyExists(key, propertyKeys));
return IteratorUtils.map(filter,
key -> new HBaseProperty<>(graph, this, key, getProperty(key)));
}
示例5: properties
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; //导入方法依赖的package包/类
@Override
public <V> Iterator<VertexProperty<V>> properties(final String... propertyKeys) {
Iterable<String> keys = getPropertyKeys();
Iterator<String> filter = IteratorUtils.filter(keys.iterator(),
key -> ElementHelper.keyExists(key, propertyKeys));
return IteratorUtils.map(filter,
key -> new HBaseVertexProperty<>(graph, this, key, getProperty(key)));
}
示例6: vertices
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; //导入方法依赖的package包/类
@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));
}
示例7: attach
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; //导入方法依赖的package包/类
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;
});
}
示例8: properties
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; //导入方法依赖的package包/类
@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)));
}
示例9: writeMemoryRDD
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; //导入方法依赖的package包/类
@Override
public <K, V> Iterator<KeyValue<K, V>> writeMemoryRDD(final Configuration configuration, final String memoryKey, final JavaPairRDD<K, V> memoryRDD) {
if (!configuration.getBoolean(Constants.GREMLIN_SPARK_PERSIST_CONTEXT, false))
LOGGER.warn("The SparkContext should be persisted in order for the RDD to persist across jobs. To do so, set " + Constants.GREMLIN_SPARK_PERSIST_CONTEXT + " to true");
if (!configuration.containsKey(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION))
throw new IllegalArgumentException("There is no provided " + Constants.GREMLIN_HADOOP_OUTPUT_LOCATION + " to write the persisted RDD to");
final String memoryRDDName = Constants.getMemoryLocation(configuration.getString(Constants.GREMLIN_HADOOP_OUTPUT_LOCATION), memoryKey);
Spark.removeRDD(memoryRDDName);
memoryRDD.setName(memoryRDDName).persist(StorageLevel.fromString(configuration.getString(Constants.GREMLIN_SPARK_PERSIST_STORAGE_LEVEL, "MEMORY_ONLY")));
Spark.refresh(); // necessary to do really fast so the Spark GC doesn't clear out the RDD
return IteratorUtils.map(memoryRDD.collect().iterator(), tuple -> new KeyValue<>(tuple._1(), tuple._2()));
}
示例10: properties
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; //导入方法依赖的package包/类
@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));
}
示例11: vertices
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; //导入方法依赖的package包/类
@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());
}
示例12: edges
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; //导入方法依赖的package包/类
@Override
public Iterator<Edge> edges(final Direction direction, final String... edgeLabels) {
return IteratorUtils.map(this.getBaseVertex().edges(direction, edgeLabels), edge -> HadoopVertex.this.graph.edges(edge.id()).next());
}
示例13: properties
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; //导入方法依赖的package包/类
@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));
}
示例14: iterator
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; //导入方法依赖的package包/类
@Override
public Iterator iterator() {
return IteratorUtils.map(this.getKeys(), k -> new Pair<>(k, this.getProperty(k)));
}
示例15: values
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; //导入方法依赖的package包/类
/**
* 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());
}