use of org.apache.hyracks.algebricks.common.exceptions.AlgebricksException in project asterixdb by apache.
the class NonTaggedFormatUtil method getTokenType.
public static IAType getTokenType(IAType keyType) throws AlgebricksException {
IAType type = keyType;
ATypeTag typeTag = keyType.getTypeTag();
// Extract item type from list.
if (typeTag == ATypeTag.MULTISET || typeTag == ATypeTag.ARRAY) {
AbstractCollectionType listType = (AbstractCollectionType) keyType;
if (!listType.isTyped()) {
throw new AlgebricksException("Cannot build an inverted index on untyped lists.)");
}
type = listType.getItemType();
}
return type;
}
use of org.apache.hyracks.algebricks.common.exceptions.AlgebricksException in project asterixdb by apache.
the class JoinMultiComparator method generateHashJoinRuntime.
private IOperatorDescriptor generateHashJoinRuntime(JobGenContext context, IOperatorSchema[] inputSchemas, int[] keysLeft, int[] keysRight, IBinaryHashFunctionFactory[] hashFunFactories, IBinaryComparatorFactory[] comparatorFactories, IPredicateEvaluatorFactory predEvaluatorFactory, RecordDescriptor recDescriptor, IOperatorDescriptorRegistry spec) throws AlgebricksException {
IOperatorDescriptor opDesc;
try {
switch(kind) {
case INNER:
opDesc = new HybridHashJoinOperatorDescriptor(spec, getMemSizeInFrames(), maxInputBuildSizeInFrames, aveRecordsPerFrame, getFudgeFactor(), keysLeft, keysRight, hashFunFactories, comparatorFactories, recDescriptor, predEvaluatorFactory, false, null);
break;
case LEFT_OUTER:
IMissingWriterFactory[] nonMatchWriterFactories = new IMissingWriterFactory[inputSchemas[1].getSize()];
for (int j = 0; j < nonMatchWriterFactories.length; j++) {
nonMatchWriterFactories[j] = context.getMissingWriterFactory();
}
opDesc = new HybridHashJoinOperatorDescriptor(spec, getMemSizeInFrames(), maxInputBuildSizeInFrames, aveRecordsPerFrame, getFudgeFactor(), keysLeft, keysRight, hashFunFactories, comparatorFactories, recDescriptor, predEvaluatorFactory, true, nonMatchWriterFactories);
break;
default:
throw new NotImplementedException();
}
} catch (HyracksDataException e) {
throw new AlgebricksException(e);
}
return opDesc;
}
use of org.apache.hyracks.algebricks.common.exceptions.AlgebricksException in project asterixdb by apache.
the class AbstractUnnestPOperator method contributeRuntimeOperator.
@Override
public void contributeRuntimeOperator(IHyracksJobBuilder builder, JobGenContext context, ILogicalOperator op, IOperatorSchema opSchema, IOperatorSchema[] inputSchemas, IOperatorSchema outerPlanSchema) throws AlgebricksException {
AbstractUnnestNonMapOperator unnest = (AbstractUnnestNonMapOperator) op;
int outCol = opSchema.findVariable(unnest.getVariable());
ILogicalExpression unnestExpr = unnest.getExpressionRef().getValue();
IExpressionRuntimeProvider expressionRuntimeProvider = context.getExpressionRuntimeProvider();
boolean exit = false;
if (unnestExpr.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
exit = true;
} else {
AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) unnestExpr;
if (fce.getKind() != FunctionKind.UNNEST) {
exit = true;
}
}
if (exit) {
throw new AlgebricksException("Unnest expression " + unnestExpr + " is not an unnesting function call.");
}
UnnestingFunctionCallExpression agg = (UnnestingFunctionCallExpression) unnestExpr;
IUnnestingEvaluatorFactory unnestingFactory = expressionRuntimeProvider.createUnnestingFunctionFactory(agg, context.getTypeEnvironment(op.getInputs().get(0).getValue()), inputSchemas, context);
int[] projectionList = JobGenHelper.projectAllVariables(opSchema);
UnnestRuntimeFactory unnestRuntime = new UnnestRuntimeFactory(outCol, unnestingFactory, projectionList, unnest.getPositionWriter(), leftOuter, context.getMissingWriterFactory());
RecordDescriptor recDesc = JobGenHelper.mkRecordDescriptor(context.getTypeEnvironment(op), opSchema, context);
builder.contributeMicroOperator(unnest, unnestRuntime, recDesc);
ILogicalOperator src = unnest.getInputs().get(0).getValue();
builder.contributeGraphEdge(src, 0, unnest, 0);
}
use of org.apache.hyracks.algebricks.common.exceptions.AlgebricksException in project asterixdb by apache.
the class IntersectPOperator method contributeRuntimeOperator.
@Override
public void contributeRuntimeOperator(IHyracksJobBuilder builder, JobGenContext context, ILogicalOperator op, IOperatorSchema opSchema, IOperatorSchema[] inputSchemas, IOperatorSchema outerPlanSchema) throws AlgebricksException {
// logical op should have checked all the mismatch issues.
IntersectOperator logicalOp = (IntersectOperator) op;
int nInput = logicalOp.getNumInput();
int[][] compareFields = new int[nInput][];
IBinaryComparatorFactory[] comparatorFactories = JobGenHelper.variablesToAscBinaryComparatorFactories(logicalOp.getInputVariables(0), context.getTypeEnvironment(op), context);
INormalizedKeyComputerFactoryProvider nkcfProvider = context.getNormalizedKeyComputerFactoryProvider();
INormalizedKeyComputerFactory nkcf = null;
if (nkcfProvider != null) {
Object type = context.getTypeEnvironment(op).getVarType(logicalOp.getInputVariables(0).get(0));
if (type != null) {
nkcf = nkcfProvider.getNormalizedKeyComputerFactory(type, true);
}
}
for (int i = 0; i < logicalOp.getNumInput(); i++) {
compareFields[i] = JobGenHelper.variablesToFieldIndexes(logicalOp.getInputVariables(i), inputSchemas[i]);
}
IOperatorDescriptorRegistry spec = builder.getJobSpec();
RecordDescriptor recordDescriptor = JobGenHelper.mkRecordDescriptor(context.getTypeEnvironment(op), opSchema, context);
IntersectOperatorDescriptor opDescriptor = null;
try {
opDescriptor = new IntersectOperatorDescriptor(spec, nInput, compareFields, nkcf, comparatorFactories, recordDescriptor);
} catch (HyracksException e) {
throw new AlgebricksException(e);
}
contributeOpDesc(builder, (AbstractLogicalOperator) op, opDescriptor);
for (int i = 0; i < op.getInputs().size(); i++) {
builder.contributeGraphEdge(op.getInputs().get(i).getValue(), 0, op, i);
}
}
use of org.apache.hyracks.algebricks.common.exceptions.AlgebricksException in project asterixdb by apache.
the class FullTextContainsParameterCheckRule method checkFirstAndSecondParamter.
/**
* Checks the correctness of the first and second argument. If the argument is a constant, we can check
* it now. If the argument is not a constant, we will defer the checking until run-time.
*/
void checkFirstAndSecondParamter(List<Mutable<ILogicalExpression>> exprs, String functionName) throws AlgebricksException {
// Check the first parameter - Expression1. If it's a constant, then we can check the type here.
ILogicalExpression firstExpr = exprs.get(0).getValue();
if (firstExpr.getExpressionTag() == LogicalExpressionTag.CONSTANT && ConstantExpressionUtil.getConstantIaObjectType(firstExpr) != ATypeTag.STRING) {
throw new AlgebricksException("The first expression of " + functionName + " should be a string.");
}
// Check the second parameter - Expression2. If it's a constant, then we can check the type here.
ILogicalExpression secondExpr = exprs.get(1).getValue();
if (secondExpr.getExpressionTag() == LogicalExpressionTag.CONSTANT) {
ATypeTag exprTypeTag = ConstantExpressionUtil.getConstantIaObjectType(secondExpr);
switch(exprTypeTag) {
case STRING:
case MULTISET:
case ARRAY:
break;
default:
throw new AlgebricksException("The second expression of " + functionName + "should be a string, an unordered list, or an ordered list.");
}
}
}
Aggregations