Search in sources :

Example 1 with ColumnConfig

use of io.druid.segment.column.ColumnConfig in project druid by druid-io.

the class AggregationTestHelper method createGroupByQueryAggregationTestHelper.

public static final AggregationTestHelper createGroupByQueryAggregationTestHelper(List<? extends Module> jsonModulesToRegister, GroupByQueryConfig config, TemporaryFolder tempFolder) {
    ObjectMapper mapper = new DefaultObjectMapper();
    GroupByQueryRunnerFactory factory = GroupByQueryRunnerTest.makeQueryRunnerFactory(mapper, config);
    IndexIO indexIO = new IndexIO(mapper, new ColumnConfig() {

        @Override
        public int columnCacheSizeBytes() {
            return 0;
        }
    });
    return new AggregationTestHelper(mapper, new IndexMerger(mapper, indexIO), indexIO, factory.getToolchest(), factory, tempFolder, jsonModulesToRegister);
}
Also used : IndexMerger(io.druid.segment.IndexMerger) GroupByQueryRunnerFactory(io.druid.query.groupby.GroupByQueryRunnerFactory) IndexIO(io.druid.segment.IndexIO) ColumnConfig(io.druid.segment.column.ColumnConfig) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with ColumnConfig

use of io.druid.segment.column.ColumnConfig in project druid by druid-io.

the class AggregationTestHelper method createTopNQueryAggregationTestHelper.

public static final AggregationTestHelper createTopNQueryAggregationTestHelper(List<? extends Module> jsonModulesToRegister, TemporaryFolder tempFolder) {
    ObjectMapper mapper = new DefaultObjectMapper();
    TopNQueryQueryToolChest toolchest = new TopNQueryQueryToolChest(new TopNQueryConfig(), QueryRunnerTestHelper.NoopIntervalChunkingQueryRunnerDecorator());
    TopNQueryRunnerFactory factory = new TopNQueryRunnerFactory(new StupidPool<>("TopNQueryRunnerFactory-bufferPool", new Supplier<ByteBuffer>() {

        @Override
        public ByteBuffer get() {
            return ByteBuffer.allocate(10 * 1024 * 1024);
        }
    }), toolchest, QueryRunnerTestHelper.NOOP_QUERYWATCHER);
    IndexIO indexIO = new IndexIO(mapper, new ColumnConfig() {

        @Override
        public int columnCacheSizeBytes() {
            return 0;
        }
    });
    return new AggregationTestHelper(mapper, new IndexMerger(mapper, indexIO), indexIO, toolchest, factory, tempFolder, jsonModulesToRegister);
}
Also used : IndexMerger(io.druid.segment.IndexMerger) TopNQueryConfig(io.druid.query.topn.TopNQueryConfig) IndexIO(io.druid.segment.IndexIO) ColumnConfig(io.druid.segment.column.ColumnConfig) TopNQueryRunnerFactory(io.druid.query.topn.TopNQueryRunnerFactory) TopNQueryQueryToolChest(io.druid.query.topn.TopNQueryQueryToolChest) Supplier(com.google.common.base.Supplier) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 3 with ColumnConfig

use of io.druid.segment.column.ColumnConfig in project druid by druid-io.

the class AggregationTestHelper method createSelectQueryAggregationTestHelper.

public static final AggregationTestHelper createSelectQueryAggregationTestHelper(List<? extends Module> jsonModulesToRegister, TemporaryFolder tempFolder) {
    ObjectMapper mapper = new DefaultObjectMapper();
    mapper.setInjectableValues(new InjectableValues.Std().addValue(SelectQueryConfig.class, new SelectQueryConfig(true)));
    Supplier<SelectQueryConfig> configSupplier = Suppliers.ofInstance(new SelectQueryConfig(true));
    SelectQueryQueryToolChest toolchest = new SelectQueryQueryToolChest(new DefaultObjectMapper(), QueryRunnerTestHelper.NoopIntervalChunkingQueryRunnerDecorator(), configSupplier);
    SelectQueryRunnerFactory factory = new SelectQueryRunnerFactory(new SelectQueryQueryToolChest(new DefaultObjectMapper(), QueryRunnerTestHelper.NoopIntervalChunkingQueryRunnerDecorator(), configSupplier), new SelectQueryEngine(configSupplier), QueryRunnerTestHelper.NOOP_QUERYWATCHER);
    IndexIO indexIO = new IndexIO(mapper, new ColumnConfig() {

        @Override
        public int columnCacheSizeBytes() {
            return 0;
        }
    });
    return new AggregationTestHelper(mapper, new IndexMerger(mapper, indexIO), indexIO, toolchest, factory, tempFolder, jsonModulesToRegister);
}
Also used : IndexMerger(io.druid.segment.IndexMerger) ColumnConfig(io.druid.segment.column.ColumnConfig) SelectQueryRunnerFactory(io.druid.query.select.SelectQueryRunnerFactory) SelectQueryConfig(io.druid.query.select.SelectQueryConfig) SelectQueryQueryToolChest(io.druid.query.select.SelectQueryQueryToolChest) SelectQueryEngine(io.druid.query.select.SelectQueryEngine) IndexIO(io.druid.segment.IndexIO) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 4 with ColumnConfig

