vinothchandar commented on code in PR #11793:
URL: https://github.com/apache/hudi/pull/11793#discussion_r1721936080


##########
rfc/README.md:
##########
@@ -115,4 +115,5 @@ The list of all RFCs can be found here.
 | 77         | [Secondary Index](./rfc-77/rfc-77.md)                           
                                                                                
                                                                     | `UNDER 
REVIEW` |
 | 78         | [Bridge release for 1.x](./rfc-78/rfc-78.md)                    
                                                                                
                                                                     | `IN 
PROGRESS`  |
 | 79         | [Robust handling of spark task retries and 
failures](./rfc-79/rfc-79.md)                                                   
                                                                                
          | `IN PROGRESS`  |
-| 80         | [Column Families](./rfc-80/rfc-80.md)                           
                                                                                
                                                                     | `UNDER 
REVIEW` |
\ No newline at end of file
+| 80         | [Column Families](./rfc-80/rfc-80.md)                           
                                                                                
                                                                     | `UNDER 
REVIEW` |
+| 81         | [Log Compaction with Merge Sort](./rfc-81/rfc-81.md)            
                                                                                
                                                                     | `UNDER 
REVIEW` |

Review Comment:
   please grab the RFC number in a separate PR.



##########
rfc/rfc-81/rfc-81.md:
##########
@@ -0,0 +1,108 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+# RFC-81: Log Compaction with Merge Sort
+
+## Proposers
+- @usberkeley
+
+## Approvers
+- @danny0405
+
+## Status
+JIRA: https://issues.apache.org/jira/browse/HUDI-8033
+
+## Abstract
+Add lightweight LogCompaction to improve the writing performance of the write 
side, and improve the query performance of the read side (Spark/Presto, etc.) 
in some scenarios without having to wait for heavy and time-consuming 
operations such as Compaction or Clustering.
+
+## Background
+The previous LogCompaction mainly merged log files through 
HoodieMergedLogRecordScanner, and used ExternalSpillableMap internally to 
achieve record merging, which resulted in performance loss of writing to disk.
+LogCompaction with Merge Sort is introduced to achieve lightweight minor 
compaction by merging records through N-way streaming of ordered data, thus 
improving the writing performance of the write side. At the same time, thanks 
to the ordered data, the query performance on the read side can be improved 
when the primary key is met.
+
+## Implementation
+### HoodieConfig etc
+Added a new configuration item for the HoodieLogBlock streaming read buffer 
size. The default value is 10MB.
+#### Flink
+Added a new configuration item to enable LogCompaction. The default value is 
false.
+Note:
+1. After Flink enables LogCompaction, the default implementation is MergeSort.
+2. Currently, the log format only supports AVRO. After enabling LogCompaction, 
need to check whether the hoodie.logfile.data.block.format configuration item 
is correct.
+
+#### Spark
+Added a new configuration item for whether to enable MergeSort in 
LogCompaction. The default value is false.
+Note:
+1. Currently, the log format only supports AVRO. After LogCompaction turns on 
MergeSort, you need to check whether the hoodie.logfile.data.block.format 
configuration item is correct.

Review Comment:
   Not true. it already supports embedding parquet, hfile etc.



##########
rfc/rfc-81/rfc-81.md:
##########
@@ -0,0 +1,108 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+# RFC-81: Log Compaction with Merge Sort
+
+## Proposers
+- @usberkeley
+
+## Approvers
+- @danny0405
+
+## Status
+JIRA: https://issues.apache.org/jira/browse/HUDI-8033
+
+## Abstract
+Add lightweight LogCompaction to improve the writing performance of the write 
side, and improve the query performance of the read side (Spark/Presto, etc.) 
in some scenarios without having to wait for heavy and time-consuming 
operations such as Compaction or Clustering.
+
+## Background
+The previous LogCompaction mainly merged log files through 
HoodieMergedLogRecordScanner, and used ExternalSpillableMap internally to 
achieve record merging, which resulted in performance loss of writing to disk.
+LogCompaction with Merge Sort is introduced to achieve lightweight minor 
compaction by merging records through N-way streaming of ordered data, thus 
improving the writing performance of the write side. At the same time, thanks 
to the ordered data, the query performance on the read side can be improved 
when the primary key is met.

Review Comment:
   Okay. I benchmarked N way sort merge once vs current hash merge (what we 
call ExternalSpillableMap). sort merge can be expensive when N is much higher.. 
Might be worth adding some microbenchmarks to understand. I am overall in favor 
of adding a sort based merge though. 
   
   
https://github.com/vinothchandar/hudi/commit/9050dd1317851bc395aef51ab60d761f74c0529d#diff-a7143db9299e96f8b0dc010a2dcb530318ddc3b30ce38f79881afebea602ad2c
 



##########
rfc/rfc-81/rfc-81.md:
##########
@@ -0,0 +1,108 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+# RFC-81: Log Compaction with Merge Sort
+
+## Proposers
+- @usberkeley
+
+## Approvers
+- @danny0405
+
+## Status
+JIRA: https://issues.apache.org/jira/browse/HUDI-8033
+
+## Abstract
+Add lightweight LogCompaction to improve the writing performance of the write 
side, and improve the query performance of the read side (Spark/Presto, etc.) 
in some scenarios without having to wait for heavy and time-consuming 
operations such as Compaction or Clustering.
+
+## Background
+The previous LogCompaction mainly merged log files through 
HoodieMergedLogRecordScanner, and used ExternalSpillableMap internally to 
achieve record merging, which resulted in performance loss of writing to disk.

Review Comment:
   lets please strive to add context on when sth is fast or slow, so its easy 
for the reader.



##########
rfc/rfc-81/rfc-81.md:
##########
@@ -0,0 +1,108 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+# RFC-81: Log Compaction with Merge Sort
+
+## Proposers
+- @usberkeley
+
+## Approvers
+- @danny0405
+
+## Status
+JIRA: https://issues.apache.org/jira/browse/HUDI-8033
+
+## Abstract
+Add lightweight LogCompaction to improve the writing performance of the write 
side, and improve the query performance of the read side (Spark/Presto, etc.) 
in some scenarios without having to wait for heavy and time-consuming 
operations such as Compaction or Clustering.
+
+## Background
+The previous LogCompaction mainly merged log files through 
HoodieMergedLogRecordScanner, and used ExternalSpillableMap internally to 
achieve record merging, which resulted in performance loss of writing to disk.

Review Comment:
   ```suggestion
   The previous LogCompaction mainly merged log files through 
HoodieMergedLogRecordScanner, and used ExternalSpillableMap internally to 
achieve record merging, which resulted in performance loss of writing to disk, 
when the amount of log data exceeds merge memory available.
   ```



##########
rfc/rfc-81/rfc-81.md:
##########
@@ -0,0 +1,108 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+# RFC-81: Log Compaction with Merge Sort
+
+## Proposers
+- @usberkeley
+
+## Approvers
+- @danny0405
+
+## Status
+JIRA: https://issues.apache.org/jira/browse/HUDI-8033
+
+## Abstract
+Add lightweight LogCompaction to improve the writing performance of the write 
side, and improve the query performance of the read side (Spark/Presto, etc.) 
in some scenarios without having to wait for heavy and time-consuming 
operations such as Compaction or Clustering.
+
+## Background
+The previous LogCompaction mainly merged log files through 
HoodieMergedLogRecordScanner, and used ExternalSpillableMap internally to 
achieve record merging, which resulted in performance loss of writing to disk.
+LogCompaction with Merge Sort is introduced to achieve lightweight minor 
compaction by merging records through N-way streaming of ordered data, thus 
improving the writing performance of the write side. At the same time, thanks 
to the ordered data, the query performance on the read side can be improved 
when the primary key is met.
+
+## Implementation
+### HoodieConfig etc
+Added a new configuration item for the HoodieLogBlock streaming read buffer 
size. The default value is 10MB.
+#### Flink
+Added a new configuration item to enable LogCompaction. The default value is 
false.
+Note:
+1. After Flink enables LogCompaction, the default implementation is MergeSort.
+2. Currently, the log format only supports AVRO. After enabling LogCompaction, 
need to check whether the hoodie.logfile.data.block.format configuration item 
is correct.
+
+#### Spark
+Added a new configuration item for whether to enable MergeSort in 
LogCompaction. The default value is false.

