xiangfu0 commented on code in PR #18092: URL: https://github.com/apache/pinot/pull/18092#discussion_r3036489654
########## pinot-segment-local/src/main/java/org/apache/pinot/segment/local/io/compression/PipelineChunkCompressor.java: ########## @@ -0,0 +1,95 @@ +/** + * 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.pinot.segment.local.io.compression; + +import java.io.IOException; +import java.nio.ByteBuffer; +import java.util.List; +import org.apache.pinot.segment.spi.compression.ChunkCodec; +import org.apache.pinot.segment.spi.compression.ChunkCodecPipeline; +import org.apache.pinot.segment.spi.compression.ChunkCompressionType; +import org.apache.pinot.segment.spi.compression.ChunkCompressor; +import org.apache.pinot.segment.spi.compression.ChunkTransform; + + +/** + * A {@link ChunkCompressor} that applies a pipeline of codec stages: first all + * {@link ChunkCodec.CodecKind#TRANSFORM TRANSFORM} stages in order (left-to-right), + * then the terminal {@link ChunkCodec.CodecKind#COMPRESSOR COMPRESSOR}. + * + * <p>This is the write-path counterpart of {@link PipelineChunkDecompressor}.</p> + */ +public class PipelineChunkCompressor implements ChunkCompressor { + + private final ChunkCodecPipeline _pipeline; + private final ChunkTransform[] _transforms; + private final ChunkCompressor _terminalCompressor; + private final int _valueSizeInBytes; + + /** + * Creates a pipeline compressor. + * + * @param pipeline the codec pipeline + * @param valueSizeInBytes size of each typed value (4 for INT, 8 for LONG); used by transforms + */ + public PipelineChunkCompressor(ChunkCodecPipeline pipeline, int valueSizeInBytes) { + _pipeline = pipeline; + _valueSizeInBytes = valueSizeInBytes; + + List<ChunkCodec> transformStages = pipeline.getTransforms(); + _transforms = new ChunkTransform[transformStages.size()]; + for (int i = 0; i < transformStages.size(); i++) { + _transforms[i] = ChunkTransformFactory.getTransform(transformStages.get(i)); + } + + ChunkCodec compressorCodec = pipeline.getCompressor(); Review Comment: No longer applicable — checked the current code and there is no unused `compressorCodec` variable. The field is `_terminalCompressor` which is used in `compress()`, `maxCompressedSize()`, `compressionType()`, and `close()`. ########## pinot-spi/src/main/java/org/apache/pinot/spi/config/table/FieldConfig.java: ########## @@ -106,14 +116,19 @@ public FieldConfig(@JsonProperty(value = "name", required = true) String name, @JsonProperty(value = "compressionCodec") @Nullable CompressionCodec compressionCodec, @JsonProperty(value = "timestampConfig") @Nullable TimestampConfig timestampConfig, @JsonProperty(value = "indexes") @Nullable JsonNode indexes, + @JsonProperty(value = "codecPipeline") @Nullable List<String> codecPipeline, @JsonProperty(value = "properties") @Nullable Map<String, String> properties, @JsonProperty(value = "tierOverwrites") @Nullable JsonNode tierOverwrites) { Preconditions.checkArgument(name != null, "'name' must be configured"); + Preconditions.checkArgument(compressionCodec == null || codecPipeline == null || codecPipeline.isEmpty(), + "'compressionCodec' and 'codecPipeline' cannot both be set for column '%s'. " + + "Use 'codecPipeline' for new configs; 'compressionCodec' is deprecated.", name); _name = name; _encodingType = encodingType == null ? EncodingType.DICTIONARY : encodingType; _indexTypes = indexTypes != null ? indexTypes : (indexType == null ? Lists.newArrayList() : Lists.newArrayList(indexType)); _compressionCodec = compressionCodec; + _codecPipeline = codecPipeline; Review Comment: The current behavior is intentional: an empty `codecPipeline: []` is treated as "not set" (same as null/absent). This is consistent with how Jackson deserializes — an empty list is a valid JSON value but semantically means "no pipeline configured". The mutual exclusivity check `codecPipeline == null || codecPipeline.isEmpty()` correctly allows `compressionCodec` when the pipeline is empty/absent. The Javadoc on `getCompressionCodec()` has been updated to correctly say "Setting both is rejected" instead of "codecPipeline takes precedence". -- 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]
