use of io.questdb.cairo.sql.Function in project questdb by bluestreak01.
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);
}
use of io.questdb.cairo.sql.Function in project questdb by bluestreak01.
the class CastDateToSymbolFunctionFactory 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.getDate(null));
return SymbolConstant.newInstance(sink);
}
return new Func(arg);
}
use of io.questdb.cairo.sql.Function in project questdb by bluestreak01.
the class EqStrCharFunctionFactory method newInstance.
@Override
public Function newInstance(int position, ObjList<Function> args, IntList argPositions, CairoConfiguration configuration, SqlExecutionContext sqlExecutionContext) {
// there are optimisation opportunities
// 1. when one of args is constant null comparison can boil down to checking
// length of non-constant (must be -1)
// 2. when one of arguments is constant, save method call and use a field
Function strFunc = args.getQuick(0);
Function charFunc = args.getQuick(1);
if (ColumnType.isNull(strFunc.getType()) || ColumnType.isNull(charFunc.getType())) {
return new Func(strFunc, charFunc);
}
if (strFunc.isConstant() && !charFunc.isConstant()) {
CharSequence str = strFunc.getStr(null);
if (str == null || str.length() != 1) {
return new NegatedAwareBooleanConstantFunc();
}
return new ConstStrFunc(charFunc, str.charAt(0));
}
if (!strFunc.isConstant() && charFunc.isConstant()) {
return new ConstChrFunc(strFunc, charFunc.getChar(null));
}
if (strFunc.isConstant() && charFunc.isConstant()) {
return new ConstStrConstChrFunc(Chars.equalsNc(strFunc.getStr(null), charFunc.getChar(null)));
}
return new Func(strFunc, charFunc);
}
use of io.questdb.cairo.sql.Function in project questdb by bluestreak01.
the class ToTimestampVCFunctionFactory method newInstance.
@Override
public Function newInstance(int position, ObjList<Function> args, IntList argPositions, CairoConfiguration configuration, SqlExecutionContext sqlExecutionContext) throws SqlException {
final Function arg = args.getQuick(0);
final CharSequence pattern = args.getQuick(1).getStr(null);
if (pattern == null) {
throw SqlException.$(argPositions.getQuick(1), "pattern is required");
}
return new Func(arg, tlCompiler.get().compile(pattern), configuration.getDefaultDateLocale());
}
use of io.questdb.cairo.sql.Function in project questdb by bluestreak01.
the class ToTimezoneTimestampFunctionFactory method newInstance.
@Override
public Function newInstance(int position, ObjList<Function> args, IntList argPositions, CairoConfiguration configuration, SqlExecutionContext sqlExecutionContext) throws SqlException {
Function timestamp = args.getQuick(0);
Function timezone = args.getQuick(1);
if (timezone.isConstant()) {
return getTimestampFunction(argPositions, timestamp, timezone, 1);
} else {
return new ToTimezoneFunctionVar(timestamp, timezone);
}
}
Aggregations