Skip to content

Commit

Permalink
Minor clean-ups
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan Clancy committed Dec 11, 2018
1 parent 56b6db8 commit 3c57b66
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions src/main/java/io/anserini/spark/JavaLuceneRDD.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.StreamSupport;

public class JavaLuceneRDD extends JavaRDD<Integer> {
Expand All @@ -20,7 +21,7 @@ public JavaLuceneRDD(JavaRDD<Integer> rdd) {
super(JavaRDD.toRDD(rdd), ClassManifestFactory.fromClass(Integer.class));
}

public JavaRDD<HashMap<String, String>> getDocs(String path) {
public JavaRDD<Map<String, String>> getDocs(String path) {

return wrapRDD(rdd()).mapPartitions((part) -> {

Expand All @@ -31,23 +32,16 @@ public JavaRDD<HashMap<String, String>> getDocs(String path) {
Iterable<Integer> iterable = () -> part;

return StreamSupport.stream(iterable.spliterator(), false).map(doc -> {

HashMap<String, String> fields = new HashMap();

Map<String, String> fields = new HashMap();
try {

Document document = reader.document(doc);

for (IndexableField field : document.getFields()) {
fields.put(field.name(), field.stringValue());
}

} catch (IOException e) {
e.printStackTrace();
}

return fields;

}).iterator();

});
Expand Down

0 comments on commit 3c57b66

Please sign in to comment.