You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2020/04/20 22:36:45 UTC

[GitHub] [incubator-hudi] satishkotha opened a new pull request #1540: [HUDI-819] Fix a bug with MergeOnReadLazyInsertIterable.

satishkotha opened a new pull request #1540:
URL: https://github.com/apache/incubator-hudi/pull/1540


   ## What is the purpose of the pull request
   
   Variable declared here [1] masks protected statuses variable. So although hoodie writes data, will not include WriteStatus in the completed section. This can cause duplicates being written
   
   [1] https://github.com/apache/incubator-hudi/blob/master/hudi-client/src/main/java/org/apache/hudi/execution/MergeOnReadLazyInsertIterable.java#L53
   
   ## Brief change log
   
   - Delete MergeOnReadLazyInsertIterable because it is exact same as COW except for the type of handle created (HoodieCreateHandle vs HoodieAppendHandle)
   - Added new 'HandleCreator' classes and reuse code in COWLazyInsertIterable
   
   Let me know if you have any other suggestions to improve this code. This refactoring also helps me with implementation of 'insert overwrite' features.
   
   ## Verify this pull request
   This pull request is already covered by existing tests in hudi-client 
   
   ## Committer checklist
   
    - [ ] Has a corresponding JIRA in PR title & commit
    
    - [ ] Commit message is descriptive of the change
    
    - [ ] CI is green
   
    - [ ] Necessary doc changes done or have another open PR
          
    - [ ] For large changes, please consider breaking it into sub-tasks under an umbrella JIRA.


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

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



[GitHub] [incubator-hudi] satishkotha commented on pull request #1540: [HUDI-819] Fix a bug with MergeOnReadLazyInsertIterable.

Posted by GitBox <gi...@apache.org>.
satishkotha commented on pull request #1540:
URL: https://github.com/apache/incubator-hudi/pull/1540#issuecomment-620126939


   @vinothchandar addressed your review comments. please take another look.


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

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



[GitHub] [incubator-hudi] vinothchandar commented on issue #1540: [HUDI-819] Fix a bug with MergeOnReadLazyInsertIterable.

Posted by GitBox <gi...@apache.org>.
vinothchandar commented on issue #1540:
URL: https://github.com/apache/incubator-hudi/pull/1540#issuecomment-618175675


   @satishkotha let's then break that up into a separate JIRA (tagged with Code Cleanup component). We can limit scope to these insert related handles and move on.. wdyt 


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

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



[GitHub] [incubator-hudi] vinothchandar commented on a change in pull request #1540: [HUDI-819] Fix a bug with MergeOnReadLazyInsertIterable.

Posted by GitBox <gi...@apache.org>.
vinothchandar commented on a change in pull request #1540:
URL: https://github.com/apache/incubator-hudi/pull/1540#discussion_r414295319



