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);
}
}
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);
}
}
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);
}
}
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);
}
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());
}
}
Aggregations