Skip to content

Commit

Permalink
ALS-6511: Fix pfb file writing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ramari16 committed Jul 23, 2024
1 parent e0f9fad commit 741aed8
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public byte[] readAllBytes() {
}
}

public void closeWriter() {
stream.closeWriter();
}

public static enum Status{
SUCCESS {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public void runQuery(Query query, AsyncResult result) {
}).collect(Collectors.toList());
result.appendResults(fieldValuesPerPatient);
});
result.closeWriter();
}

private Map<String, Map<Integer, String>> buildResult(AsyncResult result, Query query, TreeSet<Integer> ids) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,7 @@ public long estimatedSize() {
return writer.getFile().length();
}

public void closeWriter() {
writer.close();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ public interface ResultWriter {

File getFile();

void close() throws IOException;
void close();
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}
Expand Down

0 comments on commit 741aed8

Please sign in to comment.