[FOLLOW-UP] HIVE-28373: Iceberg: Refactor the code of HadoopTableOptions#6345
[FOLLOW-UP] HIVE-28373: Iceberg: Refactor the code of HadoopTableOptions#6345BsoBird wants to merge 4 commits intoapache:masterfrom
Conversation
There was a problem hiding this comment.
please drop the unnecessary casts
| String cmd = String.format("mv -n %s %s", srcPathStr, dstPathStr); | ||
| Process process = Runtime.getRuntime().exec(cmd); | ||
| assertThat(process.waitFor()).isZero(); | ||
| Files.move( |
There was a problem hiding this comment.
why such a massive copy-paste?
try {
HadoopTableOperations tableOperations = (HadoopTableOperations) baseTable.operations();
HadoopTableOperations spyOps = spy(tableOperations);
doNothing().when(spyOps).tryLock(any(), any());
doAnswer(x -> {
countDownLatch.countDown();
countDownLatch.await();
return x.callRealMethod();
}).when(spyOps).renameMetaDataFileAndCheck(any(), any(), any(), anyBoolean());
doAnswer(x -> {
Path srcPath = x.getArgument(1);
Path dstPath = x.getArgument(2);
Files.move(
Paths.get(srcPath.toUri()), Paths.get(dstPath.toUri()),
StandardCopyOption.ATOMIC_MOVE
);
return true;
}).when(spyOps).renameMetaDataFile(any(), any(), any());
TableMetadata metadataV1 = spyOps.current();
SortOrder dataSort = SortOrder.builderFor(baseTable.schema()).asc("data").build();
TableMetadata metadataV2 = metadataV1.replaceSortOrder(dataSort);
spyOps.commit(metadataV1, metadataV2);
} catch (CommitFailedException e) {
expectedException.set(e);
} catch (Throwable e) {
unexpectedException.set(e);
}
There was a problem hiding this comment.
why 8 threads? Executors.newFixedThreadPool(8)
use virtual threads instead
There was a problem hiding this comment.
Runnable commitTask = () -> {
try {
HadoopTableOperations tableOperations = (HadoopTableOperations) baseTable.operations();
HadoopTableOperations spyOps = spy(tableOperations);
doNothing().when(spyOps).tryLock(any(), any());
doAnswer(x -> {
countDownLatch.countDown();
countDownLatch.await();
return x.callRealMethod();
}).when(spyOps).renameMetaDataFileAndCheck(any(), any(), any(), anyBoolean());
doAnswer(x -> {
Path srcPath = x.getArgument(1);
Path dstPath = x.getArgument(2);
var src = Paths.get(srcPath.toUri());
var dst = Paths.get(dstPath.toUri());
Files.move(src, dst, StandardCopyOption.ATOMIC_MOVE);
return Files.exists(dst) && Files.notExists(src);
}).when(spyOps).renameMetaDataFile(any(), any(), any());
TableMetadata metadataV1 = spyOps.current();
SortOrder dataSort = SortOrder.builderFor(baseTable.schema()).asc("data").build();
TableMetadata metadataV2 = metadataV1.replaceSortOrder(dataSort);
spyOps.commit(metadataV1, metadataV2);
} catch (CommitFailedException e) {
expectedException.set(e);
} catch (Throwable e) {
unexpectedException.set(e);
}
};
Tasks.range(2)
.executeWith(executorService)
.run(i -> commitTask.run());
2.remove unnecessary casts 3.remove massive copy-paste
|
@BsoBird this test fails most of the time for me. failed on jenkins as well: https://ci.hive.apache.org/job/hive-precommit/job/PR-6345/1/testReport/junit/org.apache.iceberg.hadoop/TestHiveHadoopCommits/Testing___split_20___PostProcess___testTwoClientCommitSameVersion/ |
…entation differences.
|
|
@deniskuzZ |



What changes were proposed in this pull request?
Modify the test case to ensure it can run on macOS environments.
Why are the changes needed?
Since a considerable number of developers use macOS as their local development environment, the test case code should avoid relying on Linux-specific commands.
Does this PR introduce any user-facing change?
No