Copilot commented on code in PR #6716: URL: https://github.com/apache/paimon/pull/6716#discussion_r2591981859
########## paimon-vector/src/main/java/org/apache/paimon/vector/VectorIndexOptions.java: ########## @@ -0,0 +1,109 @@ +/* + * 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.paimon.vector; + +import org.apache.paimon.options.ConfigOption; +import org.apache.paimon.options.ConfigOptions; +import org.apache.paimon.options.Options; + +/** Options for vector index. */ +public class VectorIndexOptions { + + public static final ConfigOption<Integer> VECTOR_DIM = + ConfigOptions.key("vector.dim") + .intType() + .defaultValue(128) + .withDescription("The dimension of the vector"); + + public static final ConfigOption<String> VECTOR_METRIC = + ConfigOptions.key("vector.metric") + .stringType() + .defaultValue("EUCLIDEAN") + .withDescription( + "The similarity metric for vector search (COSINE, DOT_PRODUCT, EUCLIDEAN, MAX_INNER_PRODUCT), and EUCLIDEAN is the default"); + + public static final ConfigOption<Integer> VECTOR_M = + ConfigOptions.key("vector.m") + .intType() + .defaultValue(16) + .withDescription( + "The maximum number of connections for each element during the index construction"); + + public static final ConfigOption<Integer> VECTOR_EF_CONSTRUCTION = + ConfigOptions.key("vector.ef-construction") + .intType() + .defaultValue(100) + .withDescription( + "The size of the dynamic candidate list during the index construction"); + + public static final ConfigOption<Integer> VECTOR_SIZE_PER_INDEX = + ConfigOptions.key("vector.size-per-index") + .intType() + .defaultValue(10000) + .withDescription("The size of vectors stored in each vector index file"); + + public static final ConfigOption<Integer> VECTOR_WRITE_BUFFER_SIZE = + ConfigOptions.key("vector.write-buffer-size") + .intType() + .defaultValue(256) + .withDescription("write buffer size in MB for vector index"); + + private final int dimension; + private final String metric; + private final int m; + private final int efConstruction; + private final int sizePerIndex; + private final int writeBufferSize; + + public VectorIndexOptions(Options options) { + this.dimension = options.get(VECTOR_DIM); + this.metric = options.get(VECTOR_METRIC); + this.m = options.get(VECTOR_M); + this.efConstruction = options.get(VECTOR_EF_CONSTRUCTION); + this.sizePerIndex = + options.get(VECTOR_SIZE_PER_INDEX) > 0 + ? options.get(VECTOR_SIZE_PER_INDEX) + : VECTOR_SIZE_PER_INDEX.defaultValue(); Review Comment: The ternary expression checks if `options.get(VECTOR_SIZE_PER_INDEX) > 0` and if so, calls `options.get(VECTOR_SIZE_PER_INDEX)` again. This redundant call could be simplified by storing the value in a variable: `int size = options.get(VECTOR_SIZE_PER_INDEX); this.sizePerIndex = size > 0 ? size : VECTOR_SIZE_PER_INDEX.defaultValue();` ```suggestion int size = options.get(VECTOR_SIZE_PER_INDEX); this.sizePerIndex = size > 0 ? size : VECTOR_SIZE_PER_INDEX.defaultValue(); ``` -- 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]
