clintropolis commented on a change in pull request #6016: Druid 'Shapeshifting' Columns URL: https://github.com/apache/incubator-druid/pull/6016#discussion_r209759964
########## File path: processing/src/main/java/io/druid/segment/data/ShapeShiftingColumn.java ########## @@ -0,0 +1,332 @@ +/* + * 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; + +import com.google.common.base.Supplier; +import com.google.common.base.Suppliers; +import io.druid.collections.ResourceHolder; +import io.druid.query.monomorphicprocessing.RuntimeShapeInspector; +import io.druid.segment.CompressedPools; +import io.druid.segment.data.codecs.FormDecoder; +import sun.misc.Unsafe; + +import java.io.Closeable; +import java.io.IOException; +import java.lang.reflect.Field; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.util.Map; + +/** + * Base type for reading 'shape shifting' columns, which divide row values into chunks sized to a power of 2, each + * potentially encoded with a different algorithm which was chosen as optimal for size and speed for the given values + * at indexing time. This class generically provides common structure for loading and decoding chunks of values for + * all shape shifting column implementations, with the help of matching {@link FormDecoder<TShapeShiftImpl>}. Like + * some other column decoding strategies, shape shifting columns operate with a 'currentChunk' which is loaded when + * a 'get' operation for a row index is done, and remains until a row index on a different chunk is requested, so + * performs best of row selection is done in an ordered manner. + * + * Shape shifting columns are designed to place row retrieval functions within the column implementation for optimal + * performance with the jvm. Each chunk has a byte header that uniquely maps to a {@link FormDecoder}, andChunks are + * decoded by passing them column into {@link FormDecoder} which are tightly coupled to know how to mutate the + * implementation so row values can be retrieved. What this means is implementation specific, but for the sake of + * example, could be decoding all values of the chunk to a primitive array or setting offsets to read values directly + * from a {@link ByteBuffer}. See specific implementations for further details. + * + * @param <TShapeShiftImpl> type of {@link ShapeShiftingColumn} implementation to strongly associate {@link FormDecoder} + */ +public abstract class ShapeShiftingColumn<TShapeShiftImpl extends ShapeShiftingColumn> implements Closeable +{ + public static Unsafe getTheUnsafe() + { + try { + Field theUnsafe = Unsafe.class.getDeclaredField("theUnsafe"); + theUnsafe.setAccessible(true); + return (Unsafe) theUnsafe.get(null); + } Review comment: :+1: will try to find a home ---------------------------------------------------------------- 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]
