本文整理汇总了Java中org.apache.tinkerpop.gremlin.structure.util.ElementHelper.validateLabel方法的典型用法代码示例。如果您正苦于以下问题:Java ElementHelper.validateLabel方法的具体用法?Java ElementHelper.validateLabel怎么用?Java ElementHelper.validateLabel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tinkerpop.gremlin.structure.util.ElementHelper
的用法示例。
在下文中一共展示了ElementHelper.validateLabel方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例2: addEdge
import org.apache.tinkerpop.gremlin.structure.util.ElementHelper; //导入方法依赖的package包/类
public Edge addEdge(Vertex outVertex, Vertex inVertex, String label, Object... keyValues) {
try {
if (null == inVertex) throw Graph.Exceptions.argumentCanNotBeNull("inVertex");
ElementHelper.validateLabel(label);
ElementHelper.legalPropertyKeyValueArray(keyValues);
Object idValue = ElementHelper.getIdValue(keyValues).orElse(null);
idValue = HBaseGraphUtils.generateIdIfNeeded(idValue);
long now = System.currentTimeMillis();
HBaseEdge edge = new HBaseEdge(graph, idValue, label, now, now,
HBaseGraphUtils.propertiesToMap(keyValues), inVertex, outVertex);
edge.validate();
Iterator<IndexMetadata> indices = edge.getIndices(OperationType.WRITE);
indexEdge(edge, indices);
EdgeIndexWriter writer = new EdgeIndexWriter(graph, edge, Constants.CREATED_AT);
if (edgeIndicesMutator != null) edgeIndicesMutator.mutate(getMutationList(writer.constructInsertions()));
Creator creator = new EdgeWriter(graph, edge);
if (edgesMutator != null) edgesMutator.mutate(getMutationList(creator.constructInsertions()));
return edge;
} catch (IOException e) {
throw new HBaseGraphException(e);
}
}
示例3: 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);
Object idValue = ElementHelper.getIdValue(keyValues).orElse(null);
idValue = HBaseGraphUtils.generateIdIfNeeded(idValue);
long now = System.currentTimeMillis();
HBaseEdge newEdge = new HBaseEdge(graph, idValue, label, now, now, HBaseGraphUtils.propertiesToMap(keyValues), inVertex, this);
newEdge.validate();
newEdge.writeEdgeEndpoints();
newEdge.writeToModel();
invalidateEdgeCache();
if (!isCached()) {
HBaseVertex cachedVertex = (HBaseVertex) graph.findVertex(id, false);
if (cachedVertex != null) cachedVertex.invalidateEdgeCache();
}
((HBaseVertex) inVertex).invalidateEdgeCache();
if (!((HBaseVertex) inVertex).isCached()) {
HBaseVertex cachedInVertex = (HBaseVertex) graph.findVertex(inVertex.id(), false);
if (cachedInVertex != null) cachedInVertex.invalidateEdgeCache();
}
Edge edge = graph.findOrCreateEdge(idValue);
((HBaseEdge) edge).copyFrom(newEdge);
return edge;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: addEdge
import org.apache.tinkerpop.gremlin.structure.util.ElementHelper; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public Edge addEdge(String label, Vertex vertex, Object... keyValues) {
ElementHelper.validateLabel(label);
if (vertex == null)
throw Graph.Exceptions.argumentCanNotBeNull("vertex");
ElementHelper.legalPropertyKeyValueArray(keyValues);
// transaction should be ready for io operations
graph.tx().readWrite();
// add edge
return session.addEdge(label, this, (Neo4JVertex)vertex, keyValues);
}
示例8: 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;
}