org.apache.tinkerpop.gremlin.process.traversal.Traversal.toList()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(8.2k)|赞(0)|评价(0)|浏览(115)

本文整理了Java中org.apache.tinkerpop.gremlin.process.traversal.Traversal.toList()方法的一些代码示例,展示了Traversal.toList()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Traversal.toList()方法的具体详情如下:
包路径:org.apache.tinkerpop.gremlin.process.traversal.Traversal
类名称:Traversal
方法名:toList

Traversal.toList介绍

[英]Put all the results into an ArrayList.
[中]将所有结果放入ArrayList。

代码示例

代码示例来源:origin: JanusGraph/janusgraph

public static void assertCount(int expected, Traversal traversal) {
  org.junit.Assert.assertEquals(expected, traversal.toList().size());
}

代码示例来源:origin: apache/tinkerpop

public static <T> void checkOrderedResults(final List<T> expectedResults, final Traversal<?, T> traversal) {
  final List<T> results = traversal.toList();
  assertFalse(traversal.hasNext());
  if (expectedResults.size() != results.size()) {
    logger.error("Expected results: " + expectedResults);
    logger.error("Actual results:   " + results);
    assertEquals("Checking result size", expectedResults.size(), results.size());
  }
  for (int i = 0; i < expectedResults.size(); i++) {
    assertEquals(expectedResults.get(i), results.get(i));
  }
}

代码示例来源:origin: apache/tinkerpop

@Test
@LoadGraphWith(MODERN)
public void g_V_outXcreatedX_projectXa_bX_byXnameX_byXinXcreatedX_countX_order_byXselectXbX__descX_selectXaX() {
  final Traversal<Vertex, String> traversal = get_g_V_outXcreatedX_projectXa_bX_byXnameX_byXinXcreatedX_countX_order_byXselectXbX__descX_selectXaX();
  printTraversalForm(traversal);
  final List<String> names = traversal.toList();
  assertEquals(4, names.size());
  assertEquals("lop", names.get(0));
  assertEquals("lop", names.get(1));
  assertEquals("lop", names.get(2));
  assertEquals("ripple", names.get(3));
}

代码示例来源:origin: apache/tinkerpop

@Test
@LoadGraphWith(MODERN)
public void g_V_pageRank_order_byXpageRank_descX_name_limitX2X() {
  final Traversal<Vertex, String> traversal = get_g_V_pageRank_order_byXpageRank_descX_name_limitX2X();
  printTraversalForm(traversal);
  final List<String> names = traversal.toList();
  assertEquals(2, names.size());
  assertEquals("lop", names.get(0));
  assertEquals("ripple", names.get(1));
}

代码示例来源:origin: apache/tinkerpop

@Test
@LoadGraphWith(SINK)
public void g_V_hasLabelXloopsX_bothEXselfX() {
  final Traversal<Vertex, Edge> traversal = get_g_V_hasLabelXloopsX_bothEXselfX();
  printTraversalForm(traversal);
  List<Edge> edges = traversal.toList();
  assertEquals(2, edges.size());
  assertEquals(edges.get(0), edges.get(1));
}

代码示例来源:origin: apache/tinkerpop

@Test
@LoadGraphWith(SINK)
public void g_V_hasLabelXloopsX_bothXselfX() {
  final Traversal<Vertex, Vertex> traversal = get_g_V_hasLabelXloopsX_bothXselfX();
  printTraversalForm(traversal);
  List<Vertex> vertices = traversal.toList();
  assertEquals(2, vertices.size());
  assertEquals(vertices.get(0), vertices.get(1));
}

代码示例来源:origin: apache/tinkerpop

/**
 * Scenario: Local scope, List input, default N=1
 */
@Test
@LoadGraphWith(MODERN)
public void g_V_asXaX_out_asXaX_out_asXaX_selectXmixed_aX_byXunfold_valuesXnameX_foldX_tailXlocalX() {
  final Traversal<Vertex, String> traversal = get_g_V_asXaX_out_asXaX_out_asXaX_selectXmixed_aX_byXunfold_valuesXnameX_foldX_tailXlocalX();
  printTraversalForm(traversal);
  final Set<String> expected = new HashSet(Arrays.asList("ripple", "lop"));
  final Set<String> actual = new HashSet(traversal.toList());
  assertEquals(expected, actual);
}

代码示例来源:origin: apache/tinkerpop

/**
 * Scenario: limit step, Scope.local, 1 item requested, List input, String output
 */
@Test
@LoadGraphWith(MODERN)
public void g_V_asXaX_in_asXaX_in_asXaX_selectXmixed_aX_byXunfold_valuesXnameX_foldX_limitXlocal_1X() {
  final Traversal<Vertex, String> traversal = get_g_V_asXaX_in_asXaX_in_asXaX_selectXmixed_aX_byXunfold_valuesXnameX_foldX_limitXlocal_1X();
  printTraversalForm(traversal);
  final Set<String> expected = new HashSet<>(Arrays.asList("ripple", "lop"));
  final Set<List<String>> actual = new HashSet(traversal.toList());
  assertEquals(expected, actual);
}

代码示例来源:origin: apache/tinkerpop

/**
 * Scenario: Local scope, List input, N=1
 */
