use of com.questdb.store.factory.configuration.ColumnMetadata in project questdb by bluestreak01.
the class TestUtils method assertOrderDesc.
public static <T> void assertOrderDesc(JournalIterator<T> rs) {
ColumnMetadata meta = rs.getJournal().getMetadata().getTimestampMetadata();
long max = Long.MAX_VALUE;
for (T obj : rs) {
long timestamp = Unsafe.getUnsafe().getLong(obj, meta.offset);
if (timestamp > max) {
throw new AssertionError("Timestamp out of order. [ " + Dates.toString(timestamp) + " > " + Dates.toString(max) + "]");
}
max = timestamp;
}
}
use of com.questdb.store.factory.configuration.ColumnMetadata in project questdb by bluestreak01.
the class Journal method configureColumns.
private void configureColumns() throws JournalException {
int columnCount = getMetadata().getColumnCount();
try {
for (int i = 0; i < columnCount; i++) {
ColumnMetadata meta = metadata.getColumnQuick(i);
if (meta.type == ColumnType.SYMBOL && meta.sameAs == null) {
int tabIndex = symbolTables.size();
int tabSize = tx.symbolTableSizes.length > tabIndex ? tx.symbolTableSizes[tabIndex] : 0;
long indexTxAddress = tx.symbolTableIndexPointers.length > tabIndex ? tx.symbolTableIndexPointers[tabIndex] : 0;
MMappedSymbolTable tab = new MMappedSymbolTable(meta.distinctCountHint, meta.avgSize, getMetadata().getTxCountHint(), location, meta.name, getMode(), tabSize, indexTxAddress, meta.noCache, sequentialAccess);
symbolTables.add(tab);
symbolTableMap.put(meta.name, tab);
meta.symbolTable = tab;
}
}
} catch (JournalException e) {
closeSymbolTables();
throw e;
}
}
use of com.questdb.store.factory.configuration.ColumnMetadata in project questdb by bluestreak01.
the class Journal method configureSymbolTableSynonyms.
private void configureSymbolTableSynonyms() {
for (int i = 0, n = metadata.getColumnCount(); i < n; i++) {
ColumnMetadata meta = metadata.getColumnQuick(i);
if (meta.type == ColumnType.SYMBOL && meta.sameAs != null) {
MMappedSymbolTable tab = getSymbolTable(meta.sameAs);
symbolTableMap.put(meta.name, tab);
meta.symbolTable = tab;
}
}
}
use of com.questdb.store.factory.configuration.ColumnMetadata in project questdb by bluestreak01.
the class Partition method append.
void append(T obj) throws JournalException {
try {
for (int i = 0; i < columnCount; i++) {
ColumnMetadata m = Unsafe.arrayGet(columnMetadata, i);
switch(m.type) {
case ColumnType.LONG:
long l = Unsafe.getUnsafe().getLong(obj, m.offset);
if (m.indexed) {
sparseIndexProxies[i].getIndex().add((int) (l & m.distinctCountHint), ((FixedColumn) Unsafe.arrayGet(columns, i)).putLong(l));
} else {
((FixedColumn) Unsafe.arrayGet(columns, i)).putLong(l);
}
break;
case ColumnType.INT:
int v = Unsafe.getUnsafe().getInt(obj, m.offset);
if (m.indexed) {
sparseIndexProxies[i].getIndex().add(v & m.distinctCountHint, ((FixedColumn) Unsafe.arrayGet(columns, i)).putInt(v));
} else {
((FixedColumn) Unsafe.arrayGet(columns, i)).putInt(v);
}
break;
case ColumnType.STRING:
String s = (String) Unsafe.getUnsafe().getObject(obj, m.offset);
long offset = ((VariableColumn) Unsafe.arrayGet(columns, i)).putStr(s);
if (m.indexed) {
sparseIndexProxies[i].getIndex().add(s == null ? SymbolTable.VALUE_IS_NULL : Hash.boundedHash(s, m.distinctCountHint), offset);
}
break;
case ColumnType.SYMBOL:
int key;
String sym = (String) Unsafe.getUnsafe().getObject(obj, m.offset);
if (sym == null) {
key = SymbolTable.VALUE_IS_NULL;
} else {
key = m.symbolTable.put(sym);
}
if (m.indexed) {
sparseIndexProxies[i].getIndex().add(key, ((FixedColumn) Unsafe.arrayGet(columns, i)).putInt(key));
} else {
((FixedColumn) Unsafe.arrayGet(columns, i)).putInt(key);
}
break;
case ColumnType.BINARY:
appendBin(obj, i, m);
break;
default:
((FixedColumn) Unsafe.arrayGet(columns, i)).copy(obj, m.offset);
break;
}
Unsafe.arrayGet(columns, i).commit();
}
applyTx(Journal.TX_LIMIT_EVAL, null);
} catch (Throwable e) {
((JournalWriter) this.journal).rollback();
throw e;
}
}
use of com.questdb.store.factory.configuration.ColumnMetadata in project questdb by bluestreak01.
the class AvgAggregator method prepare.
@Override
public void prepare(ObjList<RecordColumnMetadata> columns, int offset) {
columns.add(INTERNAL_COL_TOTAL);
columns.add(INTERNAL_COL_LOCAL_TOTAL);
columns.add(INTERNAL_COL_SUM);
columns.add(INTERNAL_COL_LIST_HEAD);
columns.add(INTERNAL_COL_LIST_TAIL);
columns.add(new ColumnMetadata().setName(getName()).setType(ColumnType.DOUBLE));
oTotal = offset;
oLocalTotal = offset + 1;
oSum = offset + 2;
oListHead = offset + 3;
oListTail = offset + 4;
oAvg = offset + 5;
}
Aggregations