use of org.apache.druid.segment.ColumnInspector in project druid by druid-io.
the class TimeseriesQueryEngine method process.
/**
* Run a single-segment, single-interval timeseries query on a particular adapter. The query must have been
* scoped down to a single interval before calling this method.
*/
public Sequence<Result<TimeseriesResultValue>> process(final TimeseriesQuery query, final StorageAdapter adapter) {
if (adapter == null) {
throw new SegmentMissingException("Null storage adapter found. Probably trying to issue a query against a segment being memory unmapped.");
}
final Filter filter = Filters.convertToCNFFromQueryContext(query, Filters.toFilter(query.getFilter()));
final Interval interval = Iterables.getOnlyElement(query.getIntervals());
final Granularity gran = query.getGranularity();
final boolean descending = query.isDescending();
final ColumnInspector inspector = query.getVirtualColumns().wrapInspector(adapter);
final boolean doVectorize = QueryContexts.getVectorize(query).shouldVectorize(adapter.canVectorize(filter, query.getVirtualColumns(), descending) && VirtualColumns.shouldVectorize(query, query.getVirtualColumns(), adapter) && query.getAggregatorSpecs().stream().allMatch(aggregatorFactory -> aggregatorFactory.canVectorize(inspector)));
final Sequence<Result<TimeseriesResultValue>> result;
if (doVectorize) {
result = processVectorized(query, adapter, filter, interval, gran, descending);
} else {
result = processNonVectorized(query, adapter, filter, interval, gran, descending);
}
final int limit = query.getLimit();
if (limit < Integer.MAX_VALUE) {
return result.limit(limit);
} else {
return result;
}
}
use of org.apache.druid.segment.ColumnInspector in project druid by druid-io.
the class ExpressionVectorSelectorsTest method setup.
@Before
public void setup() {
Expr parsed = Parser.parse(expression, ExprMacroTable.nil());
outputType = parsed.getOutputType(new ColumnInspector() {
@Nullable
@Override
public ColumnCapabilities getColumnCapabilities(String column) {
return QueryableIndexStorageAdapter.getColumnCapabilities(INDEX, column);
}
});
if (outputType == null) {
outputType = ExpressionType.STRING;
}
}
use of org.apache.druid.segment.ColumnInspector in project druid by druid-io.
the class VirtualColumnsTest method testGetColumnCapabilitiesWithFallbackNilBase.
@Test
public void testGetColumnCapabilitiesWithFallbackNilBase() {
final VirtualColumns virtualColumns = makeVirtualColumns();
final ColumnInspector baseInspector = column -> null;
Assert.assertEquals(ValueType.FLOAT, virtualColumns.getColumnCapabilitiesWithFallback(baseInspector, "expr").getType());
Assert.assertEquals(ValueType.LONG, virtualColumns.getColumnCapabilitiesWithFallback(baseInspector, "expr2").getType());
Assert.assertNull(virtualColumns.getColumnCapabilitiesWithFallback(baseInspector, REAL_COLUMN_NAME));
}
use of org.apache.druid.segment.ColumnInspector in project druid by druid-io.
the class VirtualColumnsTest method testGetColumnCapabilitiesNilBase.
@Test
public void testGetColumnCapabilitiesNilBase() {
final VirtualColumns virtualColumns = makeVirtualColumns();
final ColumnInspector baseInspector = column -> null;
Assert.assertEquals(ValueType.FLOAT, virtualColumns.getColumnCapabilities(baseInspector, "expr").getType());
Assert.assertEquals(ValueType.LONG, virtualColumns.getColumnCapabilities(baseInspector, "expr2").getType());
Assert.assertNull(virtualColumns.getColumnCapabilities(baseInspector, REAL_COLUMN_NAME));
}
use of org.apache.druid.segment.ColumnInspector in project druid by druid-io.
the class VirtualColumnsTest method testWrapInspectorNilBase.
@Test
public void testWrapInspectorNilBase() {
final VirtualColumns virtualColumns = makeVirtualColumns();
final ColumnInspector baseInspector = column -> null;
final ColumnInspector wrappedInspector = virtualColumns.wrapInspector(baseInspector);
Assert.assertEquals(ValueType.FLOAT, wrappedInspector.getColumnCapabilities("expr").getType());
Assert.assertEquals(ValueType.LONG, wrappedInspector.getColumnCapabilities("expr2").getType());
Assert.assertNull(wrappedInspector.getColumnCapabilities(REAL_COLUMN_NAME));
}
Aggregations