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


Java ElementHelper.attachProperties方法代码示例

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


在下文中一共展示了ElementHelper.attachProperties方法的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: 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

示例3: 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 LiteVertex(idValue, label, this);
    insertVertexIntoRedis(vertex, this, keyValues);
    ElementHelper.attachProperties(vertex, VertexProperty.Cardinality.list, keyValues);
    return vertex;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:18,代码来源:LiteGraph.java

示例4: 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

示例5: 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

示例6: addVertex

import org.apache.tinkerpop.gremlin.structure.util.ElementHelper; //导入方法依赖的package包/类
@Override
public Vertex addVertex(final Object... keyValues) {
    if (null == this.starVertex) {
        ElementHelper.legalPropertyKeyValueArray(keyValues);
        this.starVertex = new StarVertex(ElementHelper.getIdValue(keyValues).orElse(this.nextId()), ElementHelper.getLabelValue(keyValues).orElse(Vertex.DEFAULT_LABEL));
        ElementHelper.attachProperties(this.starVertex, VertexProperty.Cardinality.list, keyValues); // TODO: is this smart? I say no... cause vertex property ids are not preserved.
        return this.starVertex;
    } else
        return new StarAdjacentVertex(ElementHelper.getIdValue(keyValues).orElse(this.nextId()));
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:11,代码来源:StarGraph.java

示例7: addOutEdge

import org.apache.tinkerpop.gremlin.structure.util.ElementHelper; //导入方法依赖的package包/类
Edge addOutEdge(final String label, final Vertex inVertex, final Object... keyValues) {
    ElementHelper.validateLabel(label);
    ElementHelper.legalPropertyKeyValueArray(keyValues);
    if (null == this.outEdges)
        this.outEdges = new HashMap<>();
    List<Edge> outE = this.outEdges.get(label);
    if (null == outE) {
        outE = new ArrayList<>();
        this.outEdges.put(label, outE);
    }
    final StarEdge outEdge = new StarOutEdge(ElementHelper.getIdValue(keyValues).orElse(nextId()), label, inVertex.id());
    ElementHelper.attachProperties(outEdge, keyValues);
    outE.add(outEdge);
    return outEdge;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:16,代码来源:StarGraph.java

示例8: addInEdge

import org.apache.tinkerpop.gremlin.structure.util.ElementHelper; //导入方法依赖的package包/类
Edge addInEdge(final String label, final Vertex outVertex, final Object... keyValues) {
    ElementHelper.validateLabel(label);
    ElementHelper.legalPropertyKeyValueArray(keyValues);
    if (null == this.inEdges)
        this.inEdges = new HashMap<>();
    List<Edge> inE = this.inEdges.get(label);
    if (null == inE) {
        inE = new ArrayList<>();
        this.inEdges.put(label, inE);
    }
    final StarEdge inEdge = new StarInEdge(ElementHelper.getIdValue(keyValues).orElse(nextId()), label, outVertex.id());
    ElementHelper.attachProperties(inEdge, keyValues);
    inE.add(inEdge);
    return inEdge;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:16,代码来源:StarGraph.java

示例9: property

import org.apache.tinkerpop.gremlin.structure.util.ElementHelper; //导入方法依赖的package包/类
@Override
public <V> VertexProperty<V> property(final VertexProperty.Cardinality cardinality, final String key, V value, final Object... keyValues) {
    ElementHelper.legalPropertyKeyValueArray(keyValues);
    if (null == this.vertexProperties)
        this.vertexProperties = new HashMap<>();
    final List<VertexProperty> list = cardinality.equals(VertexProperty.Cardinality.single) ? new ArrayList<>(1) : this.vertexProperties.getOrDefault(key, new ArrayList<>());
    final VertexProperty<V> vertexProperty = new StarVertexProperty<>(ElementHelper.getIdValue(keyValues).orElse(nextId()), key, value);
    ElementHelper.attachProperties(vertexProperty, keyValues);
    list.add(vertexProperty);
    this.vertexProperties.put(key, list);
    return vertexProperty;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:13,代码来源:StarGraph.java

示例10: property

import org.apache.tinkerpop.gremlin.structure.util.ElementHelper; //导入方法依赖的package包/类
@Override
public <V> VertexProperty<V> property(final VertexProperty.Cardinality cardinality, final String key, final V value, final Object... keyValues) {
    if (this.removed) throw elementAlreadyRemoved(Vertex.class, id);
//    ElementHelper.legalPropertyKeyValueArray(keyValues);
//    ElementHelper.validateProperty(key, value);
    final Optional<VertexProperty<V>> optionalVertexProperty = ElementHelper.stageVertexProperty(this, cardinality, key, value, keyValues);
    if (optionalVertexProperty.isPresent()) return optionalVertexProperty.get();

    final VertexProperty<V> vertexProperty = new LiteVertexProperty(this, key, value, keyValues);// later:property ignore
    //new TinkerVertexProperty<V>(idValue, this, key, value);

  //  if (null == this.properties) this.properties = new HashMap<>();
    final List<VertexProperty> list = new ArrayList<>();//this.properties.getOrDefault(key, new ArrayList<>());

    list.add(vertexProperty);
    this.properties.put(key, list);

    if (keyValues.length != 0)
        ElementHelper.attachProperties(vertexProperty, keyValues);

    insertProperty(VERTEX_PROPERTIES + this.id(), key, value);
    if (keyValues.length != 0) {
        for (int i = 0; i < keyValues.length; i += 2) {
            insertProperty(VERTEX_PROPERTIES + this.id(), keyValues[i].toString(), keyValues[i + 1]);
        }
    }
    //insertProperties(this, keyValues);

    return vertexProperty;

}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:32,代码来源:LiteVertex.java

示例11: LiteVertexProperty

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 LiteVertexProperty(final LiteVertex vertex, final String key, final V value, final Object... propertyKeyValues) {
    super(((LiteGraph) vertex.graph()).vertexPropertyIdManager.getNextId((LiteGraph) vertex.graph()), key);
    this.vertex = vertex;
    this.key = key;
    this.value = value;
    ElementHelper.legalPropertyKeyValueArray(propertyKeyValues);
    ElementHelper.attachProperties(this, propertyKeyValues);
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:14,代码来源:LiteVertexProperty.java

示例12: addVertex

import org.apache.tinkerpop.gremlin.structure.util.ElementHelper; //导入方法依赖的package包/类
@Override
public Vertex addVertex(final Object... keyValues) {
    ElementHelper.legalPropertyKeyValueArray(keyValues);
    if (ElementHelper.getIdValue(keyValues).isPresent())
        throw Vertex.Exceptions.userSuppliedIdsNotSupported();
    this.tx().readWrite();
    final Neo4jVertex vertex = new Neo4jVertex(this.baseGraph.createNode(ElementHelper.getLabelValue(keyValues).orElse(Vertex.DEFAULT_LABEL).split(Neo4jVertex.LABEL_DELIMINATOR)), this);
    ElementHelper.attachProperties(vertex, keyValues);
    return vertex;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:11,代码来源:Neo4jGraph.java

示例13: addEdge

import org.apache.tinkerpop.gremlin.structure.util.ElementHelper; //导入方法依赖的package包/类
@Override
public Edge addEdge(final String label, final Vertex inVertex, final Object... keyValues) {
    if (null == inVertex) throw Graph.Exceptions.argumentCanNotBeNull("inVertex");
    ElementHelper.validateLabel(label);
    ElementHelper.legalPropertyKeyValueArray(keyValues);
    if (ElementHelper.getIdValue(keyValues).isPresent())
        throw Edge.Exceptions.userSuppliedIdsNotSupported();

    this.graph.tx().readWrite();
    final Neo4jNode node = (Neo4jNode) this.baseElement;
    final Neo4jEdge edge = new Neo4jEdge(node.connectTo(((Neo4jVertex) inVertex).getBaseVertex(), label), this.graph);
    ElementHelper.attachProperties(edge, keyValues);
    return edge;
}
 
开发者ID:PKUSilvester,项目名称:LiteGraph,代码行数:15,代码来源:Neo4jVertex.java

示例14: addEdge

import org.apache.tinkerpop.gremlin.structure.util.ElementHelper; //导入方法依赖的package包/类
Neo4JEdge addEdge(String label, Neo4JVertex out, Neo4JVertex in, Object... keyValues) {
    Objects.requireNonNull(label, "label cannot be null");
    Objects.requireNonNull(out, "out cannot be null");
    Objects.requireNonNull(in, "in cannot be null");
    Objects.requireNonNull(keyValues, "keyValues cannot be null");
    // validate label
    ElementHelper.validateLabel(label);
    // verify parameters are key/value pairs
    ElementHelper.legalPropertyKeyValueArray(keyValues);
    // id cannot be present
    if (ElementHelper.getIdValue(keyValues).isPresent())
        throw Vertex.Exceptions.userSuppliedIdsNotSupported();
    // create edge
    Neo4JEdge edge = new Neo4JEdge(graph, this, edgeIdProvider, label, out, in);
    // register transient edge (before processing properties to avoid having a transient edge in update queue)
    transientEdges.add(edge);
    // attach properties
    ElementHelper.attachProperties(edge, keyValues);
    // register transient edge with adjacent vertices
    out.addOutEdge(edge);
    in.addInEdge(edge);
    // check edge has id
    Object id = edge.id();
    if (id != null)
        transientEdgeIndex.put(id, edge);
    // return edge
    return edge;
}
 
开发者ID:SteelBridgeLabs,项目名称:neo4j-gremlin-bolt,代码行数:29,代码来源:Neo4JSession.java

示例15: vertexProperty

import org.apache.tinkerpop.gremlin.structure.util.ElementHelper; //导入方法依赖的package包/类
/**
 * Helper for {@link BlazeVertex#property(Cardinality, String, Object, Object...)}.
 * 
 * @param vertex the BlazeVertex
 * @param cardinality the property cardinality
 * @param key the property key
 * @param val the property value
 * @param kvs the properties to attach to the BlazeVertexProperty
 * @return a BlazeVertexProperty
 */
<V> BlazeVertexProperty<V> vertexProperty(final BlazeVertex vertex, 
        final Cardinality cardinality, final String key, final V val,
        final Object... kvs) {
    final BigdataValueFactory rdfvf = rdfValueFactory();
    final URI s = vertex.rdfId();
    final URI p = rdfvf.asValue(vf.propertyURI(key));
    final Literal lit = rdfvf.asValue(vf.toLiteral(val));
    
    final BigdataStatement stmt;
    if (cardinality == Cardinality.list) {
        final Literal timestamp = rdfvf.createLiteral(
                String.valueOf(vpIdFactory.getAndIncrement()), 
                LI_DATATYPE);
        stmt = rdfvf.createStatement(s, p, timestamp);
    } else {
        stmt = rdfvf.createStatement(s, p, lit);
    }
    final BigdataBNode sid = rdfvf.createBNode(stmt);
    final String vpId = vertexPropertyId(stmt);
    
    final RepositoryConnection cxn = cxn();
    Code.wrapThrow(() -> {
        if (cardinality == Cardinality.list) {
            // <s> <key> timestamp .
            cxn.add(stmt);
            // <<<s> <key> timestamp>> rdf:value "val" .
            cxn.add(sid, VALUE, lit);
        } else {
            if (cardinality == Cardinality.single && !bulkLoad) {
                final String queryStr = sparql.cleanVertexProps(s, p, lit);
                update(queryStr);
            }
            // << stmt >> <key> "val" .
            cxn.add(stmt);
        }
    });
    
    final BlazeProperty<V> prop = 
            new BlazeProperty<>(this, vertex, p, lit);
    final BlazeVertexProperty<V> bvp =
            new BlazeVertexProperty<>(prop, vpId, sid);
    ElementHelper.attachProperties(bvp, kvs);
    return bvp;
}
 
开发者ID:blazegraph,项目名称:tinkerpop3,代码行数:55,代码来源:BlazeGraph.java


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