Last active
December 22, 2015 05:58
-
-
Save szarnyasg/6427422 to your computer and use it in GitHub Desktop.
Faunus Groovy MapReduce job for collecting edges of a specific type.
This file contains 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
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