yihua commented on code in PR #13171: URL: https://github.com/apache/hudi/pull/13171#discussion_r2053055397
########## hudi-client/hudi-java-client/src/test/java/org/apache/hudi/common/table/read/HoodieFileGroupReaderOnJavaTestBase.java: ########## @@ -0,0 +1,108 @@ +/* + * 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.table.read; + +import org.apache.hudi.client.HoodieJavaWriteClient; +import org.apache.hudi.client.common.HoodieJavaEngineContext; +import org.apache.hudi.common.config.RecordMergeMode; +import org.apache.hudi.common.engine.EngineType; +import org.apache.hudi.common.model.HoodieAvroRecord; +import org.apache.hudi.common.model.HoodieRecord; +import org.apache.hudi.common.model.HoodieRecordPayload; +import org.apache.hudi.common.table.HoodieTableMetaClient; +import org.apache.hudi.common.testutils.HoodieTestDataGenerator; +import org.apache.hudi.config.HoodieWriteConfig; +import org.apache.hudi.testutils.HoodieJavaClientTestHarness; + +import org.apache.hadoop.conf.Configuration; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public abstract class HoodieFileGroupReaderOnJavaTestBase<T> extends TestHoodieFileGroupReaderBase<T> { + + @Override + public String getBasePath() { + return tempDir.toAbsolutePath() + "/myTable"; + } + + @Override + public String getCustomPayload() { + return CustomPayloadForTesting.class.getName(); + } + + @Override + public void commitToTable(List<HoodieRecord> recordList, String operation, Map<String, String> writeConfigs) { + HoodieWriteConfig writeConfig = HoodieWriteConfig.newBuilder() + .withEngineType(EngineType.JAVA) + .withEmbeddedTimelineServerEnabled(false) + .withProps(writeConfigs) + .withPath(getBasePath()) + .withSchema(HoodieTestDataGenerator.TRIP_EXAMPLE_SCHEMA) + .build(); + + HoodieJavaClientTestHarness.TestJavaTaskContextSupplier taskContextSupplier = new HoodieJavaClientTestHarness.TestJavaTaskContextSupplier(); + HoodieJavaEngineContext context = new HoodieJavaEngineContext(getStorageConf(), taskContextSupplier); + //init table if not exists + Path basePath = new Path(getBasePath()); + try { + try (FileSystem lfs = basePath.getFileSystem(getStorageConf().unwrapAs(Configuration.class))) { + boolean basepathExists = lfs.exists(basePath); + boolean operationIsInsert = operation.equalsIgnoreCase("insert"); + if (!basepathExists || operationIsInsert) { + if (basepathExists) { + lfs.delete(new Path(getBasePath()), true); + } Review Comment: nit: the `FileSystem` usage can be replaced by `HoodieStorage` ########## hudi-client/hudi-java-client/src/test/java/org/apache/hudi/common/table/read/TestHoodieFileGroupReaderOnJava.java: ########## @@ -0,0 +1,50 @@ +/* + * 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.table.read; + +import org.apache.hudi.avro.HoodieAvroReaderContext; +import org.apache.hudi.common.engine.HoodieReaderContext; +import org.apache.hudi.common.table.HoodieTableMetaClient; +import org.apache.hudi.storage.StorageConfiguration; +import org.apache.hudi.storage.hadoop.HadoopStorageConfiguration; + +import org.apache.avro.Schema; +import org.apache.avro.generic.IndexedRecord; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +public class TestHoodieFileGroupReaderOnJava extends HoodieFileGroupReaderOnJavaTestBase<IndexedRecord> { + private static final StorageConfiguration<?> STORAGE_CONFIGURATION = new HadoopStorageConfiguration(false); + + @Override + public StorageConfiguration<?> getStorageConf() { + return STORAGE_CONFIGURATION; Review Comment: nit: it looks like the storage configuration is similar across file group reader test classes so it would be good to revisit this separately and have a common config provider to avoid custom configs disturbing the tests in an unexpected way. -- 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]
