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
public static void write(final Map<String, Object> properties, final DataOutput out) throws IOException {
if (null == properties) {
WritableUtils.writeVInt(out, 0);
} else {
WritableUtils.writeVInt(out, properties.size());
for (final Map.Entry<String, Object> entry : properties.entrySet()) {
out.writeUTF(entry.getKey());
final Class valueClass = entry.getValue().getClass();
final Object valueObject = entry.getValue();
if (valueClass.equals(Integer.class)) {
@okram
okram / gist:5303171
Last active December 15, 2015 18:19
public static void write(final Map<String, Object> properties, final DataOutput out) throws IOException {
if (null == properties) {
WritableUtils.writeVInt(out, 0);
} else {
WritableUtils.writeVInt(out, properties.size());
com.thinkaurelius.titan.graphdb.database.serialize.DataOutput o = s.getDataOutput(128, true);
for (final Map.Entry<String, Object> entry : properties.entrySet()) {
o.putString(entry.getKey());
o.writeClassAndObject(entry.getValue());
}
protected FaunusVertex readFaunusVertex(final ByteBuffer key, Iterable<Entry> entries) {
FaunusVertexLoader loader = new FaunusVertexLoader(key);
for (Entry data : entries) {
try {
FaunusVertexLoader.RelationFactory factory = loader.getFactory();
super.edgeSerializer.readRelation(factory,data,tx);
factory.build();
} catch (Exception e) {
//Log exception
}
conf = new BaseConfiguration()
conf.setProperty("storage.backend","cassandra")
//conf.setProperty("storage.hostname","localhost")
conf.setProperty("storage.hostname","10.172.137.237,10.174.89.108,10.172.111.134")
conf.setProperty("storage.batch-loading","true")
g = TitanFactory.open(conf)
bg = new BatchGraph(g, VertexIDType.NUMBER, 2000);
bg.setVertexIdKey("uid")
def getOrCreate(BatchGraph bg, long id) {
@Condition("it.out('authored').hasNext()")
@GremlinGroovy(frame = false, value =
"""
other = g.V('uri',authorUri).next()
c = 0;
it.as('x').out('authored').in('authored').loop('x'){
c++ < 100 &
new HashSet(it.path).size() == it.path.size() &
it.object != other
}.simplePath.path{it}{null}.transform{it.minus(null)}.toList()
@ExtensionNaming(namespace = "egosystem", name = "faunus")
class FaunusExtension extends AbstractRexsterExtension {
private static FaunusGremlinScriptEngine engine = new FaunusGremlinScriptEngine();
static {
Configuration configuration = new Configuration();
Properties properties = new Properties();
properties.load(FaunusExtension.class.getResourceAsStream("titan-cassandra-input.properties"));
for (Map.Entry<Object, Object> entry : properties.entrySet()) {
public void testUpdateValuesInIndexKeys() throws Exception {
KeyIndexableGraph graph = (KeyIndexableGraph) graphTest.generateGraph();
graph.createKeyIndex("name", Vertex.class);
Vertex v1 = graph.addVertex(null);
v1.setProperty("name","marko");
assertEquals(v1.getProperty("name"),"marko");
vertexCount(graph, 1);
if(graph instanceof TransactionalGraph)
package com.tinkerpop.furnace.algorithms.vertexcentric.programs.ranking;
import com.tinkerpop.blueprints.Direction;
import com.tinkerpop.blueprints.Edge;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.util.EdgeHelper;
import com.tinkerpop.furnace.algorithms.vertexcentric.GraphMemory;
import com.tinkerpop.furnace.algorithms.vertexcentric.programs.AbstractVertexProgram;
import com.tinkerpop.furnace.util.VertexQueryBuilder;
import com.tinkerpop.pipes.PipeFunction;
package com.thinkaurelius.faunus.formats.titan;
import com.thinkaurelius.faunus.FaunusVertex;
import com.thinkaurelius.faunus.Holder;
import com.thinkaurelius.faunus.formats.BlueprintsGraphOutputMapReduce;
import com.thinkaurelius.faunus.formats.JobConfigurationFormat;
import com.thinkaurelius.faunus.formats.MapReduceFormat;
import com.thinkaurelius.faunus.formats.noop.NoOpOutputFormat;
import com.thinkaurelius.faunus.hdfs.HDFSTools;
import com.thinkaurelius.faunus.mapreduce.FaunusCompiler;
package com.thinkaurelius.faunus.formats.titan;
import com.thinkaurelius.faunus.FaunusVertex;
import com.thinkaurelius.faunus.Holder;
import com.thinkaurelius.faunus.formats.BlueprintsGraphOutputMapReduce;
import com.thinkaurelius.faunus.formats.JobConfigurationFormat;
import com.thinkaurelius.faunus.formats.MapReduceFormat;
import com.thinkaurelius.faunus.formats.noop.NoOpOutputFormat;
import com.thinkaurelius.faunus.hdfs.HDFSTools;
import com.thinkaurelius.faunus.mapreduce.FaunusCompiler;