Copilot commented on code in PR #6595: URL: https://github.com/apache/hive/pull/6595#discussion_r3642460331
########## standalone-metastore/metastore-search/src/main/java/org/apache/hive/search/config/IndexStoreOptions.java: ########## @@ -0,0 +1,64 @@ +/* + * 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.hive.search.config; + +import java.net.URI; +import java.nio.file.Path; +import java.nio.file.Paths; + +import org.apache.commons.lang3.StringUtils; +import org.apache.hadoop.conf.Configuration; +import org.apache.hive.search.exception.IndexIOException; + +public record IndexStoreOptions(Configuration configuration, String indexName) { + public static final String LOCAL_PATH = "metastore.index.local.path"; + public static final String REMOTE_URI = "metastore.index.backup.remote.uri"; + public static final String MEMORY = "metastore.index.use.memory"; + + public static final Path DEFAULT_WORKDIR = Paths.get(System.getProperty("user.dir"), "indexes"); + + public Path getLocalPath() { + String path = configuration.get(LOCAL_PATH, DEFAULT_WORKDIR.toString()); + return Path.of(path); + } + + public String getRemoteUri() { + return configuration.get(REMOTE_URI, ""); + } + + public boolean hasRemote() { + String uri = getRemoteUri(); + return StringUtils.isNotEmpty(uri); + } + + public boolean useMemory() { + return configuration.getBoolean(MEMORY, false); + } + + public boolean isDistributed() { + return hasRemote(); + } + + public static void validateRemoteUri(String uriText) throws IndexIOException { + try { + URI.create(uriText); + } catch (IllegalArgumentException e) { + throw new IndexIOException("invalid store.remote.uri: " + uriText, e); + } + } Review Comment: The thrown error message references a non-existent config key ("store.remote.uri"); this makes troubleshooting harder because the real key is metastore.index.backup.remote.uri. ########## standalone-metastore/metastore-search/src/test/java/org/apache/hive/search/testutil/InMemoryIndexStateClient.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.hive.search.testutil; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Optional; +import java.util.zip.CRC32; Review Comment: The checksum field is named crc32C, but the implementation imports CRC32 (different algorithm). This makes the manifest/checksum semantics misleading and can cause mismatches if any other component expects CRC32C. This issue also appears on line 99 of the same file. ########## standalone-metastore/metastore-search/src/test/java/org/apache/hive/search/index/store/TestIndexBackupUtils.java: ########## @@ -0,0 +1,140 @@ +/* + * 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.hive.search.index.store; + +import org.apache.hadoop.hive.metastore.annotation.MetastoreUnitTest; +import org.apache.hive.search.testutil.InMemoryIndexStateClient; +import org.junit.Before; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.io.ByteArrayInputStream; +import java.util.List; +import java.util.zip.CRC32; Review Comment: This test helper is computing CRC32, but the value is named crc32C. Use CRC32C here to match the manifest field name and the intended semantics. This issue also appears on line 135 of the same file. -- 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] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