Review Comment:
   we need to add a log block header that indicates whether the log block is 
sorted or not... if even one is not sorted, then we need to fallback to hash 
merge?



##########
rfc/rfc-81/rfc-81.md:
##########
@@ -0,0 +1,108 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+# RFC-81: Log Compaction with Merge Sort
+
+## Proposers
+- @usberkeley
+
+## Approvers
+- @danny0405
+
+## Status
+JIRA: https://issues.apache.org/jira/browse/HUDI-8033
+
+## Abstract
+Add lightweight LogCompaction to improve the writing performance of the write 
side, and improve the query performance of the read side (Spark/Presto, etc.) 
in some scenarios without having to wait for heavy and time-consuming 
operations such as Compaction or Clustering.
+
+## Background
+The previous LogCompaction mainly merged log files through 
HoodieMergedLogRecordScanner, and used ExternalSpillableMap internally to 
achieve record merging, which resulted in performance loss of writing to disk.
+LogCompaction with Merge Sort is introduced to achieve lightweight minor 
compaction by merging records through N-way streaming of ordered data, thus 
improving the writing performance of the write side. At the same time, thanks 
to the ordered data, the query performance on the read side can be improved 
when the primary key is met.
+
+## Implementation
+### HoodieConfig etc
+Added a new configuration item for the HoodieLogBlock streaming read buffer 
size. The default value is 10MB.
+#### Flink
+Added a new configuration item to enable LogCompaction. The default value is 
false.
+Note:
+1. After Flink enables LogCompaction, the default implementation is MergeSort.
+2. Currently, the log format only supports AVRO. After enabling LogCompaction, 
need to check whether the hoodie.logfile.data.block.format configuration item 
is correct.
+
+#### Spark
+Added a new configuration item for whether to enable MergeSort in 
LogCompaction. The default value is false.
+Note:
+1. Currently, the log format only supports AVRO. After LogCompaction turns on 
MergeSort, you need to check whether the hoodie.logfile.data.block.format 
configuration item is correct.
+
+### DeltaCommit
+#### Flink
+When LogCompaction is enabled, DeltaCommit sorts the written data by RecordKey 
to achieve orderly records in LogBlock.
+#### Spark
+When LogCompaction turns on MergeSort, DeltaCommit sorts the written data by 
RecordKey to achieve orderly records in LogBlock.
+
+### LogCompaction
+The following contents are all about enabling LogCompaction or enabling 
MergeSort with LogCompaction.
+#### Flink
+Flink has not yet fully implemented the LogCompaction feature, so the operator 
needs to be implemented:
+1. LogCompactionPlanOperator
+2. LogCompactionOperator
+3. LogCompactionCommitSink
+
+When scanning log files, use the new log scanner: 
HoodieMergeSortLogRecordScanner to achieve N-way streaming record merging.
+
+#### Spark
+When scanning log files, use the new log scanner: 
HoodieMergeSortLogRecordScanner to achieve N-way streaming record merging.
+
+### HoodieMergeSortLogRecordScanner

Review Comment:
   we need a new write handle?



##########
rfc/rfc-81/rfc-81.md:
##########
@@ -0,0 +1,108 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+# RFC-81: Log Compaction with Merge Sort
+
+## Proposers
+- @usberkeley
+
+## Approvers
+- @danny0405
+
+## Status
+JIRA: https://issues.apache.org/jira/browse/HUDI-8033
+
+## Abstract
+Add lightweight LogCompaction to improve the writing performance of the write 
side, and improve the query performance of the read side (Spark/Presto, etc.) 
in some scenarios without having to wait for heavy and time-consuming 
operations such as Compaction or Clustering.
+
+## Background
+The previous LogCompaction mainly merged log files through 
HoodieMergedLogRecordScanner, and used ExternalSpillableMap internally to 
achieve record merging, which resulted in performance loss of writing to disk.
+LogCompaction with Merge Sort is introduced to achieve lightweight minor 
compaction by merging records through N-way streaming of ordered data, thus 
improving the writing performance of the write side. At the same time, thanks 
to the ordered data, the query performance on the read side can be improved 
when the primary key is met.

