Search in sources :

Example 1 with ObjList

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

the class SymbolMapTest method testLookupPerformance.

@Test
public void testLookupPerformance() throws Exception {
    TestUtils.assertMemoryLeak(() -> {
        int N = 10000000;
        int symbolCount = 1024;
        ObjList<String> symbols = new ObjList<>();
        try (Path path = new Path().of(configuration.getRoot())) {
            create(path, "x", symbolCount, true);
            try (SymbolMapWriter writer = new SymbolMapWriter(configuration, path, "x", 0, -1, NOOP_COLLECTOR)) {
                Rnd rnd = new Rnd();
                long prev = -1L;
                for (int i = 0; i < symbolCount; i++) {
                    CharSequence cs = rnd.nextChars(10);
                    long key = writer.put(cs);
                    symbols.add(cs.toString());
                    Assert.assertEquals(prev + 1, key);
                    prev = key;
                }
                long t = System.nanoTime();
                for (int i = 0; i < N; i++) {
                    int key = rnd.nextPositiveInt() % symbolCount;
                    Assert.assertEquals(key, writer.put(symbols.getQuick(key)));
                }
                System.out.println("SymbolMapWriter lookup performance [10M <500ms]: " + (System.nanoTime() - t) / 1000000);
            }
        }
    });
}
Also used : Path(io.questdb.std.str.Path) ObjList(io.questdb.std.ObjList) Rnd(io.questdb.std.Rnd) Test(org.junit.Test)

Example 2 with ObjList

use of io.questdb.std.ObjList 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 3 with ObjList

use of io.questdb.std.ObjList 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 4 with ObjList

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

the class NullRecordFactory method getInstance.

public static Record getInstance(ColumnTypes types) {
    final ObjList<Function> functions = new ObjList<>(types.getColumnCount());
    for (int i = 0, n = types.getColumnCount(); i < n; i++) {
        Function function = Constants.getNullConstant(types.getColumnType(i));
        assert function != null;
        functions.add(function);
    }
    return new VirtualRecord(functions);
}
Also used : Function(io.questdb.cairo.sql.Function) ObjList(io.questdb.std.ObjList) VirtualRecord(io.questdb.cairo.sql.VirtualRecord)

Example 5 with ObjList

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

the class EqTimestampStrFunctionFactoryTest method testFalseWhenVariableStringIsNotValidTimestamp.

@Test
public void testFalseWhenVariableStringIsNotValidTimestamp() throws SqlException, NumericException {
    long timestamp = parseUTCTimestamp("2020-12-31T23:59:59.000000Z");
    CharSequence invalidTimestamp = "abc";
    FunctionFactory factory = getFunctionFactory();
    ObjList<Function> args = new ObjList<>();
    args.add(TimestampColumn.newInstance(0));
    args.add(StrColumn.newInstance(5));
    IntList argPositions = new IntList();
    argPositions.add(0);
    argPositions.add(1);
    Function function = factory.newInstance(3, args, argPositions, configuration, sqlExecutionContext);
    Assert.assertFalse(function.getBool(new Record() {

        @Override
        public CharSequence getStr(int col) {
            return invalidTimestamp;
        }

        @Override
        public long getTimestamp(int col) {
            return timestamp;
        }
    }));
}
Also used : Function(io.questdb.cairo.sql.Function) ObjList(io.questdb.std.ObjList) Record(io.questdb.cairo.sql.Record) InTimestampStrFunctionFactory(io.questdb.griffin.engine.functions.bool.InTimestampStrFunctionFactory) FunctionFactory(io.questdb.griffin.FunctionFactory) IntList(io.questdb.std.IntList) Test(org.junit.Test) AbstractFunctionFactoryTest(io.questdb.griffin.engine.AbstractFunctionFactoryTest)

Aggregations

ObjList (io.questdb.std.ObjList)16 Test (org.junit.Test)14 Function (io.questdb.cairo.sql.Function)12 FunctionFactory (io.questdb.griffin.FunctionFactory)11 IntList (io.questdb.std.IntList)11 AbstractFunctionFactoryTest (io.questdb.griffin.engine.AbstractFunctionFactoryTest)10 DoubleConstant (io.questdb.griffin.engine.functions.constants.DoubleConstant)7 SqlException (io.questdb.griffin.SqlException)3 DateConstant (io.questdb.griffin.engine.functions.constants.DateConstant)3 FloatConstant (io.questdb.griffin.engine.functions.constants.FloatConstant)3 TimestampConstant (io.questdb.griffin.engine.functions.constants.TimestampConstant)3 AbstractGriffinTest (io.questdb.griffin.AbstractGriffinTest)2 ExpressionNode (io.questdb.griffin.model.ExpressionNode)2 QueryColumn (io.questdb.griffin.model.QueryColumn)2 Rnd (io.questdb.std.Rnd)2 CairoConfiguration (io.questdb.cairo.CairoConfiguration)1 ColumnType (io.questdb.cairo.ColumnType)1 Record (io.questdb.cairo.sql.Record)1 VirtualRecord (io.questdb.cairo.sql.VirtualRecord)1 SqlExecutionContext (io.questdb.griffin.SqlExecutionContext)1