[GitHub] [hudi] xushiyan commented on a change in pull request #1871: [HUDI-781] Introduce HoodieTestTable for test preparation
xushiyan commented on a change in pull request #1871: URL: https://github.com/apache/hudi/pull/1871#discussion_r468279092 ## File path: hudi-common/src/test/java/org/apache/hudi/common/testutils/HoodieTestUtils.java ## @@ -237,11 +229,12 @@ public static void createPendingCleanFiles(HoodieTableMetaClient metaClient, Str public static void createCorruptedPendingCleanFiles(HoodieTableMetaClient metaClient, String commitTime) { Arrays.asList(HoodieTimeline.makeRequestedCleanerFileName(commitTime), -HoodieTimeline.makeInflightCleanerFileName(commitTime)).forEach(f -> { +HoodieTimeline.makeInflightCleanerFileName(commitTime)) +.forEach(f -> { FSDataOutputStream os = null; try { Path commitFile = new Path( -metaClient.getBasePath() + "/" + HoodieTableMetaClient.METAFOLDER_NAME + "/" + f); +metaClient.getBasePath() + "/" + HoodieTableMetaClient.METAFOLDER_NAME + "/" + f); Review comment: ok @yanghua , understood. I agree that the work should focus on the task. I didn't intend to change these; intellij did it for me. i should have disabled the auto-formatting. will keep this sort of diffs out from now on. thanks 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: us...@infra.apache.org
[GitHub] [hudi] xushiyan commented on a change in pull request #1871: [HUDI-781] Introduce HoodieTestTable for test preparation
xushiyan commented on a change in pull request #1871: URL: https://github.com/apache/hudi/pull/1871#discussion_r468032133 ## File path: hudi-common/src/test/java/org/apache/hudi/common/testutils/HoodieTestUtils.java ## @@ -237,11 +229,12 @@ public static void createPendingCleanFiles(HoodieTableMetaClient metaClient, Str public static void createCorruptedPendingCleanFiles(HoodieTableMetaClient metaClient, String commitTime) { Arrays.asList(HoodieTimeline.makeRequestedCleanerFileName(commitTime), -HoodieTimeline.makeInflightCleanerFileName(commitTime)).forEach(f -> { +HoodieTimeline.makeInflightCleanerFileName(commitTime)) +.forEach(f -> { FSDataOutputStream os = null; try { Path commitFile = new Path( -metaClient.getBasePath() + "/" + HoodieTableMetaClient.METAFOLDER_NAME + "/" + f); +metaClient.getBasePath() + "/" + HoodieTableMetaClient.METAFOLDER_NAME + "/" + f); Review comment: sure, fixed 2 of this. Please note that, as this is from the original codebase, i didn't change all of this kind of usage in this file. I think it could be a good chance to change while moving the APIs to `HoodieTestTable`. 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: us...@infra.apache.org
[GitHub] [hudi] xushiyan commented on a change in pull request #1871: [HUDI-781] Introduce HoodieTestTable for test preparation
xushiyan commented on a change in pull request #1871: URL: https://github.com/apache/hudi/pull/1871#discussion_r468021630 ## File path: hudi-common/src/test/java/org/apache/hudi/common/testutils/HoodieTestUtils.java ## @@ -237,11 +229,12 @@ public static void createPendingCleanFiles(HoodieTableMetaClient metaClient, Str public static void createCorruptedPendingCleanFiles(HoodieTableMetaClient metaClient, String commitTime) { Arrays.asList(HoodieTimeline.makeRequestedCleanerFileName(commitTime), -HoodieTimeline.makeInflightCleanerFileName(commitTime)).forEach(f -> { +HoodieTimeline.makeInflightCleanerFileName(commitTime)) +.forEach(f -> { Review comment: intellij will force some weird indentation that breaks checkstyle rule...this is the easiest way I can find to prevent that 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: us...@infra.apache.org
[GitHub] [hudi] xushiyan commented on a change in pull request #1871: [HUDI-781] Introduce HoodieTestTable for test preparation
xushiyan commented on a change in pull request #1871: URL: https://github.com/apache/hudi/pull/1871#discussion_r467669290 ## File path: hudi-common/src/test/java/org/apache/hudi/common/testutils/HoodieTestUtils.java ## @@ -307,31 +299,26 @@ public static String createNewLogFile(FileSystem fs, String basePath, String par return fileID; } - public static void createCompactionCommitFiles(FileSystem fs, String basePath, String... instantTimes) - throws IOException { -for (String instantTime : instantTimes) { - boolean createFile = fs.createNewFile(new Path(basePath + "/" + HoodieTableMetaClient.METAFOLDER_NAME + "/" - + HoodieTimeline.makeCommitFileName(instantTime))); - if (!createFile) { -throw new IOException("cannot create commit file for commit " + instantTime); - } -} - } - public static void createCompactionRequest(HoodieTableMetaClient metaClient, String instant, - List> fileSliceList) throws IOException { + List> fileSliceList) throws IOException { Review comment: I see the issue is that we did not set `forceStrictCondition` to `true`, that's why intellij can align this and make the indentation longer than what the rule sets. https://checkstyle.sourceforge.io/config_misc.html#Indentation_Properties @yanghua Do you agree we should set it to `true`? This can be done in a separate PR. 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: us...@infra.apache.org
[GitHub] [hudi] xushiyan commented on a change in pull request #1871: [HUDI-781] Introduce HoodieTestTable for test preparation
xushiyan commented on a change in pull request #1871: URL: https://github.com/apache/hudi/pull/1871#discussion_r467664319 ## File path: hudi-common/src/test/java/org/apache/hudi/common/testutils/FilesTestUtils.java ## @@ -0,0 +1,104 @@ +/* + * 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.testutils; + +import org.apache.hudi.common.fs.FSUtils; +import org.apache.hudi.common.model.HoodieFileFormat; +import org.apache.hudi.common.model.IOType; +import org.apache.hudi.common.table.HoodieTableMetaClient; +import org.apache.hudi.common.table.timeline.HoodieTimeline; + +import java.io.File; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.nio.file.Files; +import java.nio.file.Paths; + +public class FilesTestUtils { Review comment: ok i see your point. To follow the idea of `create` in another comment, how about `FileCreateUtils` ? 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: us...@infra.apache.org
[GitHub] [hudi] xushiyan commented on a change in pull request #1871: [HUDI-781] Introduce HoodieTestTable for test preparation
xushiyan commented on a change in pull request #1871: URL: https://github.com/apache/hudi/pull/1871#discussion_r467662611 ## File path: hudi-common/src/test/java/org/apache/hudi/common/testutils/FilesTestUtils.java ## @@ -0,0 +1,104 @@ +/* + * 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.testutils; + +import org.apache.hudi.common.fs.FSUtils; +import org.apache.hudi.common.model.HoodieFileFormat; +import org.apache.hudi.common.model.IOType; +import org.apache.hudi.common.table.HoodieTableMetaClient; +import org.apache.hudi.common.table.timeline.HoodieTimeline; + +import java.io.File; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.nio.file.Files; +import java.nio.file.Paths; + +public class FilesTestUtils { + + private static void fakeMetaFile(String basePath, String instantTime, String suffix) throws IOException { +String parentPath = basePath + "/" + HoodieTableMetaClient.METAFOLDER_NAME; +new File(parentPath).mkdirs(); +new File(parentPath + "/" + instantTime + suffix).createNewFile(); + } + + public static void fakeCommit(String basePath, String instantTime) throws IOException { Review comment: @yanghua how about `create`? since it is actually "creating" stuff. e.g., legit marker files are indeed "created" by these APIs. Plus the follow-up work is to write actual data to these files, which make them real.. 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: us...@infra.apache.org
[GitHub] [hudi] xushiyan commented on a change in pull request #1871: [HUDI-781] Introduce HoodieTestTable for test preparation
xushiyan commented on a change in pull request #1871: URL: https://github.com/apache/hudi/pull/1871#discussion_r467662611 ## File path: hudi-common/src/test/java/org/apache/hudi/common/testutils/FilesTestUtils.java ## @@ -0,0 +1,104 @@ +/* + * 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.testutils; + +import org.apache.hudi.common.fs.FSUtils; +import org.apache.hudi.common.model.HoodieFileFormat; +import org.apache.hudi.common.model.IOType; +import org.apache.hudi.common.table.HoodieTableMetaClient; +import org.apache.hudi.common.table.timeline.HoodieTimeline; + +import java.io.File; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.nio.file.Files; +import java.nio.file.Paths; + +public class FilesTestUtils { + + private static void fakeMetaFile(String basePath, String instantTime, String suffix) throws IOException { +String parentPath = basePath + "/" + HoodieTableMetaClient.METAFOLDER_NAME; +new File(parentPath).mkdirs(); +new File(parentPath + "/" + instantTime + suffix).createNewFile(); + } + + public static void fakeCommit(String basePath, String instantTime) throws IOException { Review comment: @yanghua how about `make`? since it is actually "making" stuff. e.g., legit marker files are indeed "made" by these APIs. Plus the follow-up work is to write actual data to these files, which make them real.. 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: us...@infra.apache.org
[GitHub] [hudi] xushiyan commented on a change in pull request #1871: [HUDI-781] Introduce HoodieTestTable for test preparation
xushiyan commented on a change in pull request #1871: URL: https://github.com/apache/hudi/pull/1871#discussion_r467661774 ## File path: hudi-common/src/test/java/org/apache/hudi/common/testutils/FilesTestUtils.java ## @@ -0,0 +1,104 @@ +/* + * 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.testutils; + +import org.apache.hudi.common.fs.FSUtils; +import org.apache.hudi.common.model.HoodieFileFormat; +import org.apache.hudi.common.model.IOType; +import org.apache.hudi.common.table.HoodieTableMetaClient; +import org.apache.hudi.common.table.timeline.HoodieTimeline; + +import java.io.File; +import java.io.IOException; +import java.io.RandomAccessFile; +import java.nio.file.Files; +import java.nio.file.Paths; + +public class FilesTestUtils { + + private static void fakeMetaFile(String basePath, String instantTime, String suffix) throws IOException { +String parentPath = basePath + "/" + HoodieTableMetaClient.METAFOLDER_NAME; +new File(parentPath).mkdirs(); +new File(parentPath + "/" + instantTime + suffix).createNewFile(); + } + + public static void fakeCommit(String basePath, String instantTime) throws IOException { Review comment: hmm i'm a bit hesitated about using `mock` as this is commonly used by `Mockito`. it could imply mock object is used here, while we're actually creating files.. 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: us...@infra.apache.org
[GitHub] [hudi] xushiyan commented on a change in pull request #1871: [HUDI-781] Introduce HoodieTestTable for test preparation
xushiyan commented on a change in pull request #1871: URL: https://github.com/apache/hudi/pull/1871#discussion_r467661104 ## File path: hudi-common/src/test/java/org/apache/hudi/common/testutils/HoodieTestUtils.java ## @@ -307,31 +299,26 @@ public static String createNewLogFile(FileSystem fs, String basePath, String par return fileID; } - public static void createCompactionCommitFiles(FileSystem fs, String basePath, String... instantTimes) - throws IOException { -for (String instantTime : instantTimes) { - boolean createFile = fs.createNewFile(new Path(basePath + "/" + HoodieTableMetaClient.METAFOLDER_NAME + "/" - + HoodieTimeline.makeCommitFileName(instantTime))); - if (!createFile) { -throw new IOException("cannot create commit file for commit " + instantTime); - } -} - } - public static void createCompactionRequest(HoodieTableMetaClient metaClient, String instant, - List> fileSliceList) throws IOException { + List> fileSliceList) throws IOException { Review comment: Checkstyle did not complain about (or cover) it. The intellij of the new version starts to format this way. Guess it is due to missing a checkstyle rule for this, causing IDE format in its own way. Right now I've seen this style exist too in the codebase. 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: us...@infra.apache.org
[GitHub] [hudi] xushiyan commented on a change in pull request #1871: [HUDI-781] Introduce HoodieTestTable for test preparation
xushiyan commented on a change in pull request #1871: URL: https://github.com/apache/hudi/pull/1871#discussion_r467367284 ## File path: hudi-client/src/test/java/org/apache/hudi/testutils/HoodieClientTestUtils.java ## @@ -227,6 +176,8 @@ public static SparkConf getSparkConfForTest(String appName) { /** * Find total basefiles for passed in paths. + * + * @deprecated Use {@link HoodieTestTable} instead. Review comment: mark deprecated to prevent new usage; also as a reminder to migrate in future PRs. Similar to other deprecated marks. 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: us...@infra.apache.org