本文整理汇总了Java中org.apache.tinkerpop.gremlin.LoadGraphWith类的典型用法代码示例。如果您正苦于以下问题:Java LoadGraphWith类的具体用法?Java LoadGraphWith怎么用?Java LoadGraphWith使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
LoadGraphWith类属于org.apache.tinkerpop.gremlin包,在下文中一共展示了LoadGraphWith类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBaseConfiguration
import org.apache.tinkerpop.gremlin.LoadGraphWith; //导入依赖的package包/类
@Override
public Map<String, Object> getBaseConfiguration(final String graphName, final Class<?> test, final String testMethodName,
final LoadGraphWith.GraphData loadGraphWith) {
final TinkerGraph.DefaultIdManager idManager = TinkerGraph.DefaultIdManager.UUID;
final String idMaker = idManager.name();
return new HashMap<String, Object>() {{
put(Graph.GRAPH, TinkerGraph.class.getName());
put(TinkerGraph.GREMLIN_TINKERGRAPH_VERTEX_ID_MANAGER, idMaker);
put(TinkerGraph.GREMLIN_TINKERGRAPH_EDGE_ID_MANAGER, idMaker);
put(TinkerGraph.GREMLIN_TINKERGRAPH_VERTEX_PROPERTY_ID_MANAGER, idMaker);
if (requiresListCardinalityAsDefault(loadGraphWith, test, testMethodName))
put(TinkerGraph.GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY, VertexProperty.Cardinality.list.name());
if (requiresPersistence(test, testMethodName)) {
put(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_FORMAT, "gryo");
final File tempDir = TestHelper.makeTestDataPath(test, "temp");
put(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION,
tempDir.getAbsolutePath() + File.separator + testMethodName + ".kryo");
}
}};
}
示例2: getBaseConfiguration
import org.apache.tinkerpop.gremlin.LoadGraphWith; //导入依赖的package包/类
@Override
public Map<String, Object> getBaseConfiguration(final String graphName, final Class<?> test, final String testMethodName,
final LoadGraphWith.GraphData loadGraphWith) {
final TinkerGraph.DefaultIdManager idManager = selectIdMakerFromGraphData(loadGraphWith);
final String idMaker = (idManager.equals(TinkerGraph.DefaultIdManager.ANY) ? selectIdMakerFromTest(test, testMethodName) : idManager).name();
return new HashMap<String, Object>() {{
put(Graph.GRAPH, TinkerGraph.class.getName());
put(TinkerGraph.GREMLIN_TINKERGRAPH_VERTEX_ID_MANAGER, idMaker);
put(TinkerGraph.GREMLIN_TINKERGRAPH_EDGE_ID_MANAGER, idMaker);
put(TinkerGraph.GREMLIN_TINKERGRAPH_VERTEX_PROPERTY_ID_MANAGER, idMaker);
if (requiresListCardinalityAsDefault(loadGraphWith, test, testMethodName))
put(TinkerGraph.GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY, VertexProperty.Cardinality.list.name());
if (requiresPersistence(test, testMethodName)) {
put(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_FORMAT, "gryo");
final File tempDir = TestHelper.makeTestDataPath(test, "temp");
put(TinkerGraph.GREMLIN_TINKERGRAPH_GRAPH_LOCATION,
tempDir.getAbsolutePath() + File.separator + testMethodName + ".kryo");
}
}};
}
示例3: g_V_asXaX_outXcreatedX_asXbX_inXcreatedX_asXcX_dedupXa_bX_path
import org.apache.tinkerpop.gremlin.LoadGraphWith; //导入依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_V_asXaX_outXcreatedX_asXbX_inXcreatedX_asXcX_dedupXa_bX_path() {
final Traversal<Vertex, Path> traversal = get_g_V_asXaX_outXcreatedX_asXbX_inXcreatedX_asXcX_dedupXa_bX_path();
printTraversalForm(traversal);
int counter = 0;
final Set<List<Vertex>> results = new HashSet<>();
while (traversal.hasNext()) {
final Path path = traversal.next();
assertEquals(3, path.size());
assertTrue(results.add(Arrays.asList(path.get("a"), path.get("b"))));
counter++;
}
assertEquals(4, counter);
assertEquals(4, results.size());
}
示例4: g_V_hasLabelXpersonX_pageRank_byXpageRankX_order_byXpageRankX_valueMapXname_pageRankX
import org.apache.tinkerpop.gremlin.LoadGraphWith; //导入依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_V_hasLabelXpersonX_pageRank_byXpageRankX_order_byXpageRankX_valueMapXname_pageRankX() {
final Traversal<Vertex, Map<String, List<Object>>> traversal = get_g_V_hasLabelXpersonX_pageRank_byXpageRankX_order_byXpageRankX_valueMapXname_pageRankX();
printTraversalForm(traversal);
int counter = 0;
double lastPageRank = Double.MIN_VALUE;
while (traversal.hasNext()) {
final Map<String, List<Object>> map = traversal.next();
assertEquals(2, map.size());
assertEquals(1, map.get("name").size());
assertEquals(1, map.get("pageRank").size());
String name = (String) map.get("name").get(0);
double pageRank = (Double) map.get("pageRank").get(0);
assertTrue(pageRank >= lastPageRank);
lastPageRank = pageRank;
assertFalse(name.equals("lop") || name.equals("ripple"));
counter++;
}
assertEquals(4, counter);
}
示例5: g_V_out_aggregateXaX_path
import org.apache.tinkerpop.gremlin.LoadGraphWith; //导入依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_V_out_aggregateXaX_path() {
final Traversal<Vertex, Path> traversal = get_g_V_out_aggregateXaX_path();
printTraversalForm(traversal);
int count = 0;
final Map<String, Long> firstStepCounts = new HashMap<>();
final Map<String, Long> secondStepCounts = new HashMap<>();
while (traversal.hasNext()) {
count++;
final Path path = traversal.next();
final String first = path.get(0).toString();
final String second = path.get(1).toString();
assertThat(first, not(second));
MapHelper.incr(firstStepCounts, first, 1l);
MapHelper.incr(secondStepCounts, second, 1l);
}
assertEquals(6, count);
assertEquals(3, firstStepCounts.size());
assertEquals(4, secondStepCounts.size());
assertTrue(firstStepCounts.values().contains(3l));
assertTrue(firstStepCounts.values().contains(2l));
assertTrue(firstStepCounts.values().contains(1l));
assertTrue(secondStepCounts.values().contains(3l));
assertTrue(secondStepCounts.values().contains(1l));
}
示例6: g_VX1X_outE
import org.apache.tinkerpop.gremlin.LoadGraphWith; //导入依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_VX1X_outE() {
final Traversal<Vertex, Edge> traversal = get_g_VX1X_outE(convertToVertexId("marko"));
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());
}
示例7: shouldAndOrIncrCorrectlyThroughSubStages
import org.apache.tinkerpop.gremlin.LoadGraphWith; //导入依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void shouldAndOrIncrCorrectlyThroughSubStages() throws Exception {
ComputerResult results = graphProvider.getGraphComputer(graph).program(new VertexProgramG()).submit().get();
assertEquals(2, results.memory().getIteration());
assertEquals(6, results.memory().asMap().size());
assertEquals(6, results.memory().keys().size());
assertTrue(results.memory().keys().contains("a"));
assertTrue(results.memory().keys().contains("b"));
assertTrue(results.memory().keys().contains("c"));
assertTrue(results.memory().keys().contains("d"));
assertTrue(results.memory().keys().contains("e"));
assertTrue(results.memory().keys().contains("f"));
assertEquals(Long.valueOf(18), results.memory().get("a"));
assertEquals(Long.valueOf(0), results.memory().get("b"));
assertFalse(results.memory().get("c"));
assertTrue(results.memory().get("d"));
assertTrue(results.memory().get("e"));
assertEquals(3, results.memory().<Integer>get("f").intValue());
}
示例8: shouldUseOneTimeBulkLoader
import org.apache.tinkerpop.gremlin.LoadGraphWith; //导入依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void shouldUseOneTimeBulkLoader() throws Exception {
for (int iteration = 1; iteration <= 2; iteration++) {
final BulkLoaderVertexProgram blvp = BulkLoaderVertexProgram.build()
.bulkLoader(OneTimeBulkLoader.class)
.writeGraph(getWriteGraphConfiguration()).create(graph);
final BulkLoader loader = getBulkLoader(blvp);
assertTrue(loader instanceof OneTimeBulkLoader);
graphProvider.getGraphComputer(graph).workers(1).program(blvp).submit().get();
final Graph result = getWriteGraph();
assertEquals(6 * iteration, IteratorUtils.count(result.vertices()));
assertEquals(6 * iteration, IteratorUtils.count(result.edges()));
result.close();
}
}
示例9: shouldSupportPreExistingComputeKeys
import org.apache.tinkerpop.gremlin.LoadGraphWith; //导入依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void shouldSupportPreExistingComputeKeys() throws Exception {
final ComputerResult result = graphProvider.getGraphComputer(graph).program(new VertexProgramN()).submit().get();
result.graph().vertices().forEachRemaining(vertex -> {
if (vertex.label().equals("person")) {
if (vertex.value("name").equals("marko"))
assertEquals(32, vertex.<Integer>value("age").intValue());
else if (vertex.value("name").equals("peter"))
assertEquals(38, vertex.<Integer>value("age").intValue());
else if (vertex.value("name").equals("vadas"))
assertEquals(30, vertex.<Integer>value("age").intValue());
else if (vertex.value("name").equals("josh"))
assertEquals(35, vertex.<Integer>value("age").intValue());
else
throw new IllegalStateException("This vertex should not have been accessed: " + vertex);
}
});
}
示例10: shouldClearBindingsBetweenEvals
import org.apache.tinkerpop.gremlin.LoadGraphWith; //导入依赖的package包/类
@Test
@LoadGraphWith(LoadGraphWith.GraphData.MODERN)
public void shouldClearBindingsBetweenEvals() throws Exception {
final ScriptEngine engine = new GremlinGroovyScriptEngine();
engine.put("g", g);
engine.put("marko", convertToVertexId("marko"));
assertEquals(g.V(convertToVertexId("marko")).next(), engine.eval("g.V(marko).next()"));
final Bindings bindings = engine.createBindings();
bindings.put("g", g);
bindings.put("s", "marko");
assertEquals(engine.eval("g.V().has('name',s).next()", bindings), g.V(convertToVertexId("marko")).next());
try {
engine.eval("g.V().has('name',s).next()");
fail("This should have failed because s is no longer bound");
} catch (Exception ex) {
final Throwable t = ExceptionUtils.getRootCause(ex);
assertEquals(MissingPropertyException.class, t.getClass());
assertTrue(t.getMessage().startsWith("No such property: s for class"));
}
}
示例11: g_VX4X_bothEXcreatedX
import org.apache.tinkerpop.gremlin.LoadGraphWith; //导入依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_VX4X_bothEXcreatedX() {
final Traversal<Vertex, Edge> traversal = get_g_VX4X_bothEXcreatedX(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("created"));
assertEquals(edge.outVertex().id(), convertToVertexId("josh"));
}
assertEquals(2, counter);
assertEquals(2, edges.size());
}
示例12: g_V_properties_order_byXkey_decrX_key
import org.apache.tinkerpop.gremlin.LoadGraphWith; //导入依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_V_properties_order_byXkey_decrX_key() {
final Traversal<Vertex, String> traversal = get_g_V_properties_order_byXkey_decrX_key();
printTraversalForm(traversal);
assertEquals("name", traversal.next());
assertEquals("name", traversal.next());
assertEquals("name", traversal.next());
assertEquals("name", traversal.next());
assertEquals("name", traversal.next());
assertEquals("name", traversal.next());
assertEquals("lang", traversal.next());
assertEquals("lang", traversal.next());
assertEquals("age", traversal.next());
assertEquals("age", traversal.next());
assertEquals("age", traversal.next());
assertEquals("age", traversal.next());
assertFalse(traversal.hasNext());
}
示例13: g_V_asXaX_out_asXbX_out_asXcX_selectXa_b_cX_byXnameX_rangeXlocal_1_2X
import org.apache.tinkerpop.gremlin.LoadGraphWith; //导入依赖的package包/类
/** Scenario: range step, Scope.local, 1 item requested, Map input, Map output */
@Test
@LoadGraphWith(MODERN)
public void g_V_asXaX_out_asXbX_out_asXcX_selectXa_b_cX_byXnameX_rangeXlocal_1_2X() {
final Traversal<Vertex, Map<String, String>> traversal = get_g_V_asXaX_out_asXbX_out_asXcX_selectXa_b_cX_byXnameX_rangeXlocal_1_2X();
printTraversalForm(traversal);
// Since both of the tuples are identical, we count them.
final Set<Map<String, String>> expected = new HashSet<>(makeMapList(1, "b", "josh"));
final Set<Map<String, String>> actual = new HashSet<>();
int counter = 0;
while (traversal.hasNext()) {
final Map<String, String> map = traversal.next();
actual.add(map);
counter++;
}
assertEquals(2, counter);
assertEquals(expected, actual);
}
示例14: shouldExecutePeerPressure
import org.apache.tinkerpop.gremlin.LoadGraphWith; //导入依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void shouldExecutePeerPressure() throws Exception {
/*if (g.getGraphComputer().get().features().supportsResultGraphPersistCombination(GraphComputer.ResultGraph.NEW, GraphComputer.Persist.VERTEX_PROPERTIES)) {
final ComputerResult result = graph.compute(g.getGraphComputer().get().getClass()).program(PeerPressureVertexProgram.build().create(graph)).submit().get();
final Set<Object> clusters = new HashSet<>();
result.graph().traversal().V().forEachRemaining(v -> {
assertEquals(4, v.keys().size()); // name, age/lang, voteStrength, cluster
assertTrue(v.keys().contains("name"));
assertTrue(v.keys().contains(PeerPressureVertexProgram.VOTE_STRENGTH));
assertTrue(v.keys().contains(PeerPressureVertexProgram.CLUSTER));
assertEquals(1, IteratorUtils.count(v.values("name")));
assertEquals(1, IteratorUtils.count(v.values(PeerPressureVertexProgram.CLUSTER)));
final Object cluster = v.value(PeerPressureVertexProgram.CLUSTER);
clusters.add(cluster);
});
//assertEquals(2, clusters.size());
//assertEquals(3, result.memory().getIteration());
assertEquals(1, result.memory().asMap().size());
assertTrue(result.memory().keys().contains("gremlin.peerPressureVertexProgram.voteToHalt")); // this is private in PeerPressureVertexProgram (and that is okay)
}*/
}
示例15: g_V_pageRank_byXpageRankX_asXaX_outXknowsX_pageRank_asXbX_selectXa_bX
import org.apache.tinkerpop.gremlin.LoadGraphWith; //导入依赖的package包/类
@Test
@LoadGraphWith(MODERN)
public void g_V_pageRank_byXpageRankX_asXaX_outXknowsX_pageRank_asXbX_selectXa_bX() {
final Traversal<Vertex, Map<String, Object>> traversal = get_g_V_pageRank_byXpageRankX_asXaX_outXknowsX_pageRank_asXbX_selectXa_bX();
printTraversalForm(traversal);
int counter = 0;
while (traversal.hasNext()) {
final Map<String, Object> map = traversal.next();
assertEquals(2, map.size());
Vertex vertex = (Vertex) map.get("a");
double pageRank = (Double) map.get("b");
assertEquals(convertToVertexId("marko"), vertex.id());
assertTrue(pageRank > 0.15d);
counter++;
}
assertEquals(2, counter);
}