You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@gobblin.apache.org by "homatthew (via GitHub)" <gi...@apache.org> on 2023/08/25 19:17:54 UTC

[GitHub] [gobblin] homatthew commented on a diff in pull request #3751: [DRAFT] Create selftuning buffered ORC writer

homatthew commented on code in PR #3751:
URL: https://github.com/apache/gobblin/pull/3751#discussion_r1306066125


##########
gobblin-modules/gobblin-orc/src/main/java/org/apache/gobblin/writer/GobblinBaseOrcWriter.java:
##########
@@ -194,10 +295,30 @@ public void commit()
   public void write(D record)
       throws IOException {
     Preconditions.checkState(!closed, "Writer already closed");
-    valueWriter.write(record, rowBatch);
+    this.orcFileWriterLock.readLock().lock();
+    this.valueWriter.write(record, this.rowBatch);
+    int recordCount = this.recordCounter.incrementAndGet();
+    if (this.selfTuningWriter && recordCount == this.nextSelfTune) {
+      try {
+        this.orcFileWriterLock.readLock().unlock();
+        this.orcFileWriterLock.writeLock().lock();
+        this.tuneCheckCounter = Math.min(this.tuneCheckCounter + 1, 5);
+        long totalBytes = ((GenericRecordToOrcValueWriter) valueWriter).getTotalBytesConverted();
+        long totalRecords = ((GenericRecordToOrcValueWriter) valueWriter).getTotalRecordsConverted();
+        long averageSizePerRecord = totalRecords == 0 ? 0 : totalBytes / totalRecords;
+        this.estimatedRecordSize = averageSizePerRecord;

Review Comment:
   Size is in bytes right? Make sure it's part of the variable name somehow



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@gobblin.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org