Review Comment:
   Would the additional sorting, add some extra cost on the write? lets please 
call this out.



##########
rfc/rfc-81/rfc-81.md:
##########
@@ -0,0 +1,108 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+# RFC-81: Log Compaction with Merge Sort
+
+## Proposers
+- @usberkeley
+
+## Approvers
+- @danny0405
+
+## Status
+JIRA: https://issues.apache.org/jira/browse/HUDI-8033
+
+## Abstract
+Add lightweight LogCompaction to improve the writing performance of the write 
side, and improve the query performance of the read side (Spark/Presto, etc.) 
in some scenarios without having to wait for heavy and time-consuming 
operations such as Compaction or Clustering.
+
+## Background
+The previous LogCompaction mainly merged log files through 
HoodieMergedLogRecordScanner, and used ExternalSpillableMap internally to 
achieve record merging, which resulted in performance loss of writing to disk.
+LogCompaction with Merge Sort is introduced to achieve lightweight minor 
compaction by merging records through N-way streaming of ordered data, thus 
improving the writing performance of the write side. At the same time, thanks 
to the ordered data, the query performance on the read side can be improved 
when the primary key is met.
+
+## Implementation
+### HoodieConfig etc
+Added a new configuration item for the HoodieLogBlock streaming read buffer 
size. The default value is 10MB.
+#### Flink
+Added a new configuration item to enable LogCompaction. The default value is 
false.
+Note:
+1. After Flink enables LogCompaction, the default implementation is MergeSort.
+2. Currently, the log format only supports AVRO. After enabling LogCompaction, 
need to check whether the hoodie.logfile.data.block.format configuration item 
is correct.
+
+#### Spark
+Added a new configuration item for whether to enable MergeSort in 
LogCompaction. The default value is false.
+Note:
+1. Currently, the log format only supports AVRO. After LogCompaction turns on 
MergeSort, you need to check whether the hoodie.logfile.data.block.format 
configuration item is correct.
+
+### DeltaCommit
+#### Flink
+When LogCompaction is enabled, DeltaCommit sorts the written data by RecordKey 
to achieve orderly records in LogBlock.
+#### Spark
+When LogCompaction turns on MergeSort, DeltaCommit sorts the written data by 
RecordKey to achieve orderly records in LogBlock.
+
+### LogCompaction
+The following contents are all about enabling LogCompaction or enabling 
MergeSort with LogCompaction.
+#### Flink
+Flink has not yet fully implemented the LogCompaction feature, so the operator 
needs to be implemented:
+1. LogCompactionPlanOperator
+2. LogCompactionOperator
+3. LogCompactionCommitSink
+
+When scanning log files, use the new log scanner: 
HoodieMergeSortLogRecordScanner to achieve N-way streaming record merging.
+
+#### Spark
+When scanning log files, use the new log scanner: 
HoodieMergeSortLogRecordScanner to achieve N-way streaming record merging.
+
+### HoodieMergeSortLogRecordScanner
+Implement a min-heap. The heap node is a HoodieLogBlock object. The heap node 
comparison uses HoodieRecord#RecrodKey.
+When traversing the scanner record iterator, return to the top node of the 
heap and call the HoodieLogBlock object to return the record.
+
+### HoodieDataBlock
+Added a new streaming read abstract method to help 
HoodieMergeSortLogRecordScanner avoid OOM when reading N LogBlocks.

Review Comment:
   are we worried about parquet memory usage? for avro records, there should 
not be much memory overhead, right. 



-- 
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