@Test
@LoadGraphWith(MODERN)
public void g_V_asXaX_out_asXaX_out_asXaX_selectXmixed_aX_byXunfold_valuesXnameX_foldX_tailXlocal_1X() {
  final Traversal<Vertex, String> traversal = get_g_V_asXaX_out_asXaX_out_asXaX_selectXmixed_aX_byXunfold_valuesXnameX_foldX_tailXlocal_1X();
  printTraversalForm(traversal);
  final Set<String> expected = new HashSet(Arrays.asList("ripple", "lop"));
  final Set<String> actual = new HashSet(traversal.toList());
  assertEquals(expected, actual);
}

代码示例来源:origin: apache/tinkerpop

@Test
@LoadGraphWith(MODERN)
public void g_VX1X_repeatXbothEXcreatedX_whereXwithoutXeXX_aggregateXeX_otherVX_emit_path() {
  final Traversal<Vertex, Path> traversal = get_g_VX1X_repeatXbothEXcreatedX_whereXwithoutXeXX_aggregateXeX_otherVX_emit_path(convertToVertexId("marko"));
  printTraversalForm(traversal);
  final List<Path> paths = traversal.toList();
  assertEquals(4, paths.size());
  assertEquals(1, paths.stream().filter(path -> path.size() == 3).count());
  assertEquals(2, paths.stream().filter(path -> path.size() == 5).count());
  assertEquals(1, paths.stream().filter(path -> path.size() == 7).count());
  assertFalse(traversal.hasNext());
}

代码示例来源:origin: apache/tinkerpop

@Test
@LoadGraphWith(MODERN)
public void g_V_asXaX_orXselectXaX_selectXaXX() {
  final Traversal<Vertex, Vertex> traversal = get_g_V_asXaX_orXselectXaX_selectXaXX();
  printTraversalForm(traversal);
  final List<Vertex> actual = traversal.toList();
  assertEquals(6, actual.size());
}

代码示例来源:origin: apache/tinkerpop

@Test
@LoadGraphWith(MODERN)
public void g_V_selectXfirst_aX() {
  final Traversal<Vertex, Object> traversal = get_g_V_selectXfirst_aX();
  printTraversalForm(traversal);
  assertEquals(Collections.emptyList(), traversal.toList());
}

代码示例来源:origin: apache/tinkerpop

@Test
@LoadGraphWith(MODERN)
public void g_V_valueMap_selectXfirst_a_bX() {
  final Traversal<Vertex, Map<String, Object>> traversal = get_g_V_valueMap_selectXfirst_a_bX();
  printTraversalForm(traversal);
  assertEquals(Collections.emptyList(), traversal.toList());
}

代码示例来源:origin: apache/tinkerpop

@Test
@LoadGraphWith(MODERN)
public void g_V_valueMap_selectXlast_aX() {
  final Traversal<Vertex, Object> traversal = get_g_V_valueMap_selectXlast_aX();
  printTraversalForm(traversal);
  assertEquals(Collections.emptyList(), traversal.toList());
}

代码示例来源:origin: apache/tinkerpop

@Test
@LoadGraphWith(MODERN)
public void g_V_valueMap_selectXlast_a_bX() {
  final Traversal<Vertex, Map<String, Object>> traversal = get_g_V_valueMap_selectXlast_a_bX();
  printTraversalForm(traversal);
  assertEquals(Collections.emptyList(), traversal.toList());
}

代码示例来源:origin: apache/tinkerpop

@Test
@LoadGraphWith(MODERN)
public void g_V_selectXall_aX() {
  final Traversal<Vertex, Object> traversal = get_g_V_selectXall_aX();
  printTraversalForm(traversal);
  assertEquals(Collections.emptyList(), traversal.toList());
}

代码示例来源:origin: apache/tinkerpop

/** Scenario: Trivial use case from GraphTraversal */
@Test
@LoadGraphWith(MODERN)
public void g_V_constantX123X() {
  final Traversal<Vertex, Integer> traversal = get_g_V_constantX123X();
  printTraversalForm(traversal);
  assertEquals(Arrays.asList(123, 123, 123, 123, 123, 123), traversal.toList());
}

代码示例来源:origin: apache/tinkerpop

@Test
@LoadGraphWith(MODERN)
public void g_V_asXaX_andXselectXaX_selectXaXX() {
  final Traversal<Vertex, Vertex> traversal = get_g_V_asXaX_andXselectXaX_selectXaXX();
  printTraversalForm(traversal);
  final List<Vertex> actual = traversal.toList();
  assertEquals(6, actual.size());
}

代码示例来源:origin: apache/tinkerpop

/**
 * Scenario: Default scope is global
 */
@Test
@LoadGraphWith(MODERN)
public void g_V_valuesXnameX_order_tailX2X() {
  final Traversal<Vertex, String> traversal = get_g_V_valuesXnameX_order_tailX2X();
  printTraversalForm(traversal);
  assertEquals(Arrays.asList("ripple", "vadas"), traversal.toList());
}

代码示例来源:origin: apache/tinkerpop

/**
 * Scenario: range step, Scope.local, 1 item requested, List input, no items selected, stop traversal
 */
@Test
@LoadGraphWith(MODERN)
public void g_V_asXaX_out_asXaX_out_asXaX_selectXmixed_aX_byXunfold_valuesXnameX_foldX_rangeXlocal_4_5X() {
  final Traversal<Vertex, String> traversal = get_g_V_asXaX_out_asXaX_out_asXaX_selectXmixed_aX_byXunfold_valuesXnameX_foldX_rangeXlocal_4_5X();
  printTraversalForm(traversal);
  assertEquals(Arrays.asList(), traversal.toList());
}

相关文章