Search in sources :

Example 11 with IntList

use of io.questdb.std.IntList in project questdb by bluestreak01.

the class FunctionParserTest method testImplicitConstantNullSymbol.

@Test
public void testImplicitConstantNullSymbol() throws SqlException {
    functions.add(new FunctionFactory() {

        @Override
        public String getSignature() {
            return "x()";
        }

        @Override
        public Function newInstance(int position, ObjList<Function> args, IntList argPositions, CairoConfiguration configuration1, SqlExecutionContext sqlExecutionContext) {
            return new SymbolConstant(null, SymbolTable.VALUE_IS_NULL);
        }
    });
    Function function = parseFunction("x()", new GenericRecordMetadata(), createFunctionParser());
    Assert.assertTrue(function instanceof SymbolConstant);
}
Also used : Function(io.questdb.cairo.sql.Function) SysdateFunctionFactory(io.questdb.griffin.engine.functions.date.SysdateFunctionFactory) EqLongFunctionFactory(io.questdb.griffin.engine.functions.eq.EqLongFunctionFactory) ToStrDateFunctionFactory(io.questdb.griffin.engine.functions.date.ToStrDateFunctionFactory) SwitchFunctionFactory(io.questdb.griffin.engine.functions.conditional.SwitchFunctionFactory) EqIntFunctionFactory(io.questdb.griffin.engine.functions.eq.EqIntFunctionFactory) LengthSymbolFunctionFactory(io.questdb.griffin.engine.functions.str.LengthSymbolFunctionFactory) OrFunctionFactory(io.questdb.griffin.engine.functions.bool.OrFunctionFactory) LengthStrFunctionFactory(io.questdb.griffin.engine.functions.str.LengthStrFunctionFactory) EqDoubleFunctionFactory(io.questdb.griffin.engine.functions.eq.EqDoubleFunctionFactory) InStrFunctionFactory(io.questdb.griffin.engine.functions.bool.InStrFunctionFactory) NotFunctionFactory(io.questdb.griffin.engine.functions.bool.NotFunctionFactory) CursorDereferenceFunctionFactory(io.questdb.griffin.engine.functions.catalogue.CursorDereferenceFunctionFactory) ToStrTimestampFunctionFactory(io.questdb.griffin.engine.functions.date.ToStrTimestampFunctionFactory) ToCharBinFunctionFactory(io.questdb.griffin.engine.functions.str.ToCharBinFunctionFactory) CastStrToGeoHashFunctionFactory(io.questdb.griffin.engine.functions.cast.CastStrToGeoHashFunctionFactory) IntList(io.questdb.std.IntList) Test(org.junit.Test)

Example 12 with IntList

use of io.questdb.std.IntList in project questdb by bluestreak01.

the class EqDoubleFunctionFactoryTest method testRightNaNDate.

@Test
public void testRightNaNDate() throws SqlException {
    FunctionFactory factory = getFunctionFactory();
    ObjList<Function> args = new ObjList<>();
    args.add(new DateConstant(10000L));
    args.add(new DoubleConstant(Double.NaN));
    IntList argPositions = new IntList();
    argPositions.add(1);
    argPositions.add(2);
    Function function = factory.newInstance(4, args, argPositions, configuration, sqlExecutionContext);
    Assert.assertFalse(function.getBool(null));
}
Also used : Function(io.questdb.cairo.sql.Function) DoubleConstant(io.questdb.griffin.engine.functions.constants.DoubleConstant) DateConstant(io.questdb.griffin.engine.functions.constants.DateConstant) ObjList(io.questdb.std.ObjList) FunctionFactory(io.questdb.griffin.FunctionFactory) IntList(io.questdb.std.IntList) Test(org.junit.Test) AbstractFunctionFactoryTest(io.questdb.griffin.engine.AbstractFunctionFactoryTest)

Example 13 with IntList

use of io.questdb.std.IntList in project questdb by bluestreak01.

the class EqDoubleFunctionFactoryTest method testLeftNaNFloatNaN.

