xushiyan commented on code in PR #7336:
URL: https://github.com/apache/hudi/pull/7336#discussion_r1236935296
##########
hudi-client/hudi-client-common/src/main/java/org/apache/hudi/client/FailOnFirstErrorWriteStatus.java:
##########
@@ -38,9 +40,9 @@ public FailOnFirstErrorWriteStatus(Boolean
trackSuccessRecords, Double failureFr
}
@Override
- public void markFailure(HoodieRecord record, Throwable t, Option<Map<String,
String>> optionalRecordMetadata) {
- LOG.error(String.format("Error writing record %s with data %s and
optionalRecordMetadata %s", record, record.getData(),
- optionalRecordMetadata.orElse(Collections.emptyMap()), t));
- throw new HoodieException("Error writing record " + record + ": " +
t.getMessage());
+ public void markFailure(Lazy<HoodieRecordDelegate> recordDelegateLazy,
Throwable t, Option<Map<String, String>> optionalRecordMetadata) {
+ LOG.error(String.format("Error writing key %s and optionalRecordMetadata
%s error %s", recordDelegateLazy,
+ optionalRecordMetadata.orElse(Collections.emptyMap()), t));
+ throw new HoodieException("Error writing record " + recordDelegateLazy +
": " + t.getMessage());
Review Comment:
fix - using proper value for msg
##########
hudi-common/src/main/java/org/apache/hudi/common/model/HoodieRecordDelegate.java:
##########
@@ -0,0 +1,110 @@
+/*
+ * 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.util.Option;
+
+import javax.annotation.Nullable;
+
+/**
+ * Delegate for {@link HoodieRecord}.
+ */
+public class HoodieRecordDelegate {
Review Comment:
more javadoc
##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/client/functional/TestHoodieClientOnCopyOnWriteStorage.java:
##########
@@ -568,26 +569,26 @@ private void testDeduplicationKeepOperation(
List<WriteStatus> statuses = writeFn.apply(client, recordList,
newCommitTime).collect();
assertNoWriteErrors(statuses);
assertEquals(2, statuses.size());
-
assertNodupesInPartition(statuses.stream().map(WriteStatus::getWrittenRecords).flatMap(Collection::stream)
+
assertNodupesInPartition(statuses.stream().map(WriteStatus::getWrittenRecordDelegates).flatMap(Collection::stream)
.collect(Collectors.toList()));
}
}
/**
* Assert that there is no duplicate key at the partition level.
*
- * @param records List of Hoodie records
+ * @param keys List of Hoodie records
*/
- void assertNodupesInPartition(List<HoodieRecord> records) {
+ void assertNodupesInPartition(List<HoodieRecordDelegate> keys) {
Review Comment:
fix var names and javadoc
##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/client/TestWriteStatus.java:
##########
@@ -137,12 +145,66 @@ public void testSuccessWithEventTime() {
for (int i = 0; i < 1000; i++) {
Map<String, String> metadata = new HashMap<>();
metadata.put(DefaultHoodieRecordPayload.METADATA_EVENT_TIME_KEY,
String.valueOf(i));
- status.markSuccess(mock(HoodieRecord.class), Option.of(metadata));
+ status.markSuccess(eagerly(mock(HoodieRecordDelegate.class)),
Option.of(metadata));
}
assertEquals(1000, status.getTotalRecords());
assertFalse(status.hasErrors());
assertNull(status.getStat().getMaxEventTime());
assertNull(status.getStat().getMinEventTime());
}
+
+ @Test
+ public void testFailureFractionExtended() {
+ WriteStatus status = new WriteStatus(true, 0.1);
+ String fileId = UUID.randomUUID().toString();
+ String partitionPath = UUID.randomUUID().toString();
+ status.setFileId(fileId);
+ status.setPartitionPath(partitionPath);
+ Throwable t = new Exception("some error in writing");
+ for (int i = 0; i < 1000; i++) {
+ status.markFailure(lazily(()
+ -> HoodieRecordDelegate.create(UUID.randomUUID().toString(),
partitionPath)), t, Option.empty());
Review Comment:
fix - use eagerly() for mock object
##########
hudi-client/hudi-spark-client/src/test/java/org/apache/hudi/client/TestWriteStatus.java:
##########
@@ -40,7 +45,8 @@ public void testFailureFraction() {
WriteStatus status = new WriteStatus(true, 0.1);
Throwable t = new Exception("some error in writing");
for (int i = 0; i < 1000; i++) {
- status.markFailure(mock(HoodieRecord.class), t, null);
+ status.markFailure(lazily(()
+ -> HoodieRecordDelegate.create(UUID.randomUUID().toString(),
"path1", null, null)), t, null);
Review Comment:
fix - use eagerly() for mock object
--
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]