Search in sources :

Example 66 with StringSink

use of io.questdb.std.str.StringSink in project questdb by questdb.

the class CastShortToSymbolFunctionFactory method newInstance.

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

Example 67 with StringSink

use of io.questdb.std.str.StringSink in project questdb by questdb.

the class CastDateToStrFunctionFactory 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.getDate(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 68 with StringSink

use of io.questdb.std.str.StringSink in project questdb by questdb.

the class CastLongToSymbolFunctionFactory method newInstance.

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

Example 69 with StringSink

use of io.questdb.std.str.StringSink in project questdb by questdb.

the class CastCharToSymbolFunctionFactory method newInstance.

@Override
public Function newInstance(int position, ObjList<Function> args, IntList argPositions, CairoConfiguration configuration, SqlExecutionContext sqlExecutionContext) {
    final Function arg = args.getQuick(0);
    if (arg.isConstant()) {
        final char value = arg.getChar(null);
        if (value == 0) {
            return SymbolConstant.NULL;
        }
        final StringSink sink = Misc.getThreadLocalBuilder();
        sink.put(value);
        return SymbolConstant.newInstance(Chars.toString(sink));
    }
    return new Func(arg);
}
Also used : Function(io.questdb.cairo.sql.Function) StringSink(io.questdb.std.str.StringSink)

Example 70 with StringSink

use of io.questdb.std.str.StringSink in project questdb by questdb.

the class CastIntToSymbolFunctionFactory method newInstance.

@Override
public Function newInstance(int position, ObjList<Function> args, IntList argPositions, CairoConfiguration configuration, SqlExecutionContext sqlExecutionContext) {
    final Function arg = args.getQuick(0);
    if (arg.isConstant()) {
        final StringSink sink = Misc.getThreadLocalBuilder();
        sink.put(arg.getInt(null));
        return SymbolConstant.newInstance(sink);
    }
    return new Func(arg);
}
Also used : Function(io.questdb.cairo.sql.Function) StringSink(io.questdb.std.str.StringSink)

Aggregations

StringSink (io.questdb.std.str.StringSink)304 Test (org.junit.Test)173 Function (io.questdb.cairo.sql.Function)38 BaseConnection (org.postgresql.core.BaseConnection)38 UnaryFunction (io.questdb.griffin.engine.functions.UnaryFunction)28 StrConstant (io.questdb.griffin.engine.functions.constants.StrConstant)22 StrFunction (io.questdb.griffin.engine.functions.StrFunction)20 Path (io.questdb.std.str.Path)18 AbstractGriffinTest (io.questdb.griffin.AbstractGriffinTest)16 CountDownLatch (java.util.concurrent.CountDownLatch)15 CyclicBarrier (java.util.concurrent.CyclicBarrier)15 Record (io.questdb.cairo.sql.Record)14 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)13 SqlCompiler (io.questdb.griffin.SqlCompiler)12 SqlExecutionContextImpl (io.questdb.griffin.SqlExecutionContextImpl)12 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)11 SqlException (io.questdb.griffin.SqlException)9 Metrics (io.questdb.Metrics)8 io.questdb.cairo (io.questdb.cairo)8 AllowAllCairoSecurityContext (io.questdb.cairo.security.AllowAllCairoSecurityContext)8