Search in sources :

Example 1 with IntervalRecordSource

use of com.questdb.ql.interval.IntervalRecordSource in project questdb by bluestreak01.

the class QueryCompiler method filter.

private RecordSource filter(QueryModel model, RecordSource rs) throws ParserException {
    try {
        if (model.getWhereClause() == null) {
            return rs;
        }
        RecordMetadata m = rs.getMetadata();
        if (model.getAlias() != null) {
            m.setAlias(model.getAlias().token);
        }
        int timestampIndex = getTimestampIndexQuiet(model.getTimestamp(), m);
        IntrinsicModel im = queryFilterAnalyser.extract(model, model.getWhereClause(), m, null, timestampIndex);
        if (im.intrinsicValue == IntrinsicValue.FALSE) {
            return new NoOpJournalRecordSource(rs);
        }
        if (im.intervals != null) {
            rs = new IntervalRecordSource(rs, im.intervals, timestampIndex);
        }
        if (im.filter != null) {
            VirtualColumn vc = virtualColumnBuilder.createVirtualColumn(model, im.filter, m);
            if (vc.isConstant()) {
                // todo: not hit by test
                if (vc.getBool(null)) {
                    return rs;
                } else {
                    return new NoOpJournalRecordSource(rs);
                }
            }
            return new FilteredRecordSource(rs, vc, im.filter);
        } else {
            return rs;
        }
    } catch (ParserException e) {
        Misc.free(rs);
        throw e;
    }
}
Also used : IntervalRecordSource(com.questdb.ql.interval.IntervalRecordSource) ParserException(com.questdb.ex.ParserException) VirtualColumn(com.questdb.ql.ops.VirtualColumn)

Aggregations

ParserException (com.questdb.ex.ParserException)1 IntervalRecordSource (com.questdb.ql.interval.IntervalRecordSource)1 VirtualColumn (com.questdb.ql.ops.VirtualColumn)1