diff --git a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/AsyncResult.java b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/AsyncResult.java index 8c82e5a6..bbce0020 100644 --- a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/AsyncResult.java +++ b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/AsyncResult.java @@ -32,6 +32,10 @@ public byte[] readAllBytes() { } } + public void closeWriter() { + stream.closeWriter(); + } + public static enum Status{ SUCCESS { @Override diff --git a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/PfbProcessor.java b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/PfbProcessor.java index b53dcc0c..58df38df 100644 --- a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/PfbProcessor.java +++ b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/PfbProcessor.java @@ -56,6 +56,7 @@ public void runQuery(Query query, AsyncResult result) { }).collect(Collectors.toList()); result.appendResults(fieldValuesPerPatient); }); + result.closeWriter(); } private Map> buildResult(AsyncResult result, Query query, TreeSet ids) { diff --git a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/ResultStoreStream.java b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/ResultStoreStream.java index e72ca77a..3fe6cbb2 100644 --- a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/ResultStoreStream.java +++ b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/ResultStoreStream.java @@ -108,4 +108,7 @@ public long estimatedSize() { return writer.getFile().length(); } + public void closeWriter() { + writer.close(); + } } diff --git a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/io/CsvWriter.java b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/io/CsvWriter.java index d196b681..5d09b93d 100644 --- a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/io/CsvWriter.java +++ b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/io/CsvWriter.java @@ -3,6 +3,7 @@ import java.io.File; import java.io.FileWriter; import java.io.IOException; +import java.io.UncheckedIOException; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -50,7 +51,11 @@ public File getFile() { } @Override - public void close() throws IOException { - fileWriter.close(); + public void close() { + try { + fileWriter.close(); + } catch (IOException e) { + throw new UncheckedIOException(e); + } } } diff --git a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/io/ResultWriter.java b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/io/ResultWriter.java index e9542885..75cbd0ee 100644 --- a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/io/ResultWriter.java +++ b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/io/ResultWriter.java @@ -11,5 +11,5 @@ public interface ResultWriter { File getFile(); - void close() throws IOException; + void close(); } diff --git a/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/QueryService.java b/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/QueryService.java index 24d925c0..5fe1a0a9 100644 --- a/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/QueryService.java +++ b/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/QueryService.java @@ -137,7 +137,7 @@ private AsyncResult initializeResult(Query query) throws ClassNotFoundException, ResultWriter writer; if (ResultType.DATAFRAME_PFB.equals(query.getExpectedResultType())) { - writer = new PfbWriter(File.createTempFile("result-" + query.getId(), ".avro")); + writer = new PfbWriter(File.createTempFile("result-" + System.nanoTime(), ".avro")); } else { writer = new CsvWriter(File.createTempFile("result-" + System.nanoTime(), ".sstmp")); }