Search in sources :

Example 41 with PrestoException

use of com.facebook.presto.spi.PrestoException in project presto by prestodb.

the class AbstractMinMaxAggregationFunction method input.

public static void input(MethodHandle methodHandle, NullableDoubleState state, double value) {
    if (state.isNull()) {
        state.setNull(false);
        state.setDouble(value);
        return;
    }
    try {
        if ((boolean) methodHandle.invokeExact(value, state.getDouble())) {
            state.setDouble(value);
        }
    } catch (Throwable t) {
        Throwables.propagateIfInstanceOf(t, Error.class);
        Throwables.propagateIfInstanceOf(t, PrestoException.class);
        throw new PrestoException(GENERIC_INTERNAL_ERROR, t);
    }
}
Also used : PrestoException(com.facebook.presto.spi.PrestoException)

Example 42 with PrestoException

use of com.facebook.presto.spi.PrestoException in project presto by prestodb.

the class AbstractMinMaxAggregationFunction method combine.

public static void combine(MethodHandle methodHandle, NullableLongState state, NullableLongState otherState) {
    if (state.isNull()) {
        state.setNull(false);
        state.setLong(otherState.getLong());
        return;
    }
    try {
        if ((boolean) methodHandle.invokeExact(otherState.getLong(), state.getLong())) {
            state.setLong(otherState.getLong());
        }
    } catch (Throwable t) {
        Throwables.propagateIfInstanceOf(t, Error.class);
        Throwables.propagateIfInstanceOf(t, PrestoException.class);
        throw new PrestoException(GENERIC_INTERNAL_ERROR, t);
    }
}
Also used : PrestoException(com.facebook.presto.spi.PrestoException)

Example 43 with PrestoException

use of com.facebook.presto.spi.PrestoException in project presto by prestodb.

the class AbstractMinMaxAggregationFunction method input.

public static void input(MethodHandle methodHandle, NullableLongState state, long value) {
    if (state.isNull()) {
        state.setNull(false);
        state.setLong(value);
        return;
    }
    try {
        if ((boolean) methodHandle.invokeExact(value, state.getLong())) {
            state.setLong(value);
        }
    } catch (Throwable t) {
        Throwables.propagateIfInstanceOf(t, Error.class);
        Throwables.propagateIfInstanceOf(t, PrestoException.class);
        throw new PrestoException(GENERIC_INTERNAL_ERROR, t);
    }
}
Also used : PrestoException(com.facebook.presto.spi.PrestoException)

Example 44 with PrestoException

use of com.facebook.presto.spi.PrestoException in project presto by prestodb.

the class BigintGroupByHash method rehash.

private void rehash() {
    expectedHashCollisions += estimateNumberOfHashCollisions(getGroupCount(), hashCapacity);
    long newCapacityLong = hashCapacity * 2L;
    if (newCapacityLong > Integer.MAX_VALUE) {
        throw new PrestoException(GENERIC_INSUFFICIENT_RESOURCES, "Size of hash table cannot exceed 1 billion entries");
    }
    int newCapacity = (int) newCapacityLong;
    int newMask = newCapacity - 1;
    LongBigArray newValues = new LongBigArray();
    newValues.ensureCapacity(newCapacity);
    IntBigArray newGroupIds = new IntBigArray(-1);
    newGroupIds.ensureCapacity(newCapacity);
    for (int groupId = 0; groupId < nextGroupId; groupId++) {
        if (groupId == nullGroupId) {
            continue;
        }
        long value = valuesByGroupId.get(groupId);
        // find an empty slot for the address
        long hashPosition = getHashPosition(value, newMask);
        while (newGroupIds.get(hashPosition) != -1) {
            hashPosition = (hashPosition + 1) & newMask;
            hashCollisions++;
        }
        // record the mapping
        newValues.set(hashPosition, value);
        newGroupIds.set(hashPosition, groupId);
    }
    mask = newMask;
    hashCapacity = newCapacity;
    maxFill = calculateMaxFill(hashCapacity);
    values = newValues;
    groupIds = newGroupIds;
    this.valuesByGroupId.ensureCapacity(maxFill);
}
Also used : LongBigArray(com.facebook.presto.array.LongBigArray) IntBigArray(com.facebook.presto.array.IntBigArray) PrestoException(com.facebook.presto.spi.PrestoException)

Example 45 with PrestoException

use of com.facebook.presto.spi.PrestoException 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)

Aggregations

PrestoException (com.facebook.presto.spi.PrestoException)747 IOException (java.io.IOException)161 ImmutableList (com.google.common.collect.ImmutableList)106 Type (com.facebook.presto.common.type.Type)95 SchemaTableName (com.facebook.presto.spi.SchemaTableName)88 List (java.util.List)83 ArrayList (java.util.ArrayList)79 Path (org.apache.hadoop.fs.Path)78 Optional (java.util.Optional)68 ImmutableMap (com.google.common.collect.ImmutableMap)64 Map (java.util.Map)64 ImmutableList.toImmutableList (com.google.common.collect.ImmutableList.toImmutableList)58 Block (com.facebook.presto.common.block.Block)55 Table (com.facebook.presto.hive.metastore.Table)55 TableNotFoundException (com.facebook.presto.spi.TableNotFoundException)55 Objects.requireNonNull (java.util.Objects.requireNonNull)55 Slice (io.airlift.slice.Slice)50 SqlType (com.facebook.presto.spi.function.SqlType)49 Test (org.testng.annotations.Test)49 ConnectorSession (com.facebook.presto.spi.ConnectorSession)46