本文整理匯總了Java中com.tinkerpop.blueprints.Edge類的典型用法代碼示例。如果您正苦於以下問題:Java Edge類的具體用法?Java Edge怎麽用?Java Edge使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Edge類屬於com.tinkerpop.blueprints包,在下文中一共展示了Edge類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testGetGraphRelsOnly
import com.tinkerpop.blueprints.Edge; //導入依賴的package包/類
@Test
public void testGetGraphRelsOnly() {
LoadingSheetData rels
= LoadingSheetData.relsheet( "Human Being", "Car", "Purchased" );
rels.addProperties( Arrays.asList( "Price", "Date" ) );
ValueFactory vf = new ValueFactoryImpl();
Map<String, Value> props = new HashMap<>();
props.put( "Price", vf.createLiteral( "3000 USD" ) );
rels.add( "Yuri", "Yugo", props );
rels.add( "Yuri", "Pinto" );
Graph g = GsonWriter.getGraph( data );
int vsize = 0;
int esize = 0;
for ( Vertex v : g.getVertices() ) {
vsize++;
}
for ( Edge e : g.getEdges() ) {
esize++;
}
assertEquals( 3, vsize );
assertEquals( 2, esize );
}
示例2: testEdgeIndexViaRootGetEdgesWithoutTarget
import com.tinkerpop.blueprints.Edge; //導入依賴的package包/類
@Test
public void testEdgeIndexViaRootGetEdgesWithoutTarget() throws Exception {
OrientGraph g = factory.getTx();
try {
long start = System.currentTimeMillis();
for (int i = 0; i < nChecks; i++) {
OrientVertex randomDocument = items.get((int) (Math.random() * items.size()));
Iterable<Edge> edges = root.getEdges(Direction.OUT, "HAS_ITEM");
boolean found = false;
for (Edge edge : edges) {
if (edge.getVertex(Direction.IN).equals(randomDocument)) {
found = true;
break;
}
}
assertTrue(found);
}
long dur = System.currentTimeMillis() - start;
System.out.println("[root.getEdges - iterating] Duration: " + dur);
System.out.println("[root.getEdges - iterating] Duration per lookup: " + ((double) dur / (double) nChecks));
} finally {
g.shutdown();
}
}
示例3: testEdgeIndexViaRootGetEdges
import com.tinkerpop.blueprints.Edge; //導入依賴的package包/類
@Test
public void testEdgeIndexViaRootGetEdges() throws Exception {
OrientGraph g = factory.getTx();
try {
long start = System.currentTimeMillis();
for (int i = 0; i < nChecks; i++) {
OrientVertex randomDocument = items.get((int) (Math.random() * items.size()));
Iterable<Edge> edges = root.getEdges(randomDocument, Direction.OUT, "HAS_ITEM");
assertTrue(edges.iterator().hasNext());
}
long dur = System.currentTimeMillis() - start;
System.out.println("[root.getEdges] Duration: " + dur);
System.out.println("[root.getEdges] Duration per lookup: " + ((double) dur / (double) nChecks));
} finally {
g.shutdown();
}
}
示例4: migrateContainer
import com.tinkerpop.blueprints.Edge; //導入依賴的package包/類
private void migrateContainer(Vertex container) {
boolean isPublished = false;
Iterable<Edge> edges = container.getEdges(Direction.IN, "HAS_FIELD_CONTAINER");
// Check whether the container is published
for (Edge edge : edges) {
String type = edge.getProperty("edgeType");
if ("P".equals(type)) {
isPublished = true;
}
}
// The container is not published anywhere. Remove the bogus publish webroot info which otherwise causes publish webroot conflicts with new versions.
if (!isPublished) {
if (container.getProperty(WEBROOT_PUB) != null) {
log.info("Found inconsistency on container {" + container.getProperty("uuid") + "}");
container.removeProperty(WEBROOT_PUB);
log.info("Inconsistency fixed");
}
}
}
示例5: findByUuid
import com.tinkerpop.blueprints.Edge; //導入依賴的package包/類
/**
* Find the element with the given uuid.
*
* @param uuid
* Uuid of the element to be located
* @return Found element or null if the element could not be located
*/
default public T findByUuid(String uuid) {
FramedGraph graph = Tx.getActive().getGraph();
// 1. Find the element with given uuid within the whole graph
Iterator<Vertex> it = database().getVertices(getPersistanceClass(), new String[] { MeshVertex.UUID_KEY }, new String[] { uuid });
if (it.hasNext()) {
Vertex potentialElement = it.next();
// 2. Use the edge index to determine whether the element is part of this root vertex
Iterable<Edge> edges = graph.getEdges("e." + getRootLabel().toLowerCase() + "_inout", database().createComposedIndexKey(potentialElement
.getId(), getId()));
if (edges.iterator().hasNext()) {
return graph.frameElementExplicit(potentialElement, getPersistanceClass());
}
}
return null;
}
示例6: findByUuid
import com.tinkerpop.blueprints.Edge; //導入依賴的package包/類
/**
* Find the element with the given uuid.
*
* @param uuid
* Uuid of the element to be located
* @return Found element or null if the element could not be located
*/
public Job findByUuid(String uuid) {
FramedGraph graph = Tx.getActive().getGraph();
// 1. Find the element with given uuid within the whole graph
Iterator<Vertex> it = database().getVertices(MeshVertexImpl.class, new String[] { "uuid" }, new String[] { uuid });
if (it.hasNext()) {
Vertex potentialElement = it.next();
// 2. Use the edge index to determine whether the element is part of this root vertex
Iterable<Edge> edges = graph.getEdges("e." + getRootLabel().toLowerCase() + "_inout",
database().createComposedIndexKey(potentialElement.getId(), getId()));
if (edges.iterator().hasNext()) {
// Don't frame explicitly since multiple types can be returned
return graph.frameElement(potentialElement, getPersistanceClass());
}
}
return null;
}
示例7: getGraphFieldContainer
import com.tinkerpop.blueprints.Edge; //導入依賴的package包/類
/**
* Locate the field container using the provided information.
*
* @param languageTag
* Language tag of the field container
* @param releaseUuid
* Optional release to search within
* @param type
* Optional type of the field container (published, draft)
* @param classOfU
* @return
*/
protected <U extends BasicFieldContainer> U getGraphFieldContainer(String languageTag, String releaseUuid, ContainerType type,
Class<U> classOfU) {
Database db = MeshInternal.get().database();
FramedGraph graph = Tx.getActive().getGraph();
Iterable<Edge> edges = graph.getEdges("e." + HAS_FIELD_CONTAINER.toLowerCase() + "_release_type_lang", db.createComposedIndexKey(getId(),
releaseUuid, type.getCode(), languageTag));
Iterator<Edge> it = edges.iterator();
if (it.hasNext()) {
Vertex in = it.next().getVertex(IN);
return graph.frameElementExplicit(in, classOfU);
} else {
return null;
}
}
示例8: findByHash
import com.tinkerpop.blueprints.Edge; //導入依賴的package包/類
@Override
public Binary findByHash(String hash) {
FramedGraph graph = Tx.getActive().getGraph();
// 1. Find the element with given uuid within the whole graph
Iterator<Vertex> it = database().getVertices(getPersistanceClass(), new String[] { Binary.SHA512SUM_KEY }, new String[] { hash });
if (it.hasNext()) {
Vertex potentialElement = it.next();
// 2. Use the edge index to determine whether the element is part of this root vertex
Iterable<Edge> edges = graph.getEdges("e." + getRootLabel().toLowerCase() + "_inout", database().createComposedIndexKey(potentialElement
.getId(), getId()));
if (edges.iterator().hasNext()) {
return graph.frameElementExplicit(potentialElement, getPersistanceClass());
}
}
return null;
// TODO use index
// return out(HAS_BINARY).has(Binary.SHA512SUM_KEY, hash).nextOrDefaultExplicit(BinaryImpl.class, null);
}
示例9: testVerticesWithPaths
import com.tinkerpop.blueprints.Edge; //導入依賴的package包/類
public void testVerticesWithPaths() throws Exception {
Configuration config = new Configuration();
config.setBoolean(Tokens.TITAN_HADOOP_PIPELINE_TRACK_PATHS, true);
mapReduceDriver.withConfiguration(config);
Map<Long, FaunusVertex> graph = runWithGraph(generateGraph(BaseTest.ExampleGraph.TINKERGRAPH, config), mapReduceDriver);
assertEquals(graph.size(), 6);
for (FaunusVertex vertex : graph.values()) {
assertEquals(vertex.pathCount(), 1);
assertEquals(vertex.getPaths().get(0).size(), 1);
assertEquals(vertex.getPaths().get(0).get(0).getId(), vertex.getLongId());
for (Edge edge : vertex.getEdges(Direction.BOTH)) {
assertEquals(((StandardFaunusEdge) edge).pathCount(), 0);
}
}
assertEquals(DEFAULT_COMPAT.getCounter(mapReduceDriver, VerticesMap.Counters.EDGES_PROCESSED), 12);
assertEquals(DEFAULT_COMPAT.getCounter(mapReduceDriver, VerticesMap.Counters.VERTICES_PROCESSED), 6);
identicalStructure(graph, ExampleGraph.TINKERGRAPH);
}
示例10: getEdges
import com.tinkerpop.blueprints.Edge; //導入依賴的package包/類
public Iterable<Edge> getEdges(String key, Object value) {
try {
Scan scan = new Scan(Bytes.toBytes(this.graphName+"_"+key), this.getEndKey(Bytes.toBytes(this.graphName+"_"+key)));
scan.addFamily(Bytes.toBytes("edge"));
scan.setFilter(new ValueFilter(CompareOp.EQUAL, new BinaryComparator(Bytes.toBytes(String.valueOf(value)))));
return new HbaseIterable<Edge>(scan, HbaseGraphUtils.PROPERTIESTABLENAME, hbaseConf) {
@Override
public Edge next(Result result) {
for(Cell cell : result.listCells()) {
String id = Bytes.toString(CellUtil.cloneQualifier(cell));
return new HbaseEdge(id, graphName, hbaseConf);
}
return null;
}
};
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
return null;
}
}
示例11: startPath
import com.tinkerpop.blueprints.Edge; //導入依賴的package包/類
public static Map<Long, FaunusVertex> startPath(final Map<Long, FaunusVertex> graph, final Class<? extends Element> klass, final long... ids) {
if (ids.length == 0) {
for (FaunusVertex vertex : graph.values()) {
if (klass.equals(Vertex.class)) {
vertex.startPath();
} else if (klass.equals(Edge.class)) {
for (Edge edge : vertex.getEdges(Direction.BOTH)) {
((StandardFaunusEdge) edge).startPath();
}
} else {
throw new IllegalArgumentException("It can only be either edge or vertex, not both");
}
}
} else {
if (klass.equals(Edge.class))
throw new IllegalArgumentException("Currently no support for starting a path on a particular set of edges (only all edges)");
for (long id : ids) {
if (graph.get(id).hasPaths())
graph.get(id).incrPath(1);
else
graph.get(id).startPath();
}
}
return graph;
}
示例12: map
import com.tinkerpop.blueprints.Edge; //導入依賴的package包/類
@Override
public void map(final NullWritable key, final FaunusVertex value, final Mapper<NullWritable, FaunusVertex, LongWritable, Holder<FaunusVertex>>.Context context) throws IOException, InterruptedException {
long edgesInverted = 0;
for (final Edge edge : value.getEdges(this.direction)) {
final long id = (Long) edge.getVertex(this.direction.opposite()).getId();
final FaunusVertex shellVertex = new FaunusVertex(faunusConf, id);
this.longWritable.set(id);
shellVertex.addEdge(this.direction.opposite(), (StandardFaunusEdge) edge);
context.write(this.longWritable, this.vertexHolder.set('s', shellVertex));
edgesInverted++;
}
this.longWritable.set(value.getLongId());
context.write(this.longWritable, this.vertexHolder.set('r', value));
DEFAULT_COMPAT.incrementContextCounter(context, Counters.EDGES_COPIED, edgesInverted);
}
示例13: iterator
import com.tinkerpop.blueprints.Edge; //導入依賴的package包/類
@Override
public Iterator<Edge> iterator()
{
return new Iterator<Edge>()
{
final Iterator<Edge> baseIterable = iterable.iterator();
@Override
public boolean hasNext()
{
return baseIterable.hasNext();
}
@Override
public Edge next()
{
return new BjoernEdge(baseIterable.next());
}
};
}
示例14: killedDefinitions
import com.tinkerpop.blueprints.Edge; //導入依賴的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;
}
示例15: copyEdge
import com.tinkerpop.blueprints.Edge; //導入依賴的package包/類
private static void copyEdge(Graph graph, Edge edge)
{
Object id = edge.getId();
if (graph.getEdge(id) != null)
{
return;
}
Vertex src = graph.getVertex(edge.getVertex(Direction.OUT).getId());
Vertex dst = graph.getVertex(edge.getVertex(Direction.IN).getId());
if (src != null && dst != null)
{
Edge e = GraphHelper.addEdge(graph, id, src, dst, edge.getLabel());
if (e != null)
{
ElementHelper.copyProperties(edge, e);
}
}
}