yihua commented on code in PR #9872: URL: https://github.com/apache/hudi/pull/9872#discussion_r1377086649
########## hudi-common/src/main/java/org/apache/hudi/common/config/HoodieFunctionalIndexConfig.java: ########## @@ -0,0 +1,319 @@ +/* + * 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.config; + +import org.apache.hudi.common.util.BinaryUtil; +import org.apache.hudi.common.util.ConfigUtils; +import org.apache.hudi.exception.HoodieIOException; +import org.apache.hudi.index.secondary.SecondaryIndexType; +import org.apache.hudi.metadata.MetadataPartitionType; + +import org.apache.hadoop.fs.FSDataInputStream; +import org.apache.hadoop.fs.FSDataOutputStream; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.annotation.concurrent.Immutable; + +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.time.Instant; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.function.BiConsumer; + +import static org.apache.hudi.common.util.ConfigUtils.fetchConfigs; +import static org.apache.hudi.common.util.ConfigUtils.recoverIfNeeded; +import static org.apache.hudi.common.util.StringUtils.getUTF8Bytes; + +@Immutable +@ConfigClassProperty(name = "Common Index Configs", + groupName = ConfigGroups.Names.INDEXING, + subGroupName = ConfigGroups.SubGroupNames.FUNCTIONAL_INDEX, + areCommonConfigs = true, + description = "") +public class HoodieFunctionalIndexConfig extends HoodieConfig { + + private static final Logger LOG = LoggerFactory.getLogger(HoodieFunctionalIndexConfig.class); + + public static final String INDEX_DEFINITION_FILE = "index.properties"; + public static final String INDEX_DEFINITION_FILE_BACKUP = "index.properties.backup"; + public static final ConfigProperty<String> INDEX_NAME = ConfigProperty + .key("hoodie.functional.index.name") + .noDefaultValue() + .sinceVersion("1.0.0") + .withDocumentation("Name of the functional index. This is also used for the partition name in the metadata table."); + + public static final ConfigProperty<String> INDEX_TYPE = ConfigProperty + .key("hoodie.functional.index.type") + .noDefaultValue(MetadataPartitionType.COLUMN_STATS.name()) + .withValidValues( + MetadataPartitionType.FILES.name(), + MetadataPartitionType.COLUMN_STATS.name(), + MetadataPartitionType.BLOOM_FILTERS.name(), + MetadataPartitionType.RECORD_INDEX.name(), + SecondaryIndexType.LUCENE.name() Review Comment: Are all of these supported by this PR? ########## hudi-common/src/main/java/org/apache/hudi/common/config/HoodieFunctionalIndexConfig.java: ########## @@ -0,0 +1,319 @@ +/* + * 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.config; + +import org.apache.hudi.common.util.BinaryUtil; +import org.apache.hudi.common.util.ConfigUtils; +import org.apache.hudi.exception.HoodieIOException; +import org.apache.hudi.index.secondary.SecondaryIndexType; +import org.apache.hudi.metadata.MetadataPartitionType; + +import org.apache.hadoop.fs.FSDataInputStream; +import org.apache.hadoop.fs.FSDataOutputStream; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.annotation.concurrent.Immutable; + +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.time.Instant; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.function.BiConsumer; + +import static org.apache.hudi.common.util.ConfigUtils.fetchConfigs; +import static org.apache.hudi.common.util.ConfigUtils.recoverIfNeeded; +import static org.apache.hudi.common.util.StringUtils.getUTF8Bytes; + +@Immutable +@ConfigClassProperty(name = "Common Index Configs", + groupName = ConfigGroups.Names.INDEXING, + subGroupName = ConfigGroups.SubGroupNames.FUNCTIONAL_INDEX, + areCommonConfigs = true, + description = "") +public class HoodieFunctionalIndexConfig extends HoodieConfig { + + private static final Logger LOG = LoggerFactory.getLogger(HoodieFunctionalIndexConfig.class); + + public static final String INDEX_DEFINITION_FILE = "index.properties"; + public static final String INDEX_DEFINITION_FILE_BACKUP = "index.properties.backup"; + public static final ConfigProperty<String> INDEX_NAME = ConfigProperty Review Comment: Are multiple functional indexes supported by the new configs? e.g., if I'd like to create two indexes based on `month(ts)` with `FILES` and `day(ts)` with `COLUMN_STATS`. ########## hudi-common/src/main/java/org/apache/hudi/index/secondary/HoodieSecondaryIndex.java: ########## @@ -17,7 +17,7 @@ * under the License. */ -package org.apache.hudi.secondary.index; +package org.apache.hudi.index.secondary; Review Comment: Is this class a public API that a user can extend? If not, changing the package name is OK. ########## hudi-common/src/main/java/org/apache/hudi/common/config/HoodieMetadataConfig.java: ########## @@ -316,6 +316,20 @@ public final class HoodieMetadataConfig extends HoodieConfig { .withDocumentation("Initializes the metadata table by reading from the file system when the table is first created. Enabled by default. " + "Warning: This should only be disabled when manually constructing the metadata table outside of typical Hudi writer flows."); + public static final ConfigProperty<Integer> FUNCTIONAL_INDEX_FILE_GROUP_COUNT = ConfigProperty + .key(METADATA_PREFIX + ".index.functional.file.group.count") + .defaultValue(2) + .markAdvanced() + .sinceVersion("0.11.0") Review Comment: nit: `1.0.0` ########## hudi-common/src/main/java/org/apache/hudi/metadata/MetadataPartitionType.java: ########## @@ -28,7 +28,8 @@ public enum MetadataPartitionType { FILES(HoodieTableMetadataUtil.PARTITION_NAME_FILES, "files-"), COLUMN_STATS(HoodieTableMetadataUtil.PARTITION_NAME_COLUMN_STATS, "col-stats-"), BLOOM_FILTERS(HoodieTableMetadataUtil.PARTITION_NAME_BLOOM_FILTERS, "bloom-filters-"), - RECORD_INDEX(HoodieTableMetadataUtil.PARTITION_NAME_RECORD_INDEX, "record-index-"); + RECORD_INDEX(HoodieTableMetadataUtil.PARTITION_NAME_RECORD_INDEX, "record-index-"), + FUNCTIONAL_INDEX(HoodieTableMetadataUtil.PARTITION_NAME_FUNCTIONAL_INDEX_PREFIX, "func_index_"); Review Comment: Use dashes `-` to be consistent with other partition names? ########## hudi-common/src/main/java/org/apache/hudi/common/config/HoodieFunctionalIndexConfig.java: ########## @@ -0,0 +1,319 @@ +/* + * 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.config; + +import org.apache.hudi.common.util.BinaryUtil; +import org.apache.hudi.common.util.ConfigUtils; +import org.apache.hudi.exception.HoodieIOException; +import org.apache.hudi.index.secondary.SecondaryIndexType; +import org.apache.hudi.metadata.MetadataPartitionType; + +import org.apache.hadoop.fs.FSDataInputStream; +import org.apache.hadoop.fs.FSDataOutputStream; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.annotation.concurrent.Immutable; + +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.time.Instant; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.function.BiConsumer; + +import static org.apache.hudi.common.util.ConfigUtils.fetchConfigs; +import static org.apache.hudi.common.util.ConfigUtils.recoverIfNeeded; +import static org.apache.hudi.common.util.StringUtils.getUTF8Bytes; + +@Immutable +@ConfigClassProperty(name = "Common Index Configs", + groupName = ConfigGroups.Names.INDEXING, + subGroupName = ConfigGroups.SubGroupNames.FUNCTIONAL_INDEX, + areCommonConfigs = true, + description = "") +public class HoodieFunctionalIndexConfig extends HoodieConfig { + + private static final Logger LOG = LoggerFactory.getLogger(HoodieFunctionalIndexConfig.class); + + public static final String INDEX_DEFINITION_FILE = "index.properties"; + public static final String INDEX_DEFINITION_FILE_BACKUP = "index.properties.backup"; + public static final ConfigProperty<String> INDEX_NAME = ConfigProperty + .key("hoodie.functional.index.name") + .noDefaultValue() + .sinceVersion("1.0.0") + .withDocumentation("Name of the functional index. This is also used for the partition name in the metadata table."); + + public static final ConfigProperty<String> INDEX_TYPE = ConfigProperty + .key("hoodie.functional.index.type") + .noDefaultValue(MetadataPartitionType.COLUMN_STATS.name()) Review Comment: Should this be `.defaultValue(MetadataPartitionType.COLUMN_STATS.name())`? ########## hudi-common/src/main/java/org/apache/hudi/common/config/HoodieFunctionalIndexConfig.java: ########## @@ -0,0 +1,319 @@ +/* + * 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.config; + +import org.apache.hudi.common.util.BinaryUtil; +import org.apache.hudi.common.util.ConfigUtils; +import org.apache.hudi.exception.HoodieIOException; +import org.apache.hudi.index.secondary.SecondaryIndexType; +import org.apache.hudi.metadata.MetadataPartitionType; + +import org.apache.hadoop.fs.FSDataInputStream; +import org.apache.hadoop.fs.FSDataOutputStream; +import org.apache.hadoop.fs.FileSystem; +import org.apache.hadoop.fs.Path; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.annotation.concurrent.Immutable; + +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.time.Instant; +import java.util.Map; +import java.util.Properties; +import java.util.Set; +import java.util.function.BiConsumer; + +import static org.apache.hudi.common.util.ConfigUtils.fetchConfigs; +import static org.apache.hudi.common.util.ConfigUtils.recoverIfNeeded; +import static org.apache.hudi.common.util.StringUtils.getUTF8Bytes; + +@Immutable +@ConfigClassProperty(name = "Common Index Configs", + groupName = ConfigGroups.Names.INDEXING, + subGroupName = ConfigGroups.SubGroupNames.FUNCTIONAL_INDEX, + areCommonConfigs = true, + description = "") +public class HoodieFunctionalIndexConfig extends HoodieConfig { + + private static final Logger LOG = LoggerFactory.getLogger(HoodieFunctionalIndexConfig.class); + + public static final String INDEX_DEFINITION_FILE = "index.properties"; Review Comment: Should the functional index metadata be stored along with the table properties, i.e., `hoodie.properties`? Another file is another RPC call on the cloud storage. -- 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]
