Search in sources :

Example 6 with NotSupportedException

use of com.facebook.presto.common.NotSupportedException in project presto by prestodb.

the class MapSubscriptOperator method subscript.

@UsedByGeneratedCode
public static Object subscript(boolean legacyMissingKey, MissingKeyExceptionFactory missingKeyExceptionFactory, MethodHandle keyNativeHashCode, MethodHandle keyBlockNativeEquals, MethodHandle keyBlockHashCode, Type valueType, SqlFunctionProperties properties, Block map, long key) {
    SingleMapBlock mapBlock = (SingleMapBlock) map;
    int valuePosition;
    try {
        valuePosition = mapBlock.seekKeyExact(key, keyNativeHashCode, keyBlockNativeEquals, keyBlockHashCode);
    } catch (NotSupportedException e) {
        throw new PrestoException(NOT_SUPPORTED, e.getMessage(), e);
    }
    if (valuePosition == -1) {
        if (legacyMissingKey) {
            return null;
        }
        throw missingKeyExceptionFactory.create(properties, key);
    }
    return readNativeValue(valueType, mapBlock, valuePosition);
}
Also used : PrestoException(com.facebook.presto.spi.PrestoException) SingleMapBlock(com.facebook.presto.common.block.SingleMapBlock) NotSupportedException(com.facebook.presto.common.NotSupportedException) UsedByGeneratedCode(com.facebook.presto.annotation.UsedByGeneratedCode)

Example 7 with NotSupportedException

use of com.facebook.presto.common.NotSupportedException in project presto by prestodb.

the class MapSubscriptOperator method subscript.

@UsedByGeneratedCode
public static Object subscript(boolean legacyMissingKey, MissingKeyExceptionFactory missingKeyExceptionFactory, MethodHandle keyNativeHashCode, MethodHandle keyBlockNativeEquals, MethodHandle keyBlockHashCode, Type valueType, SqlFunctionProperties properties, Block map, double key) {
    SingleMapBlock mapBlock = (SingleMapBlock) map;
    int valuePosition;
    try {
        valuePosition = mapBlock.seekKeyExact(key, keyNativeHashCode, keyBlockNativeEquals, keyBlockHashCode);
    } catch (NotSupportedException e) {
        throw new PrestoException(NOT_SUPPORTED, e.getMessage(), e);
    }
    if (valuePosition == -1) {
        if (legacyMissingKey) {
            return null;
        }
        throw missingKeyExceptionFactory.create(properties, key);
    }
    return readNativeValue(valueType, mapBlock, valuePosition);
}
Also used : PrestoException(com.facebook.presto.spi.PrestoException) SingleMapBlock(com.facebook.presto.common.block.SingleMapBlock) NotSupportedException(com.facebook.presto.common.NotSupportedException) UsedByGeneratedCode(com.facebook.presto.annotation.UsedByGeneratedCode)

Example 8 with NotSupportedException

use of com.facebook.presto.common.NotSupportedException in project presto by prestodb.

the class MapSubscriptOperator method subscript.

@UsedByGeneratedCode
public static Object subscript(boolean legacyMissingKey, MissingKeyExceptionFactory missingKeyExceptionFactory, MethodHandle keyNativeHashCode, MethodHandle keyBlockNativeEquals, MethodHandle keyBlockHashCode, Type valueType, SqlFunctionProperties properties, Block map, boolean key) {
    SingleMapBlock mapBlock = (SingleMapBlock) map;
    int valuePosition;
    try {
        valuePosition = mapBlock.seekKeyExact(key, keyNativeHashCode, keyBlockNativeEquals, keyBlockHashCode);
    } catch (NotSupportedException e) {
        throw new PrestoException(NOT_SUPPORTED, e.getMessage(), e);
    }
    if (valuePosition == -1) {
        if (legacyMissingKey) {
            return null;
        }
        throw missingKeyExceptionFactory.create(properties, key);
    }
    return readNativeValue(valueType, mapBlock, valuePosition);
}
Also used : PrestoException(com.facebook.presto.spi.PrestoException) SingleMapBlock(com.facebook.presto.common.block.SingleMapBlock) NotSupportedException(com.facebook.presto.common.NotSupportedException) UsedByGeneratedCode(com.facebook.presto.annotation.UsedByGeneratedCode)

Example 9 with NotSupportedException

use of com.facebook.presto.common.NotSupportedException in project presto by prestodb.

the class MapSubscriptOperator method subscript.

@UsedByGeneratedCode
public static Object subscript(boolean legacyMissingKey, MissingKeyExceptionFactory missingKeyExceptionFactory, MethodHandle keyNativeHashCode, MethodHandle keyBlockNativeEquals, MethodHandle keyBlockHashCode, Type valueType, SqlFunctionProperties properties, Block map, Object key) {
    SingleMapBlock mapBlock = (SingleMapBlock) map;
    int valuePosition;
    try {
        valuePosition = mapBlock.seekKeyExact((Block) key, keyNativeHashCode, keyBlockNativeEquals, keyBlockHashCode);
    } catch (NotSupportedException e) {
        throw new PrestoException(NOT_SUPPORTED, e.getMessage(), e);
    }
    if (valuePosition == -1) {
        if (legacyMissingKey) {
            return null;
        }
        throw missingKeyExceptionFactory.create(properties, key);
    }
    return readNativeValue(valueType, mapBlock, valuePosition);
}
Also used : SingleMapBlock(com.facebook.presto.common.block.SingleMapBlock) Block(com.facebook.presto.common.block.Block) PrestoException(com.facebook.presto.spi.PrestoException) SingleMapBlock(com.facebook.presto.common.block.SingleMapBlock) NotSupportedException(com.facebook.presto.common.NotSupportedException) UsedByGeneratedCode(com.facebook.presto.annotation.UsedByGeneratedCode)

Example 10 with NotSupportedException

use of com.facebook.presto.common.NotSupportedException in project presto by prestodb.

the class MapSubscriptOperator method subscript.

@UsedByGeneratedCode
public static Object subscript(boolean legacyMissingKey, MissingKeyExceptionFactory missingKeyExceptionFactory, MethodHandle keyNativeHashCode, MethodHandle keyBlockNativeEquals, MethodHandle keyBlockHashCode, Type valueType, SqlFunctionProperties properties, Block map, Slice key) {
    SingleMapBlock mapBlock = (SingleMapBlock) map;
    int valuePosition;
    try {
        valuePosition = mapBlock.seekKeyExact(key, keyNativeHashCode, keyBlockNativeEquals, keyBlockHashCode);
    } catch (NotSupportedException e) {
        throw new PrestoException(NOT_SUPPORTED, e.getMessage(), e);
    }
    if (valuePosition == -1) {
        if (legacyMissingKey) {
            return null;
        }
        throw missingKeyExceptionFactory.create(properties, key);
    }
    return readNativeValue(valueType, mapBlock, valuePosition);
}
Also used : PrestoException(com.facebook.presto.spi.PrestoException) SingleMapBlock(com.facebook.presto.common.block.SingleMapBlock) NotSupportedException(com.facebook.presto.common.NotSupportedException) UsedByGeneratedCode(com.facebook.presto.annotation.UsedByGeneratedCode)

Aggregations

NotSupportedException (com.facebook.presto.common.NotSupportedException)25 PrestoException (com.facebook.presto.spi.PrestoException)24 SingleMapBlock (com.facebook.presto.common.block.SingleMapBlock)12 UsedByGeneratedCode (com.facebook.presto.annotation.UsedByGeneratedCode)11 Block (com.facebook.presto.common.block.Block)9 Type (com.facebook.presto.common.type.Type)9 BlockBuilder (com.facebook.presto.common.block.BlockBuilder)3 SortOrder (com.facebook.presto.common.block.SortOrder)3 JsonCodec (com.facebook.airlift.json.JsonCodec)1 JsonCodec.jsonCodec (com.facebook.airlift.json.JsonCodec.jsonCodec)1 Logger (com.facebook.airlift.log.Logger)1 Page (com.facebook.presto.common.Page)1 RuntimeStats (com.facebook.presto.common.RuntimeStats)1 AdaptiveLongBigArray (com.facebook.presto.common.array.AdaptiveLongBigArray)1 DuplicateMapKeyException (com.facebook.presto.common.block.DuplicateMapKeyException)1 MapBlockBuilder (com.facebook.presto.common.block.MapBlockBuilder)1 OperatorType (com.facebook.presto.common.function.OperatorType)1 CharType (com.facebook.presto.common.type.CharType)1 DecimalType (com.facebook.presto.common.type.DecimalType)1 MapType (com.facebook.presto.common.type.MapType)1