After getting some help with the generics in my Count code I have one that's a bit more advanced.
I use String identifier in most of my jobs unfortunately most of them are URL so they have a long Prefix. Since Stratophere does Prefixsort I need to invert the Strings for optimal performance. (Jobs with inverted Strings run 4 times faster on my setting)
For DataSet of Strings I use the following Funktion:
private static class invertMap extends MapFunction<String, String> {
StringBuilder build = new StringBuilder();
private static final long serialVersionUID = 1L;
@Override
public String map(String value) throws Exception {
build.setLength(0);
return build.reverse().toString();
}
}
public static DataSet<String> invertKeys(DataSet<String> keys){
return keys.map(new invertMap());
}
I would like to write something similar that takes an arbitrary Tuple as input together with the field ID that contains String to be inverted. For a Tuple2 it would look the following:
private static class invertInTupleMap extends
MapFunction<Tuple2<String, String>, Tuple2<String, String>> {
private StringBuilder build = new StringBuilder();
private final int pos;
public invertInTupleMap(int pos) {
this.pos = pos;
}
@Override
public Tuple2<String, String> map(Tuple2<String, String> value)
throws Exception {
build.setLength(0);
build.append(value.getField(pos)).reverse();
value.setField(build.toString(), pos);
return value;
}
}
public static DataSet<Tuple2<String,String>> invertKeysInTuple(DataSet<Tuple2<String,String>> keys, int pos) {
return keys.map(new invertInTupleMap(pos));
}
QUESTION1: How would I make the call Generic so I can feed it any kind of Tuple with any kind of Fields in it (besides the Field at pos that needs to be String for obvious reasons). All ways I tried so far gave me lots of red curly lines with no useful explanation.
Is this possible at all?
cheers Martin
--
You received this message because you are subscribed to the Google Groups "stratosphere-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to stratosphere-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/stratosphere-dev.
For more options, visit https://groups.google.com/d/optout.