Skip to content
Merged
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 @@ -177,10 +177,10 @@ public Page appendColumn(Block block)
return wrapBlocksWithoutCopy(positionCount, newBlocks);
}

public void compact()
public Page compact()
{
if (getRetainedSizeInBytes() <= getSizeInBytes()) {
return;
return this;
}

for (int i = 0; i < blocks.length; i++) {
Expand All @@ -202,6 +202,7 @@ public void compact()
}

updateRetainedSize();
return this;
}

private Map<DictionaryId, DictionaryBlockIndexes> getRelatedDictionaryBlocks()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import static com.facebook.presto.spiller.FileSingleStreamSpillerFactory.SPILL_FILE_PREFIX;
import static com.facebook.presto.spiller.FileSingleStreamSpillerFactory.SPILL_FILE_SUFFIX;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.Iterators.transform;
import static java.nio.file.StandardOpenOption.APPEND;
import static java.util.Objects.requireNonNull;

Expand Down Expand Up @@ -168,8 +169,9 @@ private Iterator<Page> readPages()

try {
InputStream input = closer.register(targetFile.newInputStream());
Iterator<Page> pages = PagesSerdeUtil.readPages(serde, new InputStreamSliceInput(input, BUFFER_SIZE));
return closeWhenExhausted(pages, input);
Iterator<Page> deserializedPages = PagesSerdeUtil.readPages(serde, new InputStreamSliceInput(input, BUFFER_SIZE));
Iterator<Page> compactPages = transform(deserializedPages, Page::compact);
return closeWhenExhausted(compactPages, input);
}
catch (IOException e) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, "Failed to read spilled pages", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import static com.facebook.presto.execution.buffer.PageSplitterUtil.splitPage;
import static com.facebook.presto.spi.StandardErrorCode.GENERIC_INTERNAL_ERROR;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.collect.Iterators.transform;
import static java.lang.Math.toIntExact;
import static java.util.Objects.requireNonNull;

Expand Down Expand Up @@ -181,8 +182,9 @@ private Iterator<Page> readPages()
tempStorageHandle = dataSink.commit();

InputStream input = closer.register(tempStorage.open(tempDataOperationContext, tempStorageHandle));
Iterator<Page> pages = PagesSerdeUtil.readPages(serde, new InputStreamSliceInput(input));
return closeWhenExhausted(pages, input);
Iterator<Page> deserializedPages = PagesSerdeUtil.readPages(serde, new InputStreamSliceInput(input));
Iterator<Page> compactPages = transform(deserializedPages, Page::compact);
return closeWhenExhausted(compactPages, input);
}
catch (IOException e) {
throw new PrestoException(GENERIC_INTERNAL_ERROR, "Failed to read spilled pages", e);
Expand Down