}
}
- private class HashFunction implements Function<Reader, Void> {
+ private static class HashFunction implements Function<Reader, Void> {
private final OutputStreamWriter writer;
private final String componentKey;
hasData = true;
CharStreams.copy(input, writer);
} catch (IOException e) {
- throw new IllegalStateException(String.format("Can't read line hashes of file '%s'", componentKey));
+ throw new IllegalStateException(String.format("Can't read line hashes of file '%s'", componentKey), e);
}
return null;
}
import java.io.FileInputStream;
import java.util.Collections;
import java.util.List;
+import java.util.Map;
import static org.assertj.core.api.Assertions.assertThat;
bulk.get();
}
+ public void putDocuments(String index, String type, Map<String, Object>... docs) throws Exception {
+ BulkRequestBuilder bulk = client.prepareBulk().setRefresh(true);
+ for (Map<String, Object> doc : docs) {
+ bulk.add(new IndexRequest(index, type).source(doc));
+ }
+ bulk.get();
+ }
+
public long countDocuments(String indexName, String typeName) {
return client().prepareCount(indexName).setTypes(typeName).get().getCount();
}