Skip to content

Instantly share code, notes, and snippets.

@mattwigway
Last active September 15, 2015 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattwigway/230b9589be891a95e7eb to your computer and use it in GitHub Desktop.
Save mattwigway/230b9589be891a95e7eb to your computer and use it in GitHub Desktop.
StringNPE.java
import org.mapdb.*;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
/**
* Created by matthewc on 9/15/15.
*/
public class StringNPE {
public static void main (String... args) {
// make the features
List<Fun.Tuple2<String, Integer>> features = IntStream.range(1, 6061)
.mapToObj(i -> Fun.t2("job_geomerror." + i, (Integer) i))
.collect(Collectors.toList());
DB db = DBMaker.newTempFileDB().make();
Iterator<Fun.Tuple2<String,Integer>> iter = Pump.sort(features.iterator(),
true, 100000,
Collections.reverseOrder((Fun.Tuple2 o1, Fun.Tuple2 o2) -> o1.compareTo(o2)), //reverse order comparator
db.getDefaultSerializer()
);
db.createTreeMap("test")
.pumpSource(iter)
// removing this line causes everything to work fine
.keySerializer(BTreeKeySerializer.STRING)
.make();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment