Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Marko A. Rodriguez okram

🏠
Working from home
View GitHub Profile
View gist:9601527
public Future<Graph> submit() {
try {
final FileSystem fs = FileSystem.get(this.hadoopConfiguration);
fs.delete(new Path("output"), true);
final FileSystem local = FileSystem.getLocal(this.hadoopConfiguration);
final Path vertexProgramPath = new Path("tmp/gremlin", UUID.randomUUID().toString());
final ObjectOutputStream os = new ObjectOutputStream(fs.create(vertexProgramPath));
os.writeObject(this.vertexProgram);
os.close();
fs.deleteOnExit(vertexProgramPath);
View gist:9649584
g.V().match("a", "b",
as("a").out("knows").has("name", "josh"),
as("a").out("created").has("name", "lop"),
as("a").out("created").as("b"),
as("b").has("lang", "java"),
as("b").in("created").out("created").has("name", "ripple"))
.value("name").path().forEach(System.out::println);
View gist:9669964
public class TinkerGraphVertexWriter extends VertexWriter {
GraphWriter writer;
public void initialize(final TaskAttemptContext context) {
this.writer = new GraphSONWriter.Builder().build();
}
public void writeVertex(final Vertex giraphVertex) throws IOException {
//this.writer.writeVertex(System.out, ((GiraphVertex) giraphVertex).getGremlinVertex());
View gist:9764060
gremlin> a.out.out.out.out.out.path.next(10)
==>[v[89], v[83], v[29], v[81], v[89], v[83]]
==>[v[89], v[83], v[29], v[81], v[89], v[21]]
==>[v[89], v[83], v[29], v[81], v[89], v[206]]
==>[v[89], v[83], v[29], v[81], v[89], v[127]]
==>[v[89], v[83], v[29], v[81], v[89], v[49]]
==>[v[89], v[83], v[29], v[81], v[89], v[129]]
==>[v[89], v[83], v[29], v[81], v[89], v[149]]
==>[v[89], v[83], v[29], v[81], v[89], v[148]]
==>[v[89], v[83], v[29], v[81], v[89], v[130]]
View gist:11011793
gremlin> g = FaunusFactory.open('bin/titan-cassandra-output.properties')
==>faunusgraph[graphsoninputformat->titancassandraoutputformat]
gremlin> g._()
15:03:47 WARN mapreduce.FaunusCompiler: Using the developer Faunus job jar: target/faunus-0.4.3-SNAPSHOT-job.jar
15:03:47 INFO mapreduce.FaunusCompiler: Compiled to 3 MapReduce job(s)
15:03:47 INFO mapreduce.FaunusCompiler: Executing job 1 out of 3: MapSequence[com.thinkaurelius.faunus.mapreduce.IdentityMap.Map, com.thinkaurelius.faunus.formats.titan.SchemaInferencerMapReduce.Map, com.thinkaurelius.faunus.formats.titan.SchemaInferencerMapReduce.Reduce]
15:03:47 INFO mapreduce.FaunusCompiler: Job data location: output/job-0
15:03:47 WARN mapred.JobClient: Use GenericOptionsParser for parsing the arguments. Applications should implement Tool for the same.
...
gremlin> h = TitanFactory.open('/Users/marko/software/aurelius/titan/conf/titan-cassandra.properties')
View gist:11194881
public static class Marko implements Serializable {
public Function<Integer, Integer> function = (Function & Serializable) a -> 1 + 5;
}
@Test
public void testLambdaSerialization() throws Exception {
//System.out.println(function.getClass().isLocalClass());
/*byte[] bytes = Serializer.serializeObject(new Marko());
FileOutputStream outputStream = new FileOutputStream("/tmp/function.bin");
View gist:11230355
public static class TraversalHolder implements SSupplier<Traversal> {
public Traversal get() {
return TinkerGraph.open().V().out().filter(v -> true);
}
}
View gist:11403950
public default <V> V getValue(final String key, final V orElse) {
final Property<V> property = this.getProperty(key);
return property.orElse(orElse);
}
View gist:dbafda5e718b80ab490a
this.gremlinVertex = reader.readVertex(bis, (id1, label1, properties1) -> {
final com.tinkerpop.gremlin.structure.Vertex vertex = this.graph.addVertex(Element.ID, id1, Element.LABEL, label1);
for (int i = 0; i < properties1.length; i = i + 2) {
vertex.setProperty((String) properties1[i], properties1[i + 1]);
}
return vertex;
});
View gist:ecf831a1d40267e6353c
package com.tinkerpop.gremlin.giraph.process.olap;
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.tinkerpop.gremlin.process.PathHolder;
import com.tinkerpop.gremlin.process.SimpleHolder;
import org.apache.hadoop.io.Writable;
import java.io.ByteArrayInputStream;