diff --git a/processing/src/main/java/io/druid/segment/IndexIO.java b/processing/src/main/java/io/druid/segment/IndexIO.java index 9d6f7db0552..3cd6d7c27e1 100644 --- a/processing/src/main/java/io/druid/segment/IndexIO.java +++ b/processing/src/main/java/io/druid/segment/IndexIO.java @@ -59,10 +59,10 @@ import io.druid.segment.column.ColumnConfig; import io.druid.segment.column.ColumnDescriptor; import io.druid.segment.column.ValueType; import io.druid.segment.data.ArrayIndexed; +import io.druid.segment.data.BitmapSerde; import io.druid.segment.data.BitmapSerdeFactory; import io.druid.segment.data.ByteBufferSerializer; import io.druid.segment.data.CompressedLongsIndexedSupplier; -import io.druid.segment.data.ConciseBitmapSerdeFactory; import io.druid.segment.data.GenericIndexed; import io.druid.segment.data.IndexedIterable; import io.druid.segment.data.IndexedRTree; @@ -257,7 +257,7 @@ public class IndexIO indexBuffer, GenericIndexed.stringStrategy ); final Interval dataInterval = new Interval(serializerUtils.readString(indexBuffer)); - final BitmapSerdeFactory conciseBitmapSerdeFactory = new ConciseBitmapSerdeFactory(); + final BitmapSerdeFactory bitmapSerdeFactory = BitmapSerde.createLegacyFactory(); CompressedLongsIndexedSupplier timestamps = CompressedLongsIndexedSupplier.fromByteBuffer( smooshedFiles.mapFile(makeTimeFile(inDir, BYTE_ORDER).getName()), BYTE_ORDER @@ -296,7 +296,7 @@ public class IndexIO for (int i = 0; i < availableDimensions.size(); ++i) { bitmaps.put( serializerUtils.readString(invertedBuffer), - GenericIndexed.read(invertedBuffer, conciseBitmapSerdeFactory.getObjectStrategy()) + GenericIndexed.read(invertedBuffer, bitmapSerdeFactory.getObjectStrategy()) ); } @@ -307,7 +307,7 @@ public class IndexIO serializerUtils.readString(spatialBuffer), ByteBufferSerializer.read( spatialBuffer, - new IndexedRTree.ImmutableRTreeObjectStrategy(conciseBitmapSerdeFactory.getBitmapFactory()) + new IndexedRTree.ImmutableRTreeObjectStrategy(bitmapSerdeFactory.getBitmapFactory()) ) ); } @@ -772,7 +772,7 @@ public class IndexIO if (indexBuffer.hasRemaining()) { segmentBitmapSerdeFactory = mapper.readValue(serializerUtils.readString(indexBuffer), BitmapSerdeFactory.class); } else { - segmentBitmapSerdeFactory = new ConciseBitmapSerdeFactory(); + segmentBitmapSerdeFactory = BitmapSerde.createLegacyFactory(); } Map columns = Maps.newHashMap(); diff --git a/processing/src/main/java/io/druid/segment/data/BitmapSerde.java b/processing/src/main/java/io/druid/segment/data/BitmapSerde.java new file mode 100644 index 00000000000..93af706b57b --- /dev/null +++ b/processing/src/main/java/io/druid/segment/data/BitmapSerde.java @@ -0,0 +1,50 @@ +/* + * Druid - a distributed column store. + * Copyright (C) 2014 Metamarkets Group Inc. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +package io.druid.segment.data; + +import com.metamx.common.ISE; + +public class BitmapSerde +{ + // default bitmap indices in Druid <= 0.6.x + public static final Class LEGACY_BITMAP_FACTORY = ConciseBitmapSerdeFactory.class; + + // default bitmap indices for Druid >= 0.7.x + public static final Class DEFAULT_BITMAP_FACTORY = ConciseBitmapSerdeFactory.class; + + public static BitmapSerdeFactory createDefaultFactory() + { + try { + return DEFAULT_BITMAP_FACTORY.newInstance(); + } catch(InstantiationException | IllegalAccessException e) { + // should never happen + throw new ISE(e, "Unable to instatiate BitmapSerdeFactory"); + } + } + public static BitmapSerdeFactory createLegacyFactory() + { + try { + return LEGACY_BITMAP_FACTORY.newInstance(); + } catch(InstantiationException | IllegalAccessException e) { + // should never happen + throw new ISE(e, "Unable to instatiate BitmapSerdeFactory"); + } + } +} diff --git a/processing/src/main/java/io/druid/segment/data/BitmapSerdeFactory.java b/processing/src/main/java/io/druid/segment/data/BitmapSerdeFactory.java index 09db6f5fff0..624e81fa0b0 100644 --- a/processing/src/main/java/io/druid/segment/data/BitmapSerdeFactory.java +++ b/processing/src/main/java/io/druid/segment/data/BitmapSerdeFactory.java @@ -26,12 +26,11 @@ import com.metamx.collections.bitmap.ImmutableBitmap; /** */ -@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", defaultImpl = ConciseBitmapSerdeFactory.class) +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, property = "type", defaultImpl = BitmapSerde.DEFAULT_BITMAP_FACTORY) @JsonSubTypes(value = { @JsonSubTypes.Type(name = "concise", value = ConciseBitmapSerdeFactory.class), @JsonSubTypes.Type(name = "roaring", value = RoaringBitmapSerdeFactory.class) }) - public interface BitmapSerdeFactory { public ObjectStrategy getObjectStrategy(); diff --git a/processing/src/main/java/io/druid/segment/serde/DictionaryEncodedColumnPartSerde.java b/processing/src/main/java/io/druid/segment/serde/DictionaryEncodedColumnPartSerde.java index adc30851af8..012b29a3f11 100644 --- a/processing/src/main/java/io/druid/segment/serde/DictionaryEncodedColumnPartSerde.java +++ b/processing/src/main/java/io/druid/segment/serde/DictionaryEncodedColumnPartSerde.java @@ -28,9 +28,9 @@ import com.metamx.common.IAE; import io.druid.segment.column.ColumnBuilder; import io.druid.segment.column.ColumnConfig; import io.druid.segment.column.ValueType; +import io.druid.segment.data.BitmapSerde; import io.druid.segment.data.BitmapSerdeFactory; import io.druid.segment.data.ByteBufferSerializer; -import io.druid.segment.data.ConciseBitmapSerdeFactory; import io.druid.segment.data.GenericIndexed; import io.druid.segment.data.IndexedRTree; import io.druid.segment.data.VSizeIndexed; @@ -97,7 +97,7 @@ public class DictionaryEncodedColumnPartSerde implements ColumnPartSerde { this.isSingleValued = isSingleValued; this.bitmapSerdeFactory = bitmapSerdeFactory == null - ? new ConciseBitmapSerdeFactory() + ? BitmapSerde.createLegacyFactory() : bitmapSerdeFactory; this.dictionary = null;