本文整理汇总了Java中com.tinkerpop.gremlin.java.GremlinPipeline类的典型用法代码示例。如果您正苦于以下问题:Java GremlinPipeline类的具体用法?Java GremlinPipeline怎么用?Java GremlinPipeline使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GremlinPipeline类属于com.tinkerpop.gremlin.java包,在下文中一共展示了GremlinPipeline类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: exits
import com.tinkerpop.gremlin.java.GremlinPipeline; //导入依赖的package包/类
public GremlinPipeline<?, Instruction> exits()
{
final int MAX_LOOPS = 10000;
final String[] EDGES = {Traversals.INSTR_CFLOW_EDGE, Traversals.INSTR_CFLOW_TRANSITIVE_EDGE};
if (!this.getVertices(Direction.OUT, EDGES).iterator().hasNext())
{
return new GremlinPipeline<>(this);
} else
{
return new GremlinPipeline<>(this.getBaseVertex()).as("start")
.out(EDGES).dedup().loop("start",
arg -> arg.getLoops() < MAX_LOOPS,
arg -> arg.getLoops() < MAX_LOOPS
&& !arg.getObject().getEdges(Direction.OUT, EDGES).iterator().hasNext())
.dedup()
.transform(Instruction::new);
}
}
开发者ID:octopus-platform,项目名称:bjoern,代码行数:19,代码来源:Instruction.java
示例2: killedDefinitions
import com.tinkerpop.gremlin.java.GremlinPipeline; //导入依赖的package包/类
public static Set<ReachingDefinitionAnalyser.Definition> killedDefinitions(
final Vertex vertex) {
Set<ReachingDefinitionAnalyser.Definition> killSet = new HashSet<>();
GremlinPipeline<Vertex, Edge> pipe = new GremlinPipeline<>();
pipe.start(vertex)
.out("WRITE")
.out("BELONGS_TO")
.in("BELONGS_TO")
.inE("WRITE");
for (Edge writeEdge : pipe) {
Vertex genVertex = writeEdge.getVertex(Direction.OUT);
Vertex aloc = writeEdge.getVertex(Direction.IN);
GremlinPipeline<Vertex, Object> pipe2 = new
GremlinPipeline<>();
pipe2.start(aloc)
.out("BELONGS_TO")
.in("BELONGS_TO")
.property("name");
for (Object identifier : pipe2) {
killSet.add(new ReachingDefinitionAnalyser.Definition(
genVertex, identifier));
}
}
return killSet;
}
开发者ID:octopus-platform,项目名称:bjoern,代码行数:26,代码来源:DataDependencePlugin.java
示例3: getQueryPipe
import com.tinkerpop.gremlin.java.GremlinPipeline; //导入依赖的package包/类
@Override
protected Pipe getQueryPipe() {
GremlinPipeline p;
if (guid.equals("*")) {
p = new GremlinPipeline().has(Constants.ENTITY_TEXT_PROPERTY_KEY).
hasNot(Constants.ENTITY_TYPE_PROPERTY_KEY, "Taxonomy").outE();
} else {
p = new GremlinPipeline().has(Constants.GUID_PROPERTY_KEY, guid).outE();
}
//todo: this is basically the same pipeline used in TagRelation.asPipe()
p.add(new FilterFunctionPipe<>(new PipeFunction<Edge, Boolean>() {
@Override
public Boolean compute(Edge edge) {
String type = edge.getVertex(Direction.OUT).getProperty(Constants.ENTITY_TYPE_PROPERTY_KEY);
VertexWrapper v = new TermVertexWrapper(edge.getVertex(Direction.IN));
return edge.getLabel().startsWith(type) && v.getPropertyKeys().contains("available_as_tag");
}
}));
return p.inV();
}
开发者ID:apache,项目名称:incubator-atlas,代码行数:22,代码来源:AtlasEntityTagQuery.java
示例4: TestAtlasEntityQuery
import com.tinkerpop.gremlin.java.GremlinPipeline; //导入依赖的package包/类
public TestAtlasEntityQuery(QueryExpression queryExpression,
ResourceDefinition resourceDefinition,
Request request,
GremlinPipeline initialPipeline,
Pipe queryPipe,
Pipe notDeletedPipe,
AtlasGraph graph,
VertexWrapper vWrapper) {
super(queryExpression, resourceDefinition, request);
this.initialPipeline = initialPipeline;
this.queryPipe = queryPipe;
this.notDeletedPipe = notDeletedPipe;
this.graph = graph;
this.vWrapper = vWrapper;
}
开发者ID:apache,项目名称:incubator-atlas,代码行数:17,代码来源:AtlasEntityQueryTest.java
示例5: testBulkLoading
import com.tinkerpop.gremlin.java.GremlinPipeline; //导入依赖的package包/类
@Test
public void testBulkLoading() throws Exception {
bulkLoadGraphOfTheGods(f1);
clopen();
assertEquals(12, new GremlinPipeline(g).V().count());
assertEquals(17, new GremlinPipeline(g).E().count());
new GremlinPipeline(g).V().sideEffect(new PipeFunction<Vertex, Vertex>() {
@Override
public Vertex compute(Vertex vertex) {
assertEquals(2, vertex.getPropertyKeys().size());
assertNotNull(vertex.getProperty("name"));
return vertex;
}
}).iterate();
assertEquals("saturn", new GremlinPipeline(g).V("name", "hercules").out("father").out("father").property("name").next());
List names = new GremlinPipeline(g).V("name", "hercules").outE("battled").sideEffect(new PipeFunction<Edge, Edge>() {
@Override
public Edge compute(Edge edge) {
assertNotNull(edge.getProperty("time"));
return edge;
}
}).inV().property("name").toList();
assertTrue(names.contains("nemean"));
assertTrue(names.contains("hydra"));
assertTrue(names.contains("cerberus"));
}
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:27,代码来源:TitanOutputFormatTest.java
示例6: testBulkElementDeletions
import com.tinkerpop.gremlin.java.GremlinPipeline; //导入依赖的package包/类
@Test
public void testBulkElementDeletions() throws Exception {
bulkLoadGraphOfTheGods(f1);
clopen();
assertEquals(12, new GremlinPipeline(g).V().count());
assertEquals(17, new GremlinPipeline(g).E().count());
new HadoopPipeline(f2).V().drop().submit();
clopen();
assertEquals(0, new GremlinPipeline(g).V().count());
assertEquals(0, new GremlinPipeline(g).E().count());
bulkLoadGraphOfTheGods(f1);
new HadoopPipeline(f2).E().drop().submit();
clopen();
assertEquals(12, new GremlinPipeline(g).V().count());
assertEquals(0, new GremlinPipeline(g).E().count());
new HadoopPipeline(f2).V().drop().submit();
clopen();
assertEquals(0, new GremlinPipeline(g).V().count());
assertEquals(0, new GremlinPipeline(g).E().count());
}
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:21,代码来源:TitanOutputFormatTest.java
示例7: testFewElementDeletions
import com.tinkerpop.gremlin.java.GremlinPipeline; //导入依赖的package包/类
@Test
public void testFewElementDeletions() throws Exception {
bulkLoadGraphOfTheGods(f1);
clopen();
assertEquals(12, new GremlinPipeline(g).V().count());
assertEquals(17, new GremlinPipeline(g).E().count());
new HadoopPipeline(f2).E().has("label", "battled").drop().submit();
clopen();
assertEquals(12, new GremlinPipeline(g).V().count());
assertEquals(14, new GremlinPipeline(g).E().count());
assertEquals(0, new GremlinPipeline(g).E().has("label", "battled").count());
assertEquals(1, new GremlinPipeline(g).E().has("label", "mother").count());
assertEquals(2, new GremlinPipeline(g).E().has("label", "father").count());
new HadoopPipeline(f2).V().has("name", "hercules").drop().submit();
clopen();
assertEquals(11, new GremlinPipeline(g).V().count());
assertEquals(12, new GremlinPipeline(g).E().count());
assertEquals(0, new GremlinPipeline(g).E().has("label", "battled").count());
assertEquals(0, new GremlinPipeline(g).E().has("label", "mother").count());
assertEquals(1, new GremlinPipeline(g).E().has("label", "father").count());
}
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:24,代码来源:TitanOutputFormatTest.java
示例8: testBulkVertexPropertyDeletions
import com.tinkerpop.gremlin.java.GremlinPipeline; //导入依赖的package包/类
@Test
public void testBulkVertexPropertyDeletions() throws Exception {
bulkLoadGraphOfTheGods(f1);
new HadoopPipeline(f2).V().sideEffect("{it.removeProperty('name')}").submit();
clopen();
assertEquals(12, new GremlinPipeline(g).V().count());
assertEquals(17, new GremlinPipeline(g).E().count());
for (Vertex v : g.getVertices()) {
assertNull(v.getProperty("name"));
assertEquals(1, v.getPropertyKeys().size());
}
new GremlinPipeline(g).V("name", "hercules").outE("battled").sideEffect(new PipeFunction<Edge, Edge>() {
@Override
public Edge compute(Edge edge) {
assertNotNull(edge.getProperty("time"));
return edge;
}
}).iterate();
}
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:21,代码来源:TitanOutputFormatTest.java
示例9: testUnidirectionEdges
import com.tinkerpop.gremlin.java.GremlinPipeline; //导入依赖的package包/类
@Test
public void testUnidirectionEdges() throws Exception {
// Declare schema in Titan
TitanManagement mgmt = g.getManagementSystem();
mgmt.makeEdgeLabel("father").unidirected().make();
mgmt.commit();
// // Reload schema from Titan into Faunus's Type Manager
// FaunusTypeManager.getTypeManager(null).clear();
// SchemaProvider titanSchemaProvider = new SchemaContainer(g);
// FaunusTypeManager typeManager = FaunusTypeManager.getTypeManager(null); //argument is ignored
// typeManager.setSchemaProvider(titanSchemaProvider);
bulkLoadGraphOfTheGods(f1);
clopen();
assertEquals(12, new GremlinPipeline(g).V().count());
assertEquals(17, new GremlinPipeline(g).E().count());
assertEquals(new GremlinPipeline(g).V("name", "hercules").out("father").count(), 1);
assertEquals(new GremlinPipeline(g).V("name", "jupiter").in("father").count(), 0);
// // Reset/clear types to avoid interference with subsequent tests
// typeManager.clear();
// typeManager.setSchemaProvider(DefaultSchemaProvider.INSTANCE);
}
开发者ID:graben1437,项目名称:titan0.5.4-hbase1.1.1-custom,代码行数:25,代码来源:TitanOutputFormatTest.java
示例10: testApplyLayout
import com.tinkerpop.gremlin.java.GremlinPipeline; //导入依赖的package包/类
@Test
public void testApplyLayout() throws Exception {
horizontalLayout.applyLayout( graph, 1000, 1000 );
assertThat( verticesByProperty( "degree", 0 ), containsInAnyOrder( "S0", "S1" ) );
assertThat( verticesByProperty( "degree", 1 ), contains( "A" ) );
assertThat( verticesByProperty( "degree", 2 ), contains( "B" ) );
assertThat( verticesByProperty( "degree", 3 ), containsInAnyOrder( "C", "D" ) );
List<String> orderedX = new GremlinPipeline<>( graph ).V()
.order( compareProperty( "x" ) )
.id().cast( String.class )
.toList();
assertThat( orderedX, containsInRelativeOrder( "S1", "A", "B", "D" ) );
}
开发者ID:mattyb149,项目名称:pdi-layout,代码行数:17,代码来源:HorizontalLayoutTest.java
示例11: main
import com.tinkerpop.gremlin.java.GremlinPipeline; //导入依赖的package包/类
public static void main(String[] args) {
if (args.length != 1) {
System.err.println("Please enter a graph name.");
System.err.println("graphs: memory-beta, simpsons, wookieepedia");
System.err
.println("Graph path should be set in the graphs.poperties file.");
System.exit(1);
}
TinkerGraph graph;
try {
graph = SingletonGraph.getInstance().getGraphs().get(args[0]);
Index<Vertex> index = graph.getIndex("verb-idx", Vertex.class);
GremlinPipeline<Iterable<Vertex>, Vertex> pipeline = new GremlinPipeline<Iterable<Vertex>, Vertex>();
pipeline.start(index.get("verbIndex", null)).hasNot(NerdleGraphTransformer.PROPERTY_ISSYNONYM, true);
} catch (ConfigurationException e) {
e.printStackTrace();
}
}
开发者ID:impro3-nerdle,项目名称:nerdle,代码行数:23,代码来源:GraphFactsCounter.java
示例12: testTraversalPerformance
import com.tinkerpop.gremlin.java.GremlinPipeline; //导入依赖的package包/类
@Test
public void testTraversalPerformance() {
TinkerGraph t = TinkerGraphFactory.createTinkerGraph();
FramedGraph f = new FramedGraph(t);
Timer timer = metrics.timer("gremlin");
Context time = timer.time();
for (int count = 0; count < iterations; count++) {
GremlinPipeline g = new GremlinPipeline(t);
g.V().both().both().both().toList();
}
long nanoseconds = time.stop();
System.out.println("Iterate over all GremlinPipeline " + nanoseconds / 1000000);
time = timer.time();
for (int count = 0; count < iterations; count++) {
f.V().both().both().both().toList();
}
nanoseconds = time.stop();
System.out.println("Iterate over all Totorom " + nanoseconds / 1000000);
}
开发者ID:BrynCooke,项目名称:totorom,代码行数:24,代码来源:TestPerformance.java
示例13: calcWeight
import com.tinkerpop.gremlin.java.GremlinPipeline; //导入依赖的package包/类
/**
* Calculates the weight of the comment path as defined by Q14 between a and b
* (directional)
*
* @param a Source (Person) vertex
* @param b Target (Person) vertex
* @return weight of comment-reply path between a and b as defined by Q14
*/
private double calcWeight(final Vertex a, final Vertex b) {
double w = 0.0;
GremlinPipeline<Vertex, Vertex> pipe = (new GremlinPipeline<>(a));
Iterable<Row> res1 = pipe.in("hasCreator").as("postComment").in("replyOf").out("hasCreator")
.filter(new PipesFunction<Vertex, Boolean>() {
@Override
public Boolean compute(Vertex commentCreator) {
return commentCreator.equals(b);
}
}).select();
for (Row r : res1) {
w += (((Vertex) r.getColumn(0)).getProperty("label").equals("Post") ? 1 : 0.5);
}
return w;
}
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:26,代码来源:LdbcQuery14Handler.java
示例14: collectUnis
import com.tinkerpop.gremlin.java.GremlinPipeline; //导入依赖的package包/类
/**
* Given a vertex representing a person collects information about
* the universities this person has gone to using a table.
*
* @param v Person vertex for which to collect universities
* @return list of lists, internal list is
* (uniCity:CITY)<-[:IS_LOCATED_IN]-(uni:UNIVERSITY)<-[studyAt:STUDY_AT]-(person)
*/
public static List<List<Object>> collectUnis(Vertex v) {
List<List<Object>> res = new ArrayList<>();
Table table = new Table();
GremlinPipeline<Vertex, List<Vertex>> gp = new GremlinPipeline<>(v);
// List<Edge> studyEdges= (new GremlinPipeline<Vertex,List<Edge>>(v).outE("studyAt").aggregate()).toList();
// List<Vertex> uniVertices = (new GremlinPipeline<Vertex,List<Vertex>>(v).outE("studyAt").outV().aggregate()).toList();
// List<Vertex> uniCountries = (new GremlinPipeline<Vertex,List<Vertex>>(v).outE("studyAt").outV().out("isLocatedIn").aggregate()).toList();
gp.outE("studyAt").as("e").inV().as("u").out("isLocatedIn").as("c").table(table).iterate();
for (Row r : table) {
ArrayList<Object> a = new ArrayList<>();
a.add(((Vertex) r.get(1)).getProperty("name")); //University->name
a.add(((Edge) r.get(0)).getProperty("classYear")); //studyAt->classYear
a.add(((Vertex) r.get(2)).getProperty("name")); //City->name
res.add(a);
}
return res;
}
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:27,代码来源:QueryUtils.java
示例15: collectComps
import com.tinkerpop.gremlin.java.GremlinPipeline; //导入依赖的package包/类
/**
* Given a vertex representing a person collects information about
* the companies this person has worked at using a table.
*
* @param v Person for which to collect companies
* @return list of lists, internal list is
* (companyCountry:PLACE:COUNTRY)<-[:IS_LOCATED_IN]-(company:COMPANY)<-[worksAt:WORKS_AT]-(person)
*/
public static List<List<Object>> collectComps(Vertex v) {
//TODO combine with collectUnis
List<List<Object>> res = new ArrayList<>();
Table table = new Table();
GremlinPipeline<Vertex, List<Vertex>> gp = new GremlinPipeline<>(v);
gp.outE("workAt").as("e").inV().as("c").out("isLocatedIn").as("co").table(table).iterate();
for (Row r : table) {
ArrayList<Object> a = new ArrayList<>();
a.add(((Vertex) r.get(1)).getProperty("name")); //Company->name
a.add(((Edge) r.get(0)).getProperty("workFrom")); //workAt->workFrom
a.add(((Vertex) r.get(2)).getProperty("name")); //Country->name
res.add(a);
}
return res;
}
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:24,代码来源:QueryUtils.java
示例16: getFoF
import com.tinkerpop.gremlin.java.GremlinPipeline; //导入依赖的package包/类
/**
* Given a person, returns the set of friends and friends of friends
* , excluding that person
*
* @param rootId personID to start from
* @param client TitanFTMDb.BasicClient to use for root retrieval
* @return Set<Vertex> of the persons friends and their friends
*/
public Set<Vertex> getFoF(long rootId, TitanFTMDb.BasicClient client) {
Set<Vertex> res = new HashSet<>();
Vertex root = null;
try {
root = client.getVertex(rootId, "Person");
} catch (SchemaViolationException e) {
e.printStackTrace();
}
GremlinPipeline<Vertex, Vertex> gp = (new GremlinPipeline<Vertex, Vertex>(root));
gp.out("knows").aggregate(res)
.out("knows").aggregate(res).iterate();
res.remove(root);
return res;
}
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:24,代码来源:QueryUtils.java
示例17: executeOperation
import com.tinkerpop.gremlin.java.GremlinPipeline; //导入依赖的package包/类
@Override
public void executeOperation(final LdbcShortQuery5MessageCreator operation,TitanFTMDb.BasicDbConnectionState dbConnectionState,ResultReporter resultReporter) throws DbException {
long mid = operation.messageId();
TitanFTMDb.BasicClient client = dbConnectionState.client();
Vertex m;
try {
logger.debug("Short Query 5 called on message id: {}", mid);
m = client.getVertex(mid, "Comment");
if (m==null)
m = client.getVertex(mid, "Post");
GremlinPipeline<Vertex,Vertex> gp = new GremlinPipeline<>(m);
Vertex person = gp.out("hasCreator").next();
LdbcShortQuery5MessageCreatorResult res = new LdbcShortQuery5MessageCreatorResult(
client.getVLocalId((Long)person.getId()),
(String) person.getProperty("firstName"),(String) person.getProperty("lastName"));
resultReporter.report(1, res, operation);
} catch (SchemaViolationException e) {
e.printStackTrace();
resultReporter.report(-1, null, operation);
}
}
开发者ID:ldbc,项目名称:ldbc_snb_implementations,代码行数:25,代码来源:LdbcShortQuery5Handler.java
示例18: benchmarkTeacherThroughSection
import com.tinkerpop.gremlin.java.GremlinPipeline; //导入依赖的package包/类
void benchmarkTeacherThroughSection() {
logger.log(Level.INFO, "Starting...");
StopWatch bigWatch = new StopWatch();
for (int i = 0; i < ITERATIONS; ++i) {
StopWatch subWatch = new StopWatch();
pipe = new GremlinPipeline();
long students = pipe
.start(graph.getVertices("mongoid", "2012wl-f126bd7d-cfba-11e1-a172-024224a39f1b").iterator()
.next()).inE("teacherSection").outV().outE("studentSection").inV().count();
subWatch.stop();
logger.log(Level.INFO, "Found {0} students", "" + students);
times.add(subWatch.getEndTime());
}
bigWatch.stop();
logger.log(Level.INFO, "Total {0} \t Avg {1} ms", new String[] { bigWatch.inSeconds(), "" + averageTime() });
}
开发者ID:inbloom,项目名称:secure-data-service,代码行数:17,代码来源:TeacherStudentTraversal.java
示例19: benchmarkTeacherThroughCohort
import com.tinkerpop.gremlin.java.GremlinPipeline; //导入依赖的package包/类
void benchmarkTeacherThroughCohort() {
logger.log(Level.INFO, "Starting...");
StopWatch bigWatch = new StopWatch();
for (int i = 0; i < ITERATIONS; ++i) {
StopWatch subWatch = new StopWatch();
pipe = new GremlinPipeline();
long students = pipe
.start(graph.getVertices("mongoid", "2012zc-a9b37634-cfbb-11e1-a172-024224a39f1b").iterator()
.next()).inE("staffCohort").count();
subWatch.stop();
logger.log(Level.INFO, "Found {0} students", "" + students);
times.add(subWatch.getEndTime());
}
bigWatch.stop();
logger.log(Level.INFO, "Total {0} \t Avg {1} ms", new String[] { bigWatch.inSeconds(), "" + averageTime() });
}
开发者ID:inbloom,项目名称:secure-data-service,代码行数:17,代码来源:TeacherStudentTraversal.java
示例20: benchmarkTeacherThroughProgram
import com.tinkerpop.gremlin.java.GremlinPipeline; //导入依赖的package包/类
void benchmarkTeacherThroughProgram() {
logger.log(Level.INFO, "Starting...");
StopWatch bigWatch = new StopWatch();
for (int i = 0; i < ITERATIONS; ++i) {
StopWatch subWatch = new StopWatch();
pipe = new GremlinPipeline();
long students = pipe
.start(graph.getVertices("mongoid", "2012wo-a9d9e975-cfbb-11e1-a172-024224a39f1b").iterator()
.next()).inE("staffProgram").outV().outE("staffCohort").inV().count();
subWatch.stop();
logger.log(Level.INFO, "Found {0} students", "" + students);
times.add(subWatch.getEndTime());
}
bigWatch.stop();
logger.log(Level.INFO, "Total {0} \t Avg {1} ms", new String[] { bigWatch.inSeconds(), "" + averageTime() });
}
开发者ID:inbloom,项目名称:secure-data-service,代码行数:18,代码来源:TeacherStudentTraversal.java
注:本文中的com.tinkerpop.gremlin.java.GremlinPipeline类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论