Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
/**
* Reader for a sequence a page from a given column chunk
*/
public interface PageReader {
public interface PageReader extends AutoCloseable {

/**
* @return the dictionary page in that chunk or null if none
Expand All @@ -37,4 +37,10 @@ public interface PageReader {
* @return the next page in that chunk or null if after the last page
*/
DataPage readPage();

/**
* Releases any resources this reader holds (buffers, native handles, etc.).
*/
@Override
default void close() {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,8 @@ public DictionaryPage readDictionaryPage() {
}
}

private void releaseBuffers() {
@Override
public void close() {
releaser.close();
}
}
Expand Down Expand Up @@ -415,7 +416,7 @@ public void close() {
// Wrap each reader + the releaser as an AutoCloseable so AutoCloseables.uncheckedClose()
// releases every resource even if one fails, and aggregates failures via suppressed exceptions
List<AutoCloseable> toClose = new ArrayList<>(readers.size() + 1);
readers.values().forEach(reader -> toClose.add(reader::releaseBuffers));
readers.values().forEach(reader -> toClose.add(reader));
toClose.add(releaser);
AutoCloseables.uncheckedClose(toClose);
}
Expand Down
Loading