本文整理汇总了Java中org.apache.tinkerpop.gremlin.process.traversal.step.Mutating类的典型用法代码示例。如果您正苦于以下问题:Java Mutating类的具体用法?Java Mutating怎么用?Java Mutating使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Mutating类属于org.apache.tinkerpop.gremlin.process.traversal.step包,在下文中一共展示了Mutating类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addE
import org.apache.tinkerpop.gremlin.process.traversal.step.Mutating; //导入依赖的package包/类
/**
* @deprecated As of release 3.1.0, replaced by {@link #addE(String)}
*/
@Deprecated
public default GraphTraversal<S, Edge> addE(final Direction direction, final String firstVertexKeyOrEdgeLabel, final String edgeLabelOrSecondVertexKey, final Object... propertyKeyValues) {
if (propertyKeyValues.length % 2 == 0) {
// addOutE("createdBy", "a")
this.addE(firstVertexKeyOrEdgeLabel);
if (direction.equals(Direction.OUT))
this.to(edgeLabelOrSecondVertexKey);
else
this.from(edgeLabelOrSecondVertexKey);
((Mutating) this.asAdmin().getEndStep()).addPropertyMutations(propertyKeyValues);
return (GraphTraversal<S, Edge>) this;
} else {
// addInE("a", "codeveloper", "b", "year", 2009)
this.addE(edgeLabelOrSecondVertexKey);
if (direction.equals(Direction.OUT))
this.from(firstVertexKeyOrEdgeLabel).to((String) propertyKeyValues[0]);
else
this.to(firstVertexKeyOrEdgeLabel).from((String) propertyKeyValues[0]);
((Mutating) this.asAdmin().getEndStep()).addPropertyMutations(Arrays.copyOfRange(propertyKeyValues, 1, propertyKeyValues.length));
return (GraphTraversal<S, Edge>) this;
}
}
示例2: shouldEventOnMutatingSteps
import org.apache.tinkerpop.gremlin.process.traversal.step.Mutating; //导入依赖的package包/类
@Test
public void shouldEventOnMutatingSteps() {
final MutationListener listener1 = new ConsoleMutationListener(EmptyGraph.instance());
final EventStrategy eventStrategy = EventStrategy.build()
.addListener(listener1).create();
eventStrategy.apply(traversal.asAdmin());
final AtomicInteger mutatingStepsFound = new AtomicInteger(0);
traversal.asAdmin().getSteps().stream()
.filter(s -> s instanceof Mutating)
.forEach(s -> {
final Mutating mutating = (Mutating) s;
assertEquals(1, mutating.getMutatingCallbackRegistry().getCallbacks().size());
mutatingStepsFound.incrementAndGet();
});
assertEquals(expectedMutatingStepsFound, mutatingStepsFound.get());
}
示例3: apply
import org.apache.tinkerpop.gremlin.process.traversal.step.Mutating; //导入依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
for (final Step step : traversal.getSteps()) {
if (step instanceof Mutating)
throw new VerificationException("The provided traversal has a mutating step and thus is not read only: " + step, traversal);
}
}
示例4: apply
import org.apache.tinkerpop.gremlin.process.traversal.step.Mutating; //导入依赖的package包/类
@Override
public void apply(final Traversal.Admin<?, ?> traversal) {
final EventStrategyCallback callback = new EventStrategyCallback(eventQueue);
TraversalHelper.getStepsOfAssignableClass(Mutating.class, traversal).forEach(s -> s.getMutatingCallbackRegistry().addCallback(callback));
}
示例5: property
import org.apache.tinkerpop.gremlin.process.traversal.step.Mutating; //导入依赖的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
* @return the traversal with the last step modified to add a property
* @see <a href="http://tinkerpop.apache.org/docs/${project.version}/reference/#addproperty-step" target="_blank">AddProperty Step</a>
* @since 3.0.0-incubating
*/
public default GraphTraversal<S, E> property(final VertexProperty.Cardinality cardinality, final Object key, final Object value, final Object... keyValues) {
if (null == cardinality)
this.asAdmin().getBytecode().addStep(Symbols.property, key, value, keyValues);
else
this.asAdmin().getBytecode().addStep(Symbols.property, cardinality, key, value, 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.
final Step endStep = this.asAdmin().getEndStep();
if ((endStep instanceof AddVertexStep || endStep instanceof AddEdgeStep || endStep instanceof AddVertexStartStep || endStep instanceof AddEdgeStartStep) &&
keyValues.length == 0 && null == cardinality) {
((Mutating) endStep).addPropertyMutations(key, value);
} else {
this.asAdmin().addStep(new AddPropertyStep(this.asAdmin(), cardinality, key, value));
((AddPropertyStep) this.asAdmin().getEndStep()).addPropertyMutations(keyValues);
}
return this;
}
示例6: property
import org.apache.tinkerpop.gremlin.process.traversal.step.Mutating; //导入依赖的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;
}