This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void mergeResults(final Graph original, final Graph computed, final Map<String, String> keyMapping) { | |
computed.V().forEach(v1 -> { | |
Vertex v2 = original.v(v1.getId()); | |
keyMapping.forEach((k, v) -> { | |
if (v1.getProperty(k).isPresent()) { | |
v2.setProperty(v, v1.getProperty(k).get()); | |
} | |
}); | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public <V> Property<V> setProperty(final String key, final V value) { | |
this.strategyWrappedGraph.strategy().compose( | |
s -> s.<V>getElementSetProperty(elementStrategyContext), | |
this.baseElement::setProperty).accept(key, value); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public default Set<String> getPropertyKeys() { | |
return this.getProperties().keySet(); | |
} | |
public Map<String, Property> getProperties(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public <V> Property<V> setProperty(final String key, final V value) { | |
this.strategyWrappedGraph.strategy().compose( | |
s -> s.<V>getElementSetProperty(elementStrategyContext), | |
this.baseElement::setProperty).accept(key, value); | |
return null; // TODO: Stephen, help please! This needs to return the created Property<V> | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
////// | |
public GraphTraversal<Edge, Edge> start() { | |
final TinkerEdge edge = this; | |
final GraphTraversal<Edge, Edge> traversal = new DefaultGraphTraversal<Edge, Edge>() { | |
public GraphTraversal<Edge, Edge> submit(final TraversalEngine engine) { | |
if (engine instanceof GraphComputer) { | |
this.optimizers().unregister(TinkerGraphStepOptimizer.class); | |
final String label = this.getSteps().get(0).getAs(); | |
TraversalHelper.removeStep(0, this); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gremlin> marko.out('knows').name | |
==>vadas | |
==>josh | |
----------- | |
marko | |
.filter{it.get()['name'] == 'marko'} | |
.flatMap{it.get().out('knows')} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.tinkerpop.gremlin.process.graph.sideEffect; | |
import com.tinkerpop.gremlin.process.Traversal; | |
import com.tinkerpop.gremlin.process.graph.map.MapStep; | |
import java.util.NoSuchElementException; | |
import java.util.Timer; | |
import java.util.TimerTask; | |
import java.util.concurrent.atomic.AtomicBoolean; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TimeLimitStep<S> extends MapStep<S, S> { | |
private final AtomicLong startTime = new AtomicLong(-1); | |
public TimeLimitStep(final Traversal traversal, final long timeLimit) { | |
super(traversal); | |
super.setFunction(traverser -> { | |
if (this.startTime.get() == -1l) | |
this.startTime.set(System.currentTimeMillis()); | |
if ((System.currentTimeMillis() - this.startTime.get()) >= timeLimit) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public DataOutputStream getDataOuputStream(final TaskAttemptContext job) throws IOException, InterruptedException { | |
final Configuration conf = job.getConfiguration(); | |
boolean isCompressed = getCompressOutput(job); | |
CompressionCodec codec = null; | |
String extension = ""; | |
if (isCompressed) { | |
final Class<? extends CompressionCodec> codecClass = getOutputCompressorClass(job, DefaultCodec.class); | |
codec = ReflectionUtils.newInstance(codecClass, conf); | |
extension = codec.getDefaultExtension(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{"inV":[ | |
{"inV":3,"inVLabel":"default","outVLabel":"default","id":0, | |
"label":"created","type":"edge","outV":1,"hiddens":{},"properties":{"weight":0.4}}, | |
{"inV":3,"inVLabel":"default","outVLabel":"default","id":1, | |
"label":"created","type":"edge","outV":4,"hiddens":{},"properties":{"weight":0.4}}, | |
{"inV":3,"inVLabel":"default","outVLabel":"default","id":2, | |
"label":"created","type":"edge","outV":6,"hiddens":{},"properties":{"weight":0.2}} | |
], | |
"id":3, | |
"label":"default", |