/** * A helper method to set a simple index schema with controllable metrics and rollup, and default values for the * other parameters. Note that this method is normally used for testing and benchmarking; it is unlikely that you * would use it in production settings. * * @param metrics variable array of {@link AggregatorFactory} metrics * * @return this */ @VisibleForTesting public Builder setSimpleTestingIndexSchema(@Nullable Boolean rollup, final AggregatorFactory... metrics) { IncrementalIndexSchema.Builder builder = new IncrementalIndexSchema.Builder().withMetrics(metrics); this.incrementalIndexSchema = rollup != null ? builder.withRollup(rollup).build() : builder.build(); return this; }
.withMinTimestamp(JodaUtils.MIN_INSTANT) .withDimensionsSpec(ROW_PARSER) .withMetrics(new LongSumAggregatorFactory(METRICS[0], METRICS[0])) .build(); final IncrementalIndex index = new IncrementalIndex.Builder()
new IncrementalIndexSchema.Builder() .withQueryGranularity(Granularities.MINUTE) .withMetrics(new LongMaxAggregatorFactory("max", "max")) .build()
public static IncrementalIndex makeRealtimeIndex(final CharSource source, boolean rollup) { final IncrementalIndexSchema schema = new IncrementalIndexSchema.Builder() .withMinTimestamp(DateTimes.of("2011-01-12T00:00:00.000Z").getMillis()) .withTimestampSpec(new TimestampSpec("ds", "auto", null)) .withDimensionsSpec(DIMENSIONS_SPEC) .withVirtualColumns(VIRTUAL_COLUMNS) .withMetrics(METRIC_AGGS) .withRollup(rollup) .build(); final IncrementalIndex retVal = new IncrementalIndex.Builder() .setIndexSchema(schema) .setMaxRowCount(10000) .buildOnheap(); try { return loadIncrementalIndex(retVal, source); } catch (Exception e) { if (rollup) { realtimeIndex = null; } else { noRollupRealtimeIndex = null; } throw Throwables.propagate(e); } }
private static IncrementalIndex makeIncrementalIndex( Bucket theBucket, AggregatorFactory[] aggs, HadoopDruidIndexerConfig config, Iterable<String> oldDimOrder, Map<String, ColumnCapabilitiesImpl> oldCapabilities ) { final HadoopTuningConfig tuningConfig = config.getSchema().getTuningConfig(); final IncrementalIndexSchema indexSchema = new IncrementalIndexSchema.Builder() .withMinTimestamp(theBucket.time.getMillis()) .withTimestampSpec(config.getSchema().getDataSchema().getParser().getParseSpec().getTimestampSpec()) .withDimensionsSpec(config.getSchema().getDataSchema().getParser()) .withQueryGranularity(config.getSchema().getDataSchema().getGranularitySpec().getQueryGranularity()) .withMetrics(aggs) .withRollup(config.getSchema().getDataSchema().getGranularitySpec().isRollup()) .build(); IncrementalIndex newIndex = new IncrementalIndex.Builder() .setIndexSchema(indexSchema) .setReportParseExceptions(!tuningConfig.isIgnoreInvalidRows()) // only used by OffHeapIncrementalIndex .setMaxRowCount(tuningConfig.getRowFlushBoundary()) .setMaxBytesInMemory(TuningConfigs.getMaxBytesInMemoryOrDefault(tuningConfig.getMaxBytesInMemory())) .buildOnheap(); if (oldDimOrder != null && !indexSchema.getDimensionsSpec().hasCustomDimensions()) { newIndex.loadDimensionIterable(oldDimOrder, oldCapabilities); } return newIndex; }
public MapIncrementalIndex( long minTimestamp, Granularity gran, AggregatorFactory[] metrics, int maxRowCount, long maxBytesInMemory ) { super( new IncrementalIndexSchema.Builder() .withMinTimestamp(minTimestamp) .withQueryGranularity(gran) .withMetrics(metrics) .build(), true, true, false, true, maxRowCount, maxBytesInMemory ); }
@Test public void testgetDimensions() { final IncrementalIndex<Aggregator> incrementalIndex = new IncrementalIndex.Builder() .setIndexSchema( new IncrementalIndexSchema.Builder() .withMetrics(new CountAggregatorFactory("count")) .withDimensionsSpec( new DimensionsSpec( DimensionsSpec.getDefaultSchemas(Arrays.asList("dim0", "dim1")), null, null ) ) .build() ) .setMaxRowCount(1000000) .buildOnheap(); closerRule.closeLater(incrementalIndex); Assert.assertEquals(Arrays.asList("dim0", "dim1"), incrementalIndex.getDimensionNames()); }
public LongFilteringTest( String testName, IndexBuilder indexBuilder, Function<IndexBuilder, Pair<StorageAdapter, Closeable>> finisher, boolean cnf, boolean optimize ) { super( testName, ROWS, indexBuilder.schema( new IncrementalIndexSchema.Builder() .withMetrics(new LongSumAggregatorFactory(LONG_COLUMN, LONG_COLUMN)) .build() ), finisher, cnf, optimize ); }
public static IncrementalIndex createIndex( AggregatorFactory[] aggregatorFactories, DimensionsSpec dimensionsSpec ) { if (null == aggregatorFactories) { aggregatorFactories = defaultAggregatorFactories; } return new IncrementalIndex.Builder() .setIndexSchema( new IncrementalIndexSchema.Builder() .withDimensionsSpec(dimensionsSpec) .withMetrics(aggregatorFactories) .build() ) .setMaxRowCount(1000000) .buildOnheap(); }
private IncrementalIndex makeIncIndex(boolean withRollup) { return new IncrementalIndex.Builder() .setIndexSchema( new IncrementalIndexSchema.Builder() .withMetrics(schemaInfo.getAggsArray()) .withRollup(withRollup) .build() ) .setReportParseExceptions(false) .setConcurrentEventAdd(true) .setMaxRowCount(rowsPerSegment) .buildOnheap(); }
private IncrementalIndex makeIncIndex() { return new IncrementalIndex.Builder() .setIndexSchema( new IncrementalIndexSchema.Builder() .withMetrics(schemaInfo.getAggsArray()) .withRollup(rollup) .build() ) .setReportParseExceptions(false) .setMaxRowCount(rowsPerSegment) .buildOnheap(); }
private IncrementalIndex makeIncIndex() { return new IncrementalIndex.Builder() .setIndexSchema( new IncrementalIndexSchema.Builder() .withMetrics(schemaInfo.getAggsArray()) .withRollup(rollup) .build() ) .setReportParseExceptions(false) .setMaxRowCount(rowsPerSegment) .buildOnheap(); }
private static IncrementalIndex newIndex(String minTimeStamp, int maxRowCount) { final IncrementalIndexSchema schema = new IncrementalIndexSchema.Builder() .withMinTimestamp(DateTimes.of(minTimeStamp).getMillis()) .withQueryGranularity(Granularities.HOUR) .withMetrics(TestIndex.METRIC_AGGS) .build(); return new IncrementalIndex.Builder() .setIndexSchema(schema) .setMaxRowCount(maxRowCount) .buildOnheap(); }
private static IncrementalIndex newIndex(String minTimeStamp, int maxRowCount) { final IncrementalIndexSchema schema = new IncrementalIndexSchema.Builder() .withMinTimestamp(DateTimes.of(minTimeStamp).getMillis()) .withQueryGranularity(Granularities.HOUR) .withMetrics(TestIndex.METRIC_AGGS) .build(); return new IncrementalIndex.Builder() .setIndexSchema(schema) .setMaxRowCount(maxRowCount) .buildOnheap(); }
private IncrementalIndex makeIncIndex() { return new IncrementalIndex.Builder() .setIndexSchema( new IncrementalIndexSchema.Builder() .withMetrics(schemaInfo.getAggsArray()) .withRollup(rollup) .build() ) .setReportParseExceptions(false) .setMaxRowCount(rowsPerSegment) .buildOnheap(); }
private IncrementalIndex makeIncIndex() { return new IncrementalIndex.Builder() .setIndexSchema( new IncrementalIndexSchema.Builder() .withMetrics(schemaInfo.getAggsArray()) .withRollup(rollup) .build() ) .setReportParseExceptions(false) .setMaxRowCount(rowsPerSegment * 2) .buildOnheap(); }
private IncrementalIndex getIndexWithDims(List<String> dims) { IncrementalIndexSchema schema = new IncrementalIndexSchema.Builder() .withDimensionsSpec(new DimensionsSpec(makeDimensionSchemas(dims), null, null)) .withMetrics(new CountAggregatorFactory("count")) .build(); return new IncrementalIndex.Builder() .setIndexSchema(schema) .setMaxRowCount(1000) .buildOnheap(); }
private IncrementalIndex getIndexWithDimsFromSchemata(List<DimensionSchema> dims) { IncrementalIndexSchema schema = new IncrementalIndexSchema.Builder() .withDimensionsSpec(new DimensionsSpec(dims, null, null)) .withMetrics(new CountAggregatorFactory("count")) .build(); return new IncrementalIndex.Builder() .setIndexSchema(schema) .setMaxRowCount(1000) .buildOnheap(); }
private static IndexBuilder overrideIndexBuilderSchema(IndexBuilder indexBuilder) { IncrementalIndexSchema schema = new IncrementalIndexSchema.Builder() .withMetrics( new CountAggregatorFactory("count"), new HyperUniquesAggregatorFactory("hyperion", "dim1"), new DoubleMaxAggregatorFactory("dmax", "dim0") ).build(); return indexBuilder.schema(schema); }
private static IncrementalIndex newIndex(String minTimeStamp, int maxRowCount) { final IncrementalIndexSchema schema = new IncrementalIndexSchema.Builder() .withMinTimestamp(DateTimes.of(minTimeStamp).getMillis()) .withQueryGranularity(Granularities.HOUR) .withMetrics(TestIndex.METRIC_AGGS) .build(); return new IncrementalIndex.Builder() .setIndexSchema(schema) .setMaxRowCount(maxRowCount) .buildOnheap(); }