本文整理匯總了Java中org.apache.tinkerpop.gremlin.structure.Vertex.id方法的典型用法代碼示例。如果您正苦於以下問題:Java Vertex.id方法的具體用法?Java Vertex.id怎麽用?Java Vertex.id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.tinkerpop.gremlin.structure.Vertex
的用法示例。
在下文中一共展示了Vertex.id方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: loadSection
import org.apache.tinkerpop.gremlin.structure.Vertex; //導入方法依賴的package包/類
private static void loadSection(long [] map, Iterator<? extends CharSequence> it, Graph graph, DictionarySectionRole role) {
int count=0;
while(it.hasNext()) {
String str = it.next().toString();
Vertex v = graph.addVertex(str);
// v.property("node", str);
map[count] = (long) v.id();
if((count%1000000)==0) {
System.out.println(role+" Vertex: "+(count/1000000)+"M");
}
count++;
}
}
示例2: addEdge
import org.apache.tinkerpop.gremlin.structure.Vertex; //導入方法依賴的package包/類
@Override
public Edge addEdge(String label, Vertex inVertex, Object... keyValues) {
if (keyValues.length % 2 == 1) {
throw new IllegalArgumentException("Expecting even number of items in the keyValue array. Found " + keyValues.length);
}
if (label == null) {
throw new IllegalArgumentException("You have to specify a non-null String label when adding an edge");
} else if (label.length() == 0) {
throw new IllegalArgumentException("You have to specify a non-empty String label when adding an edge");
} else if (label.charAt(0) == '~') {
throw new IllegalArgumentException("Labels beginning with ~ are invalid");
}
if (inVertex == null) {
throw new IllegalArgumentException("The inVertex supplied to addEdge() is null");
}
// Validate first
for (int i = 0; i < keyValues.length; i = i+2) {
if (keyValues[i] == T.label) {
throw new UnsupportedOperationException("Encountered T.label in addVertex");
} else if (keyValues[i] == T.id) {
throw new UnsupportedOperationException("Encountered T.id in addVertex", new BitsyException(BitsyErrorCodes.NO_CUSTOM_ID_SUPPORT));
} else if (keyValues[i] == null) {
throw new IllegalArgumentException("Encountered a null key in argument #" + i);
} else if (keyValues[i+1] == null) {
throw new IllegalArgumentException("Encountered a null value in argument #" + i);
} else if (!(keyValues[i] instanceof String)) {
throw new IllegalArgumentException("Encountered a non-string key: " + keyValues[i] + " in argument #" + i);
}
}
// Construct the edge with this as the out vertex
BitsyEdge edge = new BitsyEdge(UUID.randomUUID(), null, tx, BitsyState.M, 0, label, (UUID)id(), (UUID)inVertex.id());
for (int i = 0; i < keyValues.length; i = i+2) {
String key = (String)keyValues[i];
edge.property(key, keyValues[i+1]);
}
tx.addEdge(edge);
return edge;
}
示例3: testLargeDegreePerformance
import org.apache.tinkerpop.gremlin.structure.Vertex; //導入方法依賴的package包/類
public void testLargeDegreePerformance() {
long ts = System.currentTimeMillis();
Vertex one = graph.addVertex();
one.property("one", "1");
Object oneId = one.id();
int numVertices = 10000; // 1000000;
Object[] vids = new Object[numVertices];
for (int i = 0; i < numVertices; i++) { // Change to 1M for perf
Vertex many = graph.addVertex();
many.property("many", "2");
addEdge(graph, one, many, "toMany");
vids[i] = many.id();
if (i % 1000 == 0) {
System.out.println(i + " 1000 in " + (System.currentTimeMillis() - ts));
ts = System.currentTimeMillis();
graph.tx().commit();
one = graph.vertices(oneId).next();
}
}
for (int i=0; i < numVertices; i++) {
Vertex v = getVertex(graph, vids[i]);
Iterator<Edge> iter = v.edges(Direction.BOTH);
assertTrue(iter.hasNext());
iter.next();
assertFalse(iter.hasNext());
v.remove();
if (i % 1000 == 0) {
System.out.println(i + " 1000 in " + (System.currentTimeMillis() - ts));
if (i % 5000 == 0) {
Iterator<Edge> iter2 = getVertex(graph, one.id()).edges(Direction.BOTH);
for (int j=0; j < numVertices - i - 1; j++) {
assertTrue(iter2.hasNext());
iter2.next();
}
assertFalse(iter.hasNext());
}
ts = System.currentTimeMillis();
graph.tx().commit();
}
}
graph.tx().commit();
}
示例4: testObsolescence
import org.apache.tinkerpop.gremlin.structure.Vertex; //導入方法依賴的package包/類
public void testObsolescence() {
IGraphStore store = ((BitsyGraph)graph).getStore();
// Create a vertex
Vertex v = graph.addVertex();
Object vid = v.id();
v.property("foo", "bar");
// Self edge
Edge e = v.addEdge("self", v);
Object eid = e.id();
graph.tx().commit();
Record v1MRec = new Record(RecordType.V, "{\"id\":\"" + vid + "\",\"v\":1,\"s\":\"M\"}");
assertFalse(v1MRec.checkObsolete(store, false, 1, null));
assertFalse(v1MRec.checkObsolete(store, true, 1, null));
Record e1MRec = new Record(RecordType.E, "{\"id\":\"" + eid + "\",\"v\":1,\"s\":\"M\",\"o\":\"" + vid + "\",\"l\":\"" + vid + "\",\"i\":\"" + vid + "\"}");
assertFalse(e1MRec.checkObsolete(store, false, 1, null));
assertFalse(e1MRec.checkObsolete(store, true, 1, null));
// Create a vertex
v = graph.vertices(vid).next();
v.property("foo", "baz");
e = v.edges(Direction.IN, "self").next();
e.property("foo", "baz");
graph.tx().commit();
Record v2MRec = new Record(RecordType.V, "{\"id\":\"" + vid + "\",\"v\":2,\"s\":\"M\"}");
Record v1DRec = new Record(RecordType.V, "{\"id\":\"" + vid + "\",\"v\":1,\"s\":\"D\"}");
assertTrue(v1MRec.checkObsolete(store, false, 1, null));
assertTrue(v1MRec.checkObsolete(store, true, 1, null));
assertFalse(v1DRec.checkObsolete(store, false, 1, null));
assertTrue(v1DRec.checkObsolete(store, true, 1, null));
assertFalse(v2MRec.checkObsolete(store, false, 1, null));
assertFalse(v2MRec.checkObsolete(store, true, 1, null));
Record e2MRec = new Record(RecordType.E, "{\"id\":\"" + eid + "\",\"v\":2,\"s\":\"M\",\"o\":\"" + vid + "\",\"l\":\"" + vid + "\",\"i\":\"" + vid + "\"}");
Record e1DRec = new Record(RecordType.E, "{\"id\":\"" + eid + "\",\"v\":1,\"s\":\"D\",\"o\":\"" + vid + "\",\"l\":\"" + vid + "\",\"i\":\"" + vid + "\"}");
assertTrue(e1MRec.checkObsolete(store, false, 1, null));
assertTrue(e1MRec.checkObsolete(store, true, 1, null));
assertFalse(e1DRec.checkObsolete(store, false, 1, null));
assertTrue(e1DRec.checkObsolete(store, true, 1, null));
assertFalse(e2MRec.checkObsolete(store, false, 1, null));
assertFalse(e2MRec.checkObsolete(store, true, 1, null));
// Delete vertex
v = graph.vertices(vid).next();
v.remove();
// Edge will get deleted automatically!
graph.tx().commit();
Record v2DRec = new Record(RecordType.V, "{\"id\":\"" + vid + "\",\"v\":1,\"s\":\"D\"}");
assertFalse(v2DRec.checkObsolete(store, false, 1, null));
assertTrue(v2DRec.checkObsolete(store, true, 1, null));
}