[GitHub] [hudi] umehrot2 commented on a change in pull request #1869: [HUDI-427] Implement CLI support for performing bootstrap
umehrot2 commented on a change in pull request #1869: URL: https://github.com/apache/hudi/pull/1869#discussion_r466248630 ## File path: hudi-common/src/main/java/org/apache/hudi/common/bootstrap/index/HFileBootstrapIndex.java ## @@ -240,13 +240,21 @@ private HoodieBootstrapIndexInfo fetchBootstrapIndexInfo() throws IOException { @Override public List getIndexedPartitionPaths() { HFileScanner scanner = partitionIndexReader().getScanner(true, true); - return getAllKeys(scanner); + List cellKeys = getAllKeys(scanner); + // cellKey is in this format: + // part=datestr=2452537//LATEST_TIMESTAMP/Put/vlen=2405/seqid=0 + return cellKeys.stream().map(key -> key.split("//")[0].substring(5)) + .distinct().collect(Collectors.toList()); } @Override public List getIndexedFileIds() { HFileScanner scanner = fileIdIndexReader().getScanner(true, true); - return getAllKeys(scanner); + List cellKeys = getAllKeys(scanner); + // cellKey is in this format: + // part=datestr=2452537;fileid=baab9c50-c35e-49d1-b928-695aa7e37833//LATEST_TIMESTAMP/Put/vlen=2312/seqid=0 + return cellKeys.stream().map(key -> key.split("//")[0].split(";")[1].split("=")[1]) Review comment: I have this question too, but IIUC this code path was probably not being used till now. @zhedoubushishi can confirm. 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] umehrot2 commented on a change in pull request #1869: [HUDI-427] Implement CLI support for performing bootstrap
umehrot2 commented on a change in pull request #1869: URL: https://github.com/apache/hudi/pull/1869#discussion_r466117695 ## File path: hudi-cli/src/main/java/org/apache/hudi/cli/commands/BootstrapCommand.java ## @@ -0,0 +1,184 @@ +/* + * 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.cli.commands; + +import org.apache.hudi.cli.HoodieCLI; +import org.apache.hudi.cli.HoodiePrintHelper; +import org.apache.hudi.cli.TableHeader; +import org.apache.hudi.cli.commands.SparkMain.SparkCommand; +import org.apache.hudi.cli.utils.InputStreamConsumer; +import org.apache.hudi.cli.utils.SparkUtil; +import org.apache.hudi.common.bootstrap.index.BootstrapIndex; +import org.apache.hudi.common.model.BootstrapFileMapping; +import org.apache.hudi.common.model.HoodieFileGroupId; +import org.apache.hudi.common.table.HoodieTableMetaClient; +import org.apache.hudi.utilities.UtilHelpers; + +import org.apache.spark.launcher.SparkLauncher; +import org.apache.spark.util.Utils; +import org.springframework.shell.core.CommandMarker; +import org.springframework.shell.core.annotation.CliCommand; +import org.springframework.shell.core.annotation.CliOption; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.util.Arrays; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.stream.Collectors; + +import scala.collection.JavaConverters; + +/** + * CLI command to perform bootstrap action & display bootstrap index. + */ +@Component +public class BootstrapCommand implements CommandMarker { + + @CliCommand(value = "bootstrap run", help = "Run a bootstrap action for current Hudi table") + public String bootstrap( + @CliOption(key = {"srcPath"}, mandatory = true, help = "Bootstrap source data path of the table") final String srcPath, + @CliOption(key = {"targetPath"}, mandatory = true, + help = "Base path for the target hoodie table") final String targetPath, + @CliOption(key = {"tableName"}, mandatory = true, help = "Hoodie table name") final String tableName, + @CliOption(key = {"tableType"}, mandatory = true, help = "Hoodie table type") final String tableType, + @CliOption(key = {"rowKeyField"}, mandatory = true, help = "Record key columns for bootstrap data") final String rowKeyField, + @CliOption(key = {"partitionPathField"}, unspecifiedDefaultValue = "", + help = "Partition fields for bootstrap source data") final String partitionPathField, + @CliOption(key = {"bootstrapIndexClass"}, unspecifiedDefaultValue = "org.apache.hudi.common.bootstrap.index.HFileBootstrapIndex", + help = "Bootstrap Index Class") final String bootstrapIndexClass, + @CliOption(key = {"selectorClass"}, unspecifiedDefaultValue = "org.apache.hudi.client.bootstrap.selector.MetadataOnlyBootstrapModeSelector", + help = "Selector class for bootstrap") final String selectorClass, + @CliOption(key = {"keyGeneratorClass"}, unspecifiedDefaultValue = "org.apache.hudi.keygen.SimpleKeyGenerator", + help = "Key generator class for bootstrap") final String keyGeneratorClass, + @CliOption(key = {"fullBootstrapInputProvider"}, unspecifiedDefaultValue = "org.apache.hudi.bootstrap.SparkParquetBootstrapDataProvider", + help = "Class for Full bootstrap input provider") final String fullBootstrapInputProvider, + @CliOption(key = {"schemaProviderClass"}, unspecifiedDefaultValue = "", + help = "SchemaProvider to attach schemas to bootstrap source data") final String schemaProviderClass, + @CliOption(key = {"payloadClass"}, unspecifiedDefaultValue = "org.apache.hudi.common.model.HoodieAvroPayload", + help = "Payload Class") final String payloadClass, + @CliOption(key = {"parallelism"}, unspecifiedDefaultValue = "1500", help = "Bootstrap writer parallelism") final int parallelism, + @CliOption(key = {"sparkMaster"}, unspecifiedDefaultValue = "", help = "Spark Master") String master, + @CliOption(key = {"sparkMemory"}, unspecifiedDefaultValue = "4G", help = "Spark executor memory") final String sparkMemory, +
[GitHub] [hudi] umehrot2 commented on a change in pull request #1869: [HUDI-427] Implement CLI support for performing bootstrap
umehrot2 commented on a change in pull request #1869: URL: https://github.com/apache/hudi/pull/1869#discussion_r462677662 ## File path: hudi-cli/src/main/java/org/apache/hudi/cli/commands/BootstrapCommand.java ## @@ -0,0 +1,189 @@ +/* + * 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.cli.commands; + +import org.apache.hudi.avro.model.BootstrapIndexInfo; +import org.apache.hudi.cli.HoodieCLI; +import org.apache.hudi.cli.HoodiePrintHelper; +import org.apache.hudi.cli.TableHeader; +import org.apache.hudi.cli.commands.SparkMain.SparkCommand; +import org.apache.hudi.cli.utils.InputStreamConsumer; +import org.apache.hudi.cli.utils.SparkUtil; +import org.apache.hudi.common.model.BootstrapSourceFileMapping; +import org.apache.hudi.common.model.HoodieFileGroupId; +import org.apache.hudi.common.table.HoodieTableMetaClient; +import org.apache.hudi.utilities.UtilHelpers; + +import org.apache.spark.launcher.SparkLauncher; +import org.apache.spark.util.Utils; +import org.springframework.shell.core.CommandMarker; +import org.springframework.shell.core.annotation.CliCommand; +import org.springframework.shell.core.annotation.CliOption; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.net.URISyntaxException; +import java.util.Arrays; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.stream.Collectors; + +import scala.collection.JavaConverters; + +/** + * CLI command to perform bootstrap action & display bootstrap index. + */ +@Component +public class BootstrapCommand implements CommandMarker { + + @CliCommand(value = "bootstrap run", help = "Run a bootstrap action for current Hudi table") + public String bootstrap( Review comment: It seems like to run `bootstrap` command, it will be mandatory for the user to himself create the `target Hudi location` and connect to it before being able to perform bootstrap. I remember discussing once about this, but can you help me understand again what is the challenge in supporting this end to end without requiring to connect to a table ? I see `HDFSParquetImportCommand` being able to do this end to end, creating the target table itself without requiring the user to do it. ## File path: hudi-cli/src/main/java/org/apache/hudi/cli/commands/BootstrapCommand.java ## @@ -0,0 +1,189 @@ +/* + * 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.cli.commands; + +import org.apache.hudi.avro.model.BootstrapIndexInfo; +import org.apache.hudi.cli.HoodieCLI; +import org.apache.hudi.cli.HoodiePrintHelper; +import org.apache.hudi.cli.TableHeader; +import org.apache.hudi.cli.commands.SparkMain.SparkCommand; +import org.apache.hudi.cli.utils.InputStreamConsumer; +import org.apache.hudi.cli.utils.SparkUtil; +import org.apache.hudi.common.model.BootstrapSourceFileMapping; +import org.apache.hudi.common.model.HoodieFileGroupId; +import org.apache.hudi.common.table.HoodieTableMetaClient; +import org.apache.hudi.utilities.UtilHelpers; + +import org.apache.spark.launcher.SparkLauncher; +import org.apache.spark.util.Utils; +import org.springframework.shell.core.CommandMarker; +import org.springframework.shell.core.annotation.CliCommand; +import org.springframework.shell.core.annotation.CliOption; +import org.springframework.stereotype.Component; + +import java.io.IOException; +import java.net.URISy