@Test
public void testLeftNaNFloatNaN() throws SqlException {
    FunctionFactory factory = getFunctionFactory();
    ObjList<Function> args = new ObjList<>();
    args.add(new FloatConstant(Float.NaN));
    args.add(new DoubleConstant(Double.NaN));
    IntList argPositions = new IntList();
    argPositions.add(1);
    argPositions.add(2);
    Function function = factory.newInstance(4, args, argPositions, configuration, sqlExecutionContext);
    Assert.assertTrue(function.getBool(null));
    Assert.assertTrue(function.isConstant());
}
Also used : Function(io.questdb.cairo.sql.Function) DoubleConstant(io.questdb.griffin.engine.functions.constants.DoubleConstant) ObjList(io.questdb.std.ObjList) FloatConstant(io.questdb.griffin.engine.functions.constants.FloatConstant) FunctionFactory(io.questdb.griffin.FunctionFactory) IntList(io.questdb.std.IntList) Test(org.junit.Test) AbstractFunctionFactoryTest(io.questdb.griffin.engine.AbstractFunctionFactoryTest)

Example 14 with IntList

use of io.questdb.std.IntList in project questdb by bluestreak01.

the class CountSymbolGroupByFunction method computeNext.

@Override
public void computeNext(MapValue mapValue, Record record) {
    final IntList set = lists.getQuick(mapValue.getInt(valueIndex + 1));
    final int val = arg.getInt(record);
    if (val != VALUE_IS_NULL) {
        if (val < set.size()) {
            if (set.getQuick(val) == 1) {
                return;
            }
            set.setQuick(val, 1);
        } else {
            set.extendAndSet(val, 1);
        }
        mapValue.addLong(valueIndex, 1);
    }
}
Also used : IntList(io.questdb.std.IntList)

Example 15 with IntList

use of io.questdb.std.IntList in project questdb by bluestreak01.

the class CountSymbolGroupByFunction method computeFirst.

@Override
public void computeFirst(MapValue mapValue, Record record) {
    final IntList list;
    if (lists.size() <= setIndex) {
        lists.extendAndSet(setIndex, list = new IntList());
    } else {
        list = lists.getQuick(setIndex);
    }
    list.clear(0);
    mapValue.putInt(valueIndex + 1, setIndex);
    setIndex++;
    int val = arg.getInt(record);
    if (val != VALUE_IS_NULL) {
        list.extendAndSet(val, 1);
        mapValue.putLong(valueIndex, 1L);
    } else {
        mapValue.putLong(valueIndex, 0L);
    }
}
Also used : IntList(io.questdb.std.IntList)

Aggregations

IntList (io.questdb.std.IntList)37 Function (io.questdb.cairo.sql.Function)33 Test (org.junit.Test)31 InStrFunctionFactory (io.questdb.griffin.engine.functions.bool.InStrFunctionFactory)22 NotFunctionFactory (io.questdb.griffin.engine.functions.bool.NotFunctionFactory)22 OrFunctionFactory (io.questdb.griffin.engine.functions.bool.OrFunctionFactory)22 CastStrToGeoHashFunctionFactory (io.questdb.griffin.engine.functions.cast.CastStrToGeoHashFunctionFactory)22 CursorDereferenceFunctionFactory (io.questdb.griffin.engine.functions.catalogue.CursorDereferenceFunctionFactory)22 SwitchFunctionFactory (io.questdb.griffin.engine.functions.conditional.SwitchFunctionFactory)22 SysdateFunctionFactory (io.questdb.griffin.engine.functions.date.SysdateFunctionFactory)22 ToStrDateFunctionFactory (io.questdb.griffin.engine.functions.date.ToStrDateFunctionFactory)22 ToStrTimestampFunctionFactory (io.questdb.griffin.engine.functions.date.ToStrTimestampFunctionFactory)22 EqDoubleFunctionFactory (io.questdb.griffin.engine.functions.eq.EqDoubleFunctionFactory)22 EqIntFunctionFactory (io.questdb.griffin.engine.functions.eq.EqIntFunctionFactory)22 EqLongFunctionFactory (io.questdb.griffin.engine.functions.eq.EqLongFunctionFactory)22 LengthStrFunctionFactory (io.questdb.griffin.engine.functions.str.LengthStrFunctionFactory)22 LengthSymbolFunctionFactory (io.questdb.griffin.engine.functions.str.LengthSymbolFunctionFactory)22 ToCharBinFunctionFactory (io.questdb.griffin.engine.functions.str.ToCharBinFunctionFactory)22 Record (io.questdb.cairo.sql.Record)15 FunctionFactory (io.questdb.griffin.FunctionFactory)11