use of com.questdb.std.LongList in project questdb by bluestreak01.
the class IntervalCompilerTest method assertShortInterval.
private static void assertShortInterval(String expected, String interval) throws ParserException {
LongList out = new LongList();
IntervalCompiler.parseIntervalEx(interval, 0, interval.length(), 0, out);
TestUtils.assertEquals(expected, intervalToString(out));
}
use of com.questdb.std.LongList in project questdb by bluestreak01.
the class KvIndexTest method assertValues.
private void assertValues(long[][] values, KVIndex index) {
for (int i = 0; i < values.length; i++) {
LongList array = index.getValues(i);
Assert.assertEquals(values[i].length, array.size());
for (int k = 0; k < values[i].length; k++) {
Assert.assertEquals(values[i][k], array.get(k));
}
IndexCursor cursor = index.cursor(i);
int k = (int) cursor.size();
while (cursor.hasNext()) {
Assert.assertEquals(values[i][--k], cursor.next());
}
IndexCursor c = index.fwdCursor(i);
int n = 0;
while (c.hasNext()) {
long l = c.next();
Assert.assertEquals(values[i][n++], l);
}
}
}
use of com.questdb.std.LongList in project questdb by bluestreak01.
the class RecordChainTest method testPseudoRandomAccess.
@Test
public void testPseudoRandomAccess() throws Exception {
TestUtils.assertMemoryLeak(() -> {
int N = 10000;
try (RecordChain chain = new RecordChain(metadata, SIZE_4M)) {
Record record = new TestRecord();
LongList rows = new LongList();
long o = -1L;
for (int i = 0; i < N; i++) {
o = chain.putRecord(record, o);
rows.add(o);
}
Assert.assertEquals(N, rows.size());
Record expected = new TestRecord();
for (int i = 0, n = rows.size(); i < n; i++) {
long row = rows.getQuick(i);
Record actual = chain.recordAt(row);
Assert.assertEquals(row, actual.getRowId());
assertSame(expected, actual);
}
Record expected2 = new TestRecord();
Record rec2 = chain.newRecord();
for (int i = 0, n = rows.size(); i < n; i++) {
long row = rows.getQuick(i);
chain.recordAt(rec2, row);
Assert.assertEquals(row, rec2.getRowId());
assertSame(expected2, rec2);
}
Record expected3 = new TestRecord();
Record rec3 = chain.getRecord();
for (int i = 0, n = rows.size(); i < n; i++) {
long row = rows.getQuick(i);
chain.recordAt(rec3, row);
Assert.assertEquals(row, rec3.getRowId());
assertSame(expected3, rec3);
}
}
});
}
use of com.questdb.std.LongList in project questdb by bluestreak01.
the class IntervalCompilerTest method testInvert.
@Test
public void testInvert() throws ParserException {
final String intervalStr = "2018-01-10T10:30:00.000Z;30m;2d;2";
LongList out = new LongList();
IntervalCompiler.parseIntervalEx(intervalStr, 0, intervalStr.length(), 0, out);
IntervalCompiler.invert(out);
TestUtils.assertEquals("[{lo=, hi=2018-01-10T10:29:59.999999Z},{lo=2018-01-10T11:00:00.000001Z, hi=2018-01-12T10:29:59.999999Z},{lo=2018-01-12T11:00:00.000001Z, hi=294247-01-10T04:00:54.775807Z}]", intervalToString(out));
}
use of com.questdb.std.LongList in project questdb by bluestreak01.
the class IntervalCompilerTest method assertShortInterval.
private static void assertShortInterval(String expected, String interval) throws ParserException {
LongList out = new LongList();
IntervalCompiler.parseIntervalEx(interval, 0, interval.length(), 0, out);
Assert.assertEquals(expected, IntervalCompiler.asIntervalStr(out));
}
Aggregations