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


Java Edge类代码示例

本文整理汇总了Java中org.apache.tinkerpop.gremlin.structure.Edge的典型用法代码示例。如果您正苦于以下问题:Java Edge类的具体用法?Java Edge怎么用?Java Edge使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: testReturnOutThenInOnVertexIterator

import org.apache.tinkerpop.gremlin.structure.Edge; //导入依赖的package包/类
@Test
public void testReturnOutThenInOnVertexIterator() {
  UUID factID = mockFact(null);
  UUID inVertexObjectID = mockObject();
  UUID outVertexObjectID = mockObject();
  Edge edge = new FactEdge(getActGraph(), factID, inVertexObjectID, outVertexObjectID);

  assertEquals(outVertexObjectID, edge.outVertex().id());
  assertEquals(inVertexObjectID, edge.inVertex().id());

  Iterator<Vertex> vertices = edge.vertices(Direction.BOTH);
  assertTrue(vertices.hasNext());
  assertEquals(outVertexObjectID, vertices.next().id());
  assertTrue(vertices.hasNext());
  assertEquals(inVertexObjectID, vertices.next().id());
  assertFalse(vertices.hasNext());
}
 
开发者ID:mnemonic-no,项目名称:act-platform,代码行数:18,代码来源:FactEdgeTest.java

示例2: edges

import org.apache.tinkerpop.gremlin.structure.Edge; //导入依赖的package包/类
public Iterable<Edge> edges() {
	Iterable<Edge> in = null;
	Iterable<Edge> out = null;

	if(direction==Direction.IN || direction==Direction.BOTH) {
		if(vertex.getRole()==TripleComponentRole.OBJECT || vertex.getInternalId()<=vertex.getHDTGraph().getBaseGraph().getDictionary().getNshared()) {
			in = getEdges(new TripleID(0,0,vertex.getInternalId()));
		}
	}
	
	if(direction==Direction.OUT || direction==Direction.BOTH) {
		if(vertex.getRole()==TripleComponentRole.SUBJECT || vertex.getInternalId()<=vertex.getHDTGraph().getBaseGraph().getDictionary().getNshared()) {
			out = getEdges(new TripleID(vertex.getInternalId(),0,0));
		}
	}

	if(in!=null && out!=null) {
		return IteratorConcat.concat(in, out);
	} else if(in!=null) {
		return in;
	} else if(out!=null){
		return out;
	}
	return Collections.emptySet();
}
 
开发者ID:rdfhdt,项目名称:hdt-gremlin,代码行数:26,代码来源:HDTVertexQuery.java

示例3: smallTest

import org.apache.tinkerpop.gremlin.structure.Edge; //导入依赖的package包/类
public static void smallTest(Graph graph) {
	Iterator<Vertex> it = graph.vertices();
	int i=0;
	while(i<100 && it.hasNext()) {
		Vertex v = it.next();
		System.out.println(v.id()+"/"+v.property("node"));
		i++;

	}
	
	// Iterate over Edges
	Iterator<Edge> it2 = graph.edges();
	i=0;
	while(i<100 && it2.hasNext()) {
		Edge e = it2.next();
		System.out.println(e);
		i++;
	}
}
 
开发者ID:rdfhdt,项目名称:hdt-gremlin,代码行数:20,代码来源:HDTtoGremlin.java

示例4: TinkerGraph

import org.apache.tinkerpop.gremlin.structure.Edge; //导入依赖的package包/类
/**
 * An empty private constructor that initializes {@link TinkerGraph}.
 */
