jonvex commented on code in PR #13694:
URL: https://github.com/apache/hudi/pull/13694#discussion_r2269778488


##########
hudi-spark-datasource/hudi-spark-common/src/main/scala/org/apache/hudi/cdc/CDCFileGroupIterator.scala:
##########
@@ -489,24 +500,22 @@ class CDCFileGroupIterator(split: HoodieCDCFileGroupSplit,
       .withProps(readerProperties)
       .withLatestCommitTime(split.changes.last.getInstant)
       .build()
-    
CloseableIteratorListener.addListener(fileGroupReader.getClosableIterator).asScala
+    
CloseableIteratorListener.addListener(fileGroupReader.getClosableBufferedRecordIterator).asScala
   }
 
   private def loadLogFile(logFile: HoodieLogFile, instant: String): 
Iterator[BufferedRecord[InternalRow]] = {
     val partitionPath = 
FSUtils.getRelativePartitionPath(metaClient.getBasePath, 
logFile.getPath.getParent)
-    val readerContext = new 
SparkFileFormatInternalRowReaderContext(baseFileReader, Seq.empty, Seq.empty,
-      conf, metaClient.getTableConfig)
     readerContext.setLatestCommitTime(instant)
     readerContext.setHasBootstrapBaseFile(false)
     readerContext.setHasLogFiles(true)
-    readerContext.initRecordMerger(readerProperties)
     readerContext.setSchemaHandler(
       new FileGroupReaderSchemaHandler[InternalRow](readerContext, avroSchema, 
avroSchema,
         Option.empty(), metaClient.getTableConfig, readerProperties))
     val stats = new HoodieReadStats
-    val recordBuffer = new 
KeyBasedFileGroupRecordBuffer[InternalRow](readerContext, metaClient, 
readerContext.getMergeMode,
+    keyBasedFileGroupRecordBuffer.ifPresent(k => k.close())
+    keyBasedFileGroupRecordBuffer = Option.of(new 
KeyBasedFileGroupRecordBuffer[InternalRow](readerContext, metaClient, 
readerContext.getMergeMode,

Review Comment:
   we need to check in merge if partial merging is enabled. I was wondering if 
we could have it always enabled, but it sounded like that would harm 
performance significantly.
   ```
     private def merge(currentRecord: BufferedRecord[InternalRow], newRecord: 
BufferedRecord[InternalRow]): BufferedRecord[InternalRow] = {
       if (!isPartialMergeEnabled && keyBasedFileGroupRecordBuffer.isPresent && 
keyBasedFileGroupRecordBuffer.get().isPartialMergingEnabled) {
         isPartialMergeEnabled = true
         bufferedRecordMerger = getBufferedRecordMerger
       }
       val deltaMergeResult = bufferedRecordMerger.deltaMerge(newRecord, 
currentRecord)
       if (deltaMergeResult.isEmpty) {
         currentRecord
       } else {
         deltaMergeResult.get()
       }
     }
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to