本文整理汇总了Java中org.apache.tinkerpop.gremlin.process.traversal.Traversal.hasNext方法的典型用法代码示例。如果您正苦于以下问题:Java Traversal.hasNext方法的具体用法?Java Traversal.hasNext怎么用?Java Traversal.hasNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tinkerpop.gremlin.process.traversal.Traversal
的用法示例。
在下文中一共展示了Traversal.hasNext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: g_V_asXaX_both_asXbX_dedupXa_bX_byXlabelX_selectXa_bX
import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_V_asXaX_both_asXbX_dedupXa_bX_byXlabelX_selectXa_bX() {
final Traversal<Vertex, Map<String, Vertex>> traversal = get_g_V_asXaX_both_asXbX_dedupXa_bX_byXlabelX_selectXa_bX();
printTraversalForm(traversal);
int personPersonCounter = 0;
int personSoftwareCounter = 0;
int softwarePersonCounter = 0;
while (traversal.hasNext()) {
final Map<String, Vertex> map = traversal.next();
assertEquals(2, map.size());
if (map.get("a").label().equals("person") && map.get("b").label().equals("person"))
personPersonCounter++;
else if (map.get("a").label().equals("person") && map.get("b").label().equals("software"))
personSoftwareCounter++;
else if (map.get("a").label().equals("software") && map.get("b").label().equals("person"))
softwarePersonCounter++;
else
fail("Bad result type: " + map);
}
assertEquals(1, personPersonCounter);
assertEquals(1, personSoftwareCounter);
assertEquals(1, softwarePersonCounter);
}
示例2: g_V_out_outE_inV_inE_inV_both_name
import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_V_out_outE_inV_inE_inV_both_name() {
final Traversal<Vertex, String> traversal = get_g_V_out_outE_inV_inE_inV_both_name();
printTraversalForm(traversal);
int counter = 0;
final Map<String, Integer> counts = new HashMap<>();
while (traversal.hasNext()) {
final String key = traversal.next();
final int previousCount = counts.getOrDefault(key, 0);
counts.put(key, previousCount + 1);
counter++;
}
assertEquals(3, counts.size());
assertEquals(4, counts.get("josh").intValue());
assertEquals(3, counts.get("marko").intValue());
assertEquals(3, counts.get("peter").intValue());
assertEquals(10, counter);
assertFalse(traversal.hasNext());
}
示例3: g_VX4X_out_asXhereX_hasXlang_javaX_selectXhereX_name
import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_VX4X_out_asXhereX_hasXlang_javaX_selectXhereX_name() {
final Traversal<Vertex, String> traversal = get_g_VX4X_out_asXhereX_hasXlang_javaX_selectXhereX_name(convertToVertexId("josh"));
printTraversalForm(traversal);
int counter = 0;
final Set<String> names = new HashSet<>();
while (traversal.hasNext()) {
counter++;
names.add(traversal.next());
}
assertEquals(2, counter);
assertEquals(2, names.size());
assertTrue(names.contains("ripple"));
assertTrue(names.contains("lop"));
}
示例4: g_VX4X_bothE
import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_VX4X_bothE() {
final Traversal<Vertex, Edge> traversal = get_g_VX4X_bothE(convertToVertexId("josh"));
printTraversalForm(traversal);
int counter = 0;
final Set<Edge> edges = new HashSet<>();
while (traversal.hasNext()) {
counter++;
final Edge edge = traversal.next();
edges.add(edge);
assertTrue(edge.label().equals("knows") || edge.label().equals("created"));
}
assertEquals(3, counter);
assertEquals(3, edges.size());
}
示例5: g_VX1X_out_path_byXageX_byXnameX
import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_VX1X_out_path_byXageX_byXnameX() {
final Traversal<Vertex, Path> traversal = get_g_VX1X_out_path_byXageX_byXnameX(convertToVertexId("marko"));
printTraversalForm(traversal);
int counter = 0;
final Set<String> names = new HashSet<>();
while (traversal.hasNext()) {
counter++;
final Path path = traversal.next();
assertEquals(Integer.valueOf(29), path.<Integer>get(0));
assertTrue(path.get(1).equals("josh") || path.get(1).equals("vadas") || path.get(1).equals("lop"));
names.add(path.get(1));
}
assertEquals(3, counter);
assertEquals(3, names.size());
}
示例6: printTraversalForm
import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_V_hasLabelXsoftwareX_hasXname_rippleX_pageRankX1X_byXinEXcreatedXX_timesX1X_byXpriorsX_inXcreatedX_unionXboth__identityX_valueMapXname_priorsX() {
final Traversal<Vertex, Map<String, List<Object>>> traversal = get_g_V_hasLabelXsoftwareX_hasXname_rippleX_pageRankX1X_byXinEXcreatedXX_timesX1X_byXpriorsX_inXcreatedX_unionXboth__identityX_valueMapXname_priorsX();
printTraversalForm(traversal);
int counter = 0;
while (traversal.hasNext()) {
final Map<String, List<Object>> map = traversal.next();
assertEquals(2, map.size());
String name = (String) map.get("name").get(0);
double pageRank = (Double) map.get("priors").get(0);
assertEquals(name.equals("josh") ? 1.0d : 0.0d, pageRank, 0.0001d);
if (name.equals("peter") || name.equals("vadas"))
fail("Peter or Vadas should not have been accessed");
counter++;
}
assertEquals(4, counter);
}
示例7: assert_g_v1_outXknowsX
import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
private void assert_g_v1_outXknowsX(final Traversal<Vertex, Vertex> traversal) {
printTraversalForm(traversal);
printTraversalForm2(traversal);
int counter = 0;
final Set<Vertex> vertices = new HashSet<>();
while (traversal.hasNext()) {
counter++;
final Vertex vertex = traversal.next();
vertices.add(vertex);
assertTrue(vertex.value("name").equals("vadas") ||
vertex.value("name").equals("josh"));
}
assertEquals(2, counter);
assertEquals(2, vertices.size());
}
示例8: assert_g_v1_outXknowsX
import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
private void assert_g_v1_outXknowsX(final Traversal<Vertex, Vertex> traversal) {
printTraversalForm(traversal);
int counter = 0;
final Set<Vertex> vertices = new HashSet<>();
while (traversal.hasNext()) {
counter++;
final Vertex vertex = traversal.next();
vertices.add(vertex);
assertTrue(vertex.value("name").equals("vadas") ||
vertex.value("name").equals("josh"));
}
assertEquals(2, counter);
assertEquals(2, vertices.size());
}
示例9: printTraversalForm
import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
public void printTraversalForm(final Traversal traversal) {
logger.info(String.format("Testing: %s", name.getMethodName()));
logger.info(" pre-strategy:" + traversal);
traversal.hasNext();
logger.info(" post-strategy:" + traversal);
verifyUniqueStepIds(traversal.asAdmin());
}
示例10: g_V_localXoutE_foldX_unfold
import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_V_localXoutE_foldX_unfold() {
final Traversal<Vertex, Edge> traversal = get_g_V_localXoutE_foldX_unfold();
printTraversalForm(traversal);
int counter = 0;
final Set<Edge> edges = new HashSet<>();
while (traversal.hasNext()) {
counter++;
edges.add(traversal.next());
}
assertEquals(6, counter);
assertEquals(6, edges.size());
assertFalse(traversal.hasNext());
}
示例11: g_V_hasXageX_propertiesXnameX
import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_V_hasXageX_propertiesXnameX() {
final Traversal<Vertex, VertexProperty<String>> traversal = get_g_V_hasXageX_propertiesXnameX();
printTraversalForm(traversal);
final Set<String> keys = new HashSet<>();
final Set<String> values = new HashSet<>();
final Set<Object> ids = new HashSet<>();
int counter = 0;
while (traversal.hasNext()) {
counter++;
final VertexProperty<String> vertexProperty = traversal.next();
keys.add(vertexProperty.key());
values.add(vertexProperty.value());
ids.add(vertexProperty.id());
assertEquals("name", vertexProperty.key());
assertEquals(convertToVertex(graph, vertexProperty.value()).values("name").next(), vertexProperty.value());
// compare the ids as longs. assumes modern graph uses numeric ids only (long/integer).
assertEquals(Long.valueOf(convertToVertex(graph, vertexProperty.value()).properties("name").next().id().toString()), Long.valueOf(vertexProperty.id().toString()));
}
assertEquals(4, counter);
assertEquals(1, keys.size());
assertTrue(keys.contains("name"));
assertEquals(4, values.size());
assertTrue(values.contains("marko"));
assertTrue(values.contains("vadas"));
assertTrue(values.contains("josh"));
assertTrue(values.contains("peter"));
assertEquals(4, ids.size());
}
示例12: g_E
import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_E() {
final Traversal<Edge, Edge> traversal = get_g_E();
printTraversalForm(traversal);
int counter = 0;
final Set<Edge> edges = new HashSet<>();
while (traversal.hasNext()) {
counter++;
edges.add(traversal.next());
}
assertEquals(6, edges.size());
assertEquals(6, counter);
}
示例13: g_E_hasLabelXuses_traversesX
import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
@Test
@LoadGraphWith(CREW)
public void g_E_hasLabelXuses_traversesX() {
final Traversal<Edge, Edge> traversal = get_g_E_hasLabelXuses_traversesX();
printTraversalForm(traversal);
int counter = 0;
while (traversal.hasNext()) {
counter++;
final String label = traversal.next().label();
assertTrue(label.equals("uses") || label.equals("traverses"));
}
assertEquals(9, counter);
}
示例14: g_V_mapXselectXaXX
import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
/** TINKERPOP-782 */
@Test
@LoadGraphWith(MODERN)
public void g_V_mapXselectXaXX() {
final Traversal<Vertex, Vertex> traversal = get_g_V_mapXselectXaXX();
printTraversalForm(traversal);
int counter = 0;
while (traversal.hasNext()) {
counter++;
traversal.next();
}
assertEquals(6, counter);
}
示例15: g_VX1X_asXaX_outXknowsX_asXbX_selectXa_bX_byXnameX
import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_VX1X_asXaX_outXknowsX_asXbX_selectXa_bX_byXnameX() {
final Traversal<Vertex, Map<String, String>> traversal = get_g_VX1X_asXaX_outXknowsX_asXbX_selectXa_bX_byXnameX(convertToVertexId("marko"));
printTraversalForm(traversal);
int counter = 0;
while (traversal.hasNext()) {
counter++;
final Map<String, String> bindings = traversal.next();
assertEquals(2, bindings.size());
assertEquals("marko", bindings.get("a"));
assertTrue(bindings.get("b").equals("josh") || bindings.get("b").equals("vadas"));
}
assertEquals(2, counter);
}