Search in sources :

Example 1 with IndexIO

use of io.druid.segment.IndexIO 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 IndexIO

use of io.druid.segment.IndexIO 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 IndexIO

use of io.druid.segment.IndexIO in project druid by druid-io.

the class ValidateSegments method run.

@Override
public void run() {
    if (directories.size() != 2) {
        throw new IAE("Please provide two segment directories to compare");
    }
    final Injector injector = makeInjector();
    final IndexIO indexIO = injector.getInstance(IndexIO.class);
    try {
        String dir1 = directories.get(0);
        String dir2 = directories.get(1);
        indexIO.validateTwoSegments(new File(dir1), new File(dir2));
        log.info("Segments [%s] and [%s] are identical", dir1, dir2);
    } catch (Exception e) {
        throw Throwables.propagate(e);
    }
}
Also used : IndexIO(io.druid.segment.IndexIO) Injector(com.google.inject.Injector) IAE(io.druid.java.util.common.IAE) File(java.io.File)

Example 4 with IndexIO

use of io.druid.segment.IndexIO in project druid by druid-io.

the class KafkaIndexTaskTest method readSegmentDim1.

private List<String> readSegmentDim1(final SegmentDescriptor descriptor) throws IOException {
    File indexZip = new File(String.format("%s/%s/%s_%s/%s/%d/index.zip", getSegmentDirectory(), DATA_SCHEMA.getDataSource(), descriptor.getInterval().getStart(), descriptor.getInterval().getEnd(), descriptor.getVersion(), descriptor.getPartitionNumber()));
    File outputLocation = new File(directory, String.format("%s_%s_%s_%s", descriptor.getInterval().getStart(), descriptor.getInterval().getEnd(), descriptor.getVersion(), descriptor.getPartitionNumber()));
    outputLocation.mkdir();
    CompressionUtils.unzip(Files.asByteSource(indexZip), outputLocation, Predicates.<Throwable>alwaysFalse(), false);
    IndexIO indexIO = new TestUtils().getTestIndexIO();
    QueryableIndex index = indexIO.loadIndex(outputLocation);
    DictionaryEncodedColumn<String> dim1 = index.getColumn("dim1").getDictionaryEncoding();
    List<String> values = Lists.newArrayList();
    for (int i = 0; i < dim1.length(); i++) {
        int id = dim1.getSingleValueRow(i);
        String value = dim1.lookupName(id);
        values.add(value);
    }
    return values;
}
Also used : TestUtils(io.druid.indexing.common.TestUtils) IndexIO(io.druid.segment.IndexIO) QueryableIndex(io.druid.segment.QueryableIndex) File(java.io.File)

Example 5 with IndexIO

use of io.druid.segment.IndexIO 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)

Aggregations

IndexIO (io.druid.segment.IndexIO)8 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 DefaultObjectMapper (io.druid.jackson.DefaultObjectMapper)5 ColumnConfig (io.druid.segment.column.ColumnConfig)5 IndexMerger (io.druid.segment.IndexMerger)4 File (java.io.File)4 Injector (com.google.inject.Injector)2 IAE (io.druid.java.util.common.IAE)2 QueryableIndex (io.druid.segment.QueryableIndex)2 Supplier (com.google.common.base.Supplier)1 TestUtils (io.druid.indexing.common.TestUtils)1 SegmentizerModule (io.druid.jackson.SegmentizerModule)1 ISE (io.druid.java.util.common.ISE)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