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);
}
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));
}
};
}
}
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);
}
}
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;
}
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;
}
Aggregations