本文整理汇总了Java中org.apache.tinkerpop.gremlin.process.traversal.Contains类的典型用法代码示例。如果您正苦于以下问题:Java Contains类的具体用法?Java Contains怎么用?Java Contains使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Contains类属于org.apache.tinkerpop.gremlin.process.traversal包,在下文中一共展示了Contains类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: convertInternal
import org.apache.tinkerpop.gremlin.process.traversal.Contains; //导入依赖的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
示例2: getTypeFilter
import org.apache.tinkerpop.gremlin.process.traversal.Contains; //导入依赖的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
示例3: predicateToQuery
import org.apache.tinkerpop.gremlin.process.traversal.Contains; //导入依赖的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
示例4: getContainsCondition
import org.apache.tinkerpop.gremlin.process.traversal.Contains; //导入依赖的package包/类
private Condition getContainsCondition(Object value, BiPredicate<?, ?> biPredicate, Field<Object> field) {
if (biPredicate == Contains.without) {
if (value == null) {
return field.isNull();
} else {
return field.notIn(value);
}
} else if (biPredicate == Contains.within) {
if (value == null) {
return field.isNotNull();
} else {
return field.in(((Collection) value).toArray());
}
}
return null;
}
开发者ID:unipop-graph,项目名称:unipop,代码行数:17,代码来源:JdbcPredicatesTranslator.java
示例5: addIdHasContainers
import org.apache.tinkerpop.gremlin.process.traversal.Contains; //导入依赖的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
示例6: processHasContainerIds
import org.apache.tinkerpop.gremlin.process.traversal.Contains; //导入依赖的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
示例7: predicateToQuery
import org.apache.tinkerpop.gremlin.process.traversal.Contains; //导入依赖的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
示例8: getContainsFilter
import org.apache.tinkerpop.gremlin.process.traversal.Contains; //导入依赖的package包/类
private static QueryBuilder getContainsFilter(String key, Object value, BiPredicate<?, ?> biPredicate) {
if (biPredicate == Contains.without) return QueryBuilders.boolQuery().mustNot(QueryBuilders.existsQuery(key));
else if (biPredicate == Contains.within) {
if (value == null) return QueryBuilders.existsQuery(key);
else if (value instanceof Collection<?>)
return QueryBuilders.termsQuery(key, (Collection<?>) value);
else if (value.getClass().isArray())
return QueryBuilders.termsQuery(key, (Object[]) value);
else return QueryBuilders.termsQuery(key, value);
} else throw new IllegalArgumentException("predicate not supported by unipop: " + biPredicate.toString());
}
开发者ID:unipop-graph,项目名称:unipop,代码行数:12,代码来源:FilterHelper.java
示例9: findIndex
import org.apache.tinkerpop.gremlin.process.traversal.Contains; //导入依赖的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
示例10: processHasContainerIds
import org.apache.tinkerpop.gremlin.process.traversal.Contains; //导入依赖的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
示例11: containsToSql
import org.apache.tinkerpop.gremlin.process.traversal.Contains; //导入依赖的package包/类
private static String containsToSql(Contains contains, int size) {
String result;
if (size == 1) {
switch (contains) {
case within:
result = " = ?";
break;
case without:
result = " <> ?";
break;
default:
throw new RuntimeException("Unknown Contains" + contains.name());
}
} else {
switch (contains) {
case within:
result = " in (";
break;
case without:
result = " not in (";
break;
default:
throw new RuntimeException("Unknown Contains" + contains.name());
}
for (int i = 0; i < size; i++) {
result += "?";
if (i < size - 1 && size > 1) {
result += ", ";
}
}
result += ")";
}
return result;
}
开发者ID:pietermartin,项目名称:sqlg,代码行数:36,代码来源:WhereClause.java
示例12: getValueIterator
import org.apache.tinkerpop.gremlin.process.traversal.Contains; //导入依赖的package包/类
/**
* gets the requested values from the Has step. If it's a single value, wrap it in an array, otherwise return the array
*/
private Iterator<Object> getValueIterator(HasContainer c) {
return c.getPredicate().getBiPredicate() == Contains.within
? ((Iterable<Object>) c.getValue()).iterator()
: IteratorUtils.of(c.getValue());
}
开发者ID:orientechnologies,项目名称:orientdb-gremlin,代码行数:9,代码来源:OrientGraphStep.java
示例13: collectSchemaTableTrees
import org.apache.tinkerpop.gremlin.process.traversal.Contains; //导入依赖的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
示例14: isBulkWithinAndOut
import org.apache.tinkerpop.gremlin.process.traversal.Contains; //导入依赖的package包/类
public static boolean isBulkWithinAndOut(SqlgGraph sqlgGraph, HasContainer hasContainer) {
BiPredicate p = hasContainer.getPredicate().getBiPredicate();
return (p == Contains.within || p == Contains.without) && ((Collection) hasContainer.getPredicate().getValue()).size() > sqlgGraph.configuration().getInt("bulk.within.count", BULK_WITHIN_COUNT);
}
开发者ID:pietermartin,项目名称:sqlg,代码行数:5,代码来源:SqlgUtil.java
示例15: isBulkWithin
import org.apache.tinkerpop.gremlin.process.traversal.Contains; //导入依赖的package包/类
public static boolean isBulkWithin(SqlgGraph sqlgGraph, HasContainer hasContainer) {
BiPredicate p = hasContainer.getPredicate().getBiPredicate();
return p == Contains.within && ((Collection) hasContainer.getPredicate().getValue()).size() > sqlgGraph.configuration().getInt("bulk.within.count", BULK_WITHIN_COUNT);
}
开发者ID:pietermartin,项目名称:sqlg,代码行数:5,代码来源:SqlgUtil.java
注:本文中的org.apache.tinkerpop.gremlin.process.traversal.Contains类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论