use of io.questdb.griffin.engine.functions.constants.StrConstant in project questdb by bluestreak01.
the class CastDoubleToStrFunctionFactory 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.getDouble(null), configuration.getDoubleToStrCastScale());
return new StrConstant(Chars.toString(sink));
}
return new Func(args.getQuick(0), configuration.getDoubleToStrCastScale());
}
use of io.questdb.griffin.engine.functions.constants.StrConstant in project questdb by bluestreak01.
the class CastCharToStrFunctionFactory method newInstance.
public Function newInstance(Function func) {
if (func.isConstant()) {
final char value = func.getChar(null);
if (value == 0) {
return new StrConstant(null);
}
final StringSink sink = Misc.getThreadLocalBuilder();
sink.put(value);
return new StrConstant(Chars.toString(sink));
}
return new Func(func);
}
use of io.questdb.griffin.engine.functions.constants.StrConstant in project questdb by bluestreak01.
the class BuildFunctionFactory method createInstance.
private StrFunction createInstance(final CairoConfiguration configuration) {
final BuildInformation buildInformation = configuration.getBuildInformation();
final CharSequence information = "Build Information: QuestDB " + buildInformation.getQuestDbVersion() + ", JDK " + buildInformation.getJdkVersion() + ", Commit Hash " + buildInformation.getCommitHash();
return new StrConstant(information);
}
use of io.questdb.griffin.engine.functions.constants.StrConstant in project questdb by bluestreak01.
the class ToStrDateFunctionFactory method newInstance.
@Override
public Function newInstance(int position, ObjList<Function> args, IntList argPositions, CairoConfiguration configuration, SqlExecutionContext sqlExecutionContext) throws SqlException {
Function fmt = args.getQuick(1);
CharSequence format = fmt.getStr(null);
if (format == null) {
throw SqlException.$(argPositions.getQuick(1), "format must not be null");
}
DateFormat dateFormat = tlCompiler.get().compile(fmt.getStr(null));
Function var = args.getQuick(0);
if (var.isConstant()) {
long value = var.getDate(null);
if (value == Numbers.LONG_NaN) {
return StrConstant.NULL;
}
StringSink sink = tlSink.get();
sink.clear();
dateFormat.format(value, configuration.getDefaultDateLocale(), "Z", sink);
return new StrConstant(sink);
}
return new ToCharDateVCFFunc(args.getQuick(0), tlCompiler.get().compile(format), configuration.getDefaultDateLocale());
}
use of io.questdb.griffin.engine.functions.constants.StrConstant in project questdb by bluestreak01.
the class ToStrTimestampFunctionFactory method newInstance.
@Override
public Function newInstance(int position, ObjList<Function> args, IntList argPositions, CairoConfiguration configuration, SqlExecutionContext sqlExecutionContext) throws SqlException {
Function fmt = args.getQuick(1);
CharSequence format = fmt.getStr(null);
if (format == null) {
throw SqlException.$(argPositions.getQuick(1), "format must not be null");
}
DateFormat timestampFormat = tlCompiler.get().compile(fmt.getStr(null));
Function var = args.getQuick(0);
if (var.isConstant()) {
long value = var.getTimestamp(null);
if (value == Numbers.LONG_NaN) {
return StrConstant.NULL;
}
StringSink sink = tlSink.get();
sink.clear();
timestampFormat.format(value, configuration.getDefaultDateLocale(), "Z", sink);
return new StrConstant(sink);
}
return new ToCharDateFFunc(args.getQuick(0), timestampFormat, configuration.getDefaultDateLocale());
}
Aggregations