Closing IndexInput after every use

This commit is contained in:
expani 2024-10-19 09:53:15 +05:30
parent 4406d75b00
commit dc3d6fc9c1
1 changed files with 6 additions and 9 deletions

View File

@ -81,8 +81,6 @@ public class DocIdEncodingBenchmark {
private Path tmpDir;
private IndexInput in;
private final int[] scratch = new int[512];
private String decoderInputFile;
@ -126,8 +124,8 @@ public class DocIdEncodingBenchmark {
Files.delete(tmpDir.resolve(outputFile));
}
} else if (methodName.equalsIgnoreCase("decode")) {
try (Directory dir = FSDirectory.open(tmpDir)) {
in = dir.openInput(decoderInputFile, IOContext.DEFAULT);
try (Directory dir = FSDirectory.open(tmpDir);
IndexInput in = dir.openInput(decoderInputFile, IOContext.DEFAULT)) {
for (int[] docIdSequence : DOC_ID_SEQUENCES) {
for (int i = 1; i <= INPUT_SCALE_FACTOR; i++) {
docIdEncoder.decode(in, 0, docIdSequence.length, scratch);
@ -543,6 +541,5 @@ public class DocIdEncodingBenchmark {
} catch (IOException e) {
throw new RuntimeException(e);
}
}
}