Search in sources :

Example 1 with SingleMapBlock

use of io.prestosql.spi.block.SingleMapBlock in project hetu-core by openlookeng.

the class MapElementAtFunction method elementAt.

@UsedByGeneratedCode
public static Object elementAt(MethodHandle keyEqualsMethod, Type keyType, Type valueType, Block map, long key) {
    SingleMapBlock mapBlock = (SingleMapBlock) map;
    int valuePosition = mapBlock.seekKeyExact(key);
    if (valuePosition == -1) {
        return null;
    }
    return readNativeValue(valueType, mapBlock, valuePosition);
}
Also used : SingleMapBlock(io.prestosql.spi.block.SingleMapBlock) UsedByGeneratedCode(io.prestosql.spi.annotation.UsedByGeneratedCode)

Example 2 with SingleMapBlock

use of io.prestosql.spi.block.SingleMapBlock in project hetu-core by openlookeng.

the class MapElementAtFunction method elementAt.

@UsedByGeneratedCode
public static Object elementAt(MethodHandle keyEqualsMethod, Type keyType, Type valueType, Block map, double key) {
    SingleMapBlock mapBlock = (SingleMapBlock) map;
    int valuePosition = mapBlock.seekKeyExact(key);
    if (valuePosition == -1) {
        return null;
    }
    return readNativeValue(valueType, mapBlock, valuePosition);
}
Also used : SingleMapBlock(io.prestosql.spi.block.SingleMapBlock) UsedByGeneratedCode(io.prestosql.spi.annotation.UsedByGeneratedCode)

Example 3 with SingleMapBlock

use of io.prestosql.spi.block.SingleMapBlock in project hetu-core by openlookeng.

the class MapElementAtFunction method elementAt.

@UsedByGeneratedCode
public static Object elementAt(MethodHandle keyEqualsMethod, Type keyType, Type valueType, Block map, Slice key) {
    SingleMapBlock mapBlock = (SingleMapBlock) map;
    int valuePosition = mapBlock.seekKeyExact(key);
    if (valuePosition == -1) {
        return null;
    }
    return readNativeValue(valueType, mapBlock, valuePosition);
}
Also used : SingleMapBlock(io.prestosql.spi.block.SingleMapBlock) UsedByGeneratedCode(io.prestosql.spi.annotation.UsedByGeneratedCode)

Example 4 with SingleMapBlock

use of io.prestosql.spi.block.SingleMapBlock in project hetu-core by openlookeng.

the class MapSubscriptOperator method subscript.

@UsedByGeneratedCode
public static Object subscript(boolean legacyMissingKey, MissingKeyExceptionFactory missingKeyExceptionFactory, MethodHandle keyNativeHashCode, MethodHandle keyBlockNativeEquals, MethodHandle keyBlockHashCode, Type valueType, ConnectorSession session, Block map, boolean key) {
    SingleMapBlock mapBlock = (SingleMapBlock) map;
    int valuePosition = mapBlock.seekKeyExact(key);
    if (valuePosition == -1) {
        if (legacyMissingKey) {
            return null;
        }
        throw missingKeyExceptionFactory.create(session, key);
    }
    return readNativeValue(valueType, mapBlock, valuePosition);
}
Also used : SingleMapBlock(io.prestosql.spi.block.SingleMapBlock) UsedByGeneratedCode(io.prestosql.spi.annotation.UsedByGeneratedCode)

Example 5 with SingleMapBlock

use of io.prestosql.spi.block.SingleMapBlock in project hetu-core by openlookeng.

the class MapSubscriptOperator method subscript.

@UsedByGeneratedCode
public static Object subscript(boolean legacyMissingKey, MissingKeyExceptionFactory missingKeyExceptionFactory, MethodHandle keyNativeHashCode, MethodHandle keyBlockNativeEquals, MethodHandle keyBlockHashCode, Type valueType, ConnectorSession session, Block map, Object key) {
    SingleMapBlock mapBlock = (SingleMapBlock) map;
    int valuePosition = mapBlock.seekKeyExact((Block) key);
    if (valuePosition == -1) {
        if (legacyMissingKey) {
            return null;
        }
        throw missingKeyExceptionFactory.create(session, key);
    }
    return readNativeValue(valueType, mapBlock, valuePosition);
}
Also used : SingleMapBlock(io.prestosql.spi.block.SingleMapBlock) UsedByGeneratedCode(io.prestosql.spi.annotation.UsedByGeneratedCode)

Aggregations

SingleMapBlock (io.prestosql.spi.block.SingleMapBlock)15 UsedByGeneratedCode (io.prestosql.spi.annotation.UsedByGeneratedCode)10 HashMap (java.util.HashMap)3 MapType (io.prestosql.spi.type.MapType)2 PageBuilder (io.prestosql.spi.PageBuilder)1 PrestoException (io.prestosql.spi.PrestoException)1 Block (io.prestosql.spi.block.Block)1 BlockBuilder (io.prestosql.spi.block.BlockBuilder)1 MapBlock (io.prestosql.spi.block.MapBlock)1 Type (io.prestosql.spi.type.Type)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 Map (java.util.Map)1 ListObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ListObjectInspector)1 MapObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.MapObjectInspector)1 ObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.ObjectInspector)1 PrimitiveObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.PrimitiveObjectInspector)1 AbstractPrimitiveJavaObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.primitive.AbstractPrimitiveJavaObjectInspector)1 BinaryObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.primitive.BinaryObjectInspector)1 BooleanObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.primitive.BooleanObjectInspector)1 ByteObjectInspector (org.apache.hadoop.hive.serde2.objectinspector.primitive.ByteObjectInspector)1