Search in sources :

Example 11 with MapValue

use of io.questdb.cairo.map.MapValue in project questdb by bluestreak01.

the class QMapWriteLongBenchmark method testQMap.

@Benchmark
public void testQMap() {
    MapKey key = qmap.withKey();
    key.putLong(rnd.nextLong());
    MapValue value = key.createValue();
    value.putLong(0, 20);
}
Also used : MapKey(io.questdb.cairo.map.MapKey) MapValue(io.questdb.cairo.map.MapValue)

Example 12 with MapValue

use of io.questdb.cairo.map.MapValue in project questdb by bluestreak01.

the class LastGeoHashGroupByFunctionFactory method newInstance.

@Override
public Function newInstance(int position, ObjList<Function> args, IntList argPositions, CairoConfiguration configuration, SqlExecutionContext sqlExecutionContext) {
    Function function = args.getQuick(0);
    int type = function.getType();
    // Reuse first implementation overriding computeNext() method inline
    switch(ColumnType.tagOf(type)) {
        case ColumnType.GEOBYTE:
            return new FirstGeoHashGroupByFunctionByte(type, function) {

                @Override
                public void computeNext(MapValue mapValue, Record record) {
                    mapValue.putByte(this.valueIndex, this.function.getGeoByte(record));
                }
            };
        case ColumnType.GEOSHORT:
            return new FirstGeoHashGroupByFunctionShort(type, function) {

                @Override
                public void computeNext(MapValue mapValue, Record record) {
                    mapValue.putShort(this.valueIndex, this.function.getGeoShort(record));
                }
            };
        case ColumnType.GEOINT:
            return new FirstGeoHashGroupByFunctionInt(type, function) {

                @Override
                public void computeNext(MapValue mapValue, Record record) {
                    mapValue.putInt(this.valueIndex, this.function.getGeoInt(record));
                }
            };
        default:
            return new FirstGeoHashGroupByFunctionLong(type, function) {

                @Override
                public void computeNext(MapValue mapValue, Record record) {
                    mapValue.putLong(this.valueIndex, this.function.getGeoLong(record));
                }
            };
    }
}
Also used : Function(io.questdb.cairo.sql.Function) MapValue(io.questdb.cairo.map.MapValue) Record(io.questdb.cairo.sql.Record)

Example 13 with MapValue

use of io.questdb.cairo.map.MapValue in project questdb by bluestreak01.

the class JoinRecordMetadata method addToMap.

private void addToMap(CharSequence columnName, int dot, TableColumnMetadata cm) {
    MapKey key;
    MapValue value;
    this.columnMetadata.add(cm);
    key = map.withKey();
    key.putStr(null);
    key.putStrLowerCase(columnName, dot + 1, columnName.length());
    value = key.createValue();
    if (value.isNew()) {
        value.putInt(0, columnCount - 1);
    } else {
        // this is a duplicate columns, if somebody looks it up without alias
        // we would treat this lookup as if column hadn't been found.
        value.putInt(0, -1);
    }
}
Also used : MapKey(io.questdb.cairo.map.MapKey) MapValue(io.questdb.cairo.map.MapValue)

Example 14 with MapValue

use of io.questdb.cairo.map.MapValue in project questdb by bluestreak01.

the class JoinRecordMetadata method addAlias.

private int addAlias(CharSequence tableAlias, CharSequence columnName) {
    int dot = Chars.indexOf(columnName, '.');
    assert dot != -1 || tableAlias != null;
    // add column with its own alias
    MapKey key = map.withKey();
    if (dot == -1) {
        key.putStrLowerCase(tableAlias);
    } else {
        assert tableAlias == null;
        key.putStrLowerCase(columnName, 0, dot);
    }
    key.putStrLowerCase(columnName, dot + 1, columnName.length());
    MapValue value = key.createValue();
    if (!value.isNew()) {
        throw CairoException.instance(0).put("Duplicate column [name=").put(columnName).put(", tableAlias=").put(tableAlias).put(']');
    }
    value.putLong(0, columnCount++);
    return dot;
}
Also used : MapKey(io.questdb.cairo.map.MapKey) MapValue(io.questdb.cairo.map.MapValue)

Example 15 with MapValue

use of io.questdb.cairo.map.MapValue in project questdb by bluestreak01.

the class JoinRecordMetadata method getColumnIndexQuiet.

@Override
public int getColumnIndexQuiet(CharSequence columnName, int lo, int hi) {
    final MapKey key = map.withKey();
    final int dot = Chars.indexOf(columnName, lo, '.');
    if (dot == -1) {
        key.putStrLowerCase(null);
        key.putStrLowerCase(columnName, lo, hi);
    } else {
        key.putStrLowerCase(columnName, 0, dot);
        key.putStrLowerCase(columnName, dot + 1, columnName.length());
    }
    MapValue value = key.findValue();
    if (value != null) {
        return value.getInt(0);
    }
    return -1;
}
Also used : MapKey(io.questdb.cairo.map.MapKey) MapValue(io.questdb.cairo.map.MapValue)

Aggregations

MapValue (io.questdb.cairo.map.MapValue)23 MapKey (io.questdb.cairo.map.MapKey)17 MapRecord (io.questdb.cairo.map.MapRecord)2 RecordCursor (io.questdb.cairo.sql.RecordCursor)2 SqlExecutionInterruptor (io.questdb.griffin.SqlExecutionInterruptor)2 EmptyTableRandomRecordCursor (io.questdb.griffin.engine.EmptyTableRandomRecordCursor)2 GroupByFunction (io.questdb.griffin.engine.functions.GroupByFunction)2 Function (io.questdb.cairo.sql.Function)1 Record (io.questdb.cairo.sql.Record)1 EmptyTableNoSizeRecordCursor (io.questdb.griffin.engine.EmptyTableNoSizeRecordCursor)1