Search in sources :

Example 1 with TableReader

use of com.questdb.cairo.TableReader in project questdb by bluestreak01.

the class QueryFilterAnalyserTest method setUp2.

@BeforeClass
public static void setUp2() {
    try (TableModel model = new TableModel(configuration, "x", PartitionBy.NONE)) {
        model.col("sym", ColumnType.SYMBOL).indexed(true, 16).col("bid", ColumnType.DOUBLE).col("ask", ColumnType.DOUBLE).col("bidSize", ColumnType.INT).col("askSize", ColumnType.INT).col("mode", ColumnType.SYMBOL).indexed(true, 4).col("ex", ColumnType.SYMBOL).indexed(true, 4).timestamp();
        CairoTestUtils.create(model);
    }
    try (TableModel model = new TableModel(configuration, "y", PartitionBy.NONE)) {
        model.col("sym", ColumnType.SYMBOL).indexed(true, 16).col("bid", ColumnType.DOUBLE).col("ask", ColumnType.DOUBLE).col("bidSize", ColumnType.INT).col("askSize", ColumnType.INT).col("mode", ColumnType.SYMBOL).indexed(true, 4).col("ex", ColumnType.SYMBOL).indexed(true, 4);
        CairoTestUtils.create(model);
    }
    reader = new TableReader(configuration, "x");
    metadata = reader.getMetadata();
    noTimestampReader = new TableReader(configuration, "y");
    noTimestampmetadata = noTimestampReader.getMetadata();
}
Also used : TableModel(com.questdb.cairo.TableModel) TableReader(com.questdb.cairo.TableReader)

Example 2 with TableReader

use of com.questdb.cairo.TableReader in project questdb by bluestreak01.

the class QueryModel method getTableMetadata.

public RecordMetadata getTableMetadata(CairoEngine engine, FlyweightCharSequence charSequence) throws ParserException {
    // table name must not contain quotes by now
    ExprNode readerNode = getTableName();
    int lo = 0;
    int hi = readerNode.token.length();
    if (Chars.startsWith(readerNode.token, NO_ROWID_MARKER)) {
        lo += NO_ROWID_MARKER.length();
    }
    if (lo == hi) {
        throw ParserException.$(readerNode.position, "come on, where is table name?");
    }
    int status = engine.getStatus(readerNode.token, lo, hi);
    if (status == TableUtils.TABLE_DOES_NOT_EXIST) {
        throw ParserException.$(readerNode.position, "table does not exist");
    }
    if (status == TableUtils.TABLE_RESERVED) {
        throw ParserException.$(readerNode.position, "table directory is of unknown format");
    }
    try (TableReader r = engine.getReader(charSequence.of(readerNode.token, lo, hi - lo))) {
        return r.getMetadata();
    } catch (EntryLockedException e) {
        throw ParserException.position(readerNode.position).put("table is locked: ").put(charSequence);
    } catch (CairoException e) {
        throw ParserException.position(readerNode.position).put(e);
    }
}
Also used : ExprNode(com.questdb.griffin.common.ExprNode) CairoException(com.questdb.cairo.CairoException) TableReader(com.questdb.cairo.TableReader) EntryLockedException(com.questdb.cairo.pool.ex.EntryLockedException)

Aggregations

TableReader (com.questdb.cairo.TableReader)2 CairoException (com.questdb.cairo.CairoException)1 TableModel (com.questdb.cairo.TableModel)1 EntryLockedException (com.questdb.cairo.pool.ex.EntryLockedException)1 ExprNode (com.questdb.griffin.common.ExprNode)1