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


Java ElementHelper类代码示例

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


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

示例1: addEdge

import org.apache.tinkerpop.gremlin.structure.util.ElementHelper; //导入依赖的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

示例2: validateIds

import org.apache.tinkerpop.gremlin.structure.util.ElementHelper; //导入依赖的package包/类
/**
 * Helper to parse URIs from a list of element ids for lookup of
 * vertices or edges.
 * 
 * @see #vertices(Object...)
 * @see #edges(Object...)
 */
private List<URI> validateIds(final Object... elementIds) {
    ElementHelper.validateMixedElementIds(Element.class, elementIds);
    return Stream.of(elementIds)
            .map(elementId -> {
                if (elementId instanceof String) {
                    return (String) elementId;
                } else if (elementId instanceof Element) {
                    final Object id = ((Element) elementId).id();
                    if (id instanceof String) {
                        return (String) id;
                    }
                }
                throw new IllegalArgumentException(
                        "Unknown element id type: " + elementId + 
                        " ("+ elementId.getClass()+")");
            })
            .map(vf::elementURI)
            .collect(Collectors.toList());
}
 
开发者ID:blazegraph,项目名称:tinkerpop3,代码行数:27,代码来源:BlazeGraph.java

示例3: createMetadata

import org.apache.tinkerpop.gremlin.structure.util.ElementHelper; //导入依赖的package包/类
/**
 * If a metadata label is configured, read the vertex from the graph into a new BDIO metadata instance.
 */
public BdioMetadata createMetadata() {
    return topology().metadataLabel()
            .flatMap(label -> traversal().V().hasLabel(label).tryNext())
            .map(vertex -> {
                BdioMetadata metadata = new BdioMetadata();
                topology().identifierKey().ifPresent(key -> {
                    metadata.id(vertex.value(key));
                });
                try {
                    Object expandedMetadata = Iterables.getOnlyElement(mapper().expand(ElementHelper.propertyValueMap(vertex)), null);
                    if (expandedMetadata instanceof Map<?, ?>) {
                        ((Map<?, ?>) expandedMetadata).forEach((key, value) -> {
                            if (key instanceof String) {
                                metadata.put((String) key, value);
                            }
                        });
                    }
                } catch (JsonLdError e) {
                    // TODO How should we handle this?
                    e.printStackTrace();
                }
                return metadata;
            })
            .orElse(BdioMetadata.createRandomUUID());
}
 
开发者ID:blackducksoftware,项目名称:bdio,代码行数:29,代码来源:WriteGraphContext.java

示例4: addVertex

import org.apache.tinkerpop.gremlin.structure.util.ElementHelper; //导入依赖的package包/类
public Vertex addVertex(final Object... keyValues) {
    try {
        ElementHelper.legalPropertyKeyValueArray(keyValues);
        Object idValue = ElementHelper.getIdValue(keyValues).orElse(null);
        final String label = ElementHelper.getLabelValue(keyValues).orElse(Vertex.DEFAULT_LABEL);

        idValue = HBaseGraphUtils.generateIdIfNeeded(idValue);
        long now = System.currentTimeMillis();
        HBaseVertex vertex = new HBaseVertex(graph, idValue, label, now, now,
                HBaseGraphUtils.propertiesToMap(keyValues));
        vertex.validate();

        Iterator<IndexMetadata> indices = vertex.getIndices(OperationType.WRITE);
        indexVertex(vertex, indices);

        Creator creator = new VertexWriter(graph, vertex);
        if (verticesMutator != null) verticesMutator.mutate(getMutationList(creator.constructInsertions()));

        return vertex;
    } catch (IOException e) {
        throw new HBaseGraphException(e);
    }
}
 
开发者ID:rayokota,项目名称:hgraphdb,代码行数:24,代码来源:HBaseBulkLoader.java

示例5: property

import org.apache.tinkerpop.gremlin.structure.util.ElementHelper; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public <V> Property<V> property(String name, V value) {
    ElementHelper.validateProperty(name, value);
    // validate bolt support
    Neo4JBoltSupport.checkPropertyValue(value);
    // transaction should be ready for io operations
    graph.tx().readWrite();
    // property value for key
    Neo4JEdgeProperty<V> propertyValue = new Neo4JEdgeProperty<>(this, name, value);
    // update map
    properties.put(name, propertyValue);
    // set edge as dirty
    session.dirtyEdge(this);
    // update flag
    dirty = true;
    // return property
    return propertyValue;
}
 
开发者ID:SteelBridgeLabs,项目名称:neo4j-gremlin-bolt,代码行数:22,代码来源:Neo4JEdge.java

示例6: verticesInRange

