Skip to content

Instantly share code, notes, and snippets.

@szarnyasg
Last active December 22, 2015 05:58
Show Gist options
  • Save szarnyasg/6427422 to your computer and use it in GitHub Desktop.
Save szarnyasg/6427422 to your computer and use it in GitHub Desktop.
Faunus Groovy MapReduce job for collecting edges of a specific type.
import com.thinkaurelius.titan.core.TitanFactory
import com.tinkerpop.blueprints.Graph
import org.apache.commons.configuration.BaseConfiguration
Graph g
edgeType = "father";
v2Types = ["titan", "human"];
def setup(args) {
conf = new BaseConfiguration()
conf.setProperty("storage.backend", args[0])
conf.setProperty("storage.hostname", hostname)
g = TitanFactory.open(conf)
}
def map(v, args) {
v1 = g.v(v.id)
pipe = v1.outE(edgeType).inV
def list = []
while (pipe.hasNext()) {
v2 = pipe.next()
if (v2.type in v2Types) {
list << v2.id
}
}
def pair = [v1.id, list]
}
def cleanup(args) {
g.shutdown()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment