Skip to content

Commit

Permalink
[fix] fix comment
Browse files Browse the repository at this point in the history
  • Loading branch information
leaves12138 committed Mar 4, 2024
1 parent 0d2a508 commit 8c2003d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -279,9 +279,8 @@ public long memoryOccupancy() {

@Override
public void flushMemory() throws Exception {
if (sinkWriter.bufferSpillableWriter()) {
sinkWriter.spill();
} else {
boolean success = sinkWriter.flushMemory();
if (!success) {
flush(false, false);
}
}
Expand All @@ -307,15 +306,15 @@ private interface SinkWriter {

List<DataFileMeta> flush() throws IOException;

boolean flushMemory() throws IOException;

long memoryOccupancy();

void close();

void setMemoryPool(MemorySegmentPool memoryPool);

boolean bufferSpillableWriter();

void spill() throws IOException;
}

/**
Expand Down Expand Up @@ -346,6 +345,11 @@ public List<DataFileMeta> flush() throws IOException {
return flushedFiles;
}

@Override
public boolean flushMemory() throws IOException {
return false;
}

@Override
public long memoryOccupancy() {
return 0;
Expand All @@ -368,9 +372,6 @@ public void setMemoryPool(MemorySegmentPool memoryPool) {
public boolean bufferSpillableWriter() {
return false;
}

@Override
public void spill() throws IOException {}
}

/**
Expand Down Expand Up @@ -441,8 +442,8 @@ public boolean bufferSpillableWriter() {
}

@Override
public void spill() throws IOException {
writeBuffer.spill();
public boolean flushMemory() throws IOException {
return writeBuffer.flushMemory();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ public void reset() {
addCompleted = false;
}

@Override
public boolean flushMemory() throws IOException {
spill();
return true;
}

@Override
public boolean put(InternalRow row) throws IOException {
checkState(!addCompleted, "This buffer has add completed.");
Expand Down Expand Up @@ -126,7 +132,7 @@ private void throwTooBigException(InternalRow row) throws IOException {
+ memorySize());
}

public void spill() throws IOException {
private void spill() throws IOException {
FileIOChannel.ID channel = ioManager.createChannel();

BufferFileWriter writer = ioManager.createBufferFileWriter(channel);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ public void reset() {
}

@Override
public void spill() {
throw new UnsupportedOperationException();
public boolean flushMemory() throws IOException {
return false;
}

private void returnToSegmentPool() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public interface RowBuffer {

void reset();

void spill() throws IOException;
boolean flushMemory() throws IOException;

RowBufferIterator newIterator();

Expand Down

0 comments on commit 8c2003d

Please sign in to comment.