##########
File path: hudi-client/src/main/java/org/apache/hudi/io/AppendHandleFactory.java
##########
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+package org.apache.hudi.io;
+
+import org.apache.hudi.client.SparkTaskContextSupplier;
+import org.apache.hudi.common.model.HoodieRecordPayload;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.table.HoodieTable;
+
+public class AppendHandleFactory<T extends HoodieRecordPayload> extends CreateHandleFactory<T> {

Review comment:
       This inheritance is kind of confusing.. 

##########
File path: hudi-client/src/main/java/org/apache/hudi/io/AppendHandleFactory.java
##########
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+package org.apache.hudi.io;
+
+import org.apache.hudi.client.SparkTaskContextSupplier;
+import org.apache.hudi.common.model.HoodieRecordPayload;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.table.HoodieTable;
+
+public class AppendHandleFactory<T extends HoodieRecordPayload> extends CreateHandleFactory<T> {

Review comment:
       if you need some method in both Append and Create Handle factories, perhaps move it as a default method in the interface? 

##########
File path: hudi-client/src/main/java/org/apache/hudi/io/WriteHandleCreatorFactory.java
##########
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+package org.apache.hudi.io;
+
+import org.apache.hudi.client.SparkTaskContextSupplier;
+import org.apache.hudi.common.model.HoodieRecordPayload;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.table.HoodieTable;
+
+public interface WriteHandleCreatorFactory<T extends HoodieRecordPayload> {

Review comment:
       Rename to just `WriteHandleFactory`?

##########
File path: hudi-client/src/main/java/org/apache/hudi/execution/LazyInsertIterable.java
##########
@@ -43,26 +44,34 @@
 /**
  * Lazy Iterable, that writes a stream of HoodieRecords sorted by the partitionPath, into new files.
  */
-public class CopyOnWriteLazyInsertIterable<T extends HoodieRecordPayload>
+public class LazyInsertIterable<T extends HoodieRecordPayload>
     extends LazyIterableIterator<HoodieRecord<T>, List<WriteStatus>> {
 
   protected final HoodieWriteConfig hoodieConfig;
   protected final String instantTime;
   protected final HoodieTable<T> hoodieTable;
   protected final String idPrefix;
-  protected int numFilesWritten;
   protected SparkTaskContextSupplier sparkTaskContextSupplier;
+  protected WriteHandleCreatorFactory<T> writeHandleCreatorFactory;

Review comment:
       please rename this accordingly as well




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

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



[GitHub] [incubator-hudi] satishkotha commented on pull request #1540: [HUDI-819] Fix a bug with MergeOnReadLazyInsertIterable.

Posted by GitBox <gi...@apache.org>.
satishkotha commented on pull request #1540:
URL: https://github.com/apache/incubator-hudi/pull/1540#issuecomment-618717557


   > @satishkotha let's then break that up into a separate JIRA (tagged with Code Cleanup component). We can limit scope to these insert related handles and move on.. wdyt
   
   @vinothchandar Sure. that sounds good. I created HUDI-835 for this. Let me know if you have any other comments on create/append part


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

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



[GitHub] [incubator-hudi] vinothchandar commented on a change in pull request #1540: [HUDI-819] Fix a bug with MergeOnReadLazyInsertIterable.

Posted by GitBox <gi...@apache.org>.
vinothchandar commented on a change in pull request #1540:
URL: https://github.com/apache/incubator-hudi/pull/1540#discussion_r413294812



##########
File path: hudi-client/src/main/java/org/apache/hudi/io/HoodieHandleCreator.java
##########
@@ -0,0 +1,30 @@
+/*
+ * 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.
+ */
+
+package org.apache.hudi.io;
+
+import org.apache.hudi.client.SparkTaskContextSupplier;
+import org.apache.hudi.common.model.HoodieRecordPayload;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.table.HoodieTable;
+
+public interface HoodieHandleCreator<T extends HoodieRecordPayload> {

Review comment:
       Can we rename things per a standard factory pattern here?  `WriteHandleCreatorFactory` with a `create()` method? 

##########
File path: hudi-client/src/main/java/org/apache/hudi/io/DefaultHoodieWriteHandleCreator.java
##########
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+package org.apache.hudi.io;
+
+import org.apache.hudi.client.SparkTaskContextSupplier;
+import org.apache.hudi.common.model.HoodieRecordPayload;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.table.HoodieTable;
+
+public class DefaultHoodieWriteHandleCreator<T extends HoodieRecordPayload> implements HoodieHandleCreator<T> {

Review comment:
       this will then become `CreateHandleFactory` 

##########
File path: hudi-client/src/main/java/org/apache/hudi/io/HoodieAppendHandleCreator.java
##########
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+package org.apache.hudi.io;
+
+import org.apache.hudi.client.SparkTaskContextSupplier;
+import org.apache.hudi.common.model.HoodieRecordPayload;
+import org.apache.hudi.config.HoodieWriteConfig;
+import org.apache.hudi.table.HoodieTable;
+
+public class HoodieAppendHandleCreator<T extends HoodieRecordPayload> extends DefaultHoodieWriteHandleCreator<T> {

Review comment:
       and this `AppendHandleFactory` 




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

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



[GitHub] [incubator-hudi] satishkotha commented on issue #1540: [HUDI-819] Fix a bug with MergeOnReadLazyInsertIterable.

Posted by GitBox <gi...@apache.org>.
satishkotha commented on issue #1540:
URL: https://github.com/apache/incubator-hudi/pull/1540#issuecomment-618092361


   > +1 on the change itself.. For completeness let's also bring MergeHandle under the same factory implementation?
   
   I tried to fit in MergeHandle. But it doesn't seem to fit the pattern because constructor args requires recordItr at construction time. Other handles don't deal with recordItr directly. LazyInsertIterable deals with recordItr for these handles.  
   
   We need to make major changes to move recordItr from MergeHandle into UpdateHandler to fit it into the pattern. If you agree this is the right approach, I can implement it.
   
   What do you think? Let me know if you have other suggestions. 


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

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