use of io.questdb.cairo.TableWriter in project questdb by bluestreak01.
the class O3PartitionJob method processPartition.
public static void processPartition(long tmpBuf, O3PartitionTask task, long cursor, Sequence subSeq) {
// find "current" partition boundary in the out of order data
// once we know the boundary we can move on to calculating another one
// srcOooHi is index inclusive of value
final CharSequence pathToTable = task.getPathToTable();
final int partitionBy = task.getPartitionBy();
final ObjList<MemoryMAR> columns = task.getColumns();
final ObjList<MemoryCARW> oooColumns = task.getO3Columns();
final long srcOooLo = task.getSrcOooLo();
final long srcOooHi = task.getSrcOooHi();
final long srcOooMax = task.getSrcOooMax();
final long oooTimestampMin = task.getOooTimestampMin();
final long oooTimestampMax = task.getOooTimestampMax();
final long partitionTimestamp = task.getPartitionTimestamp();
final long maxTimestamp = task.getMaxTimestamp();
final long srcDataMax = task.getSrcDataMax();
final long srcDataTxn = task.getSrcNameTxn();
final boolean last = task.isLast();
final long txn = task.getTxn();
final long sortedTimestampsAddr = task.getSortedTimestampsAddr();
final TableWriter tableWriter = task.getTableWriter();
final AtomicInteger columnCounter = task.getColumnCounter();
final O3Basket o3Basket = task.getO3Basket();
subSeq.done(cursor);
processPartition(pathToTable, partitionBy, columns, oooColumns, srcOooLo, srcOooHi, srcOooMax, oooTimestampMin, oooTimestampMax, partitionTimestamp, maxTimestamp, srcDataMax, srcDataTxn, last, txn, sortedTimestampsAddr, tableWriter, columnCounter, o3Basket, tmpBuf);
}
use of io.questdb.cairo.TableWriter in project questdb by bluestreak01.
the class O3CopyJob method copy.
public static void copy(O3CopyTask task, long cursor, Sequence subSeq) {
final AtomicInteger columnCounter = task.getColumnCounter();
final AtomicInteger partCounter = task.getPartCounter();
final int columnType = task.getColumnType();
final int blockType = task.getBlockType();
final long timestampMergeIndexAddr = task.getTimestampMergeIndexAddr();
final long srcDataFixFd = task.getSrcDataFixFd();
final long srcDataFixAddr = task.getSrcDataFixAddr();
final long srcDataFixOffset = task.getSrcDataFixOffset();
final long srcDataFixSize = task.getSrcDataFixSize();
final long srcDataVarFd = task.getSrcDataVarFd();
final long srcDataVarAddr = task.getSrcDataVarAddr();
final long srcDataVarOffset = task.getSrcDataVarOffset();
final long srcDataVarSize = task.getSrcDataVarSize();
final long srcDataTop = task.getSrcDataTop();
final long srcDataLo = task.getSrcDataLo();
final long srcDataMax = task.getSrcDataMax();
final long srcDataHi = task.getSrcDataHi();
final long srcOooFixAddr = task.getSrcOooFixAddr();
final long srcOooVarAddr = task.getSrcOooVarAddr();
final long srcOooLo = task.getSrcOooLo();
final long srcOooHi = task.getSrcOooHi();
final long srcOooMax = task.getSrcOooMax();
final long srcOooPartitionLo = task.getSrcOooPartitionLo();
final long srcOooPartitionHi = task.getSrcOooPartitionHi();
final long timestampMin = task.getTimestampMin();
final long timestampMax = task.getTimestampMax();
final long partitionTimestamp = task.getPartitionTimestamp();
final long dstFixFd = task.getDstFixFd();
final long dstFixAddr = task.getDstFixAddr();
final long dstFixOffset = task.getDstFixOffset();
final long dstFixSize = task.getDstFixSize();
final long dstVarFd = task.getDstVarFd();
final long dstVarAddr = task.getDstVarAddr();
final long dstVarOffset = task.getDstVarOffset();
final long dstVarOffsetEnd = task.getDstVarOffsetEnd();
final long dstVarAdjust = task.getDstVarAdjust();
final long dstVarSize = task.getDstVarSize();
final long dstKFd = task.getDstKFd();
final long dskVFd = task.getDstVFd();
final long dstIndexOffset = task.getDstIndexOffset();
final long dstIndexAdjust = task.getDstIndexAdjust();
final boolean isIndexed = task.isIndexed();
final long srcTimestampFd = task.getSrcTimestampFd();
final long srcTimestampAddr = task.getSrcTimestampAddr();
final long srcTimestampSize = task.getSrcTimestampSize();
final boolean partitionMutates = task.isPartitionMutates();
final TableWriter tableWriter = task.getTableWriter();
final BitmapIndexWriter indexWriter = task.getIndexWriter();
subSeq.done(cursor);
copy(columnCounter, partCounter, columnType, blockType, timestampMergeIndexAddr, srcDataFixFd, srcDataFixAddr, srcDataFixOffset, srcDataFixSize, srcDataVarFd, srcDataVarAddr, srcDataVarOffset, srcDataVarSize, srcDataLo, srcDataHi, srcDataTop, srcDataMax, srcOooFixAddr, srcOooVarAddr, srcOooLo, srcOooHi, srcOooMax, srcOooPartitionLo, srcOooPartitionHi, timestampMin, timestampMax, partitionTimestamp, dstFixFd, dstFixAddr, dstFixOffset, dstFixSize, dstVarFd, dstVarAddr, dstVarOffset, dstVarOffsetEnd, dstVarAdjust, dstVarSize, dstKFd, dskVFd, dstIndexOffset, dstIndexAdjust, isIndexed, srcTimestampFd, srcTimestampAddr, srcTimestampSize, partitionMutates, tableWriter, indexWriter);
}
use of io.questdb.cairo.TableWriter in project questdb by bluestreak01.
the class O3OpenColumnJob method openColumn.
public static void openColumn(O3OpenColumnTask task, long cursor, Sequence subSeq, long tmpBuf) {
final int openColumnMode = task.getOpenColumnMode();
final CharSequence pathToTable = task.getPathToTable();
final int columnType = task.getColumnType();
final CharSequence columnName = task.getColumnName();
final long srcOooLo = task.getSrcOooLo();
final long srcOooHi = task.getSrcOooHi();
final long srcOooMax = task.getSrcOooMax();
final long timestampMin = task.getTimestampMin();
final long timestampMax = task.getTimestampMax();
final long oooTimestampLo = task.getOooTimestampLo();
final long partitionTimestamp = task.getPartitionTimestamp();
final long srcDataMax = task.getSrcDataMax();
final long srcDataTxn = task.getSrcDataTxn();
final long srcTimestampFd = task.getSrcTimestampFd();
final long srcTimestampAddr = task.getSrcTimestampAddr();
final long srcTimestampSize = task.getSrcTimestampSize();
final AtomicInteger columnCounter = task.getColumnCounter();
final AtomicInteger partCounter = task.getPartCounter();
final boolean isIndexed = task.isIndexed();
final long srcOooFixAddr = task.getSrcOooFixAddr();
final long srcOooVarAddr = task.getSrcOooVarAddr();
final long mergeOOOLo = task.getMergeOOOLo();
final long mergeOOOHi = task.getMergeOOOHi();
final long mergeDataLo = task.getMergeDataLo();
final long mergeDataHi = task.getMergeDataHi();
final long txn = task.getTxn();
final int prefixType = task.getPrefixType();
final long prefixLo = task.getPrefixLo();
final long prefixHi = task.getPrefixHi();
final int suffixType = task.getSuffixType();
final long suffixLo = task.getSuffixLo();
final long suffixHi = task.getSuffixHi();
final int mergeType = task.getMergeType();
final long timestampMergeIndexAddr = task.getTimestampMergeIndexAddr();
final long activeFixFd = task.getActiveFixFd();
final long activeVarFd = task.getActiveVarFd();
final long srcDataTop = task.getSrcDataTop();
final TableWriter tableWriter = task.getTableWriter();
final BitmapIndexWriter indexWriter = task.getIndexWriter();
subSeq.done(cursor);
openColumn(openColumnMode, pathToTable, columnName, columnCounter, partCounter, columnType, timestampMergeIndexAddr, srcOooFixAddr, srcOooVarAddr, srcOooLo, srcOooHi, srcOooMax, timestampMin, timestampMax, oooTimestampLo, partitionTimestamp, srcDataTop, srcDataMax, srcDataTxn, txn, prefixType, prefixLo, prefixHi, mergeType, mergeOOOLo, mergeOOOHi, mergeDataLo, mergeDataHi, suffixType, suffixLo, suffixHi, srcTimestampFd, srcTimestampAddr, srcTimestampSize, isIndexed, activeFixFd, activeVarFd, tableWriter, indexWriter, tmpBuf);
}
use of io.questdb.cairo.TableWriter in project questdb by bluestreak01.
the class EmbeddedApiTest method testReadWrite.
@Test
public void testReadWrite() throws Exception {
final CairoConfiguration configuration = new DefaultCairoConfiguration(temp.getRoot().getAbsolutePath());
TestUtils.assertMemoryLeak(() -> {
// write part
try (final CairoEngine engine = new CairoEngine(configuration);
final SqlExecutionContextImpl ctx = new SqlExecutionContextImpl(engine, 1);
final SqlCompiler compiler = new SqlCompiler(engine)) {
compiler.compile("create table abc (a int, b byte, c short, d long, e float, g double, h date, i symbol, j string, k boolean, ts timestamp) timestamp(ts)", ctx);
try (TableWriter writer = engine.getWriter(ctx.getCairoSecurityContext(), "abc", "testing")) {
for (int i = 0; i < 10; i++) {
TableWriter.Row row = writer.newRow(Os.currentTimeMicros());
row.putInt(0, 123);
row.putByte(1, (byte) 1111);
row.putShort(2, (short) 222);
row.putLong(3, 333);
row.putFloat(4, 4.44f);
row.putDouble(5, 5.55);
row.putDate(6, System.currentTimeMillis());
row.putSym(7, "xyz");
row.putStr(8, "abc");
row.putBool(9, true);
row.append();
}
writer.commit();
}
try (RecordCursorFactory factory = compiler.compile("abc", ctx).getRecordCursorFactory()) {
try (RecordCursor cursor = factory.getCursor(ctx)) {
final Record record = cursor.getRecord();
// noinspection StatementWithEmptyBody
while (cursor.hasNext()) {
// access 'record' instance for field values
}
}
}
}
});
}
use of io.questdb.cairo.TableWriter in project questdb by bluestreak01.
the class EmbeddedApiTest method testConcurrentSQLExec.
@Test
public void testConcurrentSQLExec() throws Exception {
final CairoConfiguration configuration = new DefaultCairoConfiguration(temp.getRoot().getAbsolutePath());
final Log log = LogFactory.getLog("testConcurrentSQLExec");
TestUtils.assertMemoryLeak(() -> {
WorkerPool workerPool = new WorkerPool(new WorkerPoolConfiguration() {
@Override
public int[] getWorkerAffinity() {
return new int[] { -1, -1 };
}
@Override
public int getWorkerCount() {
return 2;
}
@Override
public boolean haltOnError() {
return false;
}
});
Rnd rnd = new Rnd();
try (final CairoEngine engine = new CairoEngine(configuration)) {
workerPool.assign(new GroupByJob(engine.getMessageBus()));
workerPool.start(log);
try {
// number of cores is current thread + workers in the pool
final SqlExecutionContextImpl ctx = new SqlExecutionContextImpl(engine, 2);
try (SqlCompiler compiler = new SqlCompiler(engine)) {
compiler.compile("create table abc (g double, ts timestamp) timestamp(ts) partition by DAY", ctx);
long timestamp = 0;
try (TableWriter writer = engine.getWriter(ctx.getCairoSecurityContext(), "abc", "testing")) {
for (int i = 0; i < 10_000_000; i++) {
TableWriter.Row row = writer.newRow(timestamp);
row.putDouble(0, rnd.nextDouble());
row.append();
timestamp += 1_000_000;
}
writer.commit();
}
try (RecordCursorFactory factory = compiler.compile("select sum(g) from abc", ctx).getRecordCursorFactory()) {
try (RecordCursor cursor = factory.getCursor(ctx)) {
final Record ignored = cursor.getRecord();
// noinspection StatementWithEmptyBody
while (cursor.hasNext()) {
// access 'record' instance for field values
}
}
}
}
} finally {
workerPool.halt();
}
}
});
}
Aggregations