Skip to content

Instantly share code, notes, and snippets.

View quintona's full-sized avatar

Quinton Anderson quintona

  • Sydney Australia
View GitHub Profile
@quintona
quintona / OuterJoinReducer
Created May 11, 2013 03:25
A way of doing an outer join of 2 separate streams, in storm trident. Use an outer join reducer. Here is the code for the reducer and associated state. Simply use topology.multiReduce(s1, s2, function, outputFields).
package storm.cookbook.tfidf.functions;
import java.util.Map;
import storm.trident.operation.MultiReducer;
import storm.trident.operation.TridentCollector;
import storm.trident.operation.TridentMultiReducerContext;
import storm.trident.tuple.TridentTuple;
import backtype.storm.tuple.Values;
@quintona
quintona / gist:5385839
Last active December 16, 2015 05:39
Issue getting started with graphhopper
@Test
public void test() {
Date start = new Date();
//GraphHopper gh = new GraphHopper().forServer(); //<- this works, line below doesn't
GraphHopper gh = new GraphHopper().forServer().contractionHierarchies(true);
gh.load("./london.osm");
Date end = new Date();
System.out.println("Load Time: " + (end.getTime() - start.getTime()));
GHRequest request = new GHRequest(51.430896,0.115356,
51.564266,-0.219727);
@quintona
quintona / gist:4752613
Created February 11, 2013 04:27
A test Gist, playing with a blog entry.
@SuppressWarnings({ "rawtypes", "unchecked" })
public static Stream getSentenceStream(TridentTopology topology, ITridentSpout spout){
Stream sentenceStream = null;
if(spout == null){
FixedBatchSpout fixedSpout = new FixedBatchSpout(new Fields("sentence"), 3,
new Values("the cow jumped over the moon"),
new Values("the man went to the store and bought some candy"),
new Values("four score and seven years ago"),
new Values("how many apples can you eat"),
new Values("to be or not to be the person"));