當前位置: 首頁>>代碼示例>>Java>>正文


Java Edge類代碼示例

本文整理匯總了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 );
}
 
開發者ID:Ostrich-Emulators,項目名稱:semtool,代碼行數:25,代碼來源:GsonWriterTest.java

示例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();
	}
}
 
開發者ID:gentics,項目名稱:mesh,代碼行數:25,代碼來源:EdgeIndexPerformanceTest.java

示例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();
	}
}
 
開發者ID:gentics,項目名稱:mesh,代碼行數:18,代碼來源:EdgeIndexPerformanceTest.java

示例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");
			}
		}
	}
 
開發者ID:gentics,項目名稱:mesh,代碼行數:23,代碼來源:RemoveBogusWebrootProperty.java

示例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;
}
 
開發者ID:gentics,項目名稱:mesh,代碼行數:23,代碼來源:RootVertex.java

示例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;
}
 
開發者ID:gentics,項目名稱:mesh,代碼行數:24,代碼來源:JobRootImpl.java

示例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;
	}

}
 
開發者ID:gentics,項目名稱:mesh,代碼行數:29,代碼來源:AbstractGenericFieldContainerVertex.java

示例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);
}
 
開發者ID:gentics,項目名稱:mesh,代碼行數:20,代碼來源:BinaryRootImpl.java

示例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);
}
 
開發者ID:graben1437,項目名稱:titan0.5.4-hbase1.1.1-custom,代碼行數:24,代碼來源:VerticesMapTest.java

示例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;
	}
}
 
開發者ID:dpv91788,項目名稱:HBaseTinkerGraph,代碼行數:23,代碼來源:HbaseGraph.java

示例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;
}
 
開發者ID:graben1437,項目名稱:titan0.5.4-hbase1.1.1-custom,代碼行數:27,代碼來源:BaseTestNG.java

示例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);
}
 
開發者ID:graben1437,項目名稱:titan0.5.4-hbase1.1.1-custom,代碼行數:17,代碼來源:EdgeCopyMapReduce.java

示例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());
		}
	};
}
 
開發者ID:octopus-platform,項目名稱:bjoern,代碼行數:21,代碼來源:BjoernEdgeIterable.java

示例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;
}
 
開發者ID:octopus-platform,項目名稱:bjoern,代碼行數:26,代碼來源:DataDependencePlugin.java

示例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);
		}
	}
}
 
開發者ID:octopus-platform,項目名稱:bjoern,代碼行數:19,代碼來源:FunctionExportPlugin.java


注:本文中的com.tinkerpop.blueprints.Edge類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。