Search in sources :

Example 6 with IndexSizeExceededException

use of io.druid.segment.incremental.IndexSizeExceededException in project druid by druid-io.

the class IndexBuilder method buildIncrementalIndexWithRows.

private static IncrementalIndex buildIncrementalIndexWithRows(IncrementalIndexSchema schema, int maxRows, Iterable<InputRow> rows) {
    Preconditions.checkNotNull(schema, "schema");
    final IncrementalIndex incrementalIndex = new OnheapIncrementalIndex(schema, true, maxRows);
    for (InputRow row : rows) {
        try {
            incrementalIndex.add(row);
        } catch (IndexSizeExceededException e) {
            throw Throwables.propagate(e);
        }
    }
    return incrementalIndex;
}
Also used : IncrementalIndex(io.druid.segment.incremental.IncrementalIndex) OnheapIncrementalIndex(io.druid.segment.incremental.OnheapIncrementalIndex) OnheapIncrementalIndex(io.druid.segment.incremental.OnheapIncrementalIndex) InputRow(io.druid.data.input.InputRow) IndexSizeExceededException(io.druid.segment.incremental.IndexSizeExceededException)

Example 7 with IndexSizeExceededException

use of io.druid.segment.incremental.IndexSizeExceededException in project druid by druid-io.

the class SchemalessIndexTest method getIncrementalIndex.

public static QueryableIndex getIncrementalIndex(int index1, int index2) {
    synchronized (log) {
        if (events.isEmpty()) {
            makeEvents();
        }
        Map<Integer, QueryableIndex> entry = incrementalIndexes.get(index1);
        if (entry != null) {
            QueryableIndex index = entry.get(index2);
            if (index != null) {
                return index;
            }
        } else {
            entry = Maps.<Integer, QueryableIndex>newHashMap();
            incrementalIndexes.put(index1, entry);
        }
        IncrementalIndex theIndex = null;
        int count = 0;
        for (final Map<String, Object> event : events) {
            if (count != index1 && count != index2) {
                count++;
                continue;
            }
            final long timestamp = new DateTime(event.get(TIMESTAMP)).getMillis();
            if (theIndex == null) {
                theIndex = new OnheapIncrementalIndex(timestamp, Granularities.MINUTE, METRIC_AGGS, 1000);
            }
            final List<String> dims = Lists.newArrayList();
            for (final Map.Entry<String, Object> val : event.entrySet()) {
                if (!val.getKey().equalsIgnoreCase(TIMESTAMP) && !METRICS.contains(val.getKey())) {
                    dims.add(val.getKey());
                }
            }
            try {
                theIndex.add(new MapBasedInputRow(timestamp, dims, event));
            } catch (IndexSizeExceededException e) {
                Throwables.propagate(e);
            }
            count++;
        }
        QueryableIndex retVal = TestIndex.persistRealtimeAndLoadMMapped(theIndex);
        entry.put(index2, retVal);
        return retVal;
    }
}
Also used : IncrementalIndex(io.druid.segment.incremental.IncrementalIndex) OnheapIncrementalIndex(io.druid.segment.incremental.OnheapIncrementalIndex) OnheapIncrementalIndex(io.druid.segment.incremental.OnheapIncrementalIndex) DateTime(org.joda.time.DateTime) MapBasedInputRow(io.druid.data.input.MapBasedInputRow) Map(java.util.Map) IndexSizeExceededException(io.druid.segment.incremental.IndexSizeExceededException)

Example 8 with IndexSizeExceededException

use of io.druid.segment.incremental.IndexSizeExceededException in project druid by druid-io.

the class IngestSegmentFirehoseFactoryTimelineTest method persist.

private static Map<String, Object> persist(File tmpDir, InputRow... rows) {
    final File persistDir = new File(tmpDir, UUID.randomUUID().toString());
    final IncrementalIndexSchema schema = new IncrementalIndexSchema.Builder().withQueryGranularity(Granularities.NONE).withMinTimestamp(JodaUtils.MIN_INSTANT).withDimensionsSpec(ROW_PARSER).withMetrics(new AggregatorFactory[] { new LongSumAggregatorFactory(METRICS[0], METRICS[0]) }).build();
    final OnheapIncrementalIndex index = new OnheapIncrementalIndex(schema, true, rows.length);
    for (InputRow row : rows) {
        try {
            index.add(row);
        } catch (IndexSizeExceededException e) {
            throw Throwables.propagate(e);
        }
    }
    try {
        INDEX_MERGER.persist(index, persistDir, new IndexSpec());
    } catch (IOException e) {
        throw Throwables.propagate(e);
    }
    return ImmutableMap.<String, Object>of("type", "local", "path", persistDir.getAbsolutePath());
}
Also used : IndexSpec(io.druid.segment.IndexSpec) LongSumAggregatorFactory(io.druid.query.aggregation.LongSumAggregatorFactory) OnheapIncrementalIndex(io.druid.segment.incremental.OnheapIncrementalIndex) MapBasedInputRow(io.druid.data.input.MapBasedInputRow) InputRow(io.druid.data.input.InputRow) IOException(java.io.IOException) AggregatorFactory(io.druid.query.aggregation.AggregatorFactory) LongSumAggregatorFactory(io.druid.query.aggregation.LongSumAggregatorFactory) File(java.io.File) IncrementalIndexSchema(io.druid.segment.incremental.IncrementalIndexSchema) IndexSizeExceededException(io.druid.segment.incremental.IndexSizeExceededException)

Aggregations

IndexSizeExceededException (io.druid.segment.incremental.IndexSizeExceededException)8 OnheapIncrementalIndex (io.druid.segment.incremental.OnheapIncrementalIndex)5 InputRow (io.druid.data.input.InputRow)4 IncrementalIndex (io.druid.segment.incremental.IncrementalIndex)4 MapBasedInputRow (io.druid.data.input.MapBasedInputRow)3 AggregatorFactory (io.druid.query.aggregation.AggregatorFactory)3 ISE (io.druid.java.util.common.ISE)2 LongSumAggregatorFactory (io.druid.query.aggregation.LongSumAggregatorFactory)2 OffheapIncrementalIndex (io.druid.segment.incremental.OffheapIncrementalIndex)2 Sink (io.druid.segment.realtime.plumber.Sink)2 Function (com.google.common.base.Function)1 Supplier (com.google.common.base.Supplier)1 ImmutableList (com.google.common.collect.ImmutableList)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)1 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1 Committer (io.druid.data.input.Committer)1 MapBasedRow (io.druid.data.input.MapBasedRow)1 DimensionSchema (io.druid.data.input.impl.DimensionSchema)1 DimensionsSpec (io.druid.data.input.impl.DimensionsSpec)1