private TinkerGraph(final Configuration configuration, boolean usesSpecializedElements) {
    this.configuration = configuration;
    this.usesSpecializedElements = usesSpecializedElements;
    vertexIdManager = selectIdManager(configuration, GREMLIN_TINKERGRAPH_VERTEX_ID_MANAGER, Vertex.class);
    edgeIdManager = selectIdManager(configuration, GREMLIN_TINKERGRAPH_EDGE_ID_MANAGER, Edge.class);
    vertexPropertyIdManager = selectIdManager(configuration, GREMLIN_TINKERGRAPH_VERTEX_PROPERTY_ID_MANAGER, VertexProperty.class);
    defaultVertexPropertyCardinality = VertexProperty.Cardinality.valueOf(
            configuration.getString(GREMLIN_TINKERGRAPH_DEFAULT_VERTEX_PROPERTY_CARDINALITY, VertexProperty.Cardinality.single.name()));

    graphLocation = configuration.getString(GREMLIN_TINKERGRAPH_GRAPH_LOCATION, null);
    graphFormat = configuration.getString(GREMLIN_TINKERGRAPH_GRAPH_FORMAT, null);

    if ((graphLocation != null && null == graphFormat) || (null == graphLocation && graphFormat != null))
        throw new IllegalStateException(String.format("The %s and %s must both be specified if either is present",
                GREMLIN_TINKERGRAPH_GRAPH_LOCATION, GREMLIN_TINKERGRAPH_GRAPH_FORMAT));

    if (graphLocation != null) loadGraph();
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:22,代码来源:TinkerGraph.java

示例5: createElementIterator

import org.apache.tinkerpop.gremlin.structure.Edge; //导入依赖的package包/类
private <T extends Element> Iterator<T> createElementIterator(final Class<T> clazz, final Map<Object, T> elements,
                                                              final IdManager idManager,
                                                              final Object... ids) {
    final Iterator<T> iterator;
    if (0 == ids.length) {
        iterator = elements.values().iterator();
    } else {
        final List<Object> idList = Arrays.asList(ids);
        validateHomogenousIds(idList);

        // if the type is of Element - have to look each up because it might be an Attachable instance or
        // other implementation. the assumption is that id conversion is not required for detached
        // stuff - doesn't seem likely someone would detach a Titan vertex then try to expect that
        // vertex to be findable in OrientDB
        return clazz.isAssignableFrom(ids[0].getClass()) ?
                IteratorUtils.filter(IteratorUtils.map(idList, id -> elements.get(clazz.cast(id).id())).iterator(), Objects::nonNull)
                : IteratorUtils.filter(IteratorUtils.map(idList, id -> elements.get(idManager.convert(id))).iterator(), Objects::nonNull);
    }
    return TinkerHelper.inComputerMode(this) ?
            (Iterator<T>) (clazz.equals(Vertex.class) ?
                    IteratorUtils.filter((Iterator<Vertex>) iterator, t -> this.graphComputerView.legalVertex(t)) :
                    IteratorUtils.filter((Iterator<Edge>) iterator, t -> this.graphComputerView.legalEdge(t.outVertex(), t))) :
            iterator;
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:25,代码来源:TinkerGraph.java

示例6: addEdge

import org.apache.tinkerpop.gremlin.structure.Edge; //导入依赖的package包/类
protected static Edge addEdge(final TinkerGraph graph, final TinkerVertex outVertex, final TinkerVertex inVertex, final String label, final Object... keyValues) {
    ElementHelper.validateLabel(label);
    ElementHelper.legalPropertyKeyValueArray(keyValues);

    Object idValue = graph.edgeIdManager.convert(ElementHelper.getIdValue(keyValues).orElse(null));

    final Edge edge;
    if (null != idValue) {
        if (graph.edges.containsKey(idValue))
            throw Graph.Exceptions.edgeWithIdAlreadyExists(idValue);
    } else {
        idValue = graph.edgeIdManager.getNextId(graph);
    }

    edge = new TinkerEdge(idValue, outVertex, label, inVertex);
    ElementHelper.attachProperties(edge, keyValues);
    graph.edges.put(edge.id(), edge);
    TinkerHelper.addOutEdge(outVertex, label, edge);
    TinkerHelper.addInEdge(inVertex, label, edge);
    return edge;

}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:23,代码来源:TinkerHelper.java

示例7: getEdges

import org.apache.tinkerpop.gremlin.structure.Edge; //导入依赖的package包/类
public static Iterator<TinkerEdge> getEdges(final TinkerVertex vertex, final Direction direction, final String... edgeLabels) {
    final List<Edge> edges = new ArrayList<>();
    if (direction.equals(Direction.OUT) || direction.equals(Direction.BOTH)) {
        if (vertex.outEdges != null) {
            if (edgeLabels.length == 0)
                vertex.outEdges.values().forEach(edges::addAll);
            else if (edgeLabels.length == 1)
                edges.addAll(vertex.outEdges.getOrDefault(edgeLabels[0], Collections.emptySet()));
            else
                Stream.of(edgeLabels).map(vertex.outEdges::get).filter(Objects::nonNull).forEach(edges::addAll);
        }
    }
    if (direction.equals(Direction.IN) || direction.equals(Direction.BOTH)) {
        if (vertex.inEdges != null) {
            if (edgeLabels.length == 0)
                vertex.inEdges.values().forEach(edges::addAll);
            else if (edgeLabels.length == 1)
                edges.addAll(vertex.inEdges.getOrDefault(edgeLabels[0], Collections.emptySet()));
            else
                Stream.of(edgeLabels).map(vertex.inEdges::get).filter(Objects::nonNull).forEach(edges::addAll);
        }
    }
    return (Iterator) edges.iterator();
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:25,代码来源:TinkerHelper.java

示例8: BitsyGraph

import org.apache.tinkerpop.gremlin.structure.Edge; //导入依赖的package包/类
/** 
 * Constructor with a Configuration object with String dbPath, boolean allowFullGraphScans, long txLogThreshold and double reorgFactor 
 */
public BitsyGraph(Configuration configuration) {
	this(Paths.get(configuration.getString(DB_PATH_KEY)),
		configuration.getBoolean(ALLOW_FULL_GRAPH_SCANS_KEY, Boolean.TRUE),
		configuration.getLong(TX_LOG_THRESHOLD_KEY, DEFAULT_TX_LOG_THRESHOLD),
		configuration.getDouble(REORG_FACTOR_KEY, DEFAULT_REORG_FACTOR),
		configuration.getBoolean(CREATE_DIR_IF_MISSING_KEY, false));
	String isoLevelStr = configuration.getString(DEFAULT_ISOLATION_LEVEL_KEY);
	if (isoLevelStr != null) {
		setDefaultIsolationLevel(BitsyIsolationLevel.valueOf(isoLevelStr));
	}
	String vertexIndices = configuration.getString(VERTEX_INDICES_KEY);
	if (vertexIndices != null) {
		createIndices(Vertex.class, vertexIndices);
	}
	String edgeIndices = configuration.getString(EDGE_INDICES_KEY);
	if (edgeIndices != null) {
		createIndices(Edge.class, edgeIndices);
	}
	this.origConfig = configuration;
}
 
开发者ID:lambdazen,项目名称:bitsy,代码行数:24,代码来源:BitsyGraph.java

示例9: serialize

import org.apache.tinkerpop.gremlin.structure.Edge; //导入依赖的package包/类
@Override
public void serialize(final TinkerGraph graph, final JsonGenerator jsonGenerator, final SerializerProvider serializerProvider)
        throws IOException {
    jsonGenerator.writeStartObject();
    jsonGenerator.writeFieldName(GraphSONTokens.VERTICES);
    jsonGenerator.writeStartArray();

    final Iterator<Vertex> vertices = graph.vertices();
    while (vertices.hasNext()) {
        serializerProvider.defaultSerializeValue(vertices.next(), jsonGenerator);
    }

    jsonGenerator.writeEndArray();
    jsonGenerator.writeFieldName(GraphSONTokens.EDGES);
    jsonGenerator.writeStartArray();

    final Iterator<Edge> edges = graph.edges();
    while (edges.hasNext()) {
        serializerProvider.defaultSerializeValue(edges.next(), jsonGenerator);
    }

    jsonGenerator.writeEndArray();
    jsonGenerator.writeEndObject();
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:25,代码来源:TinkerIoRegistryV2d0.java

示例10: deserialize

import org.apache.tinkerpop.gremlin.structure.Edge; //导入依赖的package包/类
@Override
public TinkerGraph deserialize(final JsonParser jsonParser, final DeserializationContext deserializationContext) throws IOException, JsonProcessingException {
    final Configuration conf = new BaseConfiguration();
    conf.setProperty("gremlin.tinkergraph.defaultVertexPropertyCardinality", "list");
    final TinkerGraph graph = TinkerGraph.open(conf);

    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
        if (jsonParser.getCurrentName().equals("vertices")) {
            while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                if (jsonParser.currentToken() == JsonToken.START_OBJECT) {
                    final DetachedVertex v = (DetachedVertex) deserializationContext.readValue(jsonParser, Vertex.class);
                    v.attach(Attachable.Method.getOrCreate(graph));
                }
            }
        } else if (jsonParser.getCurrentName().equals("edges")) {
            while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                if (jsonParser.currentToken() == JsonToken.START_OBJECT) {
                    final DetachedEdge e = (DetachedEdge) deserializationContext.readValue(jsonParser, Edge.class);
                    e.attach(Attachable.Method.getOrCreate(graph));
                }
            }
        }
    }

    return graph;
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:27,代码来源:TinkerIoRegistryV2d0.java

示例11: getEdge

import org.apache.tinkerpop.gremlin.structure.Edge; //导入依赖的package包/类
private Edge getEdge(Object id) {
    if (id == null) {
        throw new IllegalArgumentException("The edge ID passed to getEdge() is null");
    }
    
    if (id instanceof UUID) {
        return getTx().getEdge((UUID)id);
    } else if (id instanceof String) {
        // Get the UUID from the string representation -- may fail
        UUID uuid;
        try {
            uuid = UUID.fromString((String)id);
        } catch (IllegalArgumentException e) {
            // Decoding failed
            return null;
        }
        
        return getTx().getEdge(uuid);
    } else if (id instanceof Edge) {
		return getTx().getEdge((UUID)((Edge)id).id());
    } else {
        // Wrong type
        return null;
    }
}
 
开发者ID:lambdazen,项目名称:bitsy,代码行数:26,代码来源:BitsyGraph.java

示例12: deserializersTestsEdge

import org.apache.tinkerpop.gremlin.structure.Edge; //导入依赖的package包/类
@Test
public void deserializersTestsEdge() {
    final TinkerGraph tg = TinkerGraph.open();

    final Vertex v = tg.addVertex("vertexTest");
    final Vertex v2 = tg.addVertex("vertexTest");

    final Edge ed = v.addEdge("knows", v2, "time", LocalDateTime.now());

    final GraphWriter writer = getWriter(defaultMapperV2d0);
    final GraphReader reader = getReader(defaultMapperV2d0);

    try (final ByteArrayOutputStream out = new ByteArrayOutputStream()) {
        writer.writeObject(out, ed);
        final String json = out.toString();

        // Object works, because there's a type in the payload now
        // Edge.class would work as well
        // Anything else would not because we check the type in param here with what's in the JSON, for safety.
        final Edge eRead = (Edge)reader.readObject(new ByteArrayInputStream(json.getBytes()), Object.class);
        assertEquals(ed, eRead);
    } catch (IOException e) {
        e.printStackTrace();
        fail("Should not have thrown exception: " + e.getMessage());
    }
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:27,代码来源:TinkerGraphGraphSONSerializerV2d0Test.java

示例13: createKeyIndex

import org.apache.tinkerpop.gremlin.structure.Edge; //导入依赖的package包/类
@Override
public <T extends Element> void createKeyIndex(String key, Class<T> elementType) {
    beginWrite();

    try {
        if (elementType == null) {
            throw new IllegalArgumentException("Element type in createKeyIndex() can not be null");
        } else if (elementType.equals(Vertex.class)) {
            vIndexMap.createKeyIndex(key, getAllVertices().iterator());
        } else if (elementType.equals(Edge.class)) {
            eIndexMap.createKeyIndex(key, getAllEdges().iterator());
        } else {
            throw new BitsyException(BitsyErrorCodes.UNSUPPORTED_INDEX_TYPE, "Encountered index type: " + elementType);
        }
    } finally {
        endWrite();
    }
}
 
开发者ID:lambdazen,项目名称:bitsy,代码行数:19,代码来源:MemoryGraphStore.java

示例14: dropKeyIndex

import org.apache.tinkerpop.gremlin.structure.Edge; //导入依赖的package包/类
@Override
public <T extends Element> void dropKeyIndex(String key, Class<T> elementType) {
    beginWrite();

    try {
        if (elementType == null) {
            throw new IllegalArgumentException("Element type in dropKeyIndex() can not be null");
        } else if (elementType.equals(Vertex.class)) {
            vIndexMap.dropKeyIndex(key);
        } else if (elementType.equals(Edge.class)) {
            eIndexMap.dropKeyIndex(key);
        } else {
            throw new BitsyException(BitsyErrorCodes.UNSUPPORTED_INDEX_TYPE, "Encountered index type: " + elementType);
        }
    } finally {
        endWrite();
    }
}
 
开发者ID:lambdazen,项目名称:bitsy,代码行数:19,代码来源:MemoryGraphStore.java

示例15: shouldRemoveEdgeFromAnIndex

import org.apache.tinkerpop.gremlin.structure.Edge; //导入依赖的package包/类
@Test
public void shouldRemoveEdgeFromAnIndex() {
    final TinkerGraph g = TinkerGraph.open();
    g.createIndex("oid", Edge.class);

    final Vertex v = g.addVertex();
    v.addEdge("friend", v, "oid", "1", "weight", 0.5f);
    final Edge e = v.addEdge("friend", v, "oid", "1", "weight", 0.5f);
    v.addEdge("friend", v, "oid", "2", "weight", 0.6f);

    // a tricky way to evaluate if indices are actually being used is to pass a fake BiPredicate to has()
    // to get into the Pipeline and evaluate what's going through it.  in this case, we know that at index
    // is used because only oid 1 should pass through the pipeline due to the inclusion of the
    // key index lookup on "oid".  If there's an weight of something other than 0.5f in the pipeline being
    // evaluated then something is wrong.
    assertEquals(new Long(2), g.traversal().E().has("weight", P.test((t, u) -> {
        assertEquals(0.5f, t);
        return true;
    }, 0.5)).has("oid", "1").count().next());

    e.remove();
    assertEquals(new Long(1), g.traversal().E().has("weight", P.test((t, u) -> {
        assertEquals(0.5f, t);
        return true;
    }, 0.5)).has("oid", "1").count().next());
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:27,代码来源:TinkerGraphTest.java


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