本文整理汇总了Java中org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal.has方法的典型用法代码示例。如果您正苦于以下问题:Java GraphTraversal.has方法的具体用法?Java GraphTraversal.has怎么用?Java GraphTraversal.has使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal
的用法示例。
在下文中一共展示了GraphTraversal.has方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: find
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
/**
* Find the given element using it's id, if it has one, or all of it's properties.
*/
protected <E extends Element> GraphTraversal find(E element) {
GraphTraversal traversal = g.V();
if (element.id() != null) {
traversal = traversal.hasId(element.id());
} else {
traversal = traversal.hasLabel(element.label());
Object[] properties = Properties.id(element);
if (properties == null || properties.length == 0) {
properties = Properties.all(element);
}
for (Property property : list(properties)) {
traversal = traversal.has(property.key(), property.value());
}
}
return traversal;
}
示例2: findPersons
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
public List<Person> findPersons(Optional<String> firstName) {
GraphTraversal<?, ?> traversal = g.V().hasLabel(PERSON.LABEL);
if(firstName.isPresent()) {
traversal.has(PERSON.FIRST_NAME, firstName.get());
}
return traversal.valueMap(true)
.toStream()
.map(this::toPerson)
.collect(Collectors.toList());
}
示例3: apply
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
@Override
@SneakyThrows
public GraphTraversal<Element, Element> apply(GraphTraversal<Element, Element> traversal) {
traversal.hasLabel(element.label());
List<Field> fields;
if (keyType != null) {
if (is(keyType, PrimaryKey.class)) {
fields = primaryKeyFields(element);
} else if (is(keyType, OrderingKey.class)) {
fields = orderingKeyFields(element);
} else {
throw org.apache.tinkerpop.gremlin.object.structure.Element.Exceptions
.invalidAnnotationType(keyType);
}
} else {
fields = keyFields(element);
}
for (Field field : fields) {
String key = propertyKey(field);
Object value = propertyValue(field, element);
if (isMissing(value)) {
throw org.apache.tinkerpop.gremlin.object.structure.Element.Exceptions.requiredKeysMissing(
element.getClass(), key);
}
traversal.has(key, value);
}
return traversal;
}
示例4: vertexTraversal
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
private GraphTraversal<Vertex, Vertex> vertexTraversal(GraphTraversal<Vertex, ? extends Element> traversal) {
// A vertex should always be looked up by vertex property, not the actual vertex ID which may be incorrect.
// This is because a vertex may represent a reified relation, which will use the original edge ID as an ID.
// We know only vertices have this property, so the cast is safe
//noinspection unchecked
return (GraphTraversal<Vertex, Vertex>) traversal.has(Schema.VertexProperty.ID.name(), id().getValue());
}
示例5: applyLabelsToTraversal
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
static void applyLabelsToTraversal(
GraphTraversal<?, Edge> traversal, Schema.EdgeProperty property,
@Nullable Set<Label> typeLabels, GraknTx tx) {
if (typeLabels != null) {
Set<Integer> typeIds =
typeLabels.stream().map(label -> tx.admin().convertToId(label).getValue()).collect(toSet());
traversal.has(property.name(), P.within(typeIds));
}
}
示例6: applyTraversalInner
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
@Override
public GraphTraversal<Vertex, ? extends Element> applyTraversalInner(
GraphTraversal<Vertex, ? extends Element> traversal, GraknTx graph, Collection<Var> vars) {
Set<Integer> labelIds =
labels().stream().map(label -> graph.admin().convertToId(label).getValue()).collect(toSet());
if (labelIds.size() == 1) {
int labelId = Iterables.getOnlyElement(labelIds);
return traversal.has(LABEL_ID.name(), labelId);
} else {
return traversal.has(LABEL_ID.name(), P.within(labelIds));
}
}
示例7: apply
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
@Override
public GraphTraversal<Element, Element> apply(GraphTraversal<Element, Element> traversal) {
return traversal.has(label, key, value);
}
示例8: isVertex
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
/**
* Create a traversal that filters to only vertices
*/
static <T> GraphTraversal<T, Vertex> isVertex(GraphTraversal<T, ? extends Element> traversal) {
// This cast is safe because we filter only to vertices
//noinspection unchecked
return (GraphTraversal<T, Vertex>) traversal.has(Schema.VertexProperty.ID.name());
}
示例9: applyTraversalInner
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
@Override
public GraphTraversal<Vertex, ? extends Element> applyTraversalInner(
GraphTraversal<Vertex, ? extends Element> traversal, GraknTx graph, Collection<Var> vars) {
return traversal.has(Schema.VertexProperty.IS_ABSTRACT.name(), true);
}
示例10: applyTraversalInner
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
@Override
public GraphTraversal<Vertex, ? extends Element> applyTraversalInner(
GraphTraversal<Vertex, ? extends Element> traversal, GraknTx tx, Collection<Var> vars) {
return traversal.has(DATA_TYPE.name(), dataType().getName());
}
示例11: applyTraversalInner
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
@Override
public GraphTraversal<Vertex, ? extends Element> applyTraversalInner(
GraphTraversal<Vertex, ? extends Element> traversal, GraknTx graph, Collection<Var> vars) {
return traversal.has(REGEX.name(), regex());
}
示例12: applyTraversalInner
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
@Override
public GraphTraversal<Vertex, ? extends Element> applyTraversalInner(
GraphTraversal<Vertex, ? extends Element> traversal, GraknTx graph, Collection<Var> vars) {
return traversal.has(INDEX.name(), attributeIndex());
}
示例13: applyPredicate
import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal; //导入方法依赖的package包/类
@Override
public <S, E> GraphTraversal<S, E> applyPredicate(GraphTraversal<S, E> traversal) {
return traversal.has(Schema.VertexProperty.VALUE_STRING.name(), regexPredicate());
}