Search in sources :

Example 1 with IndexIO

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

the class AggregationTestHelper method createGroupByQueryAggregationTestHelper.

public static AggregationTestHelper createGroupByQueryAggregationTestHelper(List<? extends Module> jsonModulesToRegister, GroupByQueryConfig config, TemporaryFolder tempFolder) {
    final ObjectMapper mapper = TestHelper.makeJsonMapper();
    final Pair<GroupByQueryRunnerFactory, Closer> factoryAndCloser = GroupByQueryRunnerTest.makeQueryRunnerFactory(mapper, config);
    final GroupByQueryRunnerFactory factory = factoryAndCloser.lhs;
    final Closer closer = factoryAndCloser.rhs;
    IndexIO indexIO = new IndexIO(mapper, new ColumnConfig() {

        @Override
        public int columnCacheSizeBytes() {
            return 0;
        }
    });
    return new AggregationTestHelper(mapper, new IndexMergerV9(mapper, indexIO, OffHeapMemorySegmentWriteOutMediumFactory.instance()), indexIO, factory.getToolchest(), factory, tempFolder, jsonModulesToRegister, closer, Collections.emptyMap());
}
Also used : Closer(org.apache.druid.java.util.common.io.Closer) GroupByQueryRunnerFactory(org.apache.druid.query.groupby.GroupByQueryRunnerFactory) IndexIO(org.apache.druid.segment.IndexIO) ColumnConfig(org.apache.druid.segment.column.ColumnConfig) IndexMergerV9(org.apache.druid.segment.IndexMergerV9) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 2 with IndexIO

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

the class AggregationTestHelper method createTimeseriesQueryAggregationTestHelper.

public static AggregationTestHelper createTimeseriesQueryAggregationTestHelper(List<? extends Module> jsonModulesToRegister, TemporaryFolder tempFolder) {
    ObjectMapper mapper = TestHelper.makeJsonMapper();
    TimeseriesQueryQueryToolChest toolchest = new TimeseriesQueryQueryToolChest();
    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 IndexMergerV9(mapper, indexIO, OffHeapMemorySegmentWriteOutMediumFactory.instance()), indexIO, toolchest, factory, tempFolder, jsonModulesToRegister, Closer.create(), Collections.emptyMap());
}
Also used : TimeseriesQueryEngine(org.apache.druid.query.timeseries.TimeseriesQueryEngine) TimeseriesQueryRunnerFactory(org.apache.druid.query.timeseries.TimeseriesQueryRunnerFactory) IndexIO(org.apache.druid.segment.IndexIO) ColumnConfig(org.apache.druid.segment.column.ColumnConfig) IndexMergerV9(org.apache.druid.segment.IndexMergerV9) TimeseriesQueryQueryToolChest(org.apache.druid.query.timeseries.TimeseriesQueryQueryToolChest) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 3 with IndexIO

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

the class DumpSegment method run.

@Override
public void run() {
    final Injector injector = makeInjector();
    final IndexIO indexIO = injector.getInstance(IndexIO.class);
    final DumpType dumpType;
    try {
        dumpType = DumpType.valueOf(StringUtils.toUpperCase(dumpTypeString));
    } catch (Exception e) {
        throw new IAE("Not a valid dump type: %s", dumpTypeString);
    }
    try (final QueryableIndex index = indexIO.loadIndex(new File(directory))) {
        switch(dumpType) {
            case ROWS:
                runDump(injector, index);
                break;
            case METADATA:
                runMetadata(injector, index);
                break;
            case BITMAPS:
                runBitmaps(injector, index);
                break;
            default:
                throw new ISE("dumpType[%s] has no handler", dumpType);
        }
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : IndexIO(org.apache.druid.segment.IndexIO) Injector(com.google.inject.Injector) QueryableIndex(org.apache.druid.segment.QueryableIndex) ISE(org.apache.druid.java.util.common.ISE) IAE(org.apache.druid.java.util.common.IAE) File(java.io.File) IOException(java.io.IOException)

Example 4 with IndexIO

use of org.apache.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 new RuntimeException(e);
    }
}
Also used : IndexIO(org.apache.druid.segment.IndexIO) Injector(com.google.inject.Injector) IAE(org.apache.druid.java.util.common.IAE) File(java.io.File)

Example 5 with IndexIO

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

the class SpatialFilterBonusTest method constructorFeeder.

@Parameterized.Parameters
public static Collection<?> constructorFeeder() throws IOException {
    List<Object[]> argumentArrays = new ArrayList<>();
    for (SegmentWriteOutMediumFactory segmentWriteOutMediumFactory : SegmentWriteOutMediumFactory.builtInFactories()) {
        IndexMerger indexMerger = TestHelper.getTestIndexMergerV9(segmentWriteOutMediumFactory);
        IndexIO indexIO = TestHelper.getTestIndexIO();
        final IndexSpec indexSpec = new IndexSpec();
        final IncrementalIndex rtIndex = makeIncrementalIndex();
        final QueryableIndex mMappedTestIndex = makeQueryableIndex(indexSpec, indexMerger, indexIO);
        final QueryableIndex mergedRealtimeIndex = makeMergedQueryableIndex(indexSpec, indexMerger, indexIO);
        argumentArrays.add(new Object[] { new IncrementalIndexSegment(rtIndex, null) });
        argumentArrays.add(new Object[] { new QueryableIndexSegment(mMappedTestIndex, null) });
        argumentArrays.add(new Object[] { new QueryableIndexSegment(mergedRealtimeIndex, null) });
    }
    return argumentArrays;
}
Also used : QueryableIndexSegment(org.apache.druid.segment.QueryableIndexSegment) IndexMerger(org.apache.druid.segment.IndexMerger) IndexSpec(org.apache.druid.segment.IndexSpec) IndexIO(org.apache.druid.segment.IndexIO) IncrementalIndex(org.apache.druid.segment.incremental.IncrementalIndex) OnheapIncrementalIndex(org.apache.druid.segment.incremental.OnheapIncrementalIndex) IncrementalIndexSegment(org.apache.druid.segment.IncrementalIndexSegment) QueryableIndex(org.apache.druid.segment.QueryableIndex) ArrayList(java.util.ArrayList) SegmentWriteOutMediumFactory(org.apache.druid.segment.writeout.SegmentWriteOutMediumFactory)

Aggregations

IndexIO (org.apache.druid.segment.IndexIO)16 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)8 File (java.io.File)8 DefaultObjectMapper (org.apache.druid.jackson.DefaultObjectMapper)6 IndexMergerV9 (org.apache.druid.segment.IndexMergerV9)6 ColumnConfig (org.apache.druid.segment.column.ColumnConfig)5 QueryableIndex (org.apache.druid.segment.QueryableIndex)4 Before (org.junit.Before)4 InjectableValues (com.fasterxml.jackson.databind.InjectableValues)3 ArrayList (java.util.ArrayList)3 SegmentizerModule (org.apache.druid.jackson.SegmentizerModule)3 Closer (org.apache.druid.java.util.common.io.Closer)3 IndexMerger (org.apache.druid.segment.IndexMerger)3 IndexSpec (org.apache.druid.segment.IndexSpec)3 IncrementalIndex (org.apache.druid.segment.incremental.IncrementalIndex)3 NamedType (com.fasterxml.jackson.databind.jsontype.NamedType)2 SimpleModule (com.fasterxml.jackson.databind.module.SimpleModule)2 Injector (com.google.inject.Injector)2 IAE (org.apache.druid.java.util.common.IAE)2 ExprMacroTable (org.apache.druid.math.expr.ExprMacroTable)2