clintropolis commented on a change in pull request #6016: Druid 'Shapeshifting' Columns URL: https://github.com/apache/incubator-druid/pull/6016#discussion_r209760256
########## File path: processing/src/main/java/io/druid/segment/data/codecs/ints/ConstantIntFormDecoder.java ########## @@ -0,0 +1,74 @@ +/* + * 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 io.druid.segment.data.codecs.ints; + +import io.druid.segment.data.ShapeShiftingColumnarInts; +import io.druid.segment.data.codecs.BaseFormDecoder; +import io.druid.segment.data.codecs.DirectFormDecoder; + +import java.nio.ByteOrder; +import java.util.Arrays; + +/** + * Decoder used if all values are the same within a chunk are constant. + * + * layout: + * | header: IntCodecs.CONSTANT (byte) | constant value (int) | + */ +public final class ConstantIntFormDecoder extends BaseFormDecoder<ShapeShiftingColumnarInts> + implements DirectFormDecoder<ShapeShiftingColumnarInts> +{ + public ConstantIntFormDecoder(final byte logValuesPerChunk, final ByteOrder byteOrder) + { + super(logValuesPerChunk, byteOrder); + } + + @Override + public void transform(ShapeShiftingColumnarInts columnarInts) + { + final int startOffset = columnarInts.getCurrentValuesStartOffset(); + final int currentConstant = columnarInts.getCurrentValueBuffer().getInt(startOffset); + Arrays.fill(columnarInts.getDecodedValues(), currentConstant); Review comment: Yeah, along with my native experiments in another branch, I'm also playing around to try and refactor decoding in this branch to eliminate unnecessary 'decode to array' implementations since I don't think they are worth keeping around, but I need to benchmark to prove it. If performance cost isn't noticeable this should allow me to have only a single `transform` method per decoder and simplify things a bit. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
