本文整理汇总了Java中org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils.filter方法的典型用法代码示例。如果您正苦于以下问题:Java IteratorUtils.filter方法的具体用法?Java IteratorUtils.filter怎么用?Java IteratorUtils.filter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils
的用法示例。
在下文中一共展示了IteratorUtils.filter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createElementIterator
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; //导入方法依赖的package包/类
private <T extends Element> Iterator<T> createElementIterator(final Class<T> clazz, final Map<Object, T> elements,
final IdManager idManager,
final Object... ids) {
final Iterator<T> iterator;
if (0 == ids.length) {
iterator = elements.values().iterator();
} else {
final List<Object> idList = Arrays.asList(ids);
validateHomogenousIds(idList);
// if the type is of Element - have to look each up because it might be an Attachable instance or
// other implementation. the assumption is that id conversion is not required for detached
// stuff - doesn't seem likely someone would detach a Titan vertex then try to expect that
// vertex to be findable in OrientDB
return clazz.isAssignableFrom(ids[0].getClass()) ?
IteratorUtils.filter(IteratorUtils.map(idList, id -> elements.get(clazz.cast(id).id())).iterator(), Objects::nonNull)
: IteratorUtils.filter(IteratorUtils.map(idList, id -> elements.get(idManager.convert(id))).iterator(), Objects::nonNull);
}
return TinkerHelper.inComputerMode(this) ?
(Iterator<T>) (clazz.equals(Vertex.class) ?
IteratorUtils.filter((Iterator<Vertex>) iterator, t -> this.graphComputerView.legalVertex(t)) :
IteratorUtils.filter((Iterator<Edge>) iterator, t -> this.graphComputerView.legalEdge(t.outVertex(), t))) :
iterator;
}
示例2: createElementIterator
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; //导入方法依赖的package包/类
private <T extends Element> Iterator<T> createElementIterator(final Class<T> clazz, final Map<Object, T> elements,
final IdManager idManager,
final Object... ids) {
final Iterator<T> iterator;
if (0 == ids.length) {
iterator = elements.values().iterator();
} else {
final List<Object> idList = Arrays.asList(ids);
validateHomogenousIds(idList);
// if the type is of Element - have to look each up because it might be an Attachable instance or
// other implementation. the assumption is that id conversion is not required for detached
// stuff - doesn't seem likely someone would detach a Titan vertex then try to expect that
// vertex to be findable in OrientDB
return clazz.isAssignableFrom(ids[0].getClass()) ?
IteratorUtils.filter(IteratorUtils.map(idList, id -> elements.get(clazz.cast(id).id())).iterator(), Objects::nonNull)
: IteratorUtils.filter(IteratorUtils.map(idList, id -> elements.get(idManager.convert(id))).iterator(), Objects::nonNull);
}
return TinkerHelper.inComputerMode(this) ?
(Iterator<T>) (clazz.equals(Vertex.class) ?
IteratorUtils.filter((Iterator<Vertex>) iterator, t -> this.graphComputerView.legalVertex(t)) :
IteratorUtils.filter((Iterator<Edge>) iterator, t -> this.graphComputerView.legalEdge(t.outVertex(), t))) :
iterator;
}
示例3: vertices
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; //导入方法依赖的package包/类
@Override
public Iterator<Vertex> vertices(final Direction direction, final String... edgeLabels) {
this.graph.tx().readWrite();
return new Iterator<Vertex>() {
final Iterator<Neo4jRelationship> relationshipIterator = IteratorUtils.filter(0 == edgeLabels.length ?
getBaseVertex().relationships(Neo4jHelper.mapDirection(direction)).iterator() :
getBaseVertex().relationships(Neo4jHelper.mapDirection(direction), (edgeLabels)).iterator(), graph.trait.getRelationshipPredicate());
@Override
public boolean hasNext() {
return this.relationshipIterator.hasNext();
}
@Override
public Neo4jVertex next() {
return new Neo4jVertex(this.relationshipIterator.next().other(getBaseVertex()), graph);
}
};
}
示例4: edges
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; //导入方法依赖的package包/类
@Override
public Iterator<Edge> edges(final Direction direction, final String... edgeLabels) {
this.graph.tx().readWrite();
return new Iterator<Edge>() {
final Iterator<Neo4jRelationship> relationshipIterator = IteratorUtils.filter(0 == edgeLabels.length ?
getBaseVertex().relationships(Neo4jHelper.mapDirection(direction)).iterator() :
getBaseVertex().relationships(Neo4jHelper.mapDirection(direction), (edgeLabels)).iterator(), graph.trait.getRelationshipPredicate());
@Override
public boolean hasNext() {
return this.relationshipIterator.hasNext();
}
@Override
public Neo4jEdge next() {
return new Neo4jEdge(this.relationshipIterator.next(), graph);
}
};
}
示例5: edges
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; //导入方法依赖的package包/类
@Override
public Iterator<Edge> edges(final Direction direction, final String... edgeLabels) {
final Iterator<Edge> edgeIterator = (Iterator) TinkerHelper.getEdges(this, direction, edgeLabels);
return TinkerHelper.inComputerMode(this.graph) ?
IteratorUtils.filter(edgeIterator, edge -> this.graph.graphComputerView.legalEdge(this, edge)) :
edgeIterator;
}
示例6: vertices
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; //导入方法依赖的package包/类
private Iterator<? extends Vertex> vertices() {
final TinkerGraph graph = (TinkerGraph) this.getTraversal().getGraph().get();
final HasContainer indexedContainer = getIndexKey(Vertex.class);
// ids are present, filter on them first
if (null == this.ids)
return Collections.emptyIterator();
else if (this.ids.length > 0)
return this.iteratorList(graph.vertices(this.ids));
else
return null == indexedContainer ?
this.iteratorList(graph.vertices()) :
IteratorUtils.filter(TinkerHelper.queryVertexIndex(graph, indexedContainer.getKey(), indexedContainer.getPredicate().getValue()).iterator(),
vertex -> HasContainer.testAll(vertex, this.hasContainers));
}
示例7: getIndexKey
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; //导入方法依赖的package包/类
private HasContainer getIndexKey(final Class<? extends Element> indexedClass) {
final Set<String> indexedKeys = ((TinkerGraph) this.getTraversal().getGraph().get()).getIndexedKeys(indexedClass);
final Iterator<HasContainer> itty = IteratorUtils.filter(hasContainers.iterator(),
c -> c.getPredicate().getBiPredicate() == Compare.eq && indexedKeys.contains(c.getKey()));
return itty.hasNext() ? itty.next() : null;
}
示例8: generateFinalResult
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; //导入方法依赖的package包/类
@Override
public Map<Serializable, Set<String>> generateFinalResult(Iterator<KeyValue<Serializable, Set<String>>> keyValues) {
if (this.persistentProperties.containsKey(CLUSTER_SIZE)) {
long clusterSize = (long) persistentProperties.get(CLUSTER_SIZE);
keyValues = IteratorUtils.filter(keyValues, pair -> Long.valueOf(pair.getValue().size()).equals(clusterSize));
}
final Map<Serializable, Set<String>> clusterPopulation = Utility.keyValuesToMap(keyValues);
clusterPopulation.remove(NullObject.instance());
return clusterPopulation;
}
示例9: generateFinalResult
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; //导入方法依赖的package包/类
@Override
public Map<Serializable, Long> generateFinalResult(Iterator<KeyValue<Serializable, Long>> keyValues) {
if (this.persistentProperties.containsKey(CLUSTER_SIZE)) {
long clusterSize = (long) persistentProperties.get(CLUSTER_SIZE);
keyValues = IteratorUtils.filter(keyValues, pair -> pair.getValue().equals(clusterSize));
}
final Map<Serializable, Long> clusterPopulation = Utility.keyValuesToMap(keyValues);
clusterPopulation.remove(NullObject.instance());
return clusterPopulation;
}
示例10: 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)));
}
示例11: 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)));
}
示例12: vertices
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; //导入方法依赖的package包/类
@Override
public Iterator<Vertex> vertices(final Object... vertexIds) {
try {
if (0 == vertexIds.length) {
return new HadoopVertexIterator(this);
} else {
// base the conversion function on the first item in the id list as the expectation is that these
// id values will be a uniform list
if (vertexIds[0] instanceof Vertex) {
// based on the first item assume all vertices in the argument list
if (!Stream.of(vertexIds).allMatch(id -> id instanceof Vertex))
throw Graph.Exceptions.idArgsMustBeEitherIdOrElement();
// no need to get the vertices again, so just flip it back - some implementation may want to treat this
// as a refresh operation. that's not necessary for hadoopgraph.
return Stream.of(vertexIds).map(id -> (Vertex) id).iterator();
} else {
final Class<?> firstClass = vertexIds[0].getClass();
if (!Stream.of(vertexIds).map(Object::getClass).allMatch(firstClass::equals))
throw Graph.Exceptions.idArgsMustBeEitherIdOrElement(); // todo: change exception to be ids of the same type
return IteratorUtils.filter(new HadoopVertexIterator(this), vertex -> ElementHelper.idExists(vertex.id(), vertexIds));
}
}
} catch (final IOException e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
示例13: edges
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; //导入方法依赖的package包/类
@Override
public Iterator<Edge> edges(final Object... edgeIds) {
try {
if (0 == edgeIds.length) {
return new HadoopEdgeIterator(this);
} else {
// base the conversion function on the first item in the id list as the expectation is that these
// id values will be a uniform list
if (edgeIds[0] instanceof Edge) {
// based on the first item assume all Edges in the argument list
if (!Stream.of(edgeIds).allMatch(id -> id instanceof Edge))
throw Graph.Exceptions.idArgsMustBeEitherIdOrElement();
// no need to get the vertices again, so just flip it back - some implementation may want to treat this
// as a refresh operation. that's not necessary for hadoopgraph.
return Stream.of(edgeIds).map(id -> (Edge) id).iterator();
} else {
final Class<?> firstClass = edgeIds[0].getClass();
if (!Stream.of(edgeIds).map(Object::getClass).allMatch(firstClass::equals))
throw Graph.Exceptions.idArgsMustBeEitherIdOrElement(); // todo: change exception to be ids of the same type
return IteratorUtils.filter(new HadoopEdgeIterator(this), vertex -> ElementHelper.idExists(vertex.id(), edgeIds));
}
}
} catch (final IOException e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
示例14: vertices
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; //导入方法依赖的package包/类
private Iterator<? extends Vertex> vertices() {
final TinkerGraph graph = (TinkerGraph) this.getTraversal().getGraph().get();
final HasContainer indexedContainer = getIndexKey(Vertex.class);
// ids are present, filter on them first
if (this.ids != null && this.ids.length > 0)
return this.iteratorList(graph.vertices(this.ids));
else
return null == indexedContainer ?
this.iteratorList(graph.vertices()) :
IteratorUtils.filter(TinkerHelper.queryVertexIndex(graph, indexedContainer.getKey(), indexedContainer.getPredicate().getValue()).iterator(),
vertex -> HasContainer.testAll(vertex, this.hasContainers));
}
示例15: vertices
import org.apache.tinkerpop.gremlin.util.iterator.IteratorUtils; //导入方法依赖的package包/类
private Iterator<? extends Vertex> vertices() {
if (debugInfoSwitch)programLamp();
final LiteGraph graph = (LiteGraph) this.getTraversal().getGraph().get();
final HasContainer indexedContainer = getIndexKey(Vertex.class);
// ids are present, filter on them first
if (this.ids != null && this.ids.length > 0)
return this.iteratorList(graph.vertices(this.ids));
else
return null == indexedContainer ?
this.iteratorList(graph.vertices()) :
IteratorUtils.filter(RedisHelper.queryVertexIndex(graph, indexedContainer.getKey(), indexedContainer.getPredicate().getValue()).iterator(),
vertex -> HasContainer.testAll(vertex, this.hasContainers));
}