This file contains hidden or 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
package com.tinkerpop.blueprints.util; | |
import com.tinkerpop.blueprints.Element; | |
import com.tinkerpop.blueprints.Graph; | |
import com.tinkerpop.blueprints.TransactionalGraph; | |
import java.util.Set; | |
/** | |
* @author Marko A. Rodriguez (http://markorodriguez.com) |
This file contains hidden or 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
public interface MetaGraph<G, V, E> extends Graph { | |
/** | |
* Get the raw underlying graph engine that exposes the Blueprints API. | |
* | |
* @return the raw underlying graph engine | |
*/ | |
public G getRawGraph(); | |
public V getRawVertex(Vertex vertex); |
This file contains hidden or 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
, | |
, |\ ,__ | |
|\ \/ `\ | |
\ `-.:. `\ | |
`-.__ `\/\/\| | |
/ `'/ () \ | |
.' /\ ) | |
.-' .'| \' \__ | |
.' __( \ '`(() | |
/_.'` `. | )( |
This file contains hidden or 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
public static class Map extends Mapper<NullWritable, LongWritable, NullWritable, NullWritable> { | |
private TitanGraph graph; | |
@Override | |
public void setup(final Mapper.Context context) throws IOException, InterruptedException { | |
this.graph = TitanFactory.open(context.get("titanConfiguration")); | |
} | |
@Override |
This file contains hidden or 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
public static class Map extends Mapper<ByteBuffer, SortedMap<ByteBuffer, IColumn>, Text, Text> { | |
@Override | |
public void map(final ByteBuffer key, final SortedMap<ByteBuffer, IColumn> value, final Mapper<ByteBuffer, SortedMap<ByteBuffer, IColumn>, Text, Text>.Context context) throws IOException, InterruptedException { | |
final StringBuffer string = new StringBuffer(); | |
for (java.util.Map.Entry<ByteBuffer, IColumn> entry : value.entrySet()) { | |
string.append(ByteBufferUtil.string(entry.getKey())).append("\t").append(ByteBufferUtil.string(entry.getValue().value())); | |
} | |
context.write(new Text(ByteBufferUtil.string(key, Charset.forName("UTF-8"))), new Text(string.toString())); |
This file contains hidden or 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
private static FaunusVertex createFaunusVertex(final Pair<ByteBuffer, SortedMap<ByteBuffer, IColumn>> row) { | |
final FaunusVertex vertex = new FaunusVertex(1l); | |
try { | |
for (final java.util.Map.Entry<ByteBuffer, IColumn> entry : row.right.entrySet()) { | |
vertex.setProperty(ByteBufferUtil.string(entry.getKey()), ByteBufferUtil.string(entry.getValue().value())); | |
} | |
} catch (Exception e) { | |
} | |
return vertex; | |
} |
This file contains hidden or 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
arguments to pass in: | |
twitterId | |
traversals | |
numRecommendations | |
/////////////////////////// | |
// this function will return an ordered collection | |
// one thing to optimize is to return the map, not the set of vertices (this is more information and faster) | |
// to do so, "return [:]" and no ".keySet()" on last line. |
This file contains hidden or 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
g = new Neo4jGraph('/graph/neo4pedia2') | |
counter = 0; | |
for(final Vertex v : g.V()) { | |
v.toString() | |
for(Edge e: v.getEdges(BOTH)) { | |
e.toString() | |
} | |
if((counter++ % 500) == 0) { | |
println("vertices parsed: " + counter); | |
} |
This file contains hidden or 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
public Iterator<Neo4jEdge> iterator() { | |
final Iterator<Relationship> itty; | |
if (labels.length > 0) | |
itty = node.getRelationships(direction, labels).iterator(); | |
else | |
itty = node.getRelationships(direction).iterator(); | |
return new Iterator<Neo4jEdge>() { | |
public Neo4jEdge next() { | |
return new Neo4jEdge(itty.next(), graph); |
This file contains hidden or 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
@Override | |
public boolean nextKeyValue() throws IOException, InterruptedException { | |
boolean isNext; | |
try { | |
this.vertex.readFields(this.rexsterInputStream); | |
this.value.enablePath(this.pathEnabled); | |
itemsIterated++; | |
isNext = true; | |
} catch (Exception e) { |