-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[HUDI-7269] Fallback to key based merge if positions are missing from…
… log block (#11415) Fallback to key based merging if positions are missing from a log block when doing position based read in the fg reader. Changes: - Make position based buffer extend key based buffer so we can fall back to key based buffer. - Move some position based logic from the base buffer into the position buffer because that is the only place it is used. - If a log block is found to not have positions, we call a method to convert the map to use keys instead of positions: fallbackToKeyBasedBuffer(). This conversion is not completely effective because delete records may not have key stored. We set a flag "needToDoHybridStrategy" to true and then handle this issue when merging with the base file. --------- Co-authored-by: Jonathan Vexler <=> Co-authored-by: Sagar Sumit <[email protected]>
- Loading branch information
Showing
22 changed files
with
814 additions
and
186 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
...lient/hudi-spark-client/src/main/java/org/apache/hudi/OverwriteWithLatestSparkMerger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* 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; | ||
|
||
import org.apache.hudi.common.config.TypedProperties; | ||
import org.apache.hudi.common.model.HoodieRecord; | ||
import org.apache.hudi.common.util.Option; | ||
import org.apache.hudi.common.util.collection.Pair; | ||
|
||
import org.apache.avro.Schema; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Spark merger that always chooses the newer record | ||
*/ | ||
public class OverwriteWithLatestSparkMerger extends HoodieSparkRecordMerger { | ||
|
||
@Override | ||
public String getMergingStrategy() { | ||
return OVERWRITE_MERGER_STRATEGY_UUID; | ||
} | ||
|
||
@Override | ||
public Option<Pair<HoodieRecord, Schema>> merge(HoodieRecord older, Schema oldSchema, HoodieRecord newer, Schema newSchema, TypedProperties props) throws IOException { | ||
return Option.of(Pair.of(newer, newSchema)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
hudi-common/src/main/java/org/apache/hudi/common/model/OverwriteWithLatestMerger.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* 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.common.model; | ||
|
||
import org.apache.hudi.common.config.TypedProperties; | ||
import org.apache.hudi.common.util.Option; | ||
import org.apache.hudi.common.util.collection.Pair; | ||
|
||
import org.apache.avro.Schema; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* Avro Merger that always chooses the newer record | ||
*/ | ||
public class OverwriteWithLatestMerger implements HoodieRecordMerger { | ||
|
||
@Override | ||
public Option<Pair<HoodieRecord, Schema>> merge(HoodieRecord older, Schema oldSchema, HoodieRecord newer, Schema newSchema, TypedProperties props) throws IOException { | ||
return Option.of(Pair.of(newer, newSchema)); | ||
} | ||
|
||
@Override | ||
public HoodieRecord.HoodieRecordType getRecordType() { | ||
return HoodieRecord.HoodieRecordType.AVRO; | ||
} | ||
|
||
@Override | ||
public String getMergingStrategy() { | ||
return OVERWRITE_MERGER_STRATEGY_UUID; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.