platinumhamburg commented on code in PR #2485: URL: https://github.com/apache/fluss/pull/2485#discussion_r2748527923
########## fluss-common/src/main/java/org/apache/fluss/row/decode/KeyDecoder.java: ########## @@ -0,0 +1,80 @@ +/* + * 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.fluss.row.decode; + +import org.apache.fluss.metadata.DataLakeFormat; +import org.apache.fluss.row.InternalRow; +import org.apache.fluss.types.RowType; + +import javax.annotation.Nullable; + +import java.util.List; + +/** + * Interface for decoding key bytes back to {@link InternalRow}. + * + * <p>This interface provides functionality to decode binary key bytes into internal row + * representation, typically used for primary key decoding in KV tables. + */ +public interface KeyDecoder { + /** Decode key bytes to a row containing only key fields, without non-key fields. */ + InternalRow decodeKey(byte[] keyBytes); + + static KeyDecoder ofPrimaryKeyDecoder( + RowType rowType, + List<String> keyFields, + short kvFormatVersion, + @Nullable DataLakeFormat lakeFormat, + boolean isDefaultBucketKey) { + if (kvFormatVersion == 1 || (kvFormatVersion == 2 && isDefaultBucketKey)) { + return of(rowType, keyFields, lakeFormat); + } + if (kvFormatVersion == 2) { + // use CompactedKeyEncoder to support prefix look up + return CompactedKeyDecoder.createKeyDecoder(rowType, keyFields); + } + throw new UnsupportedOperationException( + "Unsupported kv format version: " + kvFormatVersion); + } + + /** + * Create a key decoder to decode the key array bytes of the input row. + * + * @param rowType the row type of the input row + * @param keyFields the key fields to decode + */ + static KeyDecoder of( Review Comment: This method appears to be dead code now. -- 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]
