use of io.questdb.cairo.sql.Record in project questdb by bluestreak01.
the class TableReaderTest method testTableCursor.
private void testTableCursor(long inc) throws NumericException {
Rnd rnd = new Rnd();
int N = 100;
long ts = TimestampFormatUtils.parseTimestamp("2013-03-04T00:00:00.000Z") / 1000;
long blob = allocBlob();
try {
testAppend(rnd, configuration, ts, N, inc, blob, 0);
final LongList rows = new LongList();
try (TableReader reader = new TableReader(configuration, "all")) {
Assert.assertEquals(N, reader.size());
RecordCursor cursor = reader.getCursor();
final Record record = cursor.getRecord();
assertCursor(cursor, ts, inc, blob, N, BATCH1_ASSERTER);
cursor.toTop();
while (cursor.hasNext()) {
rows.add(record.getRowId());
}
Rnd exp = new Rnd();
final Record rec = cursor.getRecordB();
for (int i = 0, n = rows.size(); i < n; i++) {
cursor.recordAt(rec, rows.getQuick(i));
BATCH1_ASSERTER.assertRecord(rec, exp, ts += inc, blob);
}
}
} finally {
freeBlob(blob);
}
}
use of io.questdb.cairo.sql.Record in project questdb by bluestreak01.
the class RecordCursorPrinter method print.
public void print(RecordCursor cursor, RecordMetadata metadata, boolean header, Log sink) {
LogRecordSinkAdapter logRecSink = new LogRecordSinkAdapter();
if (header) {
LogRecord line = sink.xDebugW();
printHeaderNoNl(metadata, logRecSink.of(line));
line.$();
}
final Record record = cursor.getRecord();
while (cursor.hasNext()) {
LogRecord line = sink.xDebugW();
printRecordNoNl(record, metadata, logRecSink.of(line));
line.$();
}
}
use of io.questdb.cairo.sql.Record in project questdb by bluestreak01.
the class RecordCursorPrinter method printFullColumn.
public void printFullColumn(RecordCursor cursor, RecordMetadata metadata, int i, boolean header, CharSink sink) {
if (header) {
printHeader(metadata, sink);
}
final Record record = cursor.getRecord();
while (cursor.hasNext()) {
printColumn(record, metadata, i, sink);
sink.put('\n');
}
}
use of io.questdb.cairo.sql.Record in project questdb by bluestreak01.
the class TruncateTest method testTruncateOpenReader.
@Test
public void testTruncateOpenReader() throws Exception {
assertMemoryLeak(() -> {
createX(1_000_000);
assertQuery("count\n" + "1000000\n", "select count() from x", null, false, true);
try (RecordCursorFactory factory = compiler.compile("select * from x", sqlExecutionContext).getRecordCursorFactory()) {
try (RecordCursor cursor = factory.getCursor(sqlExecutionContext)) {
final Record record = cursor.getRecord();
while (cursor.hasNext()) {
record.getInt(0);
record.getSym(1);
record.getDouble(2);
}
}
}
compiler.compile("truncate table 'x'", sqlExecutionContext);
});
}
use of io.questdb.cairo.sql.Record in project questdb by bluestreak01.
the class TableReaderReloadBenchmark method setup.
@Setup(Level.Iteration)
public void setup() throws NumericException {
writer = new TableWriter(configuration, "test");
writer.truncate();
// create 10 partitions
appendRow(TimestampFormatUtils.parseTimestamp("2012-03-01T00:00:00.000000Z"));
appendRow(TimestampFormatUtils.parseTimestamp("2012-03-02T00:00:00.000000Z"));
appendRow(TimestampFormatUtils.parseTimestamp("2012-03-03T00:00:00.000000Z"));
appendRow(TimestampFormatUtils.parseTimestamp("2012-03-04T00:00:00.000000Z"));
appendRow(TimestampFormatUtils.parseTimestamp("2012-03-05T00:00:00.000000Z"));
appendRow(TimestampFormatUtils.parseTimestamp("2012-03-06T00:00:00.000000Z"));
appendRow(TimestampFormatUtils.parseTimestamp("2012-03-07T00:00:00.000000Z"));
appendRow(TimestampFormatUtils.parseTimestamp("2012-03-08T00:00:00.000000Z"));
appendRow(TimestampFormatUtils.parseTimestamp("2012-03-09T00:00:00.000000Z"));
appendRow(TimestampFormatUtils.parseTimestamp("2012-03-10T00:00:00.000000Z"));
writer.commit();
reader = new TableReader(configuration, "test");
// ensure reader opens all partitions and maps all data
RecordCursor cursor = reader.getCursor();
Record record = cursor.getRecord();
while (cursor.hasNext()) {
sum += record.getTimestamp(0);
}
}
Aggregations