本文整理汇总了Java中org.apache.tinkerpop.gremlin.structure.util.ElementHelper.legalPropertyKeyValueArray方法的典型用法代码示例。如果您正苦于以下问题:Java ElementHelper.legalPropertyKeyValueArray方法的具体用法?Java ElementHelper.legalPropertyKeyValueArray怎么用?Java ElementHelper.legalPropertyKeyValueArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tinkerpop.gremlin.structure.util.ElementHelper
的用法示例。
在下文中一共展示了ElementHelper.legalPropertyKeyValueArray方法的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;
}
示例2: 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);
}
}
示例3: 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;
}
示例4: 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;
}
示例5: 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;
}
示例6: 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;
}
示例7: 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);
}
示例8: addEdge
import org.apache.tinkerpop.gremlin.structure.util.ElementHelper; //导入方法依赖的package包/类
@Override
public Edge addEdge(String label, Vertex vertex, Object... keyValues) {
if (null == vertex) {
throw Graph.Exceptions.argumentCanNotBeNull("inVertex");
}
if (this.removed) {
throw elementAlreadyRemoved(Vertex.class, this.id);
}
if (graph.specializedEdgeFactoryByLabel.containsKey(label)) {
SpecializedElementFactory.ForEdge factory = graph.specializedEdgeFactoryByLabel.get(label);
Object idValue = graph.edgeIdManager.convert(ElementHelper.getIdValue(keyValues).orElse(null));
if (null != idValue) {
if (graph.edges.containsKey(idValue)) {
throw Graph.Exceptions.edgeWithIdAlreadyExists(idValue);
}
} else {
idValue = graph.edgeIdManager.getNextId(graph);
}
ElementHelper.legalPropertyKeyValueArray(keyValues);
TinkerVertex inVertex = (TinkerVertex) vertex;
TinkerVertex outVertex = this;
SpecializedTinkerEdge edge = factory.createEdge(idValue, outVertex, inVertex, ElementHelper.asMap(keyValues));
graph.edges.put(idValue, edge);
// TODO: allow to connect non-specialised vertices with specialised edges and vice versa
this.addSpecializedOutEdge(edge);
((SpecializedTinkerVertex) inVertex).addSpecializedInEdge(edge);
return edge;
} else { // edge label not registered for a specialized factory, treating as generic edge
if (graph.usesSpecializedElements) {
throw new IllegalArgumentException(
"this instance of TinkerGraph uses specialized elements, but doesn't have a factory for label " + label
+ ". Mixing specialized and generic elements is not (yet) supported");
}
return super.addEdge(label, vertex, keyValues);
}
}
示例9: 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);
}
}
示例10: 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;
}
示例11: 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()));
}
示例12: 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;
}
示例13: 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;
}
示例14: 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;
}
示例15: 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;
}