use of io.druid.segment.column.ColumnConfig in project druid by druid-io.

the class AggregationTestHelper method createTimeseriesQueryAggregationTestHelper.

public static final AggregationTestHelper createTimeseriesQueryAggregationTestHelper(List<? extends Module> jsonModulesToRegister, TemporaryFolder tempFolder) {
    ObjectMapper mapper = new DefaultObjectMapper();
    TimeseriesQueryQueryToolChest toolchest = new TimeseriesQueryQueryToolChest(QueryRunnerTestHelper.NoopIntervalChunkingQueryRunnerDecorator());
    TimeseriesQueryRunnerFactory factory = new TimeseriesQueryRunnerFactory(toolchest, new TimeseriesQueryEngine(), QueryRunnerTestHelper.NOOP_QUERYWATCHER);
    IndexIO indexIO = new IndexIO(mapper, new ColumnConfig() {

        @Override
        public int columnCacheSizeBytes() {
            return 0;
        }
    });
    return new AggregationTestHelper(mapper, new IndexMerger(mapper, indexIO), indexIO, toolchest, factory, tempFolder, jsonModulesToRegister);
}
Also used : IndexMerger(io.druid.segment.IndexMerger) TimeseriesQueryEngine(io.druid.query.timeseries.TimeseriesQueryEngine) TimeseriesQueryRunnerFactory(io.druid.query.timeseries.TimeseriesQueryRunnerFactory) IndexIO(io.druid.segment.IndexIO) ColumnConfig(io.druid.segment.column.ColumnConfig) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) TimeseriesQueryQueryToolChest(io.druid.query.timeseries.TimeseriesQueryQueryToolChest) DefaultObjectMapper(io.druid.jackson.DefaultObjectMapper) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 5 with ColumnConfig

use of io.druid.segment.column.ColumnConfig in project druid by druid-io.

the class DictionaryEncodedColumnPartSerde method getDeserializer.

