本文整理汇总了Java中org.apache.tinkerpop.gremlin.process.traversal.Compare类的典型用法代码示例。如果您正苦于以下问题:Java Compare类的具体用法?Java Compare怎么用?Java Compare使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Compare类属于org.apache.tinkerpop.gremlin.process.traversal包,在下文中一共展示了Compare类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: lookupEdges
import org.apache.tinkerpop.gremlin.process.traversal.Compare; //导入依赖的package包/类
private Iterator<Edge> lookupEdges(final Traverser.Admin<Vertex> traverser, final List<HasContainer> hasContainers) {
final HBaseGraph graph = (HBaseGraph) this.getTraversal().getGraph().get();
if (getEdgeLabels().length == 1) {
final String label = getEdgeLabels()[0];
// find an edge by label and key/value
for (final HasContainer hasContainer : hasContainers) {
if (Compare.eq == hasContainer.getBiPredicate() && !hasContainer.getKey().equals(T.label.getAccessor())) {
if (graph.hasIndex(OperationType.READ, ElementType.EDGE, label, hasContainer.getKey())) {
return IteratorUtils.stream(((HBaseVertex) traverser.get()).edges(getDirection(), label, hasContainer.getKey(), hasContainer.getValue()))
.filter(vertex -> HasContainer.testAll(vertex, hasContainers)).iterator();
}
}
}
}
// linear scan
return CloseableIteratorUtils.filter(traverser.get().edges(getDirection(), getEdgeLabels()),
edge -> HasContainer.testAll(edge, hasContainers));
}
开发者ID:rayokota,项目名称:hgraphdb,代码行数:20,代码来源:HBaseVertexStep.java
示例2: convertInternal
import org.apache.tinkerpop.gremlin.process.traversal.Compare; //导入依赖的package包/类
/**
* Convert Tinkerpop's comparison operators to Titan's
*
* @param p Any predicate
* @return A TitanPredicate equivalent to the given predicate
* @throws IllegalArgumentException if the given Predicate is unknown
*/
public static final TitanPredicate convertInternal(BiPredicate p) {
if (p instanceof TitanPredicate) {
return (TitanPredicate)p;
} else if (p instanceof Compare) {
Compare comp = (Compare)p;
switch(comp) {
case eq: return Cmp.EQUAL;
case neq: return Cmp.NOT_EQUAL;
case gt: return Cmp.GREATER_THAN;
case gte: return Cmp.GREATER_THAN_EQUAL;
case lt: return Cmp.LESS_THAN;
case lte: return Cmp.LESS_THAN_EQUAL;
default: throw new IllegalArgumentException("Unexpected comparator: " + comp);
}
} else if (p instanceof Contains) {
Contains con = (Contains)p;
switch (con) {
case within: return Contain.IN;
case without: return Contain.NOT_IN;
default: throw new IllegalArgumentException("Unexpected container: " + con);
}
} else return null;
}
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:32,代码来源:TitanPredicate.java
示例3: translate
import org.apache.tinkerpop.gremlin.process.traversal.Compare; //导入依赖的package包/类
@Override
public <V> P<V> translate(P<V> predicate) {
BiPredicate<V, V> biPredicate = predicate.getBiPredicate();
if (biPredicate instanceof Compare){
String predicateString = biPredicate.toString();
V value = predicate.getValue();
switch (predicateString){
case "eq":
return Date.eq(value);
case "neq":
return Date.neq(value);
case "lt":
return Date.lt(value);
case "gt":
return Date.gt(value);
case "lte":
return Date.lte(value);
case "gte":
return Date.gte(value);
default:
throw new IllegalArgumentException("cant convert '" + predicateString +"' to DatePredicate");
}
} else
throw new IllegalArgumentException("cant convert '" + biPredicate.toString() +"' to DatePredicate");
}
开发者ID:unipop-graph,项目名称:unipop,代码行数:26,代码来源:DateType.java
示例4: getTypeFilter
import org.apache.tinkerpop.gremlin.process.traversal.Compare; //导入依赖的package包/类
private static QueryBuilder getTypeFilter(HasContainer has) {
BiPredicate<?, ?> biPredicate = has.getBiPredicate();
if (biPredicate instanceof Compare) {
QueryBuilder query = QueryBuilders.typeQuery(has.getValue().toString());
if (biPredicate.equals(Compare.eq)) return query;
return QueryBuilders.boolQuery().mustNot(query);
} else if (biPredicate instanceof Contains) {
Collection values = (Collection) has.getValue();
BoolQueryBuilder boolQueryBuilder = QueryBuilders.boolQuery();
boolean within = biPredicate.equals(Contains.within);
values.forEach(label -> {
TypeQueryBuilder typeQueryBuilder = QueryBuilders.typeQuery(label.toString());
if (within) boolQueryBuilder.should(typeQueryBuilder);
else boolQueryBuilder.mustNot(typeQueryBuilder);
});
return boolQueryBuilder;
} else throw new IllegalArgumentException("predicate not supported by unipop: " + biPredicate.toString());
}
开发者ID:unipop-graph,项目名称:unipop,代码行数:19,代码来源:FilterHelper.java
示例5: predicateToQuery
import org.apache.tinkerpop.gremlin.process.traversal.Compare; //导入依赖的package包/类
private Condition predicateToQuery(String field, Object value, BiPredicate<?, ?> biPredicate) {
if (biPredicate instanceof Compare) {
return getCompareCondition(value, biPredicate, field(field));
} else if (biPredicate instanceof Contains) {
Condition x = getContainsCondition(value, biPredicate, field(field));
if (x != null) return x;
}
else if (biPredicate instanceof Text.TextPredicate) {
return getTextCondition(value, biPredicate, field(field));
} else if (biPredicate instanceof Date.DatePredicate) {
try {
return getDateCondition(value, biPredicate, field(field));
} catch (ParseException e) {
throw new IllegalArgumentException("cant convert to date");
}
}
throw new IllegalArgumentException("can't create condition");
}
开发者ID:unipop-graph,项目名称:unipop,代码行数:19,代码来源:JdbcPredicatesTranslator.java
示例6: getGremlinPredicate
import org.apache.tinkerpop.gremlin.process.traversal.Compare; //导入依赖的package包/类
private Compare getGremlinPredicate(ComparisionOperator op) {
switch (op) {
case EQUAL:
return Compare.eq;
case GREATER_THAN:
return Compare.gt;
case GREATER_THAN_EQUAL:
return Compare.gte;
case LESS_THAN:
return Compare.lt;
case LESS_THAN_EQUAL:
return Compare.lte;
case NOT_EQUAL:
return Compare.neq;
default:
throw new RuntimeException("Unsupported comparison operator:" + op);
}
}
开发者ID:apache,项目名称:incubator-atlas,代码行数:20,代码来源:NativeTitan1GraphQuery.java
示例7: testMultiplePath
import org.apache.tinkerpop.gremlin.process.traversal.Compare; //导入依赖的package包/类
@Test
public void testMultiplePath(){
Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "johnny", "score",2,"experience",3);
Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "pietie", "score",2,"experience",2);
Vertex v3 = this.sqlgGraph.addVertex(T.label, "Person", "name", "koosie", "score",2,"experience",1);
Vertex v4 = this.sqlgGraph.addVertex(T.label, "Group", "name", "Friends");
v4.addEdge("contains", v1);
v4.addEdge("contains", v2);
v4.addEdge("contains", v3);
Vertex v5 = this.sqlgGraph.addVertex(T.label, "Company", "name", "Acme");
v5.addEdge("groups", v4);
this.sqlgGraph.tx().commit();
GraphTraversal<Vertex, Map<String,Object>> traversal =sqlgGraph.traversal()
.V().hasLabel("Company").as("c").out("groups")
.as("g").out("contains").has("score",propertyRef(Compare.eq, "experience")).as("p")
.select("c","p");
List<Map<String,Object>> l =traversal.toList();
assertEquals(1,l.size());
assertEquals(v2,l.get(0).get("p"));
}
开发者ID:pietermartin,项目名称:sqlg,代码行数:25,代码来源:TestPropertyReference.java
示例8: compareToSql
import org.apache.tinkerpop.gremlin.process.traversal.Compare; //导入依赖的package包/类
private static String compareToSql(Compare compare) {
switch (compare) {
case eq:
return " = ?";
case neq:
return " <> ?";
case gt:
return " > ?";
case gte:
return " >= ?";
case lt:
return " < ?";
case lte:
return " <= ?";
default:
throw new RuntimeException("Unknown Compare " + compare.name());
}
}
开发者ID:pietermartin,项目名称:sqlg,代码行数:19,代码来源:WhereClause.java
示例9: addIdHasContainers
import org.apache.tinkerpop.gremlin.process.traversal.Compare; //导入依赖的package包/类
private void addIdHasContainers(SchemaTableTree schemaTableTree1, List<Multimap<BiPredicate, RecordId>> biPredicateRecordIds) {
if (biPredicateRecordIds != null) {
for (Multimap<BiPredicate, RecordId> biPredicateRecordId : biPredicateRecordIds) {
for (BiPredicate biPredicate : biPredicateRecordId.keySet()) {
Collection<RecordId> recordIds = biPredicateRecordId.get(biPredicate);
HasContainer idHasContainer;
//id hasContainers are only optimized for BaseStrategy.SUPPORTED_ID_BI_PREDICATE within, without, eq, neq
if (biPredicate == Contains.without || biPredicate == Contains.within) {
idHasContainer = new HasContainer(T.id.getAccessor(), P.test(biPredicate, recordIds));
schemaTableTree1.getHasContainers().add(idHasContainer);
} else {
Preconditions.checkState(biPredicate == Compare.eq || biPredicate == Compare.neq);
for (RecordId recordId : recordIds) {
idHasContainer = new HasContainer(T.id.getAccessor(), P.test(biPredicate, recordId));
schemaTableTree1.getHasContainers().add(idHasContainer);
}
}
}
}
}
}
开发者ID:pietermartin,项目名称:sqlg,代码行数:22,代码来源:ReplacedStep.java
示例10: getIndexKey
import org.apache.tinkerpop.gremlin.process.traversal.Compare; //导入依赖的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;
}
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:9,代码来源:TinkerGraphStep.java
示例11: labelFromWhereEqPredicate
import org.apache.tinkerpop.gremlin.process.traversal.Compare; //导入依赖的package包/类
private Optional<String> labelFromWhereEqPredicate(WherePredicateStep<Vertex> whereStep) {
Optional<P<?>> optionalPredicate = whereStep.getPredicate();
return optionalPredicate.flatMap(predicate -> {
if (!predicate.getBiPredicate().equals(Compare.eq)) return Optional.empty();
return Optional.of((String) predicate.getValue());
});
}
开发者ID:graknlabs,项目名称:grakn,代码行数:9,代码来源:JanusPreviousPropertyStepStrategy.java
示例12: processHasContainerIds
import org.apache.tinkerpop.gremlin.process.traversal.Compare; //导入依赖的package包/类
/**
* Helper method for providers that want to "fold in" {@link HasContainer}'s based on id checking into the ids of the {@link GraphStep}.
*
* @param graphStep the GraphStep to potentially {@link GraphStep#addIds(Object...)}.
* @param hasContainer The {@link HasContainer} to check for id validation.
* @return true if the {@link HasContainer} updated ids and thus, was processed.
*/
public static boolean processHasContainerIds(final GraphStep<?, ?> graphStep, final HasContainer hasContainer) {
if (hasContainer.getKey().equals(T.id.getAccessor()) && (hasContainer.getBiPredicate() == Compare.eq || hasContainer.getBiPredicate() == Contains.within)) {
graphStep.addIds(hasContainer.getValue());
return true;
}
return false;
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:15,代码来源:GraphStep.java
示例13: getIndexKey
import org.apache.tinkerpop.gremlin.process.traversal.Compare; //导入依赖的package包/类
private HasContainer getIndexKey(final Class<? extends Element> indexedClass) {
final Set<String> indexedKeys = ((LiteGraph) 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;
}
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:9,代码来源:LiteGraphStep.java
示例14: predicateToQuery
import org.apache.tinkerpop.gremlin.process.traversal.Compare; //导入依赖的package包/类
private static QueryBuilder predicateToQuery(String key, Object value, BiPredicate<?, ?> biPredicate) {
if (biPredicate instanceof Compare) return getCompareFilter(key, value, biPredicate.toString());
else if (biPredicate instanceof Contains) return getContainsFilter(key, value, biPredicate);
// else if (biPredicate instanceof Geo) return getGeoFilter(key, value, (Geo) biPredicate);
else if (biPredicate instanceof Text.TextPredicate)
return getTextFilter(key, value, (Text.TextPredicate) biPredicate);
else throw new IllegalArgumentException("predicate not supported by unipop: " + biPredicate.toString());
}
开发者ID:unipop-graph,项目名称:unipop,代码行数:9,代码来源:FilterHelper.java
示例15: findIndex
import org.apache.tinkerpop.gremlin.process.traversal.Compare; //导入依赖的package包/类
@VisibleForTesting
public Set<OrientIndexQuery> findIndex() {
final Set<OrientIndexQuery> indexedQueries = new HashSet<>();
final OrientGraph graph = getGraph();
final OIndexManagerProxy indexManager = graph.database().getMetadata().getIndexManager();
// find indexed keys only for the element subclasses (if present)
final Set<String> classLabels = findClassLabelsInHasContainers();
if (!classLabels.isEmpty()) {
final Set<String> indexedKeys = new HashSet<>();// classLabels.isPresent() ? graph.getIndexedKeys(this.returnClass, classLabels.get()) : graph.getIndexedKeys(this.returnClass);
classLabels.forEach(label -> indexedKeys.addAll(graph.getIndexedKeys(this.returnClass, label)));
this.hasContainers.stream()
.filter(c -> indexedKeys.contains(c.getKey()) && (c.getPredicate().getBiPredicate() == Compare.eq ||
c.getPredicate().getBiPredicate() == Contains.within))
.findAny()
.ifPresent(requestedKeyValue -> {
String key = requestedKeyValue.getKey();
classLabels.forEach(classLabel -> {
Iterator<Object> values = getValueIterator(requestedKeyValue);
String className = graph.labelToClassName(classLabel, isVertexStep() ? OClass.VERTEX_CLASS_NAME : OClass.EDGE_CLASS_NAME);
Set<OIndex<?>> classIndexes = indexManager.getClassIndexes(className);
Iterator<OIndex<?>> keyIndexes = classIndexes.stream().filter(idx -> idx.getDefinition().getFields().contains(key)).iterator();
if (keyIndexes.hasNext()) {
// TODO: select best index if there are multiple options
indexedQueries.add(new OrientIndexQuery(keyIndexes.next(), values));
} else {
OLogManager.instance().warn(this, "no index found for class=[" + className + "] and key=[" + key + "]");
}
});
});
}
return indexedQueries;
}
开发者ID:orientechnologies,项目名称:orientdb-gremlin,代码行数:41,代码来源:OrientGraphStep.java
示例16: has
import org.apache.tinkerpop.gremlin.process.traversal.Compare; //导入依赖的package包/类
@Override
public void has(String propertyName, QueryOperator op, Object value) {
TitanPredicate pred;
if (op instanceof ComparisionOperator) {
Compare c = getGremlinPredicate((ComparisionOperator) op);
pred = TitanPredicate.Converter.convert(c);
} else {
pred = getGremlinPredicate((MatchingOperator)op);
}
query.has(propertyName, pred, value);
}
开发者ID:apache,项目名称:incubator-atlas,代码行数:12,代码来源:NativeTitan1GraphQuery.java
示例17: processHasContainerIds
import org.apache.tinkerpop.gremlin.process.traversal.Compare; //导入依赖的package包/类
/**
* Helper method for providers that want to "fold in" {@link HasContainer}'s based on id checking into the ids of the {@link GraphStep}.
*
* @param graphStep the GraphStep to potentially {@link GraphStep#addIds(Object...)}.
* @param hasContainer The {@link HasContainer} to check for id validation.
* @return true if the {@link HasContainer} updated ids and thus, was processed.
*/
public static boolean processHasContainerIds(final GraphStep<?, ?> graphStep, final HasContainer hasContainer) {
if (hasContainer.getKey().equals(T.id.getAccessor()) && graphStep.ids.length == 0 &&
(hasContainer.getBiPredicate() == Compare.eq || hasContainer.getBiPredicate() == Contains.within)) {
graphStep.addIds(hasContainer.getValue());
return true;
}
return false;
}
开发者ID:apache,项目名称:tinkerpop,代码行数:16,代码来源:GraphStep.java
示例18: testInt
import org.apache.tinkerpop.gremlin.process.traversal.Compare; //导入依赖的package包/类
@Test
public void testInt() {
Vertex v1 = this.sqlgGraph.addVertex(T.label, "Person", "name", "johnny", "score",2,"experience",3);
Vertex v2 = this.sqlgGraph.addVertex(T.label, "Person", "name", "pietie", "score",2,"experience",2);
Vertex v3 = this.sqlgGraph.addVertex(T.label, "Person", "name", "koosie", "score",2,"experience",1);
this.sqlgGraph.tx().commit();
assertOneStepOneVertex(this.sqlgGraph.traversal().V().hasLabel("Person").has("score",propertyRef(Compare.eq, "experience"))
,v2);
assertOneStepOneVertex(this.sqlgGraph.traversal().V().hasLabel("Person").has("score",propertyRef(Compare.lt, "experience"))
,v1);
assertOneStepOneVertex(this.sqlgGraph.traversal().V().hasLabel("Person").has("score",propertyRef(Compare.gt, "experience"))
,v3);
}
开发者ID:pietermartin,项目名称:sqlg,代码行数:16,代码来源:TestPropertyReference.java
示例19: RefP
import org.apache.tinkerpop.gremlin.process.traversal.Compare; //导入依赖的package包/类
private RefP(Compare biPredicate, PropertyReference value) {
super(biPredicate, value);
}
开发者ID:pietermartin,项目名称:sqlg,代码行数:4,代码来源:PropertyReference.java
示例20: collectSchemaTableTrees
import org.apache.tinkerpop.gremlin.process.traversal.Compare; //导入依赖的package包/类
private void collectSchemaTableTrees(
SqlgGraph sqlgGraph,
int replacedStepDepth,
Set<SchemaTableTree> result,
Map<SchemaTable, List<Multimap<BiPredicate, RecordId>>> groupedIds,
String table) {
SchemaTable schemaTable = SchemaTable.from(sqlgGraph, table);
List<HasContainer> schemaTableTreeHasContainers = new ArrayList<>(this.hasContainers);
if (groupedIds != null) {
List<Multimap<BiPredicate, RecordId>> biPredicateRecordIds = groupedIds.get(schemaTable.withOutPrefix());
if (biPredicateRecordIds != null) {
for (Multimap<BiPredicate, RecordId> biPredicateRecordId : biPredicateRecordIds) {
for (BiPredicate biPredicate : biPredicateRecordId.keySet()) {
Collection<RecordId> recordIds = biPredicateRecordId.get(biPredicate);
HasContainer idHasContainer;
//id hasContainers are only optimized for BaseStrategy.SUPPORTED_ID_BI_PREDICATE within, without, eq, neq
if (biPredicate == Contains.without || biPredicate == Contains.within) {
idHasContainer = new HasContainer(T.id.getAccessor(), P.test(biPredicate, recordIds));
schemaTableTreeHasContainers.add(idHasContainer);
} else {
Preconditions.checkState(biPredicate == Compare.eq || biPredicate == Compare.neq);
for (RecordId recordId : recordIds) {
idHasContainer = new HasContainer(T.id.getAccessor(), P.test(biPredicate, recordId));
schemaTableTreeHasContainers.add(idHasContainer);
}
}
}
}
}
}
SchemaTableTree schemaTableTree = new SchemaTableTree(
sqlgGraph,
schemaTable,
0,
schemaTableTreeHasContainers,
this.andOrHasContainers,
this.sqlgComparatorHolder,
this.sqlgComparatorHolder.getComparators(),
this.sqlgRangeHolder,
SchemaTableTree.STEP_TYPE.GRAPH_STEP,
ReplacedStep.this.emit,
ReplacedStep.this.untilFirst,
ReplacedStep.this.leftJoin,
ReplacedStep.this.drop,
replacedStepDepth,
ReplacedStep.this.labels
);
result.add(schemaTableTree);
}
开发者ID:pietermartin,项目名称:sqlg,代码行数:54,代码来源:ReplacedStep.java
注:本文中的org.apache.tinkerpop.gremlin.process.traversal.Compare类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论