Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
import static com.facebook.presto.operator.SyntheticAddress.encodeSyntheticAddress;
import static com.facebook.presto.spi.StandardErrorCode.GENERIC_INSUFFICIENT_RESOURCES;
import static com.facebook.presto.sql.gen.JoinCompiler.PagesHashStrategyFactory;
import static com.facebook.presto.util.Failures.checkArgument;
import static com.facebook.presto.util.HashCollisionsEstimator.estimateNumberOfHashCollisions;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Verify.verify;
import static io.airlift.slice.SizeOf.sizeOf;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
package com.facebook.presto.operator.aggregation;

import com.facebook.airlift.stats.QuantileDigest;
import com.facebook.presto.spi.PrestoException;
import com.facebook.presto.tdigest.TDigest;
import io.airlift.slice.Slice;

import static com.facebook.presto.spi.StandardErrorCode.INVALID_FUNCTION_ARGUMENT;
import static com.google.common.base.Preconditions.checkArgument;

public class StatisticalDigestFactory
Expand Down Expand Up @@ -54,9 +56,14 @@ public void add(double value, long weight)
@Override
public void merge(StatisticalDigest other)
{
checkArgument(other instanceof StatisticalTDigest);
StatisticalTDigest toMerge = (StatisticalTDigest) other;
tDigest.merge(toMerge.tDigest);
try {
checkArgument(other instanceof StatisticalTDigest);
StatisticalTDigest toMerge = (StatisticalTDigest) other;
tDigest.merge(toMerge.tDigest);
}
catch (IllegalArgumentException ex) {
throw new PrestoException(INVALID_FUNCTION_ARGUMENT, ex.getMessage(), ex);
}
}

@Override
Expand Down Expand Up @@ -103,9 +110,14 @@ public void add(long value, long weight)
@Override
public void merge(StatisticalDigest other)
{
checkArgument(other instanceof StatisticalQuantileDigest);
StatisticalQuantileDigest toMerge = (StatisticalQuantileDigest) other;
this.qdigest.merge(toMerge.qdigest);
try {
checkArgument(other instanceof StatisticalQuantileDigest);
StatisticalQuantileDigest toMerge = (StatisticalQuantileDigest) other;
this.qdigest.merge(toMerge.qdigest);
}
catch (IllegalArgumentException ex) {
throw new PrestoException(INVALID_FUNCTION_ARGUMENT, ex.getMessage(), ex);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import java.util.Optional;

import static com.facebook.presto.sql.planner.optimizations.StreamPropertyDerivations.derivePropertiesRecursively;
import static com.google.common.base.Preconditions.checkArgument;
import static com.facebook.presto.util.Failures.checkArgument;

/**
* Verifies that input of streaming aggregations is grouped on the grouping keys
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@
public class TDigest
{
private static final int INSTANCE_SIZE = ClassLayout.parseClass(TDigest.class).instanceSize();
private static final double MAX_COMPRESSION_FACTOR = 1_000;
static final double MAX_COMPRESSION_FACTOR = 1_000;
private static final double sizeFudge = 30;
private static final double EPSILON = 0.001;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ public static ExecutionFailureInfo toFailure(Throwable failure)
return toFailure(failure, newIdentityHashSet());
}

public static void checkArgument(boolean expression, String errorMessage)
{
if (!expression) {
throw new PrestoException(StandardErrorCode.INVALID_ARGUMENTS, errorMessage);
}
}

public static void checkArgument(boolean expression, String errorMessageTemplate, Object... errorMessageArgs)
{
if (!expression) {
throw new PrestoException(StandardErrorCode.INVALID_ARGUMENTS, String.format(errorMessageTemplate, errorMessageArgs));
}
}

public static void checkCondition(boolean condition, ErrorCodeSupplier errorCode, String formatString, Object... args)
{
if (!condition) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.facebook.presto.common.predicate.TupleDomain;
import com.facebook.presto.metadata.Metadata;
import com.facebook.presto.spi.ConnectorId;
import com.facebook.presto.spi.PrestoException;
import com.facebook.presto.spi.TableHandle;
import com.facebook.presto.spi.WarningCollector;
import com.facebook.presto.spi.plan.PlanNode;
Expand Down Expand Up @@ -90,7 +91,7 @@ public void testValidateSuccessful()
ImmutableMap.of(p.variable("nationkey", BIGINT), new TpchColumnHandle("nationkey", BIGINT)))))));
}

@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = "Streaming aggregation with input not grouped on the grouping keys")
@Test(expectedExceptions = PrestoException.class, expectedExceptionsMessageRegExp = "Streaming aggregation with input not grouped on the grouping keys")
public void testValidateFailed()
{
validatePlan(
Expand Down