Skip to content
Closed
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 @@ -59,6 +59,7 @@ class InternalParquetRecordWriter<T> {

private long recordCount = 0;
private long recordCountForNextMemCheck = MINIMUM_RECORD_COUNT_FOR_CHECK;
private long lastRowGroupEndPos = 0;

private ColumnWriteStore columnStore;
private ColumnChunkPageWriteStore pageStore;
Expand Down Expand Up @@ -122,6 +123,13 @@ public void write(T value) throws IOException, InterruptedException {
checkBlockSizeReached();
}

/**
* @return the total size of data written to the file and buffered in memory
*/
public long getDataSize() {
return lastRowGroupEndPos + columnStore.getBufferedSize();
}

private void checkBlockSizeReached() throws IOException {
if (recordCount >= recordCountForNextMemCheck) { // checking the memory size is relatively expensive, so let's not do it for every record.
long memSize = columnStore.getBufferedSize();
Expand All @@ -133,6 +141,7 @@ private void checkBlockSizeReached() throws IOException {
flushRowGroupToStore();
initStore();
recordCountForNextMemCheck = min(max(MINIMUM_RECORD_COUNT_FOR_CHECK, recordCount / 2), MAXIMUM_RECORD_COUNT_FOR_CHECK);
this.lastRowGroupEndPos = parquetFileWriter.getPos();
} else {
recordCountForNextMemCheck = min(
max(MINIMUM_RECORD_COUNT_FOR_CHECK, (recordCount + (long)(nextRowGroupSize / ((float)recordSize))) / 2), // will check halfway
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,13 @@ public void close() throws IOException {
}
}

/**
* @return the total size of data written to the file and buffered in memory
*/
public long getDataSize() {
return writer.getDataSize();
}

/**
* An abstract builder class for ParquetWriter instances.
*
Expand Down