Search in sources :

Example 1 with CursorFunction

use of io.questdb.griffin.engine.functions.CursorFunction in project questdb by bluestreak01.

the class LongSequenceFunctionFactory method newInstance.

@Override
public Function newInstance(int position, ObjList<Function> args, IntList argPositions, CairoConfiguration configuration, SqlExecutionContext sqlExecutionContext) throws SqlException {
    Function countFunc;
    final Function seedLoFunc;
    final Function seedHiFunc;
    if (args != null) {
        final int argCount = args.size();
        if (argCount == 1 && SqlCompiler.isAssignableFrom(ColumnType.LONG, (countFunc = args.getQuick(0)).getType())) {
            return new CursorFunction(new LongSequenceCursorFactory(METADATA, countFunc.getLong(null)));
        }
        if (argCount > 2 && SqlCompiler.isAssignableFrom(ColumnType.LONG, (countFunc = args.getQuick(0)).getType()) && SqlCompiler.isAssignableFrom(ColumnType.LONG, (seedLoFunc = args.getQuick(1)).getType()) && SqlCompiler.isAssignableFrom(ColumnType.LONG, (seedHiFunc = args.getQuick(2)).getType())) {
            return new CursorFunction(new SeedingLongSequenceCursorFactory(METADATA, countFunc.getLong(null), seedLoFunc.getLong(null), seedHiFunc.getLong(null)));
        }
    }
    throw SqlException.position(position).put("invalid arguments");
}
Also used : CursorFunction(io.questdb.griffin.engine.functions.CursorFunction) Function(io.questdb.cairo.sql.Function) CursorFunction(io.questdb.griffin.engine.functions.CursorFunction)

Aggregations

Function (io.questdb.cairo.sql.Function)1 CursorFunction (io.questdb.griffin.engine.functions.CursorFunction)1