Search in sources :

Example 6 with ColumnMetadata

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;
    }
}
Also used : ColumnMetadata(com.questdb.store.factory.configuration.ColumnMetadata)

Example 7 with ColumnMetadata

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;
    }
}
Also used : ColumnMetadata(com.questdb.store.factory.configuration.ColumnMetadata) JournalException(com.questdb.std.ex.JournalException)

Example 8 with ColumnMetadata

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;
        }
    }
}
Also used : ColumnMetadata(com.questdb.store.factory.configuration.ColumnMetadata)

Example 9 with ColumnMetadata

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;
    }
}
Also used : ColumnMetadata(com.questdb.store.factory.configuration.ColumnMetadata)

Example 10 with ColumnMetadata

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;
}
Also used : RecordColumnMetadata(com.questdb.common.RecordColumnMetadata) ColumnMetadata(com.questdb.store.factory.configuration.ColumnMetadata)

Aggregations

ColumnMetadata (com.questdb.store.factory.configuration.ColumnMetadata)14 RecordColumnMetadata (com.questdb.common.RecordColumnMetadata)3 JournalException (com.questdb.std.ex.JournalException)3 JournalStructure (com.questdb.store.factory.configuration.JournalStructure)3 ImportedColumnMetadata (com.questdb.parser.ImportedColumnMetadata)2 IntervalRecordSource (com.questdb.ql.interval.IntervalRecordSource)1 AsOfJoinRecordSource (com.questdb.ql.join.AsOfJoinRecordSource)1 AsOfPartitionedJoinRecordSource (com.questdb.ql.join.AsOfPartitionedJoinRecordSource)1 CrossJoinRecordSource (com.questdb.ql.join.CrossJoinRecordSource)1 HashJoinRecordSource (com.questdb.ql.join.HashJoinRecordSource)1 SelectedColumnsRecordSource (com.questdb.ql.select.SelectedColumnsRecordSource)1 RBTreeSortedRecordSource (com.questdb.ql.sort.RBTreeSortedRecordSource)1 VirtualColumnRecordSource (com.questdb.ql.virtual.VirtualColumnRecordSource)1 JournalWriter (com.questdb.store.JournalWriter)1 File (java.io.File)1