use of org.neo4j.internal.batchimport.input.csv.StringDeserialization in project neo4j by neo4j.
the class CsvOutput method consume.
private void consume(String name, InputIterator entities, Header header, Deserializer deserializer) throws IOException {
try (PrintStream out = file(name + "header.csv")) {
serialize(out, header);
}
try {
int threads = Runtime.getRuntime().availableProcessors();
ExecutorService executor = Executors.newFixedThreadPool(threads);
for (int i = 0; i < threads; i++) {
int id = i;
executor.submit((Callable<Void>) () -> {
StringDeserialization deserialization = new StringDeserialization(config);
try (PrintStream out = file(name + "-" + id + ".csv");
InputChunk chunk = entities.newChunk()) {
InputEntity entity = new InputEntity();
while (entities.next(chunk)) {
while (chunk.next(entity)) {
out.println(deserializer.apply(entity, deserialization, header));
}
}
}
return null;
});
}
executor.shutdown();
executor.awaitTermination(10, TimeUnit.MINUTES);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
throw new IOException(e);
}
}
Aggregations