use of io.questdb.std.ObjList in project questdb by bluestreak01.
the class EqDoubleFunctionFactoryTest method testLeftNaNDate.
@Test
public void testLeftNaNDate() throws SqlException {
FunctionFactory factory = getFunctionFactory();
ObjList<Function> args = new ObjList<>();
args.add(new DoubleConstant(Double.NaN));
args.add(new DateConstant(10000L));
IntList argPositions = new IntList();
argPositions.add(2);
argPositions.add(1);
Function function = factory.newInstance(4, args, argPositions, configuration, sqlExecutionContext);
Assert.assertFalse(function.getBool(null));
}
use of io.questdb.std.ObjList in project questdb by bluestreak01.
the class EqDoubleFunctionFactoryTest method testRightNaNTimestampNaN.
@Test
public void testRightNaNTimestampNaN() throws SqlException {
FunctionFactory factory = getFunctionFactory();
ObjList<Function> args = new ObjList<>();
args.add(new TimestampConstant(Numbers.LONG_NaN) {
@Override
public boolean isConstant() {
return false;
}
});
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.assertFalse(function.isConstant());
}
use of io.questdb.std.ObjList in project questdb by bluestreak01.
the class SampleByTest method testSampleByFirstLastRecordCursorFactoryInvalidNotFirstLast.
@Test
public void testSampleByFirstLastRecordCursorFactoryInvalidNotFirstLast() {
try {
GenericRecordMetadata groupByMeta = new GenericRecordMetadata();
TableColumnMetadata column = new TableColumnMetadata("col1", 1, ColumnType.LONG, false, 0, false, null);
groupByMeta.add(column);
GenericRecordMetadata meta = new GenericRecordMetadata();
meta.add(column);
ObjList<QueryColumn> columns = new ObjList<>();
ExpressionNode first = ExpressionNode.FACTORY.newInstance().of(ColumnType.LONG, "min", 0, 0);
first.rhs = ExpressionNode.FACTORY.newInstance().of(ColumnType.LONG, "col1", 0, 0);
QueryColumn col = QueryColumn.FACTORY.newInstance().of("col1", first);
columns.add(col);
new SampleByFirstLastRecordCursorFactory(null, new MicroTimestampSampler(100L), groupByMeta, columns, meta, null, 0, null, 0, 0, getSymbolFilter(), -1);
Assert.fail();
} catch (SqlException e) {
TestUtils.assertContains(e.getFlyweightMessage(), "expected first() or last() functions but got min");
}
}
use of io.questdb.std.ObjList in project questdb by bluestreak01.
the class SampleByTest method testSampleByFirstLastRecordCursorFactoryInvalidColumns.
@Test
public void testSampleByFirstLastRecordCursorFactoryInvalidColumns() {
try {
GenericRecordMetadata groupByMeta = new GenericRecordMetadata();
groupByMeta.add(new TableColumnMetadata("col1", 1, ColumnType.STRING, false, 0, false, null));
GenericRecordMetadata meta = new GenericRecordMetadata();
meta.add(new TableColumnMetadata("col1", 2, ColumnType.LONG, false, 0, false, null));
ObjList<QueryColumn> columns = new ObjList<>();
ExpressionNode first = ExpressionNode.FACTORY.newInstance().of(ColumnType.LONG, "first", 0, 0);
first.rhs = ExpressionNode.FACTORY.newInstance().of(ColumnType.LONG, "col1", 0, 0);
QueryColumn col = QueryColumn.FACTORY.newInstance().of("col1", first);
columns.add(col);
new SampleByFirstLastRecordCursorFactory(null, new MicroTimestampSampler(100L), groupByMeta, columns, meta, null, 0, null, 0, 0, getSymbolFilter(), -1);
Assert.fail();
} catch (SqlException e) {
TestUtils.assertContains(e.getFlyweightMessage(), "first(), last() is not supported on data type");
}
}
use of io.questdb.std.ObjList in project questdb by bluestreak01.
the class LongChainTest method testAll.
@Test
public void testAll() throws Exception {
TestUtils.assertMemoryLeak(() -> {
try (LongChain chain = new LongChain(1024 * 1024, Integer.MAX_VALUE)) {
final int N = 1000;
final int nChains = 10;
final Rnd rnd = new Rnd();
final LongList heads = new LongList(nChains);
final ObjList<LongList> expectedValues = new ObjList<>();
for (int i = 0; i < nChains; i++) {
LongList expected = new LongList(N);
heads.add(populateChain(chain, rnd, expected));
expectedValues.add(expected);
Assert.assertEquals(N, expected.size());
}
Assert.assertEquals(nChains, expectedValues.size());
// values are be in reverse order
for (int i = 0; i < nChains; i++) {
LongChain.TreeCursor cursor = chain.getCursor(heads.getQuick(i));
LongList expected = expectedValues.get(i);
int count = 0;
while (cursor.hasNext()) {
Assert.assertEquals(expected.getQuick(count), cursor.next());
count++;
}
Assert.assertEquals(N, count);
}
}
});
}
Aggregations