本文整理汇总了Java中com.thinkaurelius.titan.core.attribute.Cmp类的典型用法代码示例。如果您正苦于以下问题:Java Cmp类的具体用法?Java Cmp怎么用?Java Cmp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Cmp类属于com.thinkaurelius.titan.core.attribute包,在下文中一共展示了Cmp类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testInstant
import com.thinkaurelius.titan.core.attribute.Cmp; //导入依赖的package包/类
private void testInstant(Instant firstTimestamp, Instant secondTimestamp, TitanVertex v1, TitanVertex v2) {
assertEquals(v1, getOnlyVertex(graph.query().has("instant", Cmp.EQUAL, firstTimestamp)));
assertEquals(v2, getOnlyVertex(graph.query().has("instant", Cmp.GREATER_THAN, firstTimestamp)));
assertEquals(Sets.newHashSet(v1, v2), Sets.newHashSet(graph.query().has("instant", Cmp.GREATER_THAN_EQUAL, firstTimestamp).vertices()));
assertEquals(v1, getOnlyVertex(graph.query().has("instant", Cmp.LESS_THAN, secondTimestamp)));
assertEquals(Sets.newHashSet(v1, v2), Sets.newHashSet(graph.query().has("instant", Cmp.LESS_THAN_EQUAL, secondTimestamp).vertices()));
assertEquals(v2, getOnlyVertex(graph.query().has("instant", Cmp.NOT_EQUAL, firstTimestamp)));
clopen();//Flush the index
assertEquals(v1, getOnlyVertex(graph.query().has("instant", Cmp.EQUAL, firstTimestamp)));
assertEquals(v2, getOnlyVertex(graph.query().has("instant", Cmp.GREATER_THAN, firstTimestamp)));
assertEquals(Sets.newHashSet(v1, v2), Sets.newHashSet(graph.query().has("instant", Cmp.GREATER_THAN_EQUAL, firstTimestamp).vertices()));
assertEquals(v1, getOnlyVertex(graph.query().has("instant", Cmp.LESS_THAN, secondTimestamp)));
assertEquals(Sets.newHashSet(v1, v2), Sets.newHashSet(graph.query().has("instant", Cmp.LESS_THAN_EQUAL, secondTimestamp).vertices()));
assertEquals(v2, getOnlyVertex(graph.query().has("instant", Cmp.NOT_EQUAL, firstTimestamp)));
}
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:18,代码来源:TitanIndexTest.java
示例2: convertInternal
import com.thinkaurelius.titan.core.attribute.Cmp; //导入依赖的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: addConstraint
import com.thinkaurelius.titan.core.attribute.Cmp; //导入依赖的package包/类
private Q addConstraint(String type, TitanPredicate rel, Object value) {
Preconditions.checkArgument(type != null && StringUtils.isNotBlank(type) && rel != null);
//Treat special cases
if (type.equals(ImplicitKey.ADJACENT_ID.name())) {
Preconditions.checkArgument(rel == Cmp.EQUAL, "Only equality constraints are supported for %s", type);
long vertexId = ElementUtils.getVertexId(value);
Preconditions.checkArgument(vertexId > 0, "Expected valid vertex id: %s", value);
return adjacent(getVertex(vertexId));
} else if (type.equals(ImplicitKey.ID.name())) {
RelationIdentifier rid = ElementUtils.getEdgeId(value);
Preconditions.checkArgument(rid != null, "Expected valid relation id: %s", value);
return addConstraint(ImplicitKey.TITANID.name(), rel, rid.getRelationId());
} else {
Preconditions.checkArgument(rel.isValidCondition(value), "Invalid condition provided: " + value);
}
if (constraints == NO_CONSTRAINTS) constraints = new ArrayList<PredicateCondition<String, TitanRelation>>(5);
constraints.add(new PredicateCondition<String, TitanRelation>(type, rel, value));
return getThis();
}
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:20,代码来源:BaseVertexCentricQueryBuilder.java
示例4: getEqualityConditionValues
import com.thinkaurelius.titan.core.attribute.Cmp; //导入依赖的package包/类
private static final Map.Entry<Condition,Collection<Object>> getEqualityConditionValues(Condition<TitanElement> condition, RelationType type) {
for (Condition c : condition.getChildren()) {
if (c instanceof Or) {
Map.Entry<RelationType,Collection> orEqual = QueryUtil.extractOrCondition((Or)c);
if (orEqual!=null && orEqual.getKey().equals(type) && !orEqual.getValue().isEmpty()) {
return new AbstractMap.SimpleImmutableEntry(c,orEqual.getValue());
}
} else if (c instanceof PredicateCondition) {
PredicateCondition<RelationType, TitanRelation> atom = (PredicateCondition)c;
if (atom.getKey().equals(type) && atom.getPredicate()==Cmp.EQUAL && atom.getValue()!=null) {
return new AbstractMap.SimpleImmutableEntry(c,ImmutableList.of(atom.getValue()));
}
}
}
return null;
}
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:18,代码来源:GraphCentricQueryBuilder.java
示例5: getQuery
import com.thinkaurelius.titan.core.attribute.Cmp; //导入依赖的package包/类
public static GraphCentricQueryBuilder getQuery(CompositeIndexType index, Object[] values, StandardTitanTx tx) {
Preconditions.checkArgument(index != null && values != null && values.length > 0 && tx != null);
Preconditions.checkArgument(values.length==index.getFieldKeys().length);
GraphCentricQueryBuilder gb = tx.query();
IndexField[] fields = index.getFieldKeys();
for (int i = 0; i <fields.length; i++) {
IndexField f = fields[i];
Object value = values[i];
Preconditions.checkNotNull(value);
PropertyKey key = f.getFieldKey();
Preconditions.checkArgument(key.dataType().equals(value.getClass()),"Incompatible data types for: " + value);
gb.has(key, Cmp.EQUAL,value);
}
if (index.hasSchemaTypeConstraint()) {
gb.has(ImplicitKey.LABEL,Cmp.EQUAL,index.getSchemaTypeConstraint().name());
}
return gb;
}
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:19,代码来源:IndexHelper.java
示例6: getEqualityConditionValues
import com.thinkaurelius.titan.core.attribute.Cmp; //导入依赖的package包/类
private static final Map.Entry<Condition, Collection<Object>> getEqualityConditionValues(Condition<TitanElement> condition, RelationType type) {
for (Condition c : condition.getChildren()) {
if (c instanceof Or) {
Map.Entry<RelationType, Collection> orEqual = QueryUtil.extractOrCondition((Or)c);
if (orEqual!=null && orEqual.getKey().equals(type) && !orEqual.getValue().isEmpty()) {
return new AbstractMap.SimpleImmutableEntry(c, orEqual.getValue());
}
} else if (c instanceof PredicateCondition) {
PredicateCondition<RelationType, TitanRelation> atom = (PredicateCondition)c;
if (atom.getKey().equals(type) && atom.getPredicate()==Cmp.EQUAL && atom.getValue()!=null) {
return new AbstractMap.SimpleImmutableEntry(c, ImmutableList.of(atom.getValue()));
}
}
}
return null;
}
开发者ID:apache,项目名称:incubator-atlas,代码行数:18,代码来源:GraphCentricQueryBuilder.java
示例7: getQuery
import com.thinkaurelius.titan.core.attribute.Cmp; //导入依赖的package包/类
public static GraphCentricQueryBuilder getQuery(CompositeIndexType index, Object[] values, StandardTitanTx tx) {
Preconditions.checkArgument(index != null && values != null && values.length > 0 && tx != null);
Preconditions.checkArgument(values.length==index.getFieldKeys().length);
GraphCentricQueryBuilder gb = tx.query();
IndexField[] fields = index.getFieldKeys();
for (int i = 0; i <fields.length; i++) {
IndexField f = fields[i];
Object value = values[i];
Preconditions.checkNotNull(value);
PropertyKey key = f.getFieldKey();
Preconditions.checkArgument(key.getDataType().equals(value.getClass()),"Incompatible data types for: " + value);
gb.has(key, Cmp.EQUAL,value);
}
if (index.hasSchemaTypeConstraint()) {
gb.has(ImplicitKey.LABEL,Cmp.EQUAL,index.getSchemaTypeConstraint().getName());
}
return gb;
}
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:19,代码来源:IndexHelper.java
示例8: getVertices
import com.thinkaurelius.titan.core.attribute.Cmp; //导入依赖的package包/类
/**
* Gets the specified vertices or null if no such vertex is found
*
* @param property name
* @param label vertex type label
* @param value value in property field
* @param limit int value limiting the result. use Integer.MAX_VALUE for unlimited
* @return the specified vertices or null if no such vertex is found
*/
public Set<Vertex> getVertices(String label, String property, Object value, int limit) throws SchemaViolationException {
Integer suffix = s.getVertexTypes().get(label);
Set<Vertex> res = new HashSet<>();
if (suffix == null)
throw new SchemaViolationException(label + " vertex type is not defined in the schema for " + s.getClass().getSimpleName());
Iterable<Vertex> qres;
GraphQuery q = g.query().has("label", label).has(property, Cmp.EQUAL, value);
if (limit == Integer.MAX_VALUE)
qres = q.vertices();
else
qres = q.limit(limit).vertices();
for (Vertex v : qres)
res.add(v);
return res;
}
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:28,代码来源:TitanFTMDb.java
示例9: getQueryString
import com.thinkaurelius.titan.core.attribute.Cmp; //导入依赖的package包/类
private final String getQueryString(String family, String key, Cmp relation, Number value) {
String columnName = getColumnName(family, key);
switch (relation) {
case EQUAL:
return columnName + ":" + value;
case NOT_EQUAL:
return "-(" + columnName + ":" + value + ")";
case LESS_THAN:
return columnName + ":[MIN TO " + value + "}";
case LESS_THAN_EQUAL:
return columnName + ":[MIN TO " + value + "]";
case GREATER_THAN:
return columnName + ":{" + value + " TO MAX]";
case GREATER_THAN_EQUAL:
return columnName + ":[" + value + " TO MAX]";
default:
throw new IllegalArgumentException("Unexpected relation: " + relation);
}
}
开发者ID:apache,项目名称:incubator-blur,代码行数:20,代码来源:BlurIndex.java
示例10: testVertexCentricIndexWithNull
import com.thinkaurelius.titan.core.attribute.Cmp; //导入依赖的package包/类
@Test
public void testVertexCentricIndexWithNull() {
EdgeLabel bought = makeLabel("bought");
PropertyKey time = makeKey("time", Long.class);
mgmt.buildEdgeIndex(bought, "byTimeDesc", BOTH, decr, time);
mgmt.buildEdgeIndex(bought, "byTimeIncr", BOTH, incr, time);
finishSchema();
TitanVertex v1 = tx.addVertex(), v2 = tx.addVertex();
v1.addEdge("bought", v2).property("time", 1);
v1.addEdge("bought", v2).property("time", 2);
v1.addEdge("bought", v2).property("time", 3);
v1.addEdge("bought", v2);
v1.addEdge("bought", v2);
assertEquals(5, v1.query().direction(OUT).labels("bought").edgeCount());
assertEquals(1, v1.query().direction(OUT).labels("bought").has("time", 1).edgeCount());
assertEquals(1, v1.query().direction(OUT).labels("bought").has("time", Cmp.LESS_THAN, 3).has("time", Cmp.GREATER_THAN, 1).edgeCount());
assertEquals(3, v1.query().direction(OUT).labels("bought").has("time", Cmp.LESS_THAN, 5).edgeCount());
assertEquals(3, v1.query().direction(OUT).labels("bought").has("time", Cmp.GREATER_THAN, 0).edgeCount());
assertEquals(2, v1.query().direction(OUT).labels("bought").has("time", Cmp.LESS_THAN, 3).edgeCount());
assertEquals(1, v1.query().direction(OUT).labels("bought").has("time", Cmp.GREATER_THAN, 2).edgeCount());
assertEquals(2, v1.query().direction(OUT).labels("bought").hasNot("time").edgeCount());
assertEquals(5, v1.query().direction(OUT).labels("bought").edgeCount());
newTx();
v1 = tx.getVertex(v1.longId());
//Queries copied from above
assertEquals(5, v1.query().direction(OUT).labels("bought").edgeCount());
assertEquals(1, v1.query().direction(OUT).labels("bought").has("time", 1).edgeCount());
assertEquals(1, v1.query().direction(OUT).labels("bought").has("time", Cmp.LESS_THAN, 3).has("time", Cmp.GREATER_THAN, 1).edgeCount());
assertEquals(3, v1.query().direction(OUT).labels("bought").has("time", Cmp.LESS_THAN, 5).edgeCount());
assertEquals(3, v1.query().direction(OUT).labels("bought").has("time", Cmp.GREATER_THAN, 0).edgeCount());
assertEquals(2, v1.query().direction(OUT).labels("bought").has("time", Cmp.LESS_THAN, 3).edgeCount());
assertEquals(1, v1.query().direction(OUT).labels("bought").has("time", Cmp.GREATER_THAN, 2).edgeCount());
assertEquals(2, v1.query().direction(OUT).labels("bought").hasNot("time").edgeCount());
assertEquals(5, v1.query().direction(OUT).labels("bought").edgeCount());
}
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:41,代码来源:TitanGraphTest.java
示例11: testBooleanIndexing
import com.thinkaurelius.titan.core.attribute.Cmp; //导入依赖的package包/类
/**
* Tests indexing boolean
*/
@Test
public void testBooleanIndexing() {
PropertyKey name = makeKey("visible", Boolean.class);
mgmt.buildIndex("booleanIndex", Vertex.class).
addKey(name).buildMixedIndex(INDEX);
finishSchema();
clopen();
TitanVertex v1 = graph.addVertex();
v1.property("visible", true);
TitanVertex v2 = graph.addVertex();
v2.property("visible", false);
assertCount(2, graph.vertices());
assertEquals(v1, getOnlyVertex(graph.query().has("visible", true)));
assertEquals(v2, getOnlyVertex(graph.query().has("visible", false)));
assertEquals(v2, getOnlyVertex(graph.query().has("visible", Cmp.NOT_EQUAL, true)));
assertEquals(v1, getOnlyVertex(graph.query().has("visible", Cmp.NOT_EQUAL, false)));
clopen();//Flush the index
assertCount(2, graph.vertices());
assertEquals(v1, getOnlyVertex(graph.query().has("visible", true)));
assertEquals(v2, getOnlyVertex(graph.query().has("visible", false)));
assertEquals(v2, getOnlyVertex(graph.query().has("visible", Cmp.NOT_EQUAL, true)));
assertEquals(v1, getOnlyVertex(graph.query().has("visible", Cmp.NOT_EQUAL, false)));
}
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:31,代码来源:TitanIndexTest.java
示例12: testDateIndexing
import com.thinkaurelius.titan.core.attribute.Cmp; //导入依赖的package包/类
/**
* Tests indexing dates
*/
@Test
public void testDateIndexing() {
PropertyKey name = makeKey("date", Date.class);
mgmt.buildIndex("dateIndex", Vertex.class).
addKey(name).buildMixedIndex(INDEX);
finishSchema();
clopen();
TitanVertex v1 = graph.addVertex();
v1.property("date", new Date(1));
TitanVertex v2 = graph.addVertex();
v2.property("date", new Date(2000));
assertEquals(v1, getOnlyVertex(graph.query().has("date", Cmp.EQUAL, new Date(1))));
assertEquals(v2, getOnlyVertex(graph.query().has("date", Cmp.GREATER_THAN, new Date(1))));
assertEquals(Sets.newHashSet(v1, v2), Sets.newHashSet(graph.query().has("date", Cmp.GREATER_THAN_EQUAL, new Date(1)).vertices()));
assertEquals(v1, getOnlyVertex(graph.query().has("date", Cmp.LESS_THAN, new Date(2000))));
assertEquals(Sets.newHashSet(v1, v2), Sets.newHashSet(graph.query().has("date", Cmp.LESS_THAN_EQUAL, new Date(2000)).vertices()));
assertEquals(v2, getOnlyVertex(graph.query().has("date", Cmp.NOT_EQUAL, new Date(1))));
clopen();//Flush the index
assertEquals(v1, getOnlyVertex(graph.query().has("date", Cmp.EQUAL, new Date(1))));
assertEquals(v2, getOnlyVertex(graph.query().has("date", Cmp.GREATER_THAN, new Date(1))));
assertEquals(Sets.newHashSet(v1, v2), Sets.newHashSet(graph.query().has("date", Cmp.GREATER_THAN_EQUAL, new Date(1)).vertices()));
assertEquals(v1, getOnlyVertex(graph.query().has("date", Cmp.LESS_THAN, new Date(2000))));
assertEquals(Sets.newHashSet(v1, v2), Sets.newHashSet(graph.query().has("date", Cmp.LESS_THAN_EQUAL, new Date(2000)).vertices()));
assertEquals(v2, getOnlyVertex(graph.query().has("date", Cmp.NOT_EQUAL, new Date(1))));
}
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:36,代码来源:TitanIndexTest.java
示例13: testUUIDIndexing
import com.thinkaurelius.titan.core.attribute.Cmp; //导入依赖的package包/类
/**
* Tests indexing boolean
*/
@Test
public void testUUIDIndexing() {
PropertyKey name = makeKey("uid", UUID.class);
mgmt.buildIndex("uuidIndex", Vertex.class).
addKey(name).buildMixedIndex(INDEX);
finishSchema();
clopen();
UUID uid1 = UUID.randomUUID();
UUID uid2 = UUID.randomUUID();
TitanVertex v1 = graph.addVertex();
v1.property("uid", uid1);
TitanVertex v2 = graph.addVertex();
v2.property("uid", uid2);
assertCount(2, graph.query().vertices());
assertEquals(v1, getOnlyVertex(graph.query().has("uid", uid1)));
assertEquals(v2, getOnlyVertex(graph.query().has("uid", uid2)));
assertEquals(v2, getOnlyVertex(graph.query().has("uid", Cmp.NOT_EQUAL, uid1)));
assertEquals(v1, getOnlyVertex(graph.query().has("uid", Cmp.NOT_EQUAL, uid2)));
clopen();//Flush the index
assertCount(2, graph.query().vertices());
assertEquals(v1, getOnlyVertex(graph.query().has("uid", uid1)));
assertEquals(v2, getOnlyVertex(graph.query().has("uid", uid2)));
assertEquals(v2, getOnlyVertex(graph.query().has("uid", Cmp.NOT_EQUAL, uid1)));
assertEquals(v1, getOnlyVertex(graph.query().has("uid", Cmp.NOT_EQUAL, uid2)));
}
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:37,代码来源:TitanIndexTest.java
示例14: checkPropertyLockingAndIndex
import com.thinkaurelius.titan.core.attribute.Cmp; //导入依赖的package包/类
@Test
public void checkPropertyLockingAndIndex() {
PropertyKey uid = makeKey("uid",String.class);
TitanGraphIndex index = mgmt.buildIndex("uid",Vertex.class).unique().addKey(uid).buildCompositeIndex();
mgmt.setConsistency(index, ConsistencyModifier.LOCK);
mgmt.makePropertyKey("name").dataType(String.class).make();
mgmt.makePropertyKey("age").dataType(Integer.class).make();
finishSchema();
metricsPrefix = "checkPropertyLockingAndIndex";
TitanTransaction tx = graph.buildTransaction().groupName(metricsPrefix).start();
TitanVertex v = tx.addVertex("uid", "v1", "age", 25, "name", "john");
assertEquals(25,v.property("age").value());
tx.commit();
verifyStoreMetrics(EDGESTORE_NAME);
verifyLockingOverwrite(INDEXSTORE_NAME, 1);
verifyStoreMetrics(METRICS_STOREMANAGER_NAME, ImmutableMap.of(M_MUTATE, 1l));
resetMetrics();
tx = graph.buildTransaction().groupName(metricsPrefix).start();
v = Iterables.getOnlyElement(tx.query().has("uid", Cmp.EQUAL, "v1").vertices());
assertEquals(25,v.property("age").value());
tx.commit();
verifyStoreMetrics(EDGESTORE_NAME, ImmutableMap.of(M_GET_SLICE,1l));
verifyStoreMetrics(INDEXSTORE_NAME, ImmutableMap.of(M_GET_SLICE,1l));
verifyStoreMetrics(METRICS_STOREMANAGER_NAME);
}
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:30,代码来源:TitanOperationCountingTest.java
示例15: supports
import com.thinkaurelius.titan.core.attribute.Cmp; //导入依赖的package包/类
@Override
public boolean supports(KeyInformation information, TitanPredicate titanPredicate) {
Class<?> dataType = information.getDataType();
Mapping mapping = getMapping(information);
if (mapping!= DEFAULT && !AttributeUtil.isString(dataType)) return false;
if (Number.class.isAssignableFrom(dataType)) {
return titanPredicate instanceof Cmp;
} else if (dataType == Geoshape.class) {
return titanPredicate == Geo.WITHIN;
} else if (AttributeUtil.isString(dataType)) {
switch(mapping) {
case DEFAULT:
case TEXT:
return titanPredicate == Text.CONTAINS || titanPredicate == Text.CONTAINS_PREFIX || titanPredicate == Text.CONTAINS_REGEX;
case STRING:
return titanPredicate == EQUAL || titanPredicate== NOT_EQUAL || titanPredicate==Text.REGEX || titanPredicate==Text.PREFIX;
// case TEXTSTRING:
// return (titanPredicate instanceof Text) || titanPredicate == Cmp.EQUAL || titanPredicate==Cmp.NOT_EQUAL;
}
} else if (dataType == Date.class) {
if (titanPredicate instanceof Cmp) return true;
} else if (dataType == Boolean.class) {
return titanPredicate == EQUAL || titanPredicate == NOT_EQUAL;
} else if (dataType == UUID.class) {
return titanPredicate == EQUAL || titanPredicate== NOT_EQUAL;
}
return false;
}
开发者ID:apache,项目名称:incubator-atlas,代码行数:30,代码来源:Solr5Index.java
示例16: addConstraint
import com.thinkaurelius.titan.core.attribute.Cmp; //导入依赖的package包/类
private Q addConstraint(String type, TitanPredicate rel, Object value) {
Preconditions.checkArgument(type!=null && StringUtils.isNotBlank(type) && rel!=null);
//Treat special cases
if (type.equals(ImplicitKey.ADJACENT_ID.getName())) {
Preconditions.checkArgument(rel == Cmp.EQUAL,"Only equality constraints are supported for %s",type);
Preconditions.checkArgument(value instanceof Number,"Expected valid vertex id: %s",value);
return adjacent(getVertex(((Number)value).longValue()));
} else if (type.equals(ImplicitKey.ID.getName())) {
Preconditions.checkArgument(value instanceof RelationIdentifier,"Expected valid relation id: %s",value);
return addConstraint(ImplicitKey.TITANID.getName(),rel,((RelationIdentifier)value).getRelationId());
}
if (constraints==NO_CONSTRAINTS) constraints = new ArrayList<PredicateCondition<String, TitanRelation>>(5);
constraints.add(new PredicateCondition<String, TitanRelation>(type, rel, value));
return getThis();
}
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:16,代码来源:BaseVertexCentricQueryBuilder.java
示例17: asTitanCmp
import com.thinkaurelius.titan.core.attribute.Cmp; //导入依赖的package包/类
public static final Cmp asTitanCmp(QueryPredicate.Compare predicate) {
switch(predicate) {
case EQUAL: return Cmp.EQUAL;
case NOT_EQUAL: return Cmp.NOT_EQUAL;
case GREATER_THAN: return Cmp.GREATER_THAN;
case GREATER_THAN_EQUAL: return Cmp.GREATER_THAN_EQUAL;
case LESS_THAN: return Cmp.LESS_THAN;
case LESS_THAN_EQUAL: return Cmp.LESS_THAN_EQUAL;
// NOTE: this shouldn't happen, because we pattern match on all cases of a sealed enum
default: return Cmp.EQUAL;
}
}
开发者ID:bio4j,项目名称:angulillos-titan,代码行数:14,代码来源:TitanConversions.java
示例18: supports
import com.thinkaurelius.titan.core.attribute.Cmp; //导入依赖的package包/类
@Override
public boolean supports(Class<?> dataType, Relation relation) {
if (Number.class.isAssignableFrom(dataType)) {
if (relation instanceof Cmp) {
return true;
}
} else if (dataType == Geoshape.class) {
return relation == Geo.INTERSECT;
} else if (dataType == String.class) {
return relation == Text.CONTAINS;
}
return false;
}
开发者ID:apache,项目名称:incubator-blur,代码行数:14,代码来源:BlurIndex.java
示例19: testGlobalIteration
import com.thinkaurelius.titan.core.attribute.Cmp; //导入依赖的package包/类
/**
* Iterating over all vertices and edges in a graph
*/
@Test
public void testGlobalIteration() {
int numV = 50;
int deleteV = 5;
TitanVertex previous = tx.addVertex("count", 0);
for (int i = 1; i < numV; i++) {
TitanVertex next = tx.addVertex("count", i);
previous.addEdge("next", next);
previous = next;
}
int numE = numV - 1;
assertCount(numV, tx.query().vertices());
assertCount(numV, tx.query().vertices());
assertCount(numE, tx.query().edges());
assertCount(numE, tx.query().edges());
clopen();
assertCount(numV, tx.query().vertices());
assertCount(numV, tx.query().vertices());
assertCount(numE, tx.query().edges());
assertCount(numE, tx.query().edges());
//tx.V().range(0,deleteV).remove();
for (TitanVertex v : tx.query().limit(deleteV).vertices()) {
v.remove();
}
for (int i = 0; i < 10; i++) { //Repeated vertex counts
assertCount(numV - deleteV, tx.query().vertices());
assertCount(numV - deleteV, tx.query().has("count", Cmp.GREATER_THAN_EQUAL, 0).vertices());
}
clopen();
for (int i = 0; i < 10; i++) { //Repeated vertex counts
assertCount(numV - deleteV, tx.query().vertices());
assertCount(numV - deleteV, tx.query().has("count", Cmp.GREATER_THAN_EQUAL, 0).vertices());
}
}
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:44,代码来源:TitanGraphTest.java
示例20: testCompositeAndMixedIndexing
import com.thinkaurelius.titan.core.attribute.Cmp; //导入依赖的package包/类
@Test
public void testCompositeAndMixedIndexing() {
PropertyKey name = makeKey("name", String.class);
PropertyKey weight = makeKey("weight", Double.class);
PropertyKey text = makeKey("text", String.class);
PropertyKey flag = makeKey("flag", Boolean.class);
TitanGraphIndex composite = mgmt.buildIndex("composite", Vertex.class).addKey(name).addKey(weight).buildCompositeIndex();
TitanGraphIndex mixed = mgmt.buildIndex("mixed", Vertex.class).addKey(weight)
.addKey(text, getTextMapping()).buildMixedIndex(INDEX);
mixed.name();
composite.name();
finishSchema();
final int numV = 100;
String[] strs = {"houseboat", "humanoid", "differential", "extraordinary"};
String[] strs2 = new String[strs.length];
for (int i = 0; i < strs.length; i++) strs2[i] = strs[i] + " " + strs[i];
final int modulo = 5;
final int divisor = modulo * strs.length;
for (int i = 0; i < numV; i++) {
TitanVertex v = tx.addVertex();
v.property("name", strs[i % strs.length]);
v.property("text", strs[i % strs.length]);
v.property("weight", (i % modulo) + 0.5);
v.property("flag", true);
}
evaluateQuery(tx.query().has("name", Cmp.EQUAL, strs[0]), ElementCategory.VERTEX,
numV / strs.length, new boolean[]{false, true});
evaluateQuery(tx.query().has("text", Text.CONTAINS, strs[0]), ElementCategory.VERTEX,
numV / strs.length, new boolean[]{true, true}, mixed.name());
evaluateQuery(tx.query().has("text", Text.CONTAINS, strs[0]).has("flag"), ElementCategory.VERTEX,
numV / strs.length, new boolean[]{false, true}, mixed.name());
evaluateQuery(tx.query().has("name", Cmp.EQUAL, strs[0]).has("weight", Cmp.EQUAL, 1.5), ElementCategory.VERTEX,
numV / divisor, new boolean[]{true, true}, composite.name());
evaluateQuery(tx.query().has("name", Cmp.EQUAL, strs[0]).has("weight", Cmp.EQUAL, 1.5).has("flag"), ElementCategory.VERTEX,
numV / divisor, new boolean[]{false, true}, composite.name());
evaluateQuery(tx.query().has("text", Text.CONTAINS, strs[2]).has("weight", Cmp.EQUAL, 2.5), ElementCategory.VERTEX,
numV / divisor, new boolean[]{true, true}, mixed.name());
evaluateQuery(tx.query().has("text", Text.CONTAINS, strs[2]).has("weight", Cmp.EQUAL, 2.5).has("flag"), ElementCategory.VERTEX,
numV / divisor, new boolean[]{false, true}, mixed.name());
evaluateQuery(tx.query().has("text", Text.CONTAINS, strs[3]).has("name", Cmp.EQUAL, strs[3]).has("weight", Cmp.EQUAL, 3.5), ElementCategory.VERTEX,
numV / divisor, new boolean[]{true, true}, mixed.name(), composite.name());
evaluateQuery(tx.query().has("text", Text.CONTAINS, strs[3]).has("name", Cmp.EQUAL, strs[3]).has("weight", Cmp.EQUAL, 3.5).has("flag"), ElementCategory.VERTEX,
numV / divisor, new boolean[]{false, true}, mixed.name(), composite.name());
clopen();
//Same queries as above
evaluateQuery(tx.query().has("name", Cmp.EQUAL, strs[0]), ElementCategory.VERTEX,
numV / strs.length, new boolean[]{false, true});
evaluateQuery(tx.query().has("text", Text.CONTAINS, strs[0]), ElementCategory.VERTEX,
numV / strs.length, new boolean[]{true, true}, mixed.name());
evaluateQuery(tx.query().has("text", Text.CONTAINS, strs[0]).has("flag"), ElementCategory.VERTEX,
numV / strs.length, new boolean[]{false, true}, mixed.name());
evaluateQuery(tx.query().has("name", Cmp.EQUAL, strs[0]).has("weight", Cmp.EQUAL, 1.5), ElementCategory.VERTEX,
numV / divisor, new boolean[]{true, true}, composite.name());
evaluateQuery(tx.query().has("name", Cmp.EQUAL, strs[0]).has("weight", Cmp.EQUAL, 1.5).has("flag"), ElementCategory.VERTEX,
numV / divisor, new boolean[]{false, true}, composite.name());
evaluateQuery(tx.query().has("text", Text.CONTAINS, strs[2]).has("weight", Cmp.EQUAL, 2.5), ElementCategory.VERTEX,
numV / divisor, new boolean[]{true, true}, mixed.name());
evaluateQuery(tx.query().has("text", Text.CONTAINS, strs[2]).has("weight", Cmp.EQUAL, 2.5).has("flag"), ElementCategory.VERTEX,
numV / divisor, new boolean[]{false, true}, mixed.name());
evaluateQuery(tx.query().has("text", Text.CONTAINS, strs[3]).has("name", Cmp.EQUAL, strs[3]).has("weight", Cmp.EQUAL, 3.5), ElementCategory.VERTEX,
numV / divisor, new boolean[]{true, true}, mixed.name(), composite.name());
evaluateQuery(tx.query().has("text", Text.CONTAINS, strs[3]).has("name", Cmp.EQUAL, strs[3]).has("weight", Cmp.EQUAL, 3.5).has("flag"), ElementCategory.VERTEX,
numV / divisor, new boolean[]{false, true}, mixed.name(), composite.name());
}
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:72,代码来源:TitanIndexTest.java
注:本文中的com.thinkaurelius.titan.core.attribute.Cmp类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论