本文整理汇总了Java中com.thinkaurelius.titan.core.TitanVertex类的典型用法代码示例。如果您正苦于以下问题:Java TitanVertex类的具体用法?Java TitanVertex怎么用?Java TitanVertex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TitanVertex类属于com.thinkaurelius.titan.core包,在下文中一共展示了TitanVertex类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testArrayEqualityUsingImplicitKey
import com.thinkaurelius.titan.core.TitanVertex; //导入依赖的package包/类
@Test
public void testArrayEqualityUsingImplicitKey() {
TitanVertex v = graph.addVertex();
byte singleDimension[] = new byte[]{127, 0, 0, 1};
byte singleDimensionCopy[] = new byte[]{127, 0, 0, 1};
final String singlePropName = "single";
v.property(singlePropName, singleDimension);
assertEquals(1, Iterables.size(graph.query().has(singlePropName, singleDimension).vertices()));
assertEquals(1, Iterables.size(graph.query().has(singlePropName, singleDimensionCopy).vertices()));
graph.tx().commit();
assertEquals(1, Iterables.size(graph.query().has(singlePropName, singleDimension).vertices()));
assertEquals(1, Iterables.size(graph.query().has(singlePropName, singleDimensionCopy).vertices()));
}
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:19,代码来源:TitanGraphTest.java
示例2: testStaleVertex
import com.thinkaurelius.titan.core.TitanVertex; //导入依赖的package包/类
@Test
public void testStaleVertex() {
PropertyKey name = mgmt.makePropertyKey("name").dataType(String.class).make();
PropertyKey age = mgmt.makePropertyKey("age").dataType(Integer.class).make();
mgmt.buildIndex("byName", Vertex.class).addKey(name).unique().buildCompositeIndex();
finishSchema();
TitanVertex cartman = graph.addVertex("name", "cartman", "age", 10);
TitanVertex stan = graph.addVertex("name", "stan", "age", 8);
graph.tx().commit();
cartman = getOnlyElement(graph.query().has("name", "cartman").vertices());
graph.tx().commit();
TitanVertexProperty p = (TitanVertexProperty) cartman.properties().next();
assertTrue(((Long) p.longId()) > 0);
graph.tx().commit();
}
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:22,代码来源:TitanGraphTest.java
示例3: testEdgesExceedCacheSize
import com.thinkaurelius.titan.core.TitanVertex; //导入依赖的package包/类
@Test
public void testEdgesExceedCacheSize() {
// Add a vertex with as many edges as the tx-cache-size. (20000 by default)
int numEdges = graph.getConfiguration().getTxVertexCacheSize();
TitanVertex parentVertex = graph.addVertex();
for (int i = 0; i < numEdges; i++) {
TitanVertex childVertex = graph.addVertex();
parentVertex.addEdge("friend", childVertex);
}
graph.tx().commit();
assertCount(numEdges, parentVertex.query().direction(Direction.OUT).edges());
// Remove an edge.
parentVertex.query().direction(OUT).edges().iterator().next().remove();
// Check that getEdges returns one fewer.
assertCount(numEdges - 1, parentVertex.query().direction(Direction.OUT).edges());
// Run the same check one more time.
// This fails! (Expected: 19999. Actual: 20000.)
assertCount(numEdges - 1, parentVertex.query().direction(Direction.OUT).edges());
}
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:23,代码来源:TitanGraphTest.java
示例4: iterator
import com.thinkaurelius.titan.core.TitanVertex; //导入依赖的package包/类
@Override
public Iterator<TitanVertex> iterator() {
return new Iterator<TitanVertex>() {
private int pos = -1;
@Override
public boolean hasNext() {
return (pos + 1) < size();
}
@Override
public TitanVertex next() {
if (!hasNext()) throw new NoSuchElementException();
pos++;
return get(pos);
}
@Override
public void remove() {
throw new UnsupportedOperationException("Vertices cannot be removed from neighborhood list");
}
};
}
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:26,代码来源:VertexLongList.java
示例5: testLargeJointIndexRetrieval
import com.thinkaurelius.titan.core.TitanVertex; //导入依赖的package包/类
@Test
public void testLargeJointIndexRetrieval() {
makeVertexIndexedKey("sid", Integer.class);
makeVertexIndexedKey("color", String.class);
finishSchema();
int sids = 17;
String[] colors = {"blue", "red", "yellow", "brown", "green", "orange", "purple"};
int multiplier = 200;
int numV = sids * colors.length * multiplier;
for (int i = 0; i < numV; i++) {
TitanVertex v = graph.addVertex(
"color", colors[i % colors.length],
"sid", i % sids);
}
clopen();
assertCount(numV / sids, graph.query().has("sid", 8).vertices());
assertCount(numV / colors.length, graph.query().has("color", colors[2]).vertices());
assertCount(multiplier, graph.query().has("sid", 11).has("color", colors[3]).vertices());
}
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:23,代码来源:TitanGraphTest.java
示例6: process
import com.thinkaurelius.titan.core.TitanVertex; //导入依赖的package包/类
@Override
public void process(TitanVertex vertex, ScanMetrics metrics) {
PreloadedVertex v = (PreloadedVertex) vertex;
if (vertexMemory != null) {
VertexMemoryHandler vh = new VertexMemoryHandler(vertexMemory, v);
v.setPropertyMixing(vh);
}
v.setAccessCheck(MAPREDUCE_CHECK);
if (idManager.isPartitionedVertex(v.longId()) && !idManager.isCanonicalVertexId(v.longId())) {
return; //Only consider the canonical partition vertex representative
} else {
for (Map.Entry<MapReduce, FulgoraMapEmitter> mapJob : mapJobs.entrySet()) {
MapReduce job = mapJob.getKey();
try {
job.map(v, mapJob.getValue());
metrics.incrementCustom(MAP_JOB_SUCCESS);
} catch (Throwable ex) {
log.error("Encountered exception executing map job [" + job + "] on vertex [" + vertex + "]:", ex);
metrics.incrementCustom(MAP_JOB_FAILURE);
}
}
}
}
开发者ID:graben1437,项目名称:titan1.0.1.kafka,代码行数:24,代码来源:VertexMapJob.java
示例7: testWidcardQuery
import com.thinkaurelius.titan.core.TitanVertex; //导入依赖的package包/类
/**
* Tests indexing using _all virtual field
*/
@Test
public void testWidcardQuery() {
if (supportsWildcardQuery()) {
PropertyKey p1 = makeKey("p1", String.class);
PropertyKey p2 = makeKey("p2", String.class);
mgmt.buildIndex("mixedIndex", Vertex.class).addKey(p1).addKey(p2).buildMixedIndex(INDEX);
finishSchema();
clopen();
TitanVertex v1 = graph.addVertex();
v1.property("p1", "test1");
v1.property("p2", "test2");
clopen();//Flush the index
assertEquals(v1, graph.indexQuery("mixedIndex", "v.*:\"test1\"").vertices().iterator().next().getElement());
assertEquals(v1, graph.indexQuery("mixedIndex", "v.*:\"test2\"").vertices().iterator().next().getElement());
}
}
开发者ID:graben1437,项目名称:titan1.0.1.kafka,代码行数:24,代码来源:TitanIndexTest.java
示例8: getRelationTypes
import com.thinkaurelius.titan.core.TitanVertex; //导入依赖的package包/类
@Override
public <T extends RelationType> Iterable<T> getRelationTypes(Class<T> clazz) {
Preconditions.checkNotNull(clazz);
Iterable<? extends TitanVertex> types = null;
if (PropertyKey.class.equals(clazz)) {
types = QueryUtil.getVertices(transaction, BaseKey.SchemaCategory, TitanSchemaCategory.PROPERTYKEY);
} else if (EdgeLabel.class.equals(clazz)) {
types = QueryUtil.getVertices(transaction, BaseKey.SchemaCategory, TitanSchemaCategory.EDGELABEL);
} else if (RelationType.class.equals(clazz)) {
types = Iterables.concat(getRelationTypes(EdgeLabel.class), getRelationTypes(PropertyKey.class));
} else throw new IllegalArgumentException("Unknown type class: " + clazz);
return Iterables.filter(Iterables.filter(types, clazz), new Predicate<T>() {
@Override
public boolean apply(@Nullable T t) {
//Filter out all relation type indexes
return ((InternalRelationType) t).getBaseType() == null;
}
});
}
开发者ID:graben1437,项目名称:titan1.0.1.kafka,代码行数:20,代码来源:ManagementSystem.java
示例9: getEdge
import com.thinkaurelius.titan.core.TitanVertex; //导入依赖的package包/类
public TitanEdge getEdge(FaunusEdge faunusEdge, TitanVertex in, TitanVertex out, TitanGraph graph, Mapper.Context context) {
Bindings bindings = new SimpleBindings();
bindings.put("faunusEdge", faunusEdge);
bindings.put("inVertex", in);
bindings.put("outVertex", out);
bindings.put("graph", graph);
bindings.put("context", context);
bindings.put("log", LOGGER);
DEFAULT_COMPAT.incrementContextCounter(context, Counters.EDGE_LOADER_SCRIPT_CALLS, 1L);
try {
TitanEdge edge = (TitanEdge)edgeMethod.eval(bindings);
LOGGER.debug("Compiled edge method returned {}", edge);
DEFAULT_COMPAT.incrementContextCounter(context, Counters.EDGE_LOADER_SCRIPT_RETURNS, 1L);
return edge;
} catch (ScriptException e) {
DEFAULT_COMPAT.incrementContextCounter(context, Counters.EDGE_LOADER_SCRIPT_EXCEPTIONS, 1L);
throw new RuntimeException(e);
}
}
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:20,代码来源:LoaderScriptWrapper.java
示例10: testInstant
import com.thinkaurelius.titan.core.TitanVertex; //导入依赖的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
示例11: testIndexQueryWithScore
import com.thinkaurelius.titan.core.TitanVertex; //导入依赖的package包/类
@Test
public void testIndexQueryWithScore() throws InterruptedException {
PropertyKey textKey = mgmt.makePropertyKey("text").dataType(String.class).make();
mgmt.buildIndex("store1", Vertex.class).addKey(textKey).buildMixedIndex(INDEX);
mgmt.commit();
TitanVertex v1 = tx.addVertex();
TitanVertex v2 = tx.addVertex();
TitanVertex v3 = tx.addVertex();
v1.property("text", "Hello Hello Hello Hello Hello Hello Hello Hello");
v2.property("text", "Hello abab abab fsdfsd sfdfsd sdffs fsdsdf fdf fsdfsd aera fsad abab abab fsdfsd sfdf");
v3.property("text", "Hello");
tx.commit();
Thread.sleep(5000);
Set<Double> scores = new HashSet<Double>();
for (TitanIndexQuery.Result<TitanVertex> r : graph.indexQuery("store1", "v.text:(Hello)").vertices()) {
scores.add(r.getScore());
}
Assert.assertEquals(3, scores.size());
}
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:26,代码来源:TitanIndexTest.java
示例12: testContainsWithMultipleValues
import com.thinkaurelius.titan.core.TitanVertex; //导入依赖的package包/类
@Test
// this tests a case when there as AND with a single CONTAINS condition inside AND(name:(was here))
// which (in case of Solr) spans multiple conditions such as AND(AND(name:was, name:here))
// so we need to make sure that we don't apply AND twice.
public void testContainsWithMultipleValues() throws Exception {
PropertyKey name = makeKey("name", String.class);
mgmt.buildIndex("store1", Vertex.class).addKey(name).buildMixedIndex(INDEX);
mgmt.commit();
TitanVertex v1 = tx.addVertex();
v1.property("name", "hercules was here");
tx.commit();
Thread.sleep(2000);
TitanVertex r = Iterables.<TitanVertex>get(graph.query().has("name", Text.CONTAINS, "hercules here").vertices(), 0);
Assert.assertEquals(r.property("name").value(), "hercules was here");
}
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:21,代码来源:TitanIndexTest.java
示例13: testForceIndexUsage
import com.thinkaurelius.titan.core.TitanVertex; //导入依赖的package包/类
@Test
public void testForceIndexUsage() {
PropertyKey age = makeKey("age", Integer.class);
PropertyKey time = makeKey("time", Long.class);
mgmt.buildIndex("time", Vertex.class).addKey(time).buildCompositeIndex();
finishSchema();
for (int i = 1; i <= 10; i++) {
TitanVertex v = tx.addVertex("time", i, "age", i);
}
//Graph query with and with-out index support
assertCount(1, tx.query().has("time", 5).vertices());
assertCount(1, tx.query().has("age", 6).vertices());
clopen(option(FORCE_INDEX_USAGE), true);
//Query with-out index support should now throw exception
assertCount(1, tx.query().has("time", 5).vertices());
try {
assertCount(1, tx.query().has("age", 6).vertices());
fail();
} catch (Exception e) {
}
}
开发者ID:graben1437,项目名称:titan1.0.1.kafka,代码行数:25,代码来源:TitanGraphTest.java
示例14: run
import com.thinkaurelius.titan.core.TitanVertex; //导入依赖的package包/类
@Override
public void run() {
try {
TitanVertex vertex = tx.getInternalVertex(vertexId);
Preconditions.checkArgument(vertex instanceof PreloadedVertex,
"The bounding transaction is not configured correctly");
PreloadedVertex v = (PreloadedVertex)vertex;
v.setAccessCheck(PreloadedVertex.OPENSTAR_CHECK);
v.addToQueryCache(VertexProgramScanJob.SYSTEM_PROPS_QUERY,preloaded);
VertexMemoryHandler.Partition<M> vh = new VertexMemoryHandler.Partition<M>(vertexMemory,v);
v.setPropertyMixing(vh);
vertexProgram.execute(v,vh,memory);
metrics.incrementCustom(PARTITION_VERTEX_POSTSUCCESS);
} catch (Throwable e) {
metrics.incrementCustom(PARTITION_VERTEX_POSTFAIL);
log.error("Error post-processing partition vertex: " + vertexId,e);
}
}
开发者ID:graben1437,项目名称:titan1.0.1.kafka,代码行数:19,代码来源:PartitionedVertexProgramExecutor.java
示例15: testValueOrdering
import com.thinkaurelius.titan.core.TitanVertex; //导入依赖的package包/类
@Test
public void testValueOrdering() {
StandardTitanGraph graph = (StandardTitanGraph) StorageSetup.getInMemoryGraph();
TitanManagement mgmt = graph.getManagementSystem();
EdgeLabel father = mgmt.makeEdgeLabel("father").multiplicity(Multiplicity.MANY2ONE).make();
for (int i=1;i<=5;i++) mgmt.makePropertyKey("key" + i).dataType(Integer.class).make();
mgmt.commit();
TitanVertex v1 = graph.addVertex(null), v2 = graph.addVertex(null);
TitanEdge e1 = v1.addEdge("father",v2);
for (int i=1;i<=5;i++) e1.setProperty("key"+i,i);
graph.commit();
e1.remove();
graph.commit();
}
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:19,代码来源:EdgeSerializerTest.java
示例16: getPartitionIDbyKey
import com.thinkaurelius.titan.core.TitanVertex; //导入依赖的package包/类
private int getPartitionIDbyKey(TitanVertex vertex) {
Preconditions.checkState(idManager!=null && key!=null,"PropertyPlacementStrategy has not been initialized correctly");
assert idManager.getPartitionBound()<=Integer.MAX_VALUE;
int partitionBound = (int)idManager.getPartitionBound();
TitanVertexProperty p = (TitanVertexProperty)Iterables.getFirst(vertex.query().keys(key).properties(),null);
if (p==null) return -1;
int hashPid = Math.abs(p.value().hashCode())%partitionBound;
assert hashPid>=0 && hashPid<partitionBound;
if (isExhaustedPartition(hashPid)) {
//We keep trying consecutive partition ids until we find a non-exhausted one
int newPid=hashPid;
do {
newPid = (newPid+1)%partitionBound;
if (newPid==hashPid) //We have gone full circle - no more ids to try
throw new IDPoolExhaustedException("Could not find non-exhausted partition");
} while (isExhaustedPartition(newPid));
return newPid;
} else return hashPid;
}
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:20,代码来源:PropertyPlacementStrategy.java
示例17: getVertex
import com.thinkaurelius.titan.core.TitanVertex; //导入依赖的package包/类
public TitanVertex getVertex(FaunusVertex faunusVertex, TitanGraph graph, Mapper.Context context) {
Bindings bindings = new SimpleBindings();
bindings.put("faunusVertex", faunusVertex);
bindings.put("graph", graph);
bindings.put("context", context);
bindings.put("log", LOGGER);
DEFAULT_COMPAT.incrementContextCounter(context, Counters.VERTEX_LOADER_SCRIPT_CALLS, 1L);
try {
TitanVertex tv = (TitanVertex)vertexMethod.eval(bindings);
LOGGER.debug("Compiled vertex loader script returned {}", tv);
DEFAULT_COMPAT.incrementContextCounter(context, Counters.VERTEX_LOADER_SCRIPT_RETURNS, 1L);
return tv;
} catch (ScriptException e) {
DEFAULT_COMPAT.incrementContextCounter(context, Counters.VERTEX_LOADER_SCRIPT_EXCEPTIONS, 1L);
throw new RuntimeException(e);
}
}
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:18,代码来源:LoaderScriptWrapper.java
示例18: getVertexId
import com.thinkaurelius.titan.core.TitanVertex; //导入依赖的package包/类
public static long getVertexId(Object id) {
if (null == id) return 0;
if (id instanceof TitanVertex) //allows vertices to be "re-attached" to the current transaction
return ((TitanVertex) id).longId();
if (id instanceof Long)
return (Long) id;
if (id instanceof Number)
return ((Number) id).longValue();
try {
// handles the case of a user passing a "detached" Vertex (DetachedVertex, StarVertex, etc).
if (id instanceof Vertex)
return Long.parseLong(((Vertex) id).id().toString());
else
return Long.valueOf(id.toString()).longValue();
} catch (NumberFormatException e) {
return 0;
}
}
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:21,代码来源:ElementUtils.java
示例19: vertices
import com.thinkaurelius.titan.core.TitanVertex; //导入依赖的package包/类
@Override
public Iterator<Result<Titan1Vertex, Titan1Edge>> vertices(int offset, int limit) {
Preconditions.checkArgument(offset >=0, "Index offset should be greater than or equals to 0");
Preconditions.checkArgument(limit >=0, "Index limit should be greater than or equals to 0");
Iterator<TitanIndexQuery.Result<TitanVertex>> results = query
.offset(offset)
.limit(limit)
.vertices().iterator();
Function<TitanIndexQuery.Result<TitanVertex>, Result<Titan1Vertex, Titan1Edge>> function =
new Function<TitanIndexQuery.Result<TitanVertex>, Result<Titan1Vertex, Titan1Edge>>() {
@Override
public Result<Titan1Vertex, Titan1Edge> apply(TitanIndexQuery.Result<TitanVertex> source) {
return new ResultImpl(source);
}
};
return Iterators.transform(results, function);
}
开发者ID:apache,项目名称:incubator-atlas,代码行数:21,代码来源:Titan1IndexQuery.java
示例20: testSelfLoop
import com.thinkaurelius.titan.core.TitanVertex; //导入依赖的package包/类
/**
* Tests that self-loop edges are handled and counted correctly
*/
@Test
public void testSelfLoop() {
TitanVertex v = tx.addVertex();
v.addEdge("self", v);
assertCount(1, v.query().direction(Direction.OUT).labels("self").edges());
assertCount(1, v.query().direction(Direction.IN).labels("self").edges());
assertCount(2, v.query().direction(Direction.BOTH).labels("self").edges());
clopen();
v = getV(tx, v);
assertNotNull(v);
assertCount(1, v.query().direction(Direction.IN).labels("self").edges());
assertCount(1, v.query().direction(Direction.OUT).labels("self").edges());
assertCount(1, v.query().direction(Direction.IN).labels("self").edges());
assertCount(2, v.query().direction(Direction.BOTH).labels("self").edges());
}
开发者ID:graben1437,项目名称:titan1.0.1.kafka,代码行数:19,代码来源:TitanGraphTest.java
注:本文中的com.thinkaurelius.titan.core.TitanVertex类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论