diff --git a/processing/src/main/java/io/druid/segment/data/BlockLayoutColumnarDoublesSupplier.java b/processing/src/main/java/io/druid/segment/data/BlockLayoutColumnarDoublesSupplier.java index 62ee6de5bb4..cd6b2229ae6 100644 --- a/processing/src/main/java/io/druid/segment/data/BlockLayoutColumnarDoublesSupplier.java +++ b/processing/src/main/java/io/druid/segment/data/BlockLayoutColumnarDoublesSupplier.java @@ -27,7 +27,6 @@ import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.DoubleBuffer; - public class BlockLayoutColumnarDoublesSupplier implements Supplier { private final GenericIndexed> baseDoubleBuffers; @@ -42,12 +41,7 @@ public class BlockLayoutColumnarDoublesSupplier implements Supplier> div; + + if (bufferNum != currBufferNum) { + loadBuffer(bufferNum); + } + + final int bufferIndex = index & rem; + return doubleBuffer.get(bufferIndex); + } + }; + } else { + return new BlockLayoutColumnarDoubles(); + } } private class BlockLayoutColumnarDoubles implements ColumnarDoubles { - final Indexed> resourceHolderIndexed = baseDoubleBuffers.singleThreaded(); - int currIndex = -1; + final Indexed> singleThreadedDoubleBuffers = baseDoubleBuffers.singleThreaded(); + + int currBufferNum = -1; ResourceHolder holder; - ByteBuffer buffer; + /** doubleBuffer's position must be 0 */ DoubleBuffer doubleBuffer; + @Override public int size() { @@ -74,23 +92,24 @@ public class BlockLayoutColumnarDoublesSupplier implements Supplier