use of com.questdb.std.str.Path in project questdb by bluestreak01.
the class CairoTestUtils method create.
public static void create(TableModel model) {
final Path path = model.getPath();
final FilesFacade ff = model.getCairoCfg().getFilesFacade();
path.of(model.getCairoCfg().getRoot()).concat(model.getName());
final int rootLen = path.length();
if (ff.mkdirs(path.put(Files.SEPARATOR).$(), model.getCairoCfg().getMkDirMode()) == -1) {
throw CairoException.instance(ff.errno()).put("Cannot create dir: ").put(path);
}
try (AppendMemory mem = model.getMem()) {
mem.of(ff, path.trimTo(rootLen).concat(META_FILE_NAME).$(), ff.getPageSize());
int count = model.getColumnCount();
mem.putInt(count);
mem.putInt(model.getPartitionBy());
mem.putInt(model.getTimestampIndex());
mem.jumpTo(TableUtils.META_OFFSET_COLUMN_TYPES);
for (int i = 0; i < count; i++) {
mem.putByte((byte) model.getColumnType(i));
mem.putBool(model.getIndexedFlag(i));
mem.putInt(model.getIndexBlockCapacity(i));
// reserved
mem.skip(10);
}
for (int i = 0; i < count; i++) {
mem.putStr(model.getColumnName(i));
}
// create symbol maps
int symbolMapCount = 0;
for (int i = 0; i < count; i++) {
if (model.getColumnType(i) == ColumnType.SYMBOL) {
SymbolMapWriter.createSymbolMapFiles(ff, mem, path.trimTo(rootLen), model.getColumnName(i), model.getSymbolCapacity(i), model.getSymbolCacheFlag(i));
symbolMapCount++;
}
}
mem.of(ff, path.trimTo(rootLen).concat(TXN_FILE_NAME).$(), ff.getPageSize());
TableUtils.resetTxn(mem, symbolMapCount);
}
}
use of com.questdb.std.str.Path in project questdb by bluestreak01.
the class TableReader method createBitmapIndexReaderAt.
@NotNull
private BitmapIndexReader createBitmapIndexReaderAt(int columnBase, int columnIndex) {
BitmapIndexReader reader;
RecordColumnMetadata meta = metadata.getColumnQuick(columnIndex);
if (!meta.isIndexed()) {
throw CairoException.instance(0).put("Not indexed: ").put(meta.getName());
}
ReadOnlyColumn col = columns.getQuick(getPrimaryColumnIndex(columnBase, columnIndex));
if (col instanceof NullColumn) {
reader = new BitmapIndexNullReader();
} else {
Path path = partitionPathGenerator.generate(this, getPartitionIndex(columnBase));
try {
reader = new BitmapIndexBackwardReader(configuration, path.chopZ(), meta.getName(), getColumnTop(columnBase, columnIndex));
} finally {
path.trimTo(rootLen);
}
}
bitmapIndexes.setQuick(columnBase / 2 + columnIndex, reader);
return reader;
}
use of com.questdb.std.str.Path in project questdb by bluestreak01.
the class TableReader method reloadPartitioned.
private boolean reloadPartitioned() {
assert timestampFloorMethod != null;
long currentPartitionTimestamp = floorToPartitionTimestamp(maxTimestamp);
boolean b = readTxn();
if (b) {
reloadStruct();
assert intervalLengthMethod != null;
// calculate timestamp delta between before and after reload.
int delta = getPartitionCountBetweenTimestamps(currentPartitionTimestamp, floorToPartitionTimestamp(maxTimestamp));
int partitionIndex = partitionCount - 1;
// do we have something to reload?
if (getPartitionRowCount(partitionIndex) > -1) {
if (delta > 0) {
incrementPartitionCountBy(delta);
Path path = partitionPathGenerator.generate(this, partitionIndex);
try {
reloadPartition(partitionIndex, readPartitionSize(ff, path.chopZ(), tempMem8b));
} finally {
path.trimTo(rootLen);
}
} else {
reloadPartition(partitionIndex, transientRowCount);
}
} else if (delta > 0) {
// although we have nothing to reload we still have to bump partition count
incrementPartitionCountBy(delta);
}
return true;
}
return false;
}
use of com.questdb.std.str.Path in project questdb by bluestreak01.
the class TableReader method createNewColumnList.
private void createNewColumnList(int columnCount, long pTransitionIndex, int columnBits) {
int capacity = partitionCount << columnBits;
final ObjList<ReadOnlyColumn> columns = new ObjList<>(capacity);
final LongList columnTops = new LongList(capacity / 2);
final ObjList<BitmapIndexReader> indexReaders = new ObjList<>(capacity / 2);
columns.setPos(capacity);
columnTops.setPos(capacity / 2);
indexReaders.setPos(capacity / 2);
final long pIndexBase = pTransitionIndex + 8;
for (int partitionIndex = 0; partitionIndex < partitionCount; partitionIndex++) {
final int base = partitionIndex << columnBits;
final int oldBase = partitionIndex << columnCountBits;
try {
Path path = partitionPathGenerator.generate(this, partitionIndex);
final long partitionRowCount = partitionRowCounts.getQuick(partitionIndex);
for (int i = 0; i < columnCount; i++) {
final int copyFrom = Unsafe.getUnsafe().getInt(pIndexBase + i * 8) - 1;
if (copyFrom > -1) {
fetchColumnsFrom(this.columns, this.columnTops, this.bitmapIndexes, oldBase, copyFrom);
copyColumnsTo(columns, columnTops, indexReaders, base, i, partitionRowCount);
} else {
// new instance
reloadColumnAt(path, columns, columnTops, indexReaders, base, i, partitionRowCount);
}
}
// free remaining columns
for (int i = 0; i < this.columnCount; i++) {
Misc.free(this.columns.getQuick(getPrimaryColumnIndex(oldBase, i)));
Misc.free(this.columns.getQuick(getSecondaryColumnIndex(oldBase, i)));
}
} finally {
path.trimTo(rootLen);
}
}
this.columns = columns;
this.columnTops = columnTops;
this.columnCountBits = columnBits;
this.bitmapIndexes = indexReaders;
}
Aggregations