当前位置: 首页>>代码示例>>Java>>正文


Java Traversal.toList方法代码示例

本文整理汇总了Java中org.apache.tinkerpop.gremlin.process.traversal.Traversal.toList方法的典型用法代码示例。如果您正苦于以下问题:Java Traversal.toList方法的具体用法?Java Traversal.toList怎么用?Java Traversal.toList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.tinkerpop.gremlin.process.traversal.Traversal的用法示例。


在下文中一共展示了Traversal.toList方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: g_V_outXcreatedX_pageRank_byXbothEX_byXprojectRankX_valueMapXname_projectRankX

import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_V_outXcreatedX_pageRank_byXbothEX_byXprojectRankX_valueMapXname_projectRankX() {
    final Traversal<Vertex, Map<String, List<Object>>> traversal = get_g_V_outXcreatedX_pageRank_byXbothEX_byXprojectRankX_timesX0X_valueMapXname_projectRankX();
    printTraversalForm(traversal);
    final List<Map<String, List<Object>>> result = traversal.toList();
    assertEquals(4, result.size());
    final Map<String, Double> map = new HashMap<>();
    result.forEach(m -> map.put((String) m.get("name").get(0), (Double) m.get("projectRank").get(0)));
    assertEquals(2, map.size());
    assertTrue(map.containsKey("lop"));
    assertTrue(map.containsKey("ripple"));
    assertTrue(map.get("lop") > map.get("ripple"));
    assertEquals(3.0d, map.get("lop"), 0.001d);
    assertEquals(1.0d, map.get("ripple"), 0.001d);
    assertFalse(traversal.hasNext());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:18,代码来源:PageRankTest.java

示例2: g_V_optionalXout_optionalXoutXX_path

import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_V_optionalXout_optionalXoutXX_path() {
    final Traversal<Vertex, Path> traversal = get_g_V_optionalXout_optionalXoutXX_path();
    printTraversalForm(traversal);
    List<Path> paths = traversal.toList();
    assertEquals(10, paths.size());
    List<Predicate<Path>> pathsToAssert = Arrays.asList(
            p -> p.size() == 2 && p.get(0).equals(convertToVertex(this.graph, "marko")) && p.get(1).equals(convertToVertex(this.graph, "lop")),
            p -> p.size() == 2 && p.get(0).equals(convertToVertex(this.graph, "marko")) && p.get(1).equals(convertToVertex(this.graph, "vadas")),
            p -> p.size() == 3 && p.get(0).equals(convertToVertex(this.graph, "marko")) && p.get(1).equals(convertToVertex(this.graph, "josh")) && p.get(2).equals(convertToVertex(this.graph, "lop")),
            p -> p.size() == 3 && p.get(0).equals(convertToVertex(this.graph, "marko")) && p.get(1).equals(convertToVertex(this.graph, "josh")) && p.get(2).equals(convertToVertex(this.graph, "ripple")),
            p -> p.size() == 1 && p.get(0).equals(convertToVertex(this.graph, "vadas")),
            p -> p.size() == 1 && p.get(0).equals(convertToVertex(this.graph, "lop")),
            p -> p.size() == 2 && p.get(0).equals(convertToVertex(this.graph, "josh")) && p.get(1).equals(convertToVertex(this.graph, "lop")),
            p -> p.size() == 2 && p.get(0).equals(convertToVertex(this.graph, "josh")) && p.get(1).equals(convertToVertex(this.graph, "ripple")),
            p -> p.size() == 1 && p.get(0).equals(convertToVertex(this.graph, "ripple")),
            p -> p.size() == 2 && p.get(0).equals(convertToVertex(this.graph, "peter")) && p.get(1).equals(convertToVertex(this.graph, "lop"))
    );
    for (Predicate<Path> pathPredicate : pathsToAssert) {
        Optional<Path> path = paths.stream().filter(pathPredicate).findAny();
        assertTrue(path.isPresent());
        assertTrue(paths.remove(path.get()));
    }
    assertTrue(paths.isEmpty());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:27,代码来源:OptionalTest.java

示例3: g_V_localXbothE_weight_foldX_order_byXsumXlocalX_decrX

import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_V_localXbothE_weight_foldX_order_byXsumXlocalX_decrX() {
    final Traversal<Vertex, List<Double>> traversal = get_g_V_localXbothE_weight_foldX_order_byXsumXlocalX_decrX();
    final List<List<Double>> list = traversal.toList();
    assertEquals(list.get(0).size(), 3);
    assertEquals(list.get(1).size(), 3);
    //assertEquals(list.get(2).size(),3);  // they both have value 1.0 and thus can't guarantee a tie order
    //assertEquals(list.get(3).size(),1);
    assertEquals(list.get(4).size(), 1);
    assertEquals(list.get(5).size(), 1);
    ///
    assertEquals(2.4d, list.get(0).stream().reduce(0.0d, (a, b) -> a + b), 0.01d);
    assertEquals(1.9d, list.get(1).stream().reduce(0.0d, (a, b) -> a + b), 0.01d);
    assertEquals(1.0d, list.get(2).stream().reduce(0.0d, (a, b) -> a + b), 0.01d);
    assertEquals(1.0d, list.get(3).stream().reduce(0.0d, (a, b) -> a + b), 0.01d);
    assertEquals(0.5d, list.get(4).stream().reduce(0.0d, (a, b) -> a + b), 0.01d);
    assertEquals(0.2d, list.get(5).stream().reduce(0.0d, (a, b) -> a + b), 0.01d);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:20,代码来源:OrderTest.java

示例4: printTraversalForm

import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_V_hasXname_rippleX_inXcreatedX_peerPressure_byXoutEX_byXclusterX_repeatXunionXidentity__bothX_timesX2X_dedup_valueMapXname_clusterX() {
    final Traversal<Vertex, Map<String, List<Object>>> traversal = get_g_V_hasXname_rippleX_inXcreatedX_peerPressure_byXoutEX_byXclusterX_repeatXunionXidentity__bothX_timesX2X_dedup_valueMapXname_clusterX();
    printTraversalForm(traversal);
    final List<Map<String, List<Object>>> results = traversal.toList();
    assertEquals(6, results.size());
    final Map<String, Object> clusters = new HashMap<>();
    results.forEach(m -> clusters.put((String) m.get("name").get(0), m.get("cluster").get(0)));
    assertEquals(2, results.get(0).size());
    assertEquals(6, clusters.size());
    assertEquals(clusters.get("josh"), clusters.get("ripple"));
    assertEquals(clusters.get("josh"), clusters.get("lop"));
    final Set<Object> ids = new HashSet<>(clusters.values());
    assertEquals(4, ids.size());
    assertTrue(ids.contains(convertToVertexId("marko")));
    assertTrue(ids.contains(convertToVertexId("vadas")));
    assertTrue(ids.contains(convertToVertexId("josh")));
    assertTrue(ids.contains(convertToVertexId("peter")));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:21,代码来源:PeerPressureTest.java

示例5: g_V_outXcreatedX_projectXa_bX_byXnameX_byXinXcreatedX_countX_order_byXselectXbX__decrX_selectXaX

import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_V_outXcreatedX_projectXa_bX_byXnameX_byXinXcreatedX_countX_order_byXselectXbX__decrX_selectXaX() {
    final Traversal<Vertex, String> traversal = get_g_V_outXcreatedX_projectXa_bX_byXnameX_byXinXcreatedX_countX_order_byXselectXbX__decrX_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));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:13,代码来源:ProjectTest.java

示例6: g_V_asXaX_in_asXbX_in_asXcX_selectXa_b_cX_byXnameX_limitXlocal_1X

import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
/** Scenario: limit step, Scope.local, 1 item requested, Map input, Map output */
@Test
@LoadGraphWith(MODERN)
public void g_V_asXaX_in_asXbX_in_asXcX_selectXa_b_cX_byXnameX_limitXlocal_1X() {
    final Traversal<Vertex, Map<String, String>> traversal = get_g_V_asXaX_in_asXbX_in_asXcX_selectXa_b_cX_byXnameX_limitXlocal_1X();
    printTraversalForm(traversal);
    final Set<Map<String, String>> expected = new HashSet<>(makeMapList(1,
             "a", "ripple",
             "a", "lop"));
    final Set<Map<String, String>> actual = new HashSet<>(traversal.toList());
    assertEquals(expected, actual);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:13,代码来源:RangeTest.java

示例7: g_V_asXaX_out_asXaX_out_asXaX_selectXaX_byXlimitXlocal_0XX_tailXlocal_1X

import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
/** Scenario: Local scope, List input, N=1, empty input */
@Test
@LoadGraphWith(MODERN)
public void g_V_asXaX_out_asXaX_out_asXaX_selectXaX_byXlimitXlocal_0XX_tailXlocal_1X() {
    final Traversal<Vertex, String> traversal = get_g_V_asXaX_out_asXaX_out_asXaX_selectXaX_byXlimitXlocal_0XX_tailXlocal_1X();
    printTraversalForm(traversal);
    final Set<String> expected = new HashSet();
    final Set<String> actual = new HashSet(traversal.toList());
    assertEquals(expected, actual);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:11,代码来源:TailTest.java

示例8: g_V_asXaX_andXselectXaX_selectXaXX

import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
@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());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:9,代码来源:AndTest.java

示例9: g_V_asXaX_out_asXaX_out_asXaX_selectXaX_byXunfold_valuesXnameX_foldX_tailXlocal_2X

import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
/** Scenario: Local scope, List input, N>1 */
@Test
@LoadGraphWith(MODERN)
public void g_V_asXaX_out_asXaX_out_asXaX_selectXaX_byXunfold_valuesXnameX_foldX_tailXlocal_2X() {
    final Traversal<Vertex, List<String>> traversal = get_g_V_asXaX_out_asXaX_out_asXaX_selectXaX_byXunfold_valuesXnameX_foldX_tailXlocal_2X();
    printTraversalForm(traversal);
    final Set<List<String>> expected =
        new HashSet(Arrays.asList(
                        Arrays.asList("josh", "ripple"),
                        Arrays.asList("josh", "lop")));
    final Set<List<String>> actual = new HashSet(traversal.toList());
    assertEquals(expected, actual);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:14,代码来源:TailTest.java

示例10: g_V_outXcreatedX_aggregateXxX_byXlangX_groupCount_programXTestProgramX_asXaX_selectXa_xX

import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_V_outXcreatedX_aggregateXxX_byXlangX_groupCount_programXTestProgramX_asXaX_selectXa_xX() {
    final Traversal<Vertex, Map<String, Object>> traversal = get_g_V_outXcreatedX_aggregateXxX_byXlangX_groupCount_programXTestProgramX_asXaX_selectXa_xX();
    final List<Map<String, Object>> results = traversal.toList();
    assertFalse(traversal.hasNext());
    assertEquals(6, results.size());
    final BulkSet<String> bulkSet = new BulkSet<>();
    bulkSet.add("java", 4);
    for (int i = 0; i < 4; i++) {
        assertEquals(bulkSet, results.get(i).get("x"));
    }
    final Set<String> strings = new HashSet<>();
    strings.add((String) results.get(0).get("a"));
    strings.add((String) results.get(1).get("a"));
    strings.add((String) results.get(2).get("a"));
    strings.add((String) results.get(3).get("a"));
    strings.add((String) results.get(4).get("a"));
    strings.add((String) results.get(5).get("a"));
    assertEquals(6, strings.size());
    assertTrue(strings.contains("hello"));
    assertTrue(strings.contains("gremlin"));
    assertTrue(strings.contains("lop"));
    assertTrue(strings.contains("ripple"));
    assertTrue(strings.contains("marko-is-my-name"));
    assertTrue(strings.contains("the-v-o-double-g"));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:28,代码来源:ProgramTest.java

示例11: g_V_both_both_dedup_byXlabelX

import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_V_both_both_dedup_byXlabelX() {
    final Traversal<Vertex, Vertex> traversal = get_g_V_both_both_dedup_byXlabelX();
    printTraversalForm(traversal);
    final List<Vertex> vertices = traversal.toList();
    assertEquals(2, vertices.size());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:9,代码来源:DedupTest.java

示例12: g_VX4X_bothE_hasXweight_lt_1X_otherV

import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_VX4X_bothE_hasXweight_lt_1X_otherV() {
    final Traversal<Vertex, Vertex> traversal = get_g_VX4X_bothE_hasXweight_lt_1X_otherV(convertToVertexId("josh"));
    printTraversalForm(traversal);
    final List<Vertex> vertices = traversal.toList();
    assertEquals(1, vertices.size());
    assertEquals(vertices.get(0).value("name"), "lop");
    assertFalse(traversal.hasNext());
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:11,代码来源:VertexTest.java

示例13: g_V_name_order_byXa1_b1X_byXb2_a2X

import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_V_name_order_byXa1_b1X_byXb2_a2X() {
    final Traversal<Vertex, String> traversal = get_g_V_name_order_byXa1_b1X_byXb2_a2X();
    printTraversalForm(traversal);
    final List<String> names = traversal.toList();
    assertEquals(names.size(), 6);
    assertEquals("marko", names.get(0));
    assertEquals("vadas", names.get(1));
    assertEquals("peter", names.get(2));
    assertEquals("ripple", names.get(3));
    assertEquals("josh", names.get(4));
    assertEquals("lop", names.get(5));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:15,代码来源:OrderTest.java

示例14: g_V_asXaX_in_asXaX_in_asXaX_selectXaX_byXunfold_valuesXnameX_foldX_limitXlocal_1X

import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
/** Scenario: limit step, Scope.local, 1 item requested, List input, String output */
@Test
@LoadGraphWith(MODERN)
public void g_V_asXaX_in_asXaX_in_asXaX_selectXaX_byXunfold_valuesXnameX_foldX_limitXlocal_1X() {
    final Traversal<Vertex, String> traversal = get_g_V_asXaX_in_asXaX_in_asXaX_selectXaX_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);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:11,代码来源:RangeTest.java

示例15: g_V_outE_order_byXweight_decrX_weight

import org.apache.tinkerpop.gremlin.process.traversal.Traversal; //导入方法依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_V_outE_order_byXweight_decrX_weight() {
    final Traversal<Vertex, Double> traversal = get_g_V_outE_order_byXweight_decrX_weight();
    printTraversalForm(traversal);
    final List<Double> weights = traversal.toList();
    assertEquals(6, weights.size());
    assertEquals(Double.valueOf(1.0d), weights.get(0));
    assertEquals(Double.valueOf(1.0d), weights.get(1));
    assertEquals(Double.valueOf(0.5d), weights.get(2));
    assertEquals(Double.valueOf(0.4d), weights.get(3));
    assertEquals(Double.valueOf(0.4d), weights.get(4));
    assertEquals(Double.valueOf(0.2d), weights.get(5));

}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:16,代码来源:OrderTest.java


注:本文中的org.apache.tinkerpop.gremlin.process.traversal.Traversal.toList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。