@Override
public Deserializer getDeserializer() {
    return new Deserializer() {

        @Override
        public void read(ByteBuffer buffer, ColumnBuilder builder, ColumnConfig columnConfig) {
            final VERSION rVersion = VERSION.fromByte(buffer.get());
            final int rFlags;
            if (rVersion.compareTo(VERSION.COMPRESSED) >= 0) {
                rFlags = buffer.getInt();
            } else {
                rFlags = rVersion.equals(VERSION.UNCOMPRESSED_MULTI_VALUE) ? Feature.MULTI_VALUE.getMask() : NO_FLAGS;
            }
            final boolean hasMultipleValues = Feature.MULTI_VALUE.isSet(rFlags) || Feature.MULTI_VALUE_V3.isSet(rFlags);
            final GenericIndexed<String> rDictionary = GenericIndexed.read(buffer, GenericIndexed.STRING_STRATEGY, builder.getFileMapper());
            builder.setType(ValueType.STRING);
            final WritableSupplier<IndexedInts> rSingleValuedColumn;
            final WritableSupplier<IndexedMultivalue<IndexedInts>> rMultiValuedColumn;
            if (hasMultipleValues) {
                rMultiValuedColumn = readMultiValuedColum(rVersion, buffer, rFlags, builder.getFileMapper());
                rSingleValuedColumn = null;
            } else {
                rSingleValuedColumn = readSingleValuedColumn(rVersion, buffer, builder.getFileMapper());
                rMultiValuedColumn = null;
            }
            builder.setHasMultipleValues(hasMultipleValues).setDictionaryEncodedColumn(new DictionaryEncodedColumnSupplier(rDictionary, rSingleValuedColumn, rMultiValuedColumn, columnConfig.columnCacheSizeBytes()));
            GenericIndexed<ImmutableBitmap> rBitmaps = GenericIndexed.read(buffer, bitmapSerdeFactory.getObjectStrategy(), builder.getFileMapper());
            builder.setBitmapIndex(new BitmapIndexColumnPartSupplier(bitmapSerdeFactory.getBitmapFactory(), rBitmaps, rDictionary));
            ImmutableRTree rSpatialIndex = null;
            if (buffer.hasRemaining()) {
                rSpatialIndex = ByteBufferSerializer.read(buffer, new IndexedRTree.ImmutableRTreeObjectStrategy(bitmapSerdeFactory.getBitmapFactory()));
                builder.setSpatialIndex(new SpatialIndexColumnPartSupplier(rSpatialIndex));
            }
        }

        private WritableSupplier<IndexedInts> readSingleValuedColumn(VERSION version, ByteBuffer buffer, SmooshedFileMapper fileMapper) {
            switch(version) {
                case UNCOMPRESSED_SINGLE_VALUE:
                    return VSizeIndexedInts.readFromByteBuffer(buffer).asWritableSupplier();
                case COMPRESSED:
                    return CompressedVSizeIntsIndexedSupplier.fromByteBuffer(buffer, byteOrder, fileMapper);
            }
            throw new IAE("Unsupported single-value version[%s]", version);
        }

        private WritableSupplier<IndexedMultivalue<IndexedInts>> readMultiValuedColum(VERSION version, ByteBuffer buffer, int flags, SmooshedFileMapper fileMapper) {
            switch(version) {
                case UNCOMPRESSED_MULTI_VALUE:
                    return VSizeIndexed.readFromByteBuffer(buffer).asWritableSupplier();
                case COMPRESSED:
                    if (Feature.MULTI_VALUE.isSet(flags)) {
                        return CompressedVSizeIndexedSupplier.fromByteBuffer(buffer, byteOrder, fileMapper);
                    } else if (Feature.MULTI_VALUE_V3.isSet(flags)) {
                        return CompressedVSizeIndexedV3Supplier.fromByteBuffer(buffer, byteOrder, fileMapper);
                    } else {
                        throw new IAE("Unrecognized multi-value flag[%d]", flags);
                    }
            }
            throw new IAE("Unsupported multi-value version[%s]", version);
        }
    };
}
Also used : ColumnConfig(io.druid.segment.column.ColumnConfig) ImmutableBitmap(io.druid.collections.bitmap.ImmutableBitmap) IAE(io.druid.java.util.common.IAE) ByteBuffer(java.nio.ByteBuffer) ImmutableRTree(io.druid.collections.spatial.ImmutableRTree) VSizeIndexedInts(io.druid.segment.data.VSizeIndexedInts) IndexedInts(io.druid.segment.data.IndexedInts) IndexedMultivalue(io.druid.segment.data.IndexedMultivalue) ColumnBuilder(io.druid.segment.column.ColumnBuilder) SmooshedFileMapper(io.druid.java.util.common.io.smoosh.SmooshedFileMapper)

Aggregations

ColumnConfig (io.druid.segment.column.ColumnConfig)8 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 DefaultObjectMapper (io.druid.jackson.DefaultObjectMapper)5 IndexIO (io.druid.segment.IndexIO)5 IndexMerger (io.druid.segment.IndexMerger)4 ColumnBuilder (io.druid.segment.column.ColumnBuilder)3 ByteBuffer (java.nio.ByteBuffer)3 Supplier (com.google.common.base.Supplier)1 ImmutableBitmap (io.druid.collections.bitmap.ImmutableBitmap)1 ImmutableRTree (io.druid.collections.spatial.ImmutableRTree)1 SegmentizerModule (io.druid.jackson.SegmentizerModule)1 IAE (io.druid.java.util.common.IAE)1 SmooshedFileMapper (io.druid.java.util.common.io.smoosh.SmooshedFileMapper)1 GroupByQueryRunnerFactory (io.druid.query.groupby.GroupByQueryRunnerFactory)1 SelectQueryConfig (io.druid.query.select.SelectQueryConfig)1 SelectQueryEngine (io.druid.query.select.SelectQueryEngine)1 SelectQueryQueryToolChest (io.druid.query.select.SelectQueryQueryToolChest)1 SelectQueryRunnerFactory (io.druid.query.select.SelectQueryRunnerFactory)1 TimeseriesQueryEngine (io.druid.query.timeseries.TimeseriesQueryEngine)1 TimeseriesQueryQueryToolChest (io.druid.query.timeseries.TimeseriesQueryQueryToolChest)1