import org.apache.tinkerpop.gremlin.structure.util.ElementHelper; //导入依赖的package包/类
public Iterator<Vertex> verticesInRange(String label, String key, Object inclusiveFrom, Object exclusiveTo) {
    ElementHelper.validateProperty(key, inclusiveFrom);
    ElementHelper.validateProperty(key, exclusiveTo);
    IndexMetadata index = graph.getIndex(OperationType.READ, ElementType.VERTEX, label, key);
    if (index != null) {
        LOGGER.debug("Using vertex index for ({}, {})", label, key);
        return graph.getVertexIndexModel().verticesInRange(label, index.isUnique(), key, inclusiveFrom, exclusiveTo);
    }
    final VertexReader parser = new VertexReader(graph);

    byte[] fromVal = ValueUtils.serializePropertyValue(graph, ElementType.VERTEX, label, key, inclusiveFrom);
    byte[] toVal = ValueUtils.serializePropertyValue(graph, ElementType.VERTEX, label, key, exclusiveTo);
    final byte[] keyBytes = Bytes.toBytes(key);
    Scan scan = getPropertyScan(label, keyBytes, fromVal, toVal);
    ResultScanner scanner = null;
    try {
        scanner = table.getScanner(scan);
        return HBaseGraphUtils.mapWithCloseAtEnd(scanner, parser::parse);
    } catch (IOException e) {
        throw new HBaseGraphException(e);
    }
}
 
开发者ID:rayokota,项目名称:hgraphdb,代码行数:23,代码来源:VertexModel.java

示例7: addVertex

import org.apache.tinkerpop.gremlin.structure.util.ElementHelper; //导入依赖的package包/类
@Override
public Vertex addVertex(final Object... keyValues) {
    ElementHelper.legalPropertyKeyValueArray(keyValues);
    Object idValue = ElementHelper.getIdValue(keyValues).orElse(null);
    final String label = ElementHelper.getLabelValue(keyValues).orElse(Vertex.DEFAULT_LABEL);

    idValue = HBaseGraphUtils.generateIdIfNeeded(idValue);
    long now = System.currentTimeMillis();
    HBaseVertex newVertex = new HBaseVertex(this, idValue, label, now, now, HBaseGraphUtils.propertiesToMap(keyValues));
    newVertex.validate();
    newVertex.writeToIndexModel();
    newVertex.writeToModel();

    Vertex vertex = findOrCreateVertex(idValue);
    ((HBaseVertex) vertex).copyFrom(newVertex);
    return vertex;
}
 
开发者ID:rayokota,项目名称:hgraphdb,代码行数:18,代码来源:HBaseGraph.java

示例8: edges

import org.apache.tinkerpop.gremlin.structure.util.ElementHelper; //导入依赖的package包/类
@Override
public Iterator<Edge> edges(final Object... edgeIds) {
    return null == this.starVertex ?
            Collections.emptyIterator() :
            Stream.concat(
                    null == this.starVertex.inEdges ? Stream.empty() : this.starVertex.inEdges.values().stream(),
                    null == this.starVertex.outEdges ? Stream.empty() : this.starVertex.outEdges.values().stream())
                    .flatMap(List::stream)
                    .filter(edge -> {
                        // todo: kinda fishy - need to better nail down how stuff should work here - none of these feel consistent right now.
                        if (edgeIds.length > 0 && edgeIds[0] instanceof Edge)
                            return ElementHelper.idExists(edge.id(), Stream.of(edgeIds).map(e -> ((Edge) e).id()).toArray());
                        else
                            return ElementHelper.idExists(edge.id(), edgeIds);
                    })
                    .iterator();
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:18,代码来源:StarGraph.java

示例9: properties

import org.apache.tinkerpop.gremlin.structure.util.ElementHelper; //导入依赖的package包/类
@Override
public <V> Iterator<VertexProperty<V>> properties(final String... propertyKeys) {
    if (null == this.vertexProperties || this.vertexProperties.isEmpty())
        return Collections.emptyIterator();
    else if (propertyKeys.length == 0)
        return (Iterator) this.vertexProperties.entrySet().stream()
                .flatMap(entry -> entry.getValue().stream())
                .iterator();
    else if (propertyKeys.length == 1)
        return (Iterator) this.vertexProperties.getOrDefault(propertyKeys[0], Collections.emptyList()).iterator();
    else
        return (Iterator) this.vertexProperties.entrySet().stream()
                .filter(entry -> ElementHelper.keyExists(entry.getKey(), propertyKeys))
                .flatMap(entry -> entry.getValue().stream())
                .iterator();
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:17,代码来源:StarGraph.java

示例10: addVertex

import org.apache.tinkerpop.gremlin.structure.util.ElementHelper; //导入依赖的package包/类
public Neo4JVertex addVertex(Object... keyValues) {
    Objects.requireNonNull(keyValues, "keyValues cannot be null");
    // verify parameters are key/value pairs
    ElementHelper.legalPropertyKeyValueArray(keyValues);
    // id cannot be present
    if (ElementHelper.getIdValue(keyValues).isPresent())
        throw Vertex.Exceptions.userSuppliedIdsNotSupported();
    // create vertex
    Neo4JVertex vertex = new Neo4JVertex(graph, this, vertexIdProvider, edgeIdProvider, Arrays.asList(ElementHelper.getLabelValue(keyValues).orElse(Vertex.DEFAULT_LABEL).split(Neo4JVertex.LabelDelimiter)));
    // add vertex to transient set (before processing properties to avoid having a transient vertex in update queue)
    transientVertices.add(vertex);
    // attach properties
    ElementHelper.attachProperties(vertex, keyValues);
    // check vertex has id
    Object id = vertex.id();
    if (id != null)
        transientVertexIndex.put(id, vertex);
    // return vertex
    return vertex;
}
 
开发者ID:SteelBridgeLabs,项目名称:neo4j-gremlin-bolt,代码行数:21,代码来源:Neo4JSession.java

示例11: addVertex

import org.apache.tinkerpop.gremlin.structure.util.ElementHelper; //导入依赖的package包/类
@Override
public Vertex addVertex(final Object... keyValues) {
    ElementHelper.legalPropertyKeyValueArray(keyValues);
    Object idValue = vertexIdManager.convert(ElementHelper.getIdValue(keyValues).orElse(null));
    final String label = ElementHelper.getLabelValue(keyValues).orElse(Vertex.DEFAULT_LABEL);

    if (null != idValue) {
        if (this.vertices.containsKey(idValue))
            throw Exceptions.vertexWithIdAlreadyExists(idValue);
    } else {
        idValue = vertexIdManager.getNextId(this);
    }

    final Vertex vertex = new TinkerVertex(idValue, label, this);
    this.vertices.put(vertex.id(), vertex);

    ElementHelper.attachProperties(vertex, VertexProperty.Cardinality.list, keyValues);
    return vertex;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:20,代码来源:TinkerGraph.java

示例12: property

import org.apache.tinkerpop.gremlin.structure.util.ElementHelper; //导入依赖的package包/类
@Override
public <V> Property<V> property(final String key, final V value) {
    if (this.removed) throw elementAlreadyRemoved(Edge.class, id);
    ElementHelper.validateProperty(key, value);
    final Property oldProperty = super.property(key);
    final Property<V> newProperty = new TinkerProperty<>(this, key, value);
    if (null == this.properties) this.properties = new HashMap<>();
    this.properties.put(key, newProperty);
    TinkerHelper.autoUpdateIndex(this, key, value, oldProperty.isPresent() ? oldProperty.value() : null);
    return newProperty;

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

示例13: properties

import org.apache.tinkerpop.gremlin.structure.util.ElementHelper; //导入依赖的package包/类
@Override
public <V> Iterator<Property<V>> properties(final String... propertyKeys) {
    if (null == this.properties) return Collections.emptyIterator();
    if (propertyKeys.length == 1) {
        final Property<V> property = this.properties.get(propertyKeys[0]);
        return null == property ? Collections.emptyIterator() : IteratorUtils.of(property);
    } else
        return (Iterator) this.properties.entrySet().stream().filter(entry -> ElementHelper.keyExists(entry.getKey(), propertyKeys)).map(entry -> entry.getValue()).collect(Collectors.toList()).iterator();
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:10,代码来源:TinkerEdge.java

示例14: TinkerVertexProperty

import org.apache.tinkerpop.gremlin.structure.util.ElementHelper; //导入依赖的package包/类
/**
 * This constructor will not validate the ID type against the {@link Graph}.  It will always just use a
 * {@code Long} for its identifier.  This is useful for constructing a {@link VertexProperty} for usage
 * with {@link TinkerGraphComputerView}.
 */
public TinkerVertexProperty(final TinkerVertex vertex, final String key, final V value, final Object... propertyKeyValues) {
    super(((TinkerGraph) vertex.graph()).vertexPropertyIdManager.getNextId((TinkerGraph) vertex.graph()), key);
    this.vertex = vertex;
    this.key = key;
    this.value = value;
    ElementHelper.legalPropertyKeyValueArray(propertyKeyValues);
    ElementHelper.attachProperties(this, propertyKeyValues);
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:14,代码来源:TinkerVertexProperty.java

示例15: properties

import org.apache.tinkerpop.gremlin.structure.util.ElementHelper; //导入依赖的package包/类
@Override
public <U> Iterator<Property<U>> properties(final String... propertyKeys) {
    if (null == this.properties) return Collections.emptyIterator();
    if (propertyKeys.length == 1) {
        final Property<U> property = this.properties.get(propertyKeys[0]);
        return null == property ? Collections.emptyIterator() : IteratorUtils.of(property);
    } else
        return (Iterator) this.properties.entrySet().stream().filter(entry -> ElementHelper.keyExists(entry.getKey(), propertyKeys)).map(entry -> entry.getValue()).collect(Collectors.toList()).iterator();
}
 
开发者ID:ShiftLeftSecurity,项目名称:tinkergraph-gremlin,代码行数:10,代码来源:TinkerVertexProperty.java


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