-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[HUDI-1013] Adding Bulk Insert V2 implementation #1834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d491a32
Bulk Insert Dataset Based Implementation using Datasource to improve …
bvaradar 06c1370
Code review comments, cleanup, fixes, restructuring
vinothchandar 383a745
Some fixes to key generators and adding more tests for Row apis
nsivabalan fefd4b7
Cleaning up config placements, naming
vinothchandar 865d8d6
Clean up changes made on the public KeyGenerator class
vinothchandar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
150 changes: 150 additions & 0 deletions
150
hudi-client/src/main/java/org/apache/hudi/client/HoodieInternalWriteStatus.java
This file contains hidden or 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,150 @@ | ||
| /* | ||
| * 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.client; | ||
|
|
||
| import org.apache.hudi.common.model.HoodieWriteStat; | ||
| import org.apache.hudi.common.util.collection.Pair; | ||
|
|
||
| import java.io.Serializable; | ||
| import java.util.ArrayList; | ||
| import java.util.List; | ||
| import java.util.Random; | ||
|
|
||
| /** | ||
| * Hoodie's internal write status used in datasource implementation of bulk insert. | ||
| */ | ||
| public class HoodieInternalWriteStatus implements Serializable { | ||
|
|
||
| private static final long serialVersionUID = 1L; | ||
| private static final long RANDOM_SEED = 9038412832L; | ||
|
|
||
| private String fileId; | ||
| private String partitionPath; | ||
| private List<String> successRecordKeys = new ArrayList<>(); | ||
| private List<Pair<String, Throwable>> failedRecordKeys = new ArrayList<>(); | ||
|
|
||
| private HoodieWriteStat stat; | ||
|
|
||
| private long totalRecords = 0; | ||
| private long totalErrorRecords = 0; | ||
| private Throwable globalError = null; | ||
|
|
||
| private final double failureFraction; | ||
| private final boolean trackSuccessRecords; | ||
| private final transient Random random; | ||
|
|
||
| public HoodieInternalWriteStatus(Boolean trackSuccessRecords, Double failureFraction) { | ||
| this.trackSuccessRecords = trackSuccessRecords; | ||
| this.failureFraction = failureFraction; | ||
| this.random = new Random(RANDOM_SEED); | ||
| } | ||
|
|
||
| public void markSuccess(String recordKey) { | ||
| if (trackSuccessRecords) { | ||
| this.successRecordKeys.add(recordKey); | ||
| } | ||
| totalRecords++; | ||
| } | ||
|
|
||
| public void markFailure(String recordKey, Throwable t) { | ||
| if (failedRecordKeys.isEmpty() || (random.nextDouble() <= failureFraction)) { | ||
| failedRecordKeys.add(Pair.of(recordKey, t)); | ||
| } | ||
| totalRecords++; | ||
| } | ||
|
|
||
| public boolean hasErrors() { | ||
| return failedRecordKeys.size() != 0; | ||
| } | ||
|
|
||
| public HoodieWriteStat getStat() { | ||
| return stat; | ||
| } | ||
|
|
||
| public void setStat(HoodieWriteStat stat) { | ||
| this.stat = stat; | ||
| } | ||
|
|
||
| public String getFileId() { | ||
| return fileId; | ||
| } | ||
|
|
||
| public void setFileId(String fileId) { | ||
| this.fileId = fileId; | ||
| } | ||
|
|
||
| public String getPartitionPath() { | ||
| return partitionPath; | ||
| } | ||
|
|
||
| public void setPartitionPath(String partitionPath) { | ||
| this.partitionPath = partitionPath; | ||
| } | ||
|
|
||
| public List<String> getSuccessRecordKeys() { | ||
| return successRecordKeys; | ||
| } | ||
|
|
||
| public long getFailedRowsSize() { | ||
| return failedRecordKeys.size(); | ||
| } | ||
|
|
||
| public List<Pair<String, Throwable>> getFailedRecordKeys() { | ||
| return failedRecordKeys; | ||
| } | ||
|
|
||
| public void setFailedRecordKeys(List<Pair<String, Throwable>> failedRecordKeys) { | ||
| this.failedRecordKeys = failedRecordKeys; | ||
| } | ||
|
|
||
| public long getTotalRecords() { | ||
| return totalRecords; | ||
| } | ||
|
|
||
| public void setTotalRecords(long totalRecords) { | ||
| this.totalRecords = totalRecords; | ||
| } | ||
|
|
||
| public long getTotalErrorRecords() { | ||
| return totalErrorRecords; | ||
| } | ||
|
|
||
| public void setTotalErrorRecords(long totalErrorRecords) { | ||
| this.totalErrorRecords = totalErrorRecords; | ||
| } | ||
|
|
||
| public Throwable getGlobalError() { | ||
| return globalError; | ||
| } | ||
|
|
||
| public void setGlobalError(Throwable globalError) { | ||
| this.globalError = globalError; | ||
| } | ||
|
|
||
| public void setSuccessRecordKeys(List<String> successRecordKeys) { | ||
| this.successRecordKeys = successRecordKeys; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "PartitionPath " + partitionPath + ", FileID " + fileId + ", Success records " | ||
| + totalRecords + ", errored Rows " + totalErrorRecords | ||
| + ", global error " + (globalError != null); | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.