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 @@ -102,7 +102,8 @@ public boolean flushMemory() throws IOException {
}
}

private long getDiskUsage() {
@VisibleForTesting
public long getDiskUsage() {
long bytes = 0;

for (ChannelWithMeta spillChannelID : spilledChannelIDs) {
Expand Down Expand Up @@ -164,7 +165,7 @@ private void spill() throws IOException {
LOG.info(
"here spill the reset buffer data with {} records {} bytes",
inMemoryBuffer.size(),
channelWriterOutputView.getNumBytes());
channelWriterOutputView.getWriteBytes());
channelWriterOutputView.close();
} catch (IOException e) {
channelWriterOutputView.closeAndDelete();
Expand All @@ -175,7 +176,7 @@ private void spill() throws IOException {
new ChannelWithMeta(
channel,
inMemoryBuffer.getNumRecordBuffers(),
channelWriterOutputView.getNumBytes()));
channelWriterOutputView.getWriteBytes()));

inMemoryBuffer.reset();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
import org.junit.jupiter.api.io.TempDir;

import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
Expand Down Expand Up @@ -115,6 +117,20 @@ public void testSpillMaxDiskSize() throws Exception {
assertThat(buffer.getSpillChannels().size()).isGreaterThan(0);
assertThat(buffer.flushMemory()).isFalse();

assertThat(buffer.getDiskUsage())
.isEqualTo(
buffer.getSpillChannels().stream()
.map(
c -> {
try {
return Files.size(
Paths.get(c.getChannel().getPath()));
} catch (IOException e) {
throw new RuntimeException(e);
}
})
.reduce(0L, Long::sum));

// repeat read
assertBuffer(expected, buffer);
buffer.newIterator();
Expand Down