Skip to content

Instantly share code, notes, and snippets.

View okram's full-sized avatar
🏠
Working from home

Marko A. Rodriguez okram

🏠
Working from home
View GitHub Profile
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);
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());
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]]
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')
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");
public static class TraversalHolder implements SSupplier<Traversal> {
public Traversal get() {
return TinkerGraph.open().V().out().filter(v -> true);
}
}
public default <V> V getValue(final String key, final V orElse) {
final Property<V> property = this.getProperty(key);
return property.orElse(orElse);
}
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;
});
System.out.println("READING:" + this.getId().get() + "!!!!!" + this.getValue().getLength() + "!!!!" + new String(this.getValue().getBytes(), 0, 3));
final ByteArrayInputStream bis = new ByteArrayInputStream(this.getValue().getBytes());
final KryoReader reader = KryoReader.create().build();
this.gremlinGraph = TinkerGraph.open();
reader.readGraph(bis, this.gremlinGraph);
bis.close();
this.gremlinVertex = this.gremlinGraph.v(this.getId().get());
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;