Search in sources :

Example 6 with StrConstant

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

the class CastTimestampToStrFunctionFactory method newInstance.

@Override
public Function newInstance(int position, ObjList<Function> args, IntList argPositions, CairoConfiguration configuration, SqlExecutionContext sqlExecutionContext) {
    Function func = args.getQuick(0);
    if (func.isConstant()) {
        StringSink sink = Misc.getThreadLocalBuilder();
        sink.put(func.getTimestamp(null));
        return new StrConstant(Chars.toString(sink));
    }
    return new Func(args.getQuick(0));
}
Also used : Function(io.questdb.cairo.sql.Function) StrFunction(io.questdb.griffin.engine.functions.StrFunction) UnaryFunction(io.questdb.griffin.engine.functions.UnaryFunction) StringSink(io.questdb.std.str.StringSink) StrConstant(io.questdb.griffin.engine.functions.constants.StrConstant)

Example 7 with StrConstant

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

the class CastIntToStrFunctionFactory method newInstance.

@Override
public Function newInstance(int position, ObjList<Function> args, IntList argPositions, CairoConfiguration configuration, SqlExecutionContext sqlExecutionContext) {
    Function intFunc = args.getQuick(0);
    if (intFunc.isConstant()) {
        StringSink sink = Misc.getThreadLocalBuilder();
        sink.put(intFunc.getInt(null));
        return new StrConstant(Chars.toString(sink));
    }
    return new Func(args.getQuick(0));
}
Also used : Function(io.questdb.cairo.sql.Function) StrFunction(io.questdb.griffin.engine.functions.StrFunction) UnaryFunction(io.questdb.griffin.engine.functions.UnaryFunction) StringSink(io.questdb.std.str.StringSink) StrConstant(io.questdb.griffin.engine.functions.constants.StrConstant)

Example 8 with StrConstant

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

the class CastShortToStrFunctionFactory method newInstance.

@Override
public Function newInstance(int position, ObjList<Function> args, IntList argPositions, CairoConfiguration configuration, SqlExecutionContext sqlExecutionContext) {
    Function intFunc = args.getQuick(0);
    if (intFunc.isConstant()) {
        final StringSink sink = Misc.getThreadLocalBuilder();
        sink.put(intFunc.getShort(null));
        return new StrConstant(Chars.toString(sink));
    }
    return new Func(args.getQuick(0));
}
Also used : UnaryFunction(io.questdb.griffin.engine.functions.UnaryFunction) Function(io.questdb.cairo.sql.Function) StrFunction(io.questdb.griffin.engine.functions.StrFunction) StringSink(io.questdb.std.str.StringSink) StrConstant(io.questdb.griffin.engine.functions.constants.StrConstant)

Example 9 with StrConstant

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

the class CastLongToStrFunctionFactory method newInstance.

@Override
public Function newInstance(int position, ObjList<Function> args, IntList argPositions, CairoConfiguration configuration, SqlExecutionContext sqlExecutionContext) {
    Function func = args.getQuick(0);
    if (func.isConstant()) {
        StringSink sink = Misc.getThreadLocalBuilder();
        sink.put(func.getLong(null));
        return new StrConstant(Chars.toString(sink));
    }
    return new Func(args.getQuick(0));
}
Also used : Function(io.questdb.cairo.sql.Function) StrFunction(io.questdb.griffin.engine.functions.StrFunction) UnaryFunction(io.questdb.griffin.engine.functions.UnaryFunction) StringSink(io.questdb.std.str.StringSink) StrConstant(io.questdb.griffin.engine.functions.constants.StrConstant)

Example 10 with StrConstant

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

the class CastFloatToStrFunctionFactory method newInstance.

@Override
public Function newInstance(int position, ObjList<Function> args, IntList argPositions, CairoConfiguration configuration, SqlExecutionContext sqlExecutionContext) {
    Function intFunc = args.getQuick(0);
    if (intFunc.isConstant()) {
        final StringSink sink = Misc.getThreadLocalBuilder();
        sink.put(intFunc.getFloat(null), configuration.getFloatToStrCastScale());
        return new StrConstant(Chars.toString(sink));
    }
    return new Func(args.getQuick(0), configuration.getFloatToStrCastScale());
}
Also used : UnaryFunction(io.questdb.griffin.engine.functions.UnaryFunction) Function(io.questdb.cairo.sql.Function) StrFunction(io.questdb.griffin.engine.functions.StrFunction) StringSink(io.questdb.std.str.StringSink) StrConstant(io.questdb.griffin.engine.functions.constants.StrConstant)

Aggregations

StrConstant (io.questdb.griffin.engine.functions.constants.StrConstant)12 StringSink (io.questdb.std.str.StringSink)11 Function (io.questdb.cairo.sql.Function)10 StrFunction (io.questdb.griffin.engine.functions.StrFunction)10 UnaryFunction (io.questdb.griffin.engine.functions.UnaryFunction)10 DateFormat (io.questdb.std.datetime.DateFormat)2 BuildInformation (io.questdb.BuildInformation)1