Search in sources :

Example 1 with LowerExtractionFn

use of org.apache.druid.query.extraction.LowerExtractionFn in project druid by druid-io.

the class SearchBenchmark method basicC.

private static SearchQueryBuilder basicC(final GeneratorSchemaInfo basicSchema) {
    final QuerySegmentSpec intervalSpec = new MultipleIntervalSegmentSpec(Collections.singletonList(basicSchema.getDataInterval()));
    final List<String> dimUniformFilterVals = new ArrayList<>();
    final int resultNum = (int) (100000 * 0.1);
    final int step = 100000 / resultNum;
    for (int i = 1; i < 100001 && dimUniformFilterVals.size() < resultNum; i += step) {
        dimUniformFilterVals.add(String.valueOf(i));
    }
    final String dimName = "dimUniform";
    final List<DimFilter> dimFilters = new ArrayList<>();
    dimFilters.add(new InDimFilter(dimName, dimUniformFilterVals, IdentityExtractionFn.getInstance()));
    dimFilters.add(new SelectorDimFilter(dimName, "3", StrlenExtractionFn.instance()));
    dimFilters.add(new BoundDimFilter(dimName, "100", "10000", true, true, true, new DimExtractionFn() {

        @Override
        public byte[] getCacheKey() {
            return new byte[] { 0xF };
        }

        @Override
        public String apply(String value) {
            return String.valueOf(Long.parseLong(value) + 1);
        }

        @Override
        public boolean preservesOrdering() {
            return false;
        }

        @Override
        public ExtractionType getExtractionType() {
            return ExtractionType.ONE_TO_ONE;
        }
    }, null));
    dimFilters.add(new InDimFilter(dimName, dimUniformFilterVals, new LowerExtractionFn(null)));
    dimFilters.add(new InDimFilter(dimName, dimUniformFilterVals, new UpperExtractionFn(null)));
    dimFilters.add(new InDimFilter(dimName, dimUniformFilterVals, new SubstringDimExtractionFn(1, 3)));
    return Druids.newSearchQueryBuilder().dataSource("blah").granularity(Granularities.ALL).intervals(intervalSpec).query("").dimensions(Collections.singletonList("dimUniform")).filters(new AndDimFilter(dimFilters));
}
Also used : BoundDimFilter(org.apache.druid.query.filter.BoundDimFilter) AndDimFilter(org.apache.druid.query.filter.AndDimFilter) ArrayList(java.util.ArrayList) MultipleIntervalSegmentSpec(org.apache.druid.query.spec.MultipleIntervalSegmentSpec) SubstringDimExtractionFn(org.apache.druid.query.extraction.SubstringDimExtractionFn) LowerExtractionFn(org.apache.druid.query.extraction.LowerExtractionFn) SelectorDimFilter(org.apache.druid.query.filter.SelectorDimFilter) InDimFilter(org.apache.druid.query.filter.InDimFilter) QuerySegmentSpec(org.apache.druid.query.spec.QuerySegmentSpec) SelectorDimFilter(org.apache.druid.query.filter.SelectorDimFilter) AndDimFilter(org.apache.druid.query.filter.AndDimFilter) DimFilter(org.apache.druid.query.filter.DimFilter) BoundDimFilter(org.apache.druid.query.filter.BoundDimFilter) InDimFilter(org.apache.druid.query.filter.InDimFilter) DimExtractionFn(org.apache.druid.query.extraction.DimExtractionFn) SubstringDimExtractionFn(org.apache.druid.query.extraction.SubstringDimExtractionFn) UpperExtractionFn(org.apache.druid.query.extraction.UpperExtractionFn)

Aggregations

ArrayList (java.util.ArrayList)1 DimExtractionFn (org.apache.druid.query.extraction.DimExtractionFn)1 LowerExtractionFn (org.apache.druid.query.extraction.LowerExtractionFn)1 SubstringDimExtractionFn (org.apache.druid.query.extraction.SubstringDimExtractionFn)1 UpperExtractionFn (org.apache.druid.query.extraction.UpperExtractionFn)1 AndDimFilter (org.apache.druid.query.filter.AndDimFilter)1 BoundDimFilter (org.apache.druid.query.filter.BoundDimFilter)1 DimFilter (org.apache.druid.query.filter.DimFilter)1 InDimFilter (org.apache.druid.query.filter.InDimFilter)1 SelectorDimFilter (org.apache.druid.query.filter.SelectorDimFilter)1 MultipleIntervalSegmentSpec (org.apache.druid.query.spec.MultipleIntervalSegmentSpec)1 QuerySegmentSpec (org.apache.druid.query.spec.QuerySegmentSpec)1