Search in sources :

Example 1 with NotSupportedException

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

the class SimplePagesHashStrategy method positionEqualsPositionIgnoreNulls.

@Override
public boolean positionEqualsPositionIgnoreNulls(int leftBlockIndex, int leftPosition, int rightBlockIndex, int rightPosition) {
    for (int hashChannel : hashChannels) {
        Type type = types.get(hashChannel);
        List<Block> channel = channels.get(hashChannel);
        Block leftBlock = channel.get(leftBlockIndex);
        Block rightBlock = channel.get(rightBlockIndex);
        try {
            if (!type.equalTo(leftBlock, leftPosition, rightBlock, rightPosition)) {
                return false;
            }
        } catch (NotSupportedException e) {
            throw new PrestoException(NOT_SUPPORTED, e.getMessage(), e);
        }
    }
    return true;
}
Also used : Type(com.facebook.presto.common.type.Type) Block(com.facebook.presto.common.block.Block) PrestoException(com.facebook.presto.spi.PrestoException) NotSupportedException(com.facebook.presto.common.NotSupportedException)

Example 2 with NotSupportedException

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

the class RowComparator method compare.

@Override
public int compare(Page leftRow, Page rightRow) {
    for (int index = 0; index < sortChannels.size(); index++) {
        Type type = sortTypes.get(index);
        int channel = sortChannels.get(index);
        SortOrder sortOrder = sortOrders.get(index);
        Block left = leftRow.getBlock(channel);
        Block right = rightRow.getBlock(channel);
        int comparison;
        try {
            comparison = sortOrder.compareBlockValue(type, left, 0, right, 0);
        } catch (NotSupportedException e) {
            throw new PrestoException(NOT_SUPPORTED, e.getMessage(), e);
        }
        if (comparison != 0) {
            return comparison;
        }
    }
    return 0;
}
Also used : Type(com.facebook.presto.common.type.Type) SortOrder(com.facebook.presto.common.block.SortOrder) Block(com.facebook.presto.common.block.Block) PrestoException(com.facebook.presto.spi.PrestoException) NotSupportedException(com.facebook.presto.common.NotSupportedException)

Example 3 with NotSupportedException

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

the class SimplePagesIndexComparator method compareTo.

@Override
public int compareTo(PagesIndex pagesIndex, int leftPosition, int rightPosition) {
    AdaptiveLongBigArray valueAddresses = pagesIndex.getValueAddresses();
    long leftPageAddress = valueAddresses.get(leftPosition);
    long rightPageAddress = valueAddresses.get(rightPosition);
    int leftBlockIndex = decodeSliceIndex(leftPageAddress);
    int leftBlockPosition = decodePosition(leftPageAddress);
    int rightBlockIndex = decodeSliceIndex(rightPageAddress);
    int rightBlockPosition = decodePosition(rightPageAddress);
    for (int i = 0; i < sortChannels.length; i++) {
        int sortChannel = sortChannels[i];
        SortOrder sortOrder = sortOrders[i];
        Type sortType = sortTypes[i];
        List<Block> indexChannel = pagesIndex.getChannel(sortChannel);
        Block leftBlock = indexChannel.get(leftBlockIndex);
        Block rightBlock = indexChannel.get(rightBlockIndex);
        try {
            int compare = sortOrder.compareBlockValue(sortType, leftBlock, leftBlockPosition, rightBlock, rightBlockPosition);
            if (compare != 0) {
                return compare;
            }
        } catch (NotSupportedException e) {
            throw new PrestoException(NOT_SUPPORTED, e.getMessage(), e);
        }
    }
    return 0;
}
Also used : Type(com.facebook.presto.common.type.Type) SortOrder(com.facebook.presto.common.block.SortOrder) Block(com.facebook.presto.common.block.Block) PrestoException(com.facebook.presto.spi.PrestoException) AdaptiveLongBigArray(com.facebook.presto.common.array.AdaptiveLongBigArray) NotSupportedException(com.facebook.presto.common.NotSupportedException)

Example 4 with NotSupportedException

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

the class MapElementAtFunction method elementAt.

@UsedByGeneratedCode
public static Object elementAt(MethodHandle keyNativeHashCode, MethodHandle keyBlockNativeEquals, MethodHandle keyBlockHashCode, Type valueType, 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) {
        return null;
    }
    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 5 with NotSupportedException

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

the class MapElementAtFunction method elementAt.

@UsedByGeneratedCode
public static Object elementAt(MethodHandle keyNativeHashCode, MethodHandle keyBlockNativeEquals, MethodHandle keyBlockHashCode, Type valueType, 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) {
        return null;
    }
    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