本文整理汇总了Java中org.apache.tinkerpop.gremlin.structure.VertexProperty.Cardinality方法的典型用法代码示例。如果您正苦于以下问题:Java VertexProperty.Cardinality方法的具体用法?Java VertexProperty.Cardinality怎么用?Java VertexProperty.Cardinality使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.tinkerpop.gremlin.structure.VertexProperty
的用法示例。
在下文中一共展示了VertexProperty.Cardinality方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: stageVertexProperty
import org.apache.tinkerpop.gremlin.structure.VertexProperty; //导入方法依赖的package包/类
/**
* This is a helper method for dealing with vertex property cardinality and typically used in {@link Vertex#property(org.apache.tinkerpop.gremlin.structure.VertexProperty.Cardinality, String, Object, Object...)}.
* If the cardinality is list, simply return {@link Optional#empty}.
* If the cardinality is single, delete all existing properties of the provided key and return {@link Optional#empty}.
* If the cardinality is set, find one that has the same key/value and attached the properties to it and return it. Else, if no equal value is found, return {@link Optional#empty}.
*
* @param vertex the vertex to stage a vertex property for
* @param cardinality the cardinality of the vertex property
* @param key the key of the vertex property
* @param value the value of the vertex property
* @param keyValues the properties of vertex property
* @param <V> the type of the vertex property value
* @return a vertex property if it has been found in set with equal value
*/
public static <V> Optional<VertexProperty<V>> stageVertexProperty(final Vertex vertex, final VertexProperty.Cardinality cardinality, final String key, final V value, final Object... keyValues) {
if (cardinality.equals(VertexProperty.Cardinality.single))
vertex.properties(key).forEachRemaining(VertexProperty::remove);
else if (cardinality.equals(VertexProperty.Cardinality.set)) {
final Iterator<VertexProperty<V>> itty = vertex.properties(key);
while (itty.hasNext()) {
final VertexProperty<V> property = itty.next();
if (property.value().equals(value)) {
ElementHelper.attachProperties(property, keyValues);
return Optional.of(property);
}
}
} // do nothing on Cardinality.list
return Optional.empty();
}
示例2: property
import org.apache.tinkerpop.gremlin.structure.VertexProperty; //导入方法依赖的package包/类
@Override
public <V> VertexProperty<V> property(final VertexProperty.Cardinality cardinality, final String key, final V value, final Object... keyValues) {
if (cardinality != Cardinality.single) {
// For some reason, TP3 tests fail with this exception
//throw new BitsyException(BitsyErrorCodes.NO_MULTI_PROPERTY_SUPPORT, "Encountered cardinality: " + cardinality.toString());
} else if (keyValues.length != 0) {
throw new UnsupportedOperationException("Encountered key values: " + keyValues.toString(), new BitsyException(BitsyErrorCodes.NO_META_PROPERTY_SUPPORT));
}
return property(key, value);
}
示例3: property
import org.apache.tinkerpop.gremlin.structure.VertexProperty; //导入方法依赖的package包/类
@Override
public <V> VertexProperty<V> property(final VertexProperty.Cardinality cardinality, final String key, final V value, final Object... keyValues) {
ElementHelper.validateProperty(key, value);
if (ElementHelper.getIdValue(keyValues).isPresent())
throw Vertex.Exceptions.userSuppliedIdsNotSupported();
this.graph.tx().readWrite();
return this.graph.trait.setVertexProperty(this, cardinality, key, value, keyValues);
}
示例4: attachProperties
import org.apache.tinkerpop.gremlin.structure.VertexProperty; //导入方法依赖的package包/类
/**
* Assign key/value pairs as properties to a {@link org.apache.tinkerpop.gremlin.structure.Vertex}.
* If the value of {@link T#id} or {@link T#label} is in the set of pairs, then they are ignored.
*
* @param vertex the vertex to attach the properties to
* @param cardinality the cardinality of the key value pair settings
* @param propertyKeyValues the key/value pairs to assign to the {@code element}
* @throws ClassCastException if the value of the key is not a {@link String}
* @throws IllegalArgumentException if the value of {@code element} is null
*/
public static void attachProperties(final Vertex vertex, final VertexProperty.Cardinality cardinality, final Object... propertyKeyValues) {
if (null == vertex) {
throw Graph.Exceptions.argumentCanNotBeNull("vertex");
}
//System.out.println("property number="+propertyKeyValues.length);
for (int i = 0; i < propertyKeyValues.length; i = i + 2) {
if (!propertyKeyValues[i].equals(T.id) && !propertyKeyValues[i].equals(T.label)) {
//System.out.println("cardinality="+cardinality+"\tkey="+propertyKeyValues[i]+"\tvalue="+propertyKeyValues[i+1]);
vertex.property(cardinality, (String) propertyKeyValues[i], propertyKeyValues[i + 1]);
}
}
}
示例5: AddPropertyStep
import org.apache.tinkerpop.gremlin.structure.VertexProperty; //导入方法依赖的package包/类
public AddPropertyStep(final Traversal.Admin traversal, final VertexProperty.Cardinality cardinality, final Object keyObject, final Object valueObject) {
super(traversal);
this.parameters.set(T.key, keyObject);
this.parameters.set(T.value, valueObject);
this.cardinality = cardinality;
this.parameters.integrateTraversals(this);
}
示例6: property
import org.apache.tinkerpop.gremlin.structure.VertexProperty; //导入方法依赖的package包/类
@Override
public <V> VertexProperty<V> property(final VertexProperty.Cardinality cardinality, final String key, final V value, final Object... keyValues) {
if (state.equals(State.MAP_REDUCE))
throw GraphComputer.Exceptions.vertexPropertiesCanNotBeUpdatedInMapReduce();
if (!computeKeys.contains(key))
throw GraphComputer.Exceptions.providedKeyIsNotAnElementComputeKey(key);
return new ComputerVertexProperty<>(this.getBaseVertex().property(cardinality, key, value, keyValues));
}
示例7: setVertexProperty
import org.apache.tinkerpop.gremlin.structure.VertexProperty; //导入方法依赖的package包/类
@Override
public <V> VertexProperty<V> setVertexProperty(final Neo4jVertex vertex, final VertexProperty.Cardinality cardinality, final String key, final V value, final Object... keyValues) {
if (cardinality != VertexProperty.Cardinality.single)
throw VertexProperty.Exceptions.multiPropertiesNotSupported();
if (keyValues.length > 0)
throw VertexProperty.Exceptions.metaPropertiesNotSupported();
try {
vertex.getBaseVertex().setProperty(key, value);
return new Neo4jVertexProperty<>(vertex, key, value);
} catch (final IllegalArgumentException iae) {
throw Property.Exceptions.dataTypeOfPropertyValueNotSupported(value, iae);
}
}
示例8: getCardinality
import org.apache.tinkerpop.gremlin.structure.VertexProperty; //导入方法依赖的package包/类
@Override
public VertexProperty.Cardinality getCardinality(final String key) {
return defaultVertexPropertyCardinality;
}
示例9: getCardinality
import org.apache.tinkerpop.gremlin.structure.VertexProperty; //导入方法依赖的package包/类
@Override
public VertexProperty.Cardinality getCardinality(final String key) {
return VertexProperty.Cardinality.single;
}
示例10: property
import org.apache.tinkerpop.gremlin.structure.VertexProperty; //导入方法依赖的package包/类
@Override
public <V> VertexProperty<V> property(final VertexProperty.Cardinality cardinality, final String key, final V value, final Object... keyValues) {
throw Element.Exceptions.propertyAdditionNotSupported();
}
示例11: property
import org.apache.tinkerpop.gremlin.structure.VertexProperty; //导入方法依赖的package包/类
@Override
public <V> VertexProperty<V> property(final VertexProperty.Cardinality cardinality, final String key, final V value, final Object... keyValues) {
throw GraphComputer.Exceptions.adjacentVertexPropertiesCanNotBeReadOrUpdated();
}
示例12: getCardinality
import org.apache.tinkerpop.gremlin.structure.VertexProperty; //导入方法依赖的package包/类
@Override
public VertexProperty.Cardinality getCardinality(final String key) {
// probably not much hurt here in returning list...it's an "empty graph"
return VertexProperty.Cardinality.list;
}
示例13: getCardinality
import org.apache.tinkerpop.gremlin.structure.VertexProperty; //导入方法依赖的package包/类
@Override
public VertexProperty.Cardinality getCardinality(final String key) {
return trait.getCardinality(key);
}
示例14: getCardinality
import org.apache.tinkerpop.gremlin.structure.VertexProperty; //导入方法依赖的package包/类
@Override
public VertexProperty.Cardinality getCardinality(final String key) {
return VertexProperty.Cardinality.list;
}
示例15: property
import org.apache.tinkerpop.gremlin.structure.VertexProperty; //导入方法依赖的package包/类
/**
* Sets a {@link Property} value and related meta properties if supplied, if supported by the {@link Graph}
* and if the {@link Element} is a {@link VertexProperty}. This method is the long-hand version of
* {@link #property(Object, Object, Object...)} with the difference that the
* {@link org.apache.tinkerpop.gremlin.structure.VertexProperty.Cardinality} can be supplied.
* <p/>
* Generally speaking, this method will append an {@link AddPropertyStep} to the {@link Traversal} but when
* possible, this method will attempt to fold key/value pairs into an {@link AddVertexStep}, {@link AddEdgeStep} or
* {@link AddVertexStartStep}. This potential optimization can only happen if cardinality is not supplied
* and when meta-properties are not included.
*
* @param cardinality the specified cardinality of the property where {@code null} will allow the {@link Graph}
* to use its default settings
* @param key the key for the property
* @param value the value for the property
* @param keyValues any meta properties to be assigned to this property
*/
public default GraphTraversal<S, E> property(final VertexProperty.Cardinality cardinality, final Object key, final Object value, final Object... keyValues) {
// if it can be detected that this call to property() is related to an addV/E() then we can attempt to fold
// the properties into that step to gain an optimization for those graphs that support such capabilities.
if ((this.asAdmin().getEndStep() instanceof AddVertexStep || this.asAdmin().getEndStep() instanceof AddEdgeStep
|| this.asAdmin().getEndStep() instanceof AddVertexStartStep) && keyValues.length == 0 && null == cardinality) {
((Mutating) this.asAdmin().getEndStep()).addPropertyMutations(key, value);
} else {
this.asAdmin().addStep(new AddPropertyStep(this.asAdmin(), cardinality, key, value));
((AddPropertyStep) this.asAdmin().getEndStep()).addPropertyMutations(keyValues);
}
return this;
}