Search in sources :

Example 1 with ExceededMemoryLimitException

use of com.facebook.presto.ExceededMemoryLimitException in project presto by prestodb.

the class Histogram method combine.

public static void combine(HistogramState state, HistogramState otherState) {
    if (state.get() != null && otherState.get() != null) {
        TypedHistogram typedHistogram = state.get();
        long startSize = typedHistogram.getEstimatedSize();
        try {
            typedHistogram.addAll(otherState.get());
        } catch (ExceededMemoryLimitException e) {
            throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("The result of histogram may not exceed %s", e.getMaxMemory()));
        }
        state.addMemoryUsage(typedHistogram.getEstimatedSize() - startSize);
    } else if (state.get() == null) {
        state.set(otherState.get());
    }
}
Also used : PrestoException(com.facebook.presto.spi.PrestoException) ExceededMemoryLimitException(com.facebook.presto.ExceededMemoryLimitException)

Example 2 with ExceededMemoryLimitException

use of com.facebook.presto.ExceededMemoryLimitException in project presto by prestodb.

the class MapAggregationFunction method input.

public static void input(Type keyType, Type valueType, KeyValuePairsState state, Block key, Block value, int position) {
    KeyValuePairs pairs = state.get();
    if (pairs == null) {
        pairs = new KeyValuePairs(keyType, valueType);
        state.set(pairs);
    }
    long startSize = pairs.estimatedInMemorySize();
    try {
        pairs.add(key, value, position, position);
    } catch (ExceededMemoryLimitException e) {
        throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("The result of map_agg may not exceed %s", e.getMaxMemory()));
    }
    state.addMemoryUsage(pairs.estimatedInMemorySize() - startSize);
}
Also used : PrestoException(com.facebook.presto.spi.PrestoException) ExceededMemoryLimitException(com.facebook.presto.ExceededMemoryLimitException)

Example 3 with ExceededMemoryLimitException

use of com.facebook.presto.ExceededMemoryLimitException in project presto by prestodb.

the class MultimapAggregationFunction method combine.

public static void combine(MultiKeyValuePairsState state, MultiKeyValuePairsState otherState) {
    if (state.get() != null && otherState.get() != null) {
        Block keys = otherState.get().getKeys();
        Block values = otherState.get().getValues();
        MultiKeyValuePairs pairs = state.get();
        long startSize = pairs.estimatedInMemorySize();
        for (int i = 0; i < keys.getPositionCount(); i++) {
            try {
                pairs.add(keys, values, i, i);
            } catch (ExceededMemoryLimitException e) {
                throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("The result of map_agg may not exceed %s", e.getMaxMemory()));
            }
        }
        state.addMemoryUsage(pairs.estimatedInMemorySize() - startSize);
    } else if (state.get() == null) {
        state.set(otherState.get());
    }
}
Also used : Block(com.facebook.presto.spi.block.Block) PrestoException(com.facebook.presto.spi.PrestoException) ExceededMemoryLimitException(com.facebook.presto.ExceededMemoryLimitException)

Example 4 with ExceededMemoryLimitException

use of com.facebook.presto.ExceededMemoryLimitException in project presto by prestodb.

the class MultimapAggregationFunction method input.

public static void input(MultiKeyValuePairsState state, Block key, Block value, int position) {
    MultiKeyValuePairs pairs = state.get();
    if (pairs == null) {
        pairs = new MultiKeyValuePairs(state.getKeyType(), state.getValueType());
        state.set(pairs);
    }
    long startSize = pairs.estimatedInMemorySize();
    try {
        pairs.add(key, value, position, position);
    } catch (ExceededMemoryLimitException e) {
        throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("The result of map_agg may not exceed %s", e.getMaxMemory()));
    }
    state.addMemoryUsage(pairs.estimatedInMemorySize() - startSize);
}
Also used : PrestoException(com.facebook.presto.spi.PrestoException) ExceededMemoryLimitException(com.facebook.presto.ExceededMemoryLimitException)

Example 5 with ExceededMemoryLimitException

use of com.facebook.presto.ExceededMemoryLimitException in project presto by prestodb.

the class Histogram method input.

public static void input(Type type, HistogramState state, Block key, int position) {
    TypedHistogram typedHistogram = state.get();
    if (typedHistogram == null) {
        typedHistogram = new TypedHistogram(type, EXPECTED_SIZE_FOR_HASHING);
        state.set(typedHistogram);
    }
    long startSize = typedHistogram.getEstimatedSize();
    try {
        typedHistogram.add(position, key, 1L);
    } catch (ExceededMemoryLimitException e) {
        throw new PrestoException(INVALID_FUNCTION_ARGUMENT, format("The result of histogram may not exceed %s", e.getMaxMemory()));
    }
    state.addMemoryUsage(typedHistogram.getEstimatedSize() - startSize);
}
Also used : PrestoException(com.facebook.presto.spi.PrestoException) ExceededMemoryLimitException(com.facebook.presto.ExceededMemoryLimitException)

Aggregations

ExceededMemoryLimitException (com.facebook.presto.ExceededMemoryLimitException)6 PrestoException (com.facebook.presto.spi.PrestoException)6 Block (com.facebook.presto.spi.block.Block)2