diff --git a/processing/src/test/java/io/druid/segment/data/BitmapCreationBenchmark.java b/processing/src/test/java/io/druid/segment/data/BitmapCreationBenchmark.java index 8872efd3937..baa4a9d7f8d 100644 --- a/processing/src/test/java/io/druid/segment/data/BitmapCreationBenchmark.java +++ b/processing/src/test/java/io/druid/segment/data/BitmapCreationBenchmark.java @@ -33,6 +33,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; +import java.nio.ByteBuffer; import java.util.Arrays; import java.util.Collection; import java.util.List; @@ -104,6 +105,7 @@ public class BitmapCreationBenchmark extends AbstractBenchmark ImmutableBitmap baseImmutableBitmap; MutableBitmap baseMutableBitmap; byte[] baseBytes; + ByteBuffer baseByteBuffer; @Before public void setup() @@ -114,6 +116,7 @@ public class BitmapCreationBenchmark extends AbstractBenchmark } baseImmutableBitmap = factory.makeImmutableBitmap(baseMutableBitmap); baseBytes = baseImmutableBitmap.toBytes(); + baseByteBuffer = ByteBuffer.wrap(baseBytes); } @@ -159,4 +162,13 @@ public class BitmapCreationBenchmark extends AbstractBenchmark Assert.assertArrayEquals(baseBytes, immutableBitmap.toBytes()); } + + @BenchmarkOptions(warmupRounds = 10, benchmarkRounds = 1000) + @Test + public void testFromImmutableByteArray() + { + ImmutableBitmap immutableBitmap = factory.mapImmutableBitmap(baseByteBuffer); + Assert.assertEquals(numBits, immutableBitmap.size()); + } + }