ASTERIXDB-1228: Add MISSING into the data model.
1. MISSING repsents the value of a non-existing field in a record
or an out-of-bound index access of a collection;
2. NULL represents that the value of an optional field in a record
is unknown or the value of existing collection entry is unknown.
3. Unit tests for all missing/null-in-missing/null-out scalar functions.
Change-Id: Ia49ed8474bfc5d6604231819065117468c5b0897
Reviewed-on: https://asterix-gerrit.ics.uci.edu/846
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/jobgen/QueryLogicalExpressionJobGen.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/jobgen/QueryLogicalExpressionJobGen.java
index f4a926c..37f59dd 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/jobgen/QueryLogicalExpressionJobGen.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/jobgen/QueryLogicalExpressionJobGen.java
@@ -26,7 +26,6 @@
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IExternalFunctionInfo;
import org.apache.asterix.om.functions.IFunctionDescriptor;
-import org.apache.asterix.runtime.evaluators.comparisons.ComparisonEvalFactory;
import org.apache.asterix.runtime.formats.FormatUtils;
import org.apache.commons.lang3.mutable.Mutable;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -40,14 +39,11 @@
import org.apache.hyracks.algebricks.core.algebra.expressions.StatefulFunctionCallExpression;
import org.apache.hyracks.algebricks.core.algebra.expressions.UnnestingFunctionCallExpression;
import org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression;
-import org.apache.hyracks.algebricks.core.algebra.functions.AlgebricksBuiltinFunctions;
-import org.apache.hyracks.algebricks.core.algebra.functions.AlgebricksBuiltinFunctions.ComparisonKind;
-import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import org.apache.hyracks.algebricks.core.algebra.operators.logical.IOperatorSchema;
import org.apache.hyracks.algebricks.core.jobgen.impl.JobGenContext;
import org.apache.hyracks.algebricks.runtime.base.IAggregateEvaluatorFactory;
-import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.algebricks.runtime.base.IRunningAggregateEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluatorFactory;
import org.apache.hyracks.algebricks.runtime.base.IUnnestingEvaluatorFactory;
import org.apache.hyracks.algebricks.runtime.evaluators.ColumnAccessEvalFactory;
@@ -62,7 +58,7 @@
@Override
public IAggregateEvaluatorFactory createAggregateFunctionFactory(AggregateFunctionCallExpression expr,
IVariableTypeEnvironment env, IOperatorSchema[] inputSchemas, JobGenContext context)
- throws AlgebricksException {
+ throws AlgebricksException {
IScalarEvaluatorFactory[] args = codegenArguments(expr, env, inputSchemas, context);
IFunctionDescriptor fd = getFunctionDescriptor(expr, env, context);
switch (fd.getFunctionDescriptorTag()) {
@@ -78,9 +74,9 @@
}
@Override
- public IRunningAggregateEvaluatorFactory createRunningAggregateFunctionFactory(
- StatefulFunctionCallExpression expr, IVariableTypeEnvironment env, IOperatorSchema[] inputSchemas,
- JobGenContext context) throws AlgebricksException {
+ public IRunningAggregateEvaluatorFactory createRunningAggregateFunctionFactory(StatefulFunctionCallExpression expr,
+ IVariableTypeEnvironment env, IOperatorSchema[] inputSchemas, JobGenContext context)
+ throws AlgebricksException {
IScalarEvaluatorFactory[] args = codegenArguments(expr, env, inputSchemas, context);
return getFunctionDescriptor(expr, env, context).createRunningAggregateEvaluatorFactory(args);
}
@@ -88,7 +84,7 @@
@Override
public IUnnestingEvaluatorFactory createUnnestingFunctionFactory(UnnestingFunctionCallExpression expr,
IVariableTypeEnvironment env, IOperatorSchema[] inputSchemas, JobGenContext context)
- throws AlgebricksException {
+ throws AlgebricksException {
IScalarEvaluatorFactory[] args = codegenArguments(expr, env, inputSchemas, context);
return getFunctionDescriptor(expr, env, context).createUnnestingEvaluatorFactory(args);
}
@@ -133,14 +129,8 @@
private IScalarEvaluatorFactory createScalarFunctionEvaluatorFactory(AbstractFunctionCallExpression expr,
IVariableTypeEnvironment env, IOperatorSchema[] inputSchemas, JobGenContext context)
- throws AlgebricksException {
+ throws AlgebricksException {
IScalarEvaluatorFactory[] args = codegenArguments(expr, env, inputSchemas, context);
- FunctionIdentifier fi = expr.getFunctionIdentifier();
- ComparisonKind ck = AlgebricksBuiltinFunctions.getComparisonType(fi);
- if (ck != null) {
- return new ComparisonEvalFactory(args[0], args[1], ck);
- }
-
IFunctionDescriptor fd = null;
if (!(expr.getFunctionInfo() instanceof IExternalFunctionInfo)) {
IDataFormat format = FormatUtils.getDefaultFormat();
@@ -158,8 +148,9 @@
return format.getConstantEvalFactory(expr.getValue());
}
- private IScalarEvaluatorFactory[] codegenArguments(AbstractFunctionCallExpression expr, IVariableTypeEnvironment env,
- IOperatorSchema[] inputSchemas, JobGenContext context) throws AlgebricksException {
+ private IScalarEvaluatorFactory[] codegenArguments(AbstractFunctionCallExpression expr,
+ IVariableTypeEnvironment env, IOperatorSchema[] inputSchemas, JobGenContext context)
+ throws AlgebricksException {
List<Mutable<ILogicalExpression>> arguments = expr.getArguments();
int n = arguments.size();
IScalarEvaluatorFactory[] args = new IScalarEvaluatorFactory[n];
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ByNameToByIndexFieldAccessRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ByNameToByIndexFieldAccessRule.java
index 20bfea5..b4f8ac3 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ByNameToByIndexFieldAccessRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ByNameToByIndexFieldAccessRule.java
@@ -19,7 +19,6 @@
package org.apache.asterix.optimizer.rules;
-import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@@ -85,9 +84,9 @@
ILogicalExpression a0 = fce.getArguments().get(0).getValue();
if (a0.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
LogicalVariable var1 = context.newVar();
- ArrayList<LogicalVariable> varArray = new ArrayList<LogicalVariable>(1);
+ ArrayList<LogicalVariable> varArray = new ArrayList<>(1);
varArray.add(var1);
- ArrayList<Mutable<ILogicalExpression>> exprArray = new ArrayList<Mutable<ILogicalExpression>>(1);
+ ArrayList<Mutable<ILogicalExpression>> exprArray = new ArrayList<>(1);
exprArray.add(new MutableObject<ILogicalExpression>(a0));
AssignOperator assignVar = new AssignOperator(varArray, exprArray);
fce.getArguments().get(0).setValue(new VariableReferenceExpression(var1));
@@ -100,44 +99,37 @@
}
IAType t = (IAType) env.getType(fce.getArguments().get(0).getValue());
- try {
- switch (t.getTypeTag()) {
- case ANY: {
- return false || changed;
+ switch (t.getTypeTag()) {
+ case ANY:
+ return changed;
+ case RECORD:
+ ARecordType recType = (ARecordType) t;
+ ILogicalExpression fai = createFieldAccessByIndex(recType, fce);
+ if (fai == null) {
+ return changed;
}
- case RECORD: {
- ARecordType recType = (ARecordType) t;
- ILogicalExpression fai = createFieldAccessByIndex(recType, fce);
- if (fai == null) {
- return false || changed;
- }
- expressions.get(i).setValue(fai);
- changed = true;
- break;
- }
- case UNION: {
- AUnionType unionT = (AUnionType) t;
- if (unionT.isNullableType()) {
- IAType t2 = unionT.getNullableType();
- if (t2.getTypeTag() == ATypeTag.RECORD) {
- ARecordType recType = (ARecordType) t2;
- ILogicalExpression fai = createFieldAccessByIndex(recType, fce);
- if (fai == null) {
- return false || changed;
- }
- expressions.get(i).setValue(fai);
- changed = true;
- break;
- }
- }
+ expressions.get(i).setValue(fai);
+ changed = true;
+ break;
+ case UNION:
+ AUnionType unionT = (AUnionType) t;
+ if (!unionT.isUnknownableType()) {
throw new NotImplementedException("Union " + unionT);
}
- default: {
+ IAType t2 = unionT.getActualType();
+ if (t2.getTypeTag() != ATypeTag.RECORD) {
throw new AlgebricksException("Cannot call field-access on data of type " + t);
}
- }
- } catch (IOException e) {
- throw new AlgebricksException(e);
+ recType = (ARecordType) t2;
+ fai = createFieldAccessByIndex(recType, fce);
+ if (fai == null) {
+ return changed;
+ }
+ expressions.get(i).setValue(fai);
+ changed = true;
+ break;
+ default:
+ throw new AlgebricksException("Cannot call field-access on data of type " + t);
}
}
assign.removeAnnotation(AsterixOperatorAnnotations.PUSHED_FIELD_ACCESS);
@@ -145,8 +137,8 @@
}
@SuppressWarnings("unchecked")
- private static ILogicalExpression createFieldAccessByIndex(ARecordType recType, AbstractFunctionCallExpression fce)
- throws IOException {
+ private static ILogicalExpression createFieldAccessByIndex(ARecordType recType,
+ AbstractFunctionCallExpression fce) {
String s = getStringSecondArgument(fce);
if (s == null) {
return null;
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/CheckFilterExpressionTypeRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/CheckFilterExpressionTypeRule.java
index cda7619..1400950 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/CheckFilterExpressionTypeRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/CheckFilterExpressionTypeRule.java
@@ -76,8 +76,8 @@
*/
private boolean isPossibleBoolean(IAType type) {
while (NonTaggedFormatUtil.isOptional(type)) {
- type = ((AUnionType) type).getNullableType();
- if (type.getTypeTag() == ATypeTag.BOOLEAN || type.getTypeTag() == ATypeTag.ANY) {
+ IAType actualType = ((AUnionType) type).getActualType();
+ if (actualType.getTypeTag() == ATypeTag.BOOLEAN || actualType.getTypeTag() == ATypeTag.ANY) {
return true;
}
}
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ConstantFoldingRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ConstantFoldingRule.java
index fb48395..b29f110 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ConstantFoldingRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ConstantFoldingRule.java
@@ -25,8 +25,7 @@
import org.apache.asterix.common.config.GlobalConfig;
import org.apache.asterix.dataflow.data.common.AqlExpressionTypeComputer;
-import org.apache.asterix.dataflow.data.common.AqlNullableTypeComputer;
-import org.apache.asterix.dataflow.data.nontagged.AqlNullWriterFactory;
+import org.apache.asterix.dataflow.data.nontagged.AqlMissingWriterFactory;
import org.apache.asterix.formats.nontagged.AqlADMPrinterFactoryProvider;
import org.apache.asterix.formats.nontagged.AqlBinaryBooleanInspectorImpl;
import org.apache.asterix.formats.nontagged.AqlBinaryComparatorFactoryProvider;
@@ -40,7 +39,7 @@
import org.apache.asterix.om.base.IAObject;
import org.apache.asterix.om.constants.AsterixConstantValue;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
+import org.apache.asterix.om.typecomputer.base.TypeCastUtils;
import org.apache.asterix.om.types.ARecordType;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.AbstractCollectionType;
@@ -126,10 +125,9 @@
AqlSerializerDeserializerProvider.INSTANCE, AqlBinaryHashFunctionFactoryProvider.INSTANCE,
AqlBinaryHashFunctionFamilyProvider.INSTANCE, AqlBinaryComparatorFactoryProvider.INSTANCE,
AqlTypeTraitProvider.INSTANCE, AqlBinaryBooleanInspectorImpl.FACTORY, AqlBinaryIntegerInspector.FACTORY,
- AqlADMPrinterFactoryProvider.INSTANCE, AqlNullWriterFactory.INSTANCE, null,
+ AqlADMPrinterFactoryProvider.INSTANCE, AqlMissingWriterFactory.INSTANCE, null,
new LogicalExpressionJobGenToExpressionRuntimeProviderAdapter(QueryLogicalExpressionJobGen.INSTANCE),
- AqlExpressionTypeComputer.INSTANCE, AqlNullableTypeComputer.INSTANCE, null, null, null, null,
- GlobalConfig.DEFAULT_FRAME_SIZE, null);
+ AqlExpressionTypeComputer.INSTANCE, null, null, null, null, GlobalConfig.DEFAULT_FRAME_SIZE, null);
private static final IOperatorSchema[] _emptySchemas = new IOperatorSchema[] {};
@@ -195,7 +193,7 @@
//Current List SerDe assumes a strongly typed list, so we do not constant fold the list constructors if they are not strongly typed
if (expr.getFunctionIdentifier().equals(AsterixBuiltinFunctions.UNORDERED_LIST_CONSTRUCTOR)
|| expr.getFunctionIdentifier().equals(AsterixBuiltinFunctions.ORDERED_LIST_CONSTRUCTOR)) {
- AbstractCollectionType listType = (AbstractCollectionType) TypeComputerUtilities.getRequiredType(expr);
+ AbstractCollectionType listType = (AbstractCollectionType) TypeCastUtils.getRequiredType(expr);
if (listType != null && (listType.getItemType().getTypeTag() == ATypeTag.ANY
|| listType.getItemType() instanceof AbstractCollectionType)) {
//case1: listType == null, could be a nested list inside a list<ANY>
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/FuzzyJoinRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/FuzzyJoinRule.java
index 427eda7..406d4ee 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/FuzzyJoinRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/FuzzyJoinRule.java
@@ -31,8 +31,8 @@
import org.apache.asterix.lang.common.struct.Identifier;
import org.apache.asterix.metadata.declared.AqlMetadataProvider;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
+import org.apache.asterix.om.typecomputer.impl.TypeComputeUtils;
import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.types.TypeHelper;
import org.apache.asterix.optimizer.base.FuzzyUtils;
import org.apache.asterix.translator.AqlPlusExpressionToPlanTranslator;
import org.apache.commons.lang3.mutable.Mutable;
@@ -197,8 +197,8 @@
IAType leftType = (IAType) context.getOutputTypeEnvironment(leftInputOp).getVarType(leftInputVar);
IAType rightType = (IAType) context.getOutputTypeEnvironment(rightInputOp).getVarType(rightInputVar);
// left-hand side and right-hand side of "~=" has the same type
- IAType left2 = TypeHelper.getNonOptionalType(leftType);
- IAType right2 = TypeHelper.getNonOptionalType(rightType);
+ IAType left2 = TypeComputeUtils.getActualType(leftType);
+ IAType right2 = TypeComputeUtils.getActualType(rightType);
if (!left2.deepEqual(right2)) {
return false;
}
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/InlineUnnestFunctionRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/InlineUnnestFunctionRule.java
index 1c27a6e..092c561 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/InlineUnnestFunctionRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/InlineUnnestFunctionRule.java
@@ -22,10 +22,9 @@
import java.util.ArrayList;
import java.util.List;
+import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.commons.lang3.mutable.Mutable;
import org.apache.commons.lang3.mutable.MutableObject;
-
-import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.common.utils.Pair;
import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
@@ -49,7 +48,8 @@
public class InlineUnnestFunctionRule implements IAlgebraicRewriteRule {
@Override
- public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context) throws AlgebricksException {
+ public boolean rewritePre(Mutable<ILogicalOperator> opRef, IOptimizationContext context)
+ throws AlgebricksException {
return false;
}
@@ -57,20 +57,23 @@
public boolean rewritePost(Mutable<ILogicalOperator> opRef, IOptimizationContext context)
throws AlgebricksException {
AbstractLogicalOperator op1 = (AbstractLogicalOperator) opRef.getValue();
- if (context.checkIfInDontApplySet(this, op1))
+ if (context.checkIfInDontApplySet(this, op1)) {
return false;
+ }
context.addToDontApplySet(this, op1);
- if (op1.getOperatorTag() != LogicalOperatorTag.UNNEST)
+ if (op1.getOperatorTag() != LogicalOperatorTag.UNNEST) {
return false;
+ }
UnnestOperator unnestOperator = (UnnestOperator) op1;
AbstractFunctionCallExpression expr = (AbstractFunctionCallExpression) unnestOperator.getExpressionRef()
.getValue();
//we only inline for the scan-collection function
- if (expr.getFunctionIdentifier() != AsterixBuiltinFunctions.SCAN_COLLECTION)
+ if (expr.getFunctionIdentifier() != AsterixBuiltinFunctions.SCAN_COLLECTION) {
return false;
+ }
// inline all variables from an unnesting function call
- AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expr;
+ AbstractFunctionCallExpression funcExpr = expr;
List<Mutable<ILogicalExpression>> args = funcExpr.getArguments();
for (int i = 0; i < args.size(); i++) {
ILogicalExpression argExpr = args.get(i).getValue();
@@ -95,8 +98,8 @@
AbstractFunctionCallExpression expr = (AbstractFunctionCallExpression) unnestOp.getExpressionRef().getValue();
List<Pair<AbstractFunctionCallExpression, Integer>> parentAndIndexList = new ArrayList<Pair<AbstractFunctionCallExpression, Integer>>();
getParentFunctionExpression(usedVar, expr, parentAndIndexList);
- ILogicalExpression usedVarOrginExpr = findUsedVarOrigin(usedVar, unnestOp, (AbstractLogicalOperator) unnestOp
- .getInputs().get(0).getValue());
+ ILogicalExpression usedVarOrginExpr = findUsedVarOrigin(usedVar, unnestOp,
+ (AbstractLogicalOperator) unnestOp.getInputs().get(0).getValue());
if (usedVarOrginExpr != null) {
for (Pair<AbstractFunctionCallExpression, Integer> parentAndIndex : parentAndIndexList) {
//we only rewrite the top scan-collection function
@@ -116,8 +119,9 @@
ILogicalExpression argExpr = args.get(i).getValue();
if (argExpr.getExpressionTag() == LogicalExpressionTag.VARIABLE) {
VariableReferenceExpression varExpr = (VariableReferenceExpression) argExpr;
- if (varExpr.getVariableReference().equals(usedVar))
+ if (varExpr.getVariableReference().equals(usedVar)) {
parentAndIndexList.add(new Pair<AbstractFunctionCallExpression, Integer>(funcExpr, i));
+ }
}
if (argExpr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
getParentFunctionExpression(usedVar, argExpr, parentAndIndexList);
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceAutogenerateIDRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceAutogenerateIDRule.java
index a7327ff..fee1c96 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceAutogenerateIDRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceAutogenerateIDRule.java
@@ -130,7 +130,7 @@
List<Mutable<ILogicalExpression>> args = new ArrayList<>();
args.add(new MutableObject<ILogicalExpression>(mergedRec));
AbstractFunctionCallExpression notNullFn = new ScalarFunctionCallExpression(
- FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.NOT_NULL), args);
+ FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.CHECK_UNKNOWN), args);
return notNullFn;
}
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceDynamicTypeCastForExternalFunctionRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceDynamicTypeCastForExternalFunctionRule.java
index d3370a5..0fb5b0b 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceDynamicTypeCastForExternalFunctionRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceDynamicTypeCastForExternalFunctionRule.java
@@ -121,25 +121,25 @@
IAType inputRecordType = (IAType) env.getVarType(recordVar.get(0));
/** the input record type can be an union type -- for the case when it comes from a subplan or left-outer join */
- boolean checkNull = false;
+ boolean checkUnknown = false;
while (NonTaggedFormatUtil.isOptional(inputRecordType)) {
/** while-loop for the case there is a nested multi-level union */
- inputRecordType = ((AUnionType) inputRecordType).getNullableType();
- checkNull = true;
+ inputRecordType = ((AUnionType) inputRecordType).getActualType();
+ checkUnknown = true;
}
/** see whether the input record type needs to be casted */
boolean cast = !IntroduceDynamicTypeCastRule.compatible(requiredRecordType, inputRecordType);
- if (checkNull) {
+ if (checkUnknown) {
recordVar.set(0, IntroduceDynamicTypeCastRule.addWrapperFunction(requiredRecordType, recordVar.get(0),
- assignOp1, context, AsterixBuiltinFunctions.NOT_NULL));
+ assignOp1, context, AsterixBuiltinFunctions.CHECK_UNKNOWN));
}
if (cast) {
IntroduceDynamicTypeCastRule.addWrapperFunction(requiredRecordType, recordVar.get(0), assignOp1, context,
AsterixBuiltinFunctions.CAST_RECORD);
}
- return cast || checkNull;
+ return cast || checkUnknown;
}
}
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceDynamicTypeCastRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceDynamicTypeCastRule.java
index f8bbba8..a58da0d 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceDynamicTypeCastRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceDynamicTypeCastRule.java
@@ -25,7 +25,7 @@
import org.apache.asterix.lang.common.util.FunctionUtil;
import org.apache.asterix.metadata.declared.AqlDataSource;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
+import org.apache.asterix.om.typecomputer.base.TypeCastUtils;
import org.apache.asterix.om.types.ARecordType;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.AUnionType;
@@ -160,24 +160,24 @@
IAType inputRecordType = (IAType) env.getVarType(recordVar);
/** the input record type can be an union type -- for the case when it comes from a subplan or left-outer join */
- boolean checkNull = false;
+ boolean checkUnknown = false;
while (NonTaggedFormatUtil.isOptional(inputRecordType)) {
/** while-loop for the case there is a nested multi-level union */
- inputRecordType = ((AUnionType) inputRecordType).getNullableType();
- checkNull = true;
+ inputRecordType = ((AUnionType) inputRecordType).getActualType();
+ checkUnknown = true;
}
/** see whether the input record type needs to be casted */
boolean cast = !compatible(requiredRecordType, inputRecordType);
- if (checkNull) {
+ if (checkUnknown) {
recordVar = addWrapperFunction(requiredRecordType, recordVar, op, context,
- AsterixBuiltinFunctions.NOT_NULL);
+ AsterixBuiltinFunctions.CHECK_UNKNOWN);
}
if (cast) {
addWrapperFunction(requiredRecordType, recordVar, op, context, AsterixBuiltinFunctions.CAST_RECORD);
}
- return cast || checkNull;
+ return cast || checkUnknown;
}
/**
@@ -217,7 +217,7 @@
cast.getArguments()
.add(new MutableObject<ILogicalExpression>(new VariableReferenceExpression(var)));
/** enforce the required record type */
- TypeComputerUtilities.setRequiredAndInputTypes(cast, requiredRecordType, actualType);
+ TypeCastUtils.setRequiredAndInputTypes(cast, requiredRecordType, actualType);
LogicalVariable newAssignVar = context.newVar();
AssignOperator newAssignOperator = new AssignOperator(newAssignVar,
new MutableObject<ILogicalExpression>(cast));
@@ -274,7 +274,7 @@
}
IAType reqTypeInside = reqTypes[i];
if (NonTaggedFormatUtil.isOptional(reqTypes[i])) {
- reqTypeInside = ((AUnionType) reqTypes[i]).getNullableType();
+ reqTypeInside = ((AUnionType) reqTypes[i]).getActualType();
}
IAType inputTypeInside = inputTypes[i];
if (NonTaggedFormatUtil.isOptional(inputTypes[i])) {
@@ -282,9 +282,9 @@
/** if the required type is not optional, the two types are incompatible */
return false;
}
- inputTypeInside = ((AUnionType) inputTypes[i]).getNullableType();
+ inputTypeInside = ((AUnionType) inputTypes[i]).getActualType();
}
- if (inputTypeInside.getTypeTag() != ATypeTag.NULL && !reqTypeInside.equals(inputTypeInside)) {
+ if (inputTypeInside.getTypeTag() != ATypeTag.MISSING && !reqTypeInside.equals(inputTypeInside)) {
return false;
}
}
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceEnforcedListTypeRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceEnforcedListTypeRule.java
index 8b2e003..3ff2a1b 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceEnforcedListTypeRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceEnforcedListTypeRule.java
@@ -24,7 +24,7 @@
import org.apache.commons.lang3.mutable.Mutable;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
+import org.apache.asterix.om.typecomputer.base.TypeCastUtils;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.optimizer.rules.typecast.StaticTypeCastUtil;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -89,7 +89,7 @@
AbstractFunctionCallExpression argFuncExpr = (AbstractFunctionCallExpression) expr;
IAType exprType = (IAType) env.getType(argFuncExpr);
if (StaticTypeCastUtil.rewriteListExpr(argFuncExpr, exprType, exprType, env)) {
- TypeComputerUtilities.resetRequiredAndInputTypes(argFuncExpr);
+ TypeCastUtils.resetRequiredAndInputTypes(argFuncExpr);
changed = true;
}
}
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceSecondaryIndexInsertDeleteRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceSecondaryIndexInsertDeleteRule.java
index e3cca9b..0a7d196 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceSecondaryIndexInsertDeleteRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceSecondaryIndexInsertDeleteRule.java
@@ -41,7 +41,7 @@
import org.apache.asterix.om.base.AString;
import org.apache.asterix.om.constants.AsterixConstantValue;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
+import org.apache.asterix.om.typecomputer.base.TypeCastUtils;
import org.apache.asterix.om.types.AOrderedListType;
import org.apache.asterix.om.types.ARecordType;
import org.apache.asterix.om.types.ATypeTag;
@@ -240,7 +240,7 @@
// The first argument is the record
castFunc.getArguments()
.add(new MutableObject<ILogicalExpression>(insertOp.getPayloadExpression().getValue()));
- TypeComputerUtilities.setRequiredAndInputTypes(castFunc, enforcedType, insertRecType);
+ TypeCastUtils.setRequiredAndInputTypes(castFunc, enforcedType, insertRecType);
// AssignOperator puts in the cast var the casted record
AssignOperator castedRecordAssignOperator = new AssignOperator(castedRecVar,
new MutableObject<ILogicalExpression>(castFunc));
@@ -467,7 +467,7 @@
new MutableObject<ILogicalExpression>(new VariableReferenceExpression(secondaryKeyVar)));
}
if (isPointMBR && isBulkload) {
- //for PointMBR optimization: see SecondaryRTreeOperationsHelper.buildLoadingJobSpec() and
+ //for PointMBR optimization: see SecondaryRTreeOperationsHelper.buildLoadingJobSpec() and
//createFieldPermutationForBulkLoadOp(int) for more details.
for (LogicalVariable secondaryKeyVar : keyVarList) {
secondaryExpressions.add(new MutableObject<ILogicalExpression>(
@@ -502,7 +502,7 @@
new VariableReferenceExpression(secondaryKeyVar)));
}
if (isPointMBR && isBulkload) {
- //for PointMBR optimization: see SecondaryRTreeOperationsHelper.buildLoadingJobSpec() and
+ //for PointMBR optimization: see SecondaryRTreeOperationsHelper.buildLoadingJobSpec() and
//createFieldPermutationForBulkLoadOp(int) for more details.
for (LogicalVariable secondaryKeyVar : originalKeyVarList) {
prevSecondaryExpressions.add(new MutableObject<ILogicalExpression>(
@@ -620,8 +620,8 @@
// if a an enforced field already exists and the type is correct
IAType enforcedFieldType = recordNameTypesMap.get(splits.get(splits.size() - 1));
if (enforcedFieldType != null && enforcedFieldType.getTypeTag() == ATypeTag.UNION
- && ((AUnionType) enforcedFieldType).isNullableType()) {
- enforcedFieldType = ((AUnionType) enforcedFieldType).getNullableType();
+ && ((AUnionType) enforcedFieldType).isUnknownableType()) {
+ enforcedFieldType = ((AUnionType) enforcedFieldType).getActualType();
}
if (enforcedFieldType != null && !ATypeHierarchy.canPromote(enforcedFieldType.getTypeTag(),
index.getKeyFieldTypes().get(i).getTypeTag())) {
@@ -731,7 +731,7 @@
continue;
}
ScalarFunctionCallExpression isNullFuncExpr = new ScalarFunctionCallExpression(
- FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.IS_NULL),
+ FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.IS_UNKOWN),
new MutableObject<ILogicalExpression>(new VariableReferenceExpression(secondaryKeyVar)));
ScalarFunctionCallExpression notFuncExpr = new ScalarFunctionCallExpression(
FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.NOT),
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceStaticTypeCastForInsertRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceStaticTypeCastForInsertRule.java
index 223fab3..89280be 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceStaticTypeCastForInsertRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/IntroduceStaticTypeCastForInsertRule.java
@@ -23,7 +23,7 @@
import java.util.List;
import org.apache.asterix.metadata.declared.AqlDataSource;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
+import org.apache.asterix.om.typecomputer.base.TypeCastUtils;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.optimizer.rules.typecast.StaticTypeCastUtil;
import org.apache.commons.lang3.mutable.Mutable;
@@ -144,7 +144,7 @@
AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expr;
// that expression has been rewritten, and it will not
// fail but just return false
- if (TypeComputerUtilities.getRequiredType(funcExpr) != null) {
+ if (TypeCastUtils.getRequiredType(funcExpr) != null) {
context.computeAndSetTypeEnvironmentForOperator(assignOp);
return false;
}
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ReplaceSinkOpWithCommitOpRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ReplaceSinkOpWithCommitOpRule.java
index 0628681..8aefd1a 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ReplaceSinkOpWithCommitOpRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/ReplaceSinkOpWithCommitOpRule.java
@@ -102,17 +102,17 @@
upsertVar = context.newVar();
AbstractFunctionCallExpression orFunc = new ScalarFunctionCallExpression(
FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.OR));
- // is new value null? -> this means that the expected operation is delete
- AbstractFunctionCallExpression isNewNullFunc = new ScalarFunctionCallExpression(
- FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.IS_NULL));
- isNewNullFunc.getArguments().add(insertDeleteUpsertOperator.getPayloadExpression());
- AbstractFunctionCallExpression isPrevNullFunc = new ScalarFunctionCallExpression(
- FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.IS_NULL));
+ // is new value missing? -> this means that the expected operation is delete
+ AbstractFunctionCallExpression isNewMissingFunc = new ScalarFunctionCallExpression(
+ FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.IS_MISSING));
+ isNewMissingFunc.getArguments().add(insertDeleteUpsertOperator.getPayloadExpression());
+ AbstractFunctionCallExpression isPrevMissingFunc = new ScalarFunctionCallExpression(
+ FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.IS_MISSING));
// argument is the previous record
- isPrevNullFunc.getArguments().add(new MutableObject<ILogicalExpression>(
+ isPrevMissingFunc.getArguments().add(new MutableObject<ILogicalExpression>(
new VariableReferenceExpression(insertDeleteUpsertOperator.getPrevRecordVar())));
- orFunc.getArguments().add(new MutableObject<ILogicalExpression>(isPrevNullFunc));
- orFunc.getArguments().add(new MutableObject<ILogicalExpression>(isNewNullFunc));
+ orFunc.getArguments().add(new MutableObject<ILogicalExpression>(isPrevMissingFunc));
+ orFunc.getArguments().add(new MutableObject<ILogicalExpression>(isNewMissingFunc));
// AssignOperator puts in the cast var the casted record
upsertFlagAssign = new AssignOperator(upsertVar, new MutableObject<ILogicalExpression>(orFunc));
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/SetClosedRecordConstructorsRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/SetClosedRecordConstructorsRule.java
index 1af312d..ee55aa1 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/SetClosedRecordConstructorsRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/SetClosedRecordConstructorsRule.java
@@ -21,7 +21,7 @@
import org.apache.asterix.common.config.GlobalConfig;
import org.apache.asterix.lang.common.util.FunctionUtil;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
+import org.apache.asterix.om.typecomputer.base.TypeCastUtils;
import org.apache.asterix.om.types.AOrderedListType;
import org.apache.asterix.om.types.ARecordType;
import org.apache.asterix.om.types.AUnionType;
@@ -108,7 +108,7 @@
boolean allClosed = true;
boolean changed = false;
if (expr.getFunctionIdentifier().equals(AsterixBuiltinFunctions.OPEN_RECORD_CONSTRUCTOR)) {
- ARecordType reqType = (ARecordType) TypeComputerUtilities.getRequiredType(expr);
+ ARecordType reqType = (ARecordType) TypeCastUtils.getRequiredType(expr);
if (reqType == null || !reqType.isOpen()) {
int n = expr.getArguments().size();
if (n % 2 > 0) {
@@ -142,7 +142,7 @@
boolean rewrite = true;
if (expr.getFunctionIdentifier().equals(AsterixBuiltinFunctions.ORDERED_LIST_CONSTRUCTOR)
|| (expr.getFunctionIdentifier().equals(AsterixBuiltinFunctions.UNORDERED_LIST_CONSTRUCTOR))) {
- IAType reqType = TypeComputerUtilities.getRequiredType(expr);
+ IAType reqType = TypeCastUtils.getRequiredType(expr);
if (reqType == null) {
rewrite = false;
}
@@ -172,45 +172,21 @@
throw new AlgebricksException(
"Could not infer type for variable '" + expr.getVariableReference() + "'.");
}
- boolean dataIsClosed = isClosedRec((IAType) varType);
+ boolean dataIsClosed = isClosed((IAType) varType);
return new ClosedDataInfo(false, dataIsClosed, expr);
}
private boolean hasClosedType(ILogicalExpression expr) throws AlgebricksException {
IAType t = (IAType) context.getExpressionTypeComputer().getType(expr, context.getMetadataProvider(), env);
- return isClosedRec(t);
+ return isClosed(t);
}
- private static boolean isClosedRec(IAType t) throws AlgebricksException {
+ private static boolean isClosed(IAType t) throws AlgebricksException {
switch (t.getTypeTag()) {
+ case MISSING:
case ANY: {
return false;
}
- case CIRCLE:
- case INT8:
- case INT16:
- case INT32:
- case INT64:
- case BINARY:
- case BITARRAY:
- case FLOAT:
- case DOUBLE:
- case STRING:
- case LINE:
- case NULL:
- case BOOLEAN:
- case DATETIME:
- case DATE:
- case TIME:
- case UUID:
- case DURATION:
- case YEARMONTHDURATION:
- case DAYTIMEDURATION:
- case INTERVAL:
- case POINT:
- case POINT3D:
- case POLYGON:
- case RECTANGLE:
case SHORTWITHOUTTYPEINFO: {
return true;
}
@@ -219,24 +195,21 @@
}
case UNION: {
AUnionType ut = (AUnionType) t;
- for (IAType t2 : ut.getUnionList()) {
- if (!isClosedRec(t2)) {
- return false;
- }
+ if (!isClosed(ut.getActualType())) {
+ return false;
}
return true;
}
case ORDEREDLIST: {
AOrderedListType ol = (AOrderedListType) t;
- return isClosedRec(ol.getItemType());
+ return isClosed(ol.getItemType());
}
case UNORDEREDLIST: {
AUnorderedListType ul = (AUnorderedListType) t;
- return isClosedRec(ul.getItemType());
+ return isClosed(ul.getItemType());
}
- default: {
- throw new IllegalStateException("Closed type analysis not implemented for type " + t);
- }
+ default:
+ return true;
}
}
}
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AbstractIntroduceAccessMethodRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AbstractIntroduceAccessMethodRule.java
index 0152c12..d17b663 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AbstractIntroduceAccessMethodRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AbstractIntroduceAccessMethodRule.java
@@ -443,7 +443,7 @@
// Need to also verify the index is pending no op
if (index.getKeyFieldNames().contains(fieldName) && index.getPendingOp() == IMetadataEntity.PENDING_NO_OP) {
indexCandidates.add(index);
- if (optFuncExpr.getFieldType(varIdx) == BuiltinType.ANULL
+ if (optFuncExpr.getFieldType(varIdx) == BuiltinType.AMISSING
|| optFuncExpr.getFieldType(varIdx) == BuiltinType.ANY) {
optFuncExpr.setFieldType(varIdx,
index.getKeyFieldTypes().get(index.getKeyFieldNames().indexOf(fieldName)));
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java
index 2ce43c2..db2c627 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/AccessMethodUtils.java
@@ -516,7 +516,7 @@
return primaryIndexUnnestOp;
}
- public static ScalarFunctionCallExpression findLOJIsNullFuncInGroupBy(GroupByOperator lojGroupbyOp)
+ public static ScalarFunctionCallExpression findLOJIsMissingFuncInGroupBy(GroupByOperator lojGroupbyOp)
throws AlgebricksException {
//find IS_NULL function of which argument has the nullPlaceholder variable in the nested plan of groupby.
ALogicalPlanImpl subPlan = (ALogicalPlanImpl) lojGroupbyOp.getNestedPlans().get(0);
@@ -536,7 +536,7 @@
if (notFuncExpr.getArguments().get(0).getValue()
.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
if (((AbstractFunctionCallExpression) notFuncExpr.getArguments().get(0).getValue())
- .getFunctionIdentifier().equals(AlgebricksBuiltinFunctions.IS_NULL)) {
+ .getFunctionIdentifier().equals(AlgebricksBuiltinFunctions.IS_MISSING)) {
isNullFuncExpr = (ScalarFunctionCallExpression) notFuncExpr.getArguments().get(0)
.getValue();
if (isNullFuncExpr.getArguments().get(0).getValue()
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceJoinAccessMethodRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceJoinAccessMethodRule.java
index 8a9bb3f..e1cda09 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceJoinAccessMethodRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/IntroduceJoinAccessMethodRule.java
@@ -158,7 +158,7 @@
if (isLeftOuterJoin && hasGroupBy) {
analysisCtx.setLOJGroupbyOpRef(opRef);
ScalarFunctionCallExpression isNullFuncExpr = AccessMethodUtils
- .findLOJIsNullFuncInGroupBy((GroupByOperator) opRef.getValue());
+ .findLOJIsMissingFuncInGroupBy((GroupByOperator) opRef.getValue());
analysisCtx.setLOJIsNullFuncInGroupBy(isNullFuncExpr);
}
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/InvertedIndexAccessMethod.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/InvertedIndexAccessMethod.java
index 06776ed..305d1a9 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/InvertedIndexAccessMethod.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/am/InvertedIndexAccessMethod.java
@@ -34,7 +34,7 @@
import org.apache.asterix.metadata.entities.Index;
import org.apache.asterix.om.base.AFloat;
import org.apache.asterix.om.base.AInt32;
-import org.apache.asterix.om.base.ANull;
+import org.apache.asterix.om.base.AMissing;
import org.apache.asterix.om.base.AString;
import org.apache.asterix.om.base.IACollection;
import org.apache.asterix.om.base.IAObject;
@@ -142,7 +142,7 @@
public boolean analyzeGetItemFuncExpr(AbstractFunctionCallExpression funcExpr,
List<AbstractLogicalOperator> assignsAndUnnests, AccessMethodAnalysisContext analysisCtx)
- throws AlgebricksException {
+ throws AlgebricksException {
if (funcExpr.getFunctionIdentifier() != AsterixBuiltinFunctions.GET_ITEM) {
return false;
}
@@ -812,7 +812,7 @@
private void addFunctionSpecificArgs(IOptimizableFuncExpr optFuncExpr, InvertedIndexJobGenParams jobGenParams) {
if (optFuncExpr.getFuncExpr().getFunctionIdentifier() == AsterixBuiltinFunctions.STRING_CONTAINS) {
jobGenParams.setSearchModifierType(SearchModifierType.CONJUNCTIVE);
- jobGenParams.setSimilarityThreshold(new AsterixConstantValue(ANull.NULL));
+ jobGenParams.setSimilarityThreshold(new AsterixConstantValue(AMissing.MISSING));
}
if (optFuncExpr.getFuncExpr().getFunctionIdentifier() == AsterixBuiltinFunctions.SIMILARITY_JACCARD_CHECK) {
jobGenParams.setSearchModifierType(SearchModifierType.JACCARD);
@@ -836,7 +836,7 @@
private void addKeyVarsAndExprs(IOptimizableFuncExpr optFuncExpr, ArrayList<LogicalVariable> keyVarList,
ArrayList<Mutable<ILogicalExpression>> keyExprList, IOptimizationContext context)
- throws AlgebricksException {
+ throws AlgebricksException {
// For now we are assuming a single secondary index key.
// Add a variable and its expr to the lists which will be passed into an assign op.
LogicalVariable keyVar = context.newVar();
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/subplan/InlineSubplanInputForNestedTupleSourceRule.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/subplan/InlineSubplanInputForNestedTupleSourceRule.java
index c018e8e..1881461 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/subplan/InlineSubplanInputForNestedTupleSourceRule.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/subplan/InlineSubplanInputForNestedTupleSourceRule.java
@@ -431,8 +431,8 @@
List<Mutable<ILogicalExpression>> args = new ArrayList<Mutable<ILogicalExpression>>();
args.add(filterVarExpr);
List<Mutable<ILogicalExpression>> argsForNotFunction = new ArrayList<Mutable<ILogicalExpression>>();
- argsForNotFunction.add(new MutableObject<ILogicalExpression>(
- new ScalarFunctionCallExpression(FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.IS_NULL), args)));
+ argsForNotFunction.add(new MutableObject<ILogicalExpression>(new ScalarFunctionCallExpression(
+ FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.IS_MISSING), args)));
SelectOperator selectOp = new SelectOperator(
new MutableObject<ILogicalExpression>(new ScalarFunctionCallExpression(
FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.NOT), argsForNotFunction)),
@@ -525,7 +525,7 @@
args.add(filterVarExpr);
List<Mutable<ILogicalExpression>> argsForNotFunction = new ArrayList<Mutable<ILogicalExpression>>();
argsForNotFunction.add(new MutableObject<ILogicalExpression>(new ScalarFunctionCallExpression(
- FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.IS_NULL), args)));
+ FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.IS_MISSING), args)));
nullCheckExprRefs.add(new MutableObject<ILogicalExpression>(new ScalarFunctionCallExpression(
FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.NOT), argsForNotFunction)));
}
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/typecast/StaticTypeCastUtil.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/typecast/StaticTypeCastUtil.java
index c553231..eaf9484 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/typecast/StaticTypeCastUtil.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/optimizer/rules/typecast/StaticTypeCastUtil.java
@@ -31,7 +31,7 @@
import org.apache.asterix.om.constants.AsterixConstantValue;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
+import org.apache.asterix.om.typecomputer.base.TypeCastUtils;
import org.apache.asterix.om.types.ARecordType;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.AUnionType;
@@ -187,14 +187,15 @@
*/
private static boolean rewriteRecordFuncExpr(AbstractFunctionCallExpression funcExpr,
ARecordType requiredRecordType, ARecordType inputRecordType, IVariableTypeEnvironment env)
- throws AlgebricksException {
+ throws AlgebricksException {
// if already rewritten, the required type is not null
- if (TypeComputerUtilities.getRequiredType(funcExpr) != null)
+ if (TypeCastUtils.getRequiredType(funcExpr) != null) {
return false;
+ }
boolean casted = staticRecordTypeCast(funcExpr, requiredRecordType, inputRecordType, env);
if (casted) {
//enforce the required type if it is statically casted
- TypeComputerUtilities.setRequiredAndInputTypes(funcExpr, requiredRecordType, inputRecordType);
+ TypeCastUtils.setRequiredAndInputTypes(funcExpr, requiredRecordType, inputRecordType);
}
return casted;
}
@@ -213,11 +214,12 @@
*/
private static boolean rewriteListFuncExpr(AbstractFunctionCallExpression funcExpr,
AbstractCollectionType requiredListType, AbstractCollectionType inputListType, IVariableTypeEnvironment env)
- throws AlgebricksException {
- if (TypeComputerUtilities.getRequiredType(funcExpr) != null)
+ throws AlgebricksException {
+ if (TypeCastUtils.getRequiredType(funcExpr) != null) {
return false;
+ }
- TypeComputerUtilities.setRequiredAndInputTypes(funcExpr, requiredListType, inputListType);
+ TypeCastUtils.setRequiredAndInputTypes(funcExpr, requiredListType, inputListType);
List<Mutable<ILogicalExpression>> args = funcExpr.getArguments();
IAType itemType = requiredListType.getItemType();
@@ -305,9 +307,9 @@
// match the optional field
if (NonTaggedFormatUtil.isOptional(reqFieldType)) {
- IAType itemType = ((AUnionType) reqFieldType).getNullableType();
+ IAType itemType = ((AUnionType) reqFieldType).getActualType();
reqFieldType = itemType;
- if (fieldType.equals(BuiltinType.ANULL) || fieldType.equals(itemType)) {
+ if (fieldType.equals(BuiltinType.AMISSING) || fieldType.equals(itemType)) {
fieldPermutation[j] = i;
openFields[i] = false;
matched = true;
@@ -324,14 +326,14 @@
// match the optional type input for a non-optional field
// delay that to runtime by calling the not-null function
if (NonTaggedFormatUtil.isOptional(fieldType)) {
- IAType itemType = ((AUnionType) fieldType).getNullableType();
+ IAType itemType = ((AUnionType) fieldType).getActualType();
if (reqFieldType.equals(itemType)) {
fieldPermutation[j] = i;
openFields[i] = false;
matched = true;
ScalarFunctionCallExpression notNullFunc = new ScalarFunctionCallExpression(
- FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.NOT_NULL));
+ FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.CHECK_UNKNOWN));
notNullFunc.getArguments().add(new MutableObject<ILogicalExpression>(arg));
//wrap the not null function to the original function
func.getArguments().get(2 * i + 1).setValue(notNullFunc);
@@ -365,8 +367,9 @@
for (int j = 0; j < inputFieldNames.length; j++) {
String fieldName = inputFieldNames[j];
IAType fieldType = inputFieldTypes[j];
- if (!fieldName.equals(reqFieldName))
+ if (!fieldName.equals(reqFieldName)) {
continue;
+ }
// should check open field here
// because number of entries in fieldPermuations is the
// number of required schema fields
@@ -378,16 +381,18 @@
}
// match the optional field
- if (NonTaggedFormatUtil.isOptional(reqFieldType)) {
- IAType itemType = ((AUnionType) reqFieldType).getNullableType();
- if (fieldType.equals(BuiltinType.ANULL) || fieldType.equals(itemType)) {
- matched = true;
- break;
- }
+ if (!NonTaggedFormatUtil.isOptional(reqFieldType)) {
+ continue;
+ }
+ IAType itemType = ((AUnionType) reqFieldType).getActualType();
+ if (fieldType.equals(BuiltinType.AMISSING) || fieldType.equals(itemType)) {
+ matched = true;
+ break;
}
}
- if (matched)
+ if (matched) {
continue;
+ }
if (NonTaggedFormatUtil.isOptional(reqFieldType)) {
// add a null field
@@ -470,19 +475,18 @@
injectCastFunction(FunctionUtil.getFunctionInfo(fi), reqFieldType, inputFieldType, expRef, argExpr);
castInjected = true;
}
- if (argExpr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
- //recursively rewrite function arguments
- if (TypeComputerUtilities.getRequiredType((AbstractFunctionCallExpression) argExpr) == null
- && reqFieldType != null) {
- if (castInjected) {
- //rewrite the arg expression inside the dynamic cast
- ScalarFunctionCallExpression argFunc = (ScalarFunctionCallExpression) argExpr;
- rewriteFuncExpr(argFunc, inputFieldType, inputFieldType, env);
- } else {
- //rewrite arg
- ScalarFunctionCallExpression argFunc = (ScalarFunctionCallExpression) argExpr;
- rewriteFuncExpr(argFunc, reqFieldType, inputFieldType, env);
- }
+ //recursively rewrite function arguments
+ if (argExpr.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL
+ && TypeCastUtils.getRequiredType((AbstractFunctionCallExpression) argExpr) == null
+ && reqFieldType != null) {
+ if (castInjected) {
+ //rewrite the arg expression inside the dynamic cast
+ ScalarFunctionCallExpression argFunc = (ScalarFunctionCallExpression) argExpr;
+ rewriteFuncExpr(argFunc, inputFieldType, inputFieldType, env);
+ } else {
+ //rewrite arg
+ ScalarFunctionCallExpression argFunc = (ScalarFunctionCallExpression) argExpr;
+ rewriteFuncExpr(argFunc, reqFieldType, inputFieldType, env);
}
}
}
@@ -508,7 +512,7 @@
ScalarFunctionCallExpression cast = new ScalarFunctionCallExpression(funcInfo);
cast.getArguments().add(new MutableObject<ILogicalExpression>(argExpr));
exprRef.setValue(cast);
- TypeComputerUtilities.setRequiredAndInputTypes(cast, reqType, inputType);
+ TypeCastUtils.setRequiredAndInputTypes(cast, reqType, inputType);
}
/**
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/ConstantHelper.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/ConstantHelper.java
index 8a2d3a5..8ded10b 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/ConstantHelper.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/ConstantHelper.java
@@ -29,6 +29,7 @@
import org.apache.asterix.om.base.AFloat;
import org.apache.asterix.om.base.AInt32;
import org.apache.asterix.om.base.AInt64;
+import org.apache.asterix.om.base.AMissing;
import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.AString;
import org.apache.asterix.om.base.IAObject;
@@ -37,38 +38,31 @@
public static IAObject objectFromLiteral(Literal valLiteral) {
switch (valLiteral.getLiteralType()) {
- case DOUBLE: {
+ case DOUBLE:
DoubleLiteral d = (DoubleLiteral) valLiteral;
return new ADouble(d.getValue());
- }
- case FALSE: {
+ case FALSE:
return ABoolean.FALSE;
- }
- case FLOAT: {
+ case FLOAT:
FloatLiteral fl = (FloatLiteral) valLiteral;
return new AFloat(fl.getValue());
- }
- case INTEGER: {
+ case INTEGER:
IntegerLiteral il = (IntegerLiteral) valLiteral;
return new AInt32(il.getValue());
- }
- case LONG: {
- LongIntegerLiteral il = (LongIntegerLiteral) valLiteral;
- return new AInt64(il.getValue());
- }
- case NULL: {
+ case LONG:
+ LongIntegerLiteral ll = (LongIntegerLiteral) valLiteral;
+ return new AInt64(ll.getValue());
+ case MISSING:
+ return AMissing.MISSING;
+ case NULL:
return ANull.NULL;
- }
- case STRING: {
+ case STRING:
StringLiteral sl = (StringLiteral) valLiteral;
return new AString(sl.getValue());
- }
- case TRUE: {
+ case TRUE:
return ABoolean.TRUE;
- }
- default: {
+ default:
throw new IllegalStateException();
- }
}
}
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java
index 551fa85..bfa29ec 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/LangExpressionToPlanTranslator.java
@@ -1363,6 +1363,7 @@
List<Mutable<ILogicalExpression>> argRefs = new ArrayList<>();
argRefs.add(new MutableObject<ILogicalExpression>(expr));
switch (expr.getExpressionTag()) {
+ case CONSTANT:
case VARIABLE: {
return new UnnestingFunctionCallExpression(
FunctionUtil.getFunctionInfo(AsterixBuiltinFunctions.SCAN_COLLECTION), argRefs);
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/TypeTranslator.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/TypeTranslator.java
index 2d405f7..d2dfd30 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/TypeTranslator.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/TypeTranslator.java
@@ -60,7 +60,7 @@
public static Map<TypeSignature, IAType> computeTypes(MetadataTransactionContext mdTxnCtx, TypeExpression typeExpr,
String typeName, String typeDataverse, Map<TypeSignature, IAType> typeMap)
- throws AlgebricksException, MetadataException {
+ throws AlgebricksException, MetadataException {
Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes = new HashMap<String, Map<ARecordType, List<Integer>>>();
Map<TypeSignature, List<AbstractCollectionType>> incompleteItemTypes = new HashMap<TypeSignature, List<AbstractCollectionType>>();
Map<TypeSignature, List<TypeSignature>> incompleteTopLevelTypeReferences = new HashMap<TypeSignature, List<TypeSignature>>();
@@ -69,9 +69,11 @@
secondPass(mdTxnCtx, typeMap, incompleteFieldTypes, incompleteItemTypes, incompleteTopLevelTypeReferences,
typeDataverse);
- for (IAType type : typeMap.values())
- if (type.getTypeTag().isDerivedType())
+ for (IAType type : typeMap.values()) {
+ if (type.getTypeTag().isDerivedType()) {
((AbstractComplexType) type).generateNestedDerivedTypeNames();
+ }
+ }
return typeMap;
}
@@ -81,7 +83,7 @@
Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes,
Map<TypeSignature, List<AbstractCollectionType>> incompleteItemTypes,
Map<TypeSignature, List<TypeSignature>> incompleteTopLevelTypeReferences, String typeDataverse)
- throws AlgebricksException {
+ throws AlgebricksException {
if (builtinTypeMap.get(typeName) != null) {
throw new AlgebricksException("Cannot redefine builtin type " + typeName + " .");
@@ -134,7 +136,7 @@
Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes,
Map<TypeSignature, List<AbstractCollectionType>> incompleteItemTypes,
Map<TypeSignature, List<TypeSignature>> incompleteTopLevelTypeReferences, String typeDataverse)
- throws AlgebricksException, MetadataException {
+ throws AlgebricksException, MetadataException {
// solve remaining top level references
for (TypeSignature typeSignature : incompleteTopLevelTypeReferences.keySet()) {
@@ -143,8 +145,9 @@
typeSignature.getName());
if (dt == null) {
throw new AlgebricksException("Could not resolve type " + typeSignature);
- } else
+ } else {
t = dt.getDatatype();
+ }
for (TypeSignature sign : incompleteTopLevelTypeReferences.get(typeSignature)) {
typeMap.put(sign, t);
}
@@ -155,8 +158,9 @@
Datatype dt = MetadataManager.INSTANCE.getDatatype(mdTxnCtx, typeDataverse, trefName);
if (dt == null) {
throw new AlgebricksException("Could not resolve type " + trefName);
- } else
+ } else {
t = dt.getDatatype();
+ }
Map<ARecordType, List<Integer>> fieldsToFix = incompleteFieldTypes.get(trefName);
for (ARecordType recType : fieldsToFix.keySet()) {
List<Integer> positions = fieldsToFix.get(recType);
@@ -166,7 +170,7 @@
fldTypes[pos] = t;
} else { // nullable
AUnionType nullableUnion = (AUnionType) fldTypes[pos];
- nullableUnion.setTypeAtIndex(t, 1);
+ nullableUnion.setActualType(t);
}
}
}
@@ -195,7 +199,7 @@
private static AOrderedListType computeOrderedListType(TypeSignature typeSignature, OrderedListTypeDefinition oltd,
Map<TypeSignature, IAType> typeMap, Map<TypeSignature, List<AbstractCollectionType>> incompleteItemTypes,
Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes, String defaultDataverse)
- throws AsterixException {
+ throws AsterixException {
TypeExpression tExpr = oltd.getItemTypeExpression();
String typeName = typeSignature != null ? typeSignature.getName() : null;
AOrderedListType aolt = new AOrderedListType(null, typeName);
@@ -207,7 +211,7 @@
UnorderedListTypeDefinition ultd, Map<TypeSignature, IAType> typeMap,
Map<TypeSignature, List<AbstractCollectionType>> incompleteItemTypes,
Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes, String defaulDataverse)
- throws AsterixException {
+ throws AsterixException {
TypeExpression tExpr = ultd.getItemTypeExpression();
String typeName = typeSignature != null ? typeSignature.getName() : null;
AUnorderedListType ault = new AUnorderedListType(null, typeName);
@@ -312,7 +316,7 @@
private static ARecordType computeRecordType(TypeSignature typeSignature, RecordTypeDefinition rtd,
Map<TypeSignature, IAType> typeMap, Map<String, Map<ARecordType, List<Integer>>> incompleteFieldTypes,
Map<TypeSignature, List<AbstractCollectionType>> incompleteItemTypes, String defaultDataverse)
- throws AsterixException {
+ throws AsterixException {
List<String> names = rtd.getFieldNames();
int n = names.size();
String[] fldNames = new String[n];
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/util/FunctionCollection.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/util/FunctionCollection.java
index c575476f..820d935 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/util/FunctionCollection.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/util/FunctionCollection.java
@@ -93,6 +93,12 @@
import org.apache.asterix.runtime.evaluators.accessors.TemporalMonthAccessor;
import org.apache.asterix.runtime.evaluators.accessors.TemporalSecondAccessor;
import org.apache.asterix.runtime.evaluators.accessors.TemporalYearAccessor;
+import org.apache.asterix.runtime.evaluators.comparisons.EqualsDescriptor;
+import org.apache.asterix.runtime.evaluators.comparisons.GreaterThanDescriptor;
+import org.apache.asterix.runtime.evaluators.comparisons.GreaterThanOrEqualsDescriptor;
+import org.apache.asterix.runtime.evaluators.comparisons.LessThanDescriptor;
+import org.apache.asterix.runtime.evaluators.comparisons.LessThanOrEqualsDescriptor;
+import org.apache.asterix.runtime.evaluators.comparisons.NotEqualsDescriptor;
import org.apache.asterix.runtime.evaluators.constructors.ABinaryBase64StringConstructorDescriptor;
import org.apache.asterix.runtime.evaluators.constructors.ABinaryHexStringConstructorDescriptor;
import org.apache.asterix.runtime.evaluators.constructors.ABooleanConstructorDescriptor;
@@ -127,6 +133,7 @@
import org.apache.asterix.runtime.evaluators.functions.AnyCollectionMemberDescriptor;
import org.apache.asterix.runtime.evaluators.functions.CastListDescriptor;
import org.apache.asterix.runtime.evaluators.functions.CastRecordDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.CheckUnknownDescriptor;
import org.apache.asterix.runtime.evaluators.functions.CodePointToStringDescriptor;
import org.apache.asterix.runtime.evaluators.functions.CountHashedGramTokensDescriptor;
import org.apache.asterix.runtime.evaluators.functions.CountHashedWordTokensDescriptor;
@@ -142,21 +149,19 @@
import org.apache.asterix.runtime.evaluators.functions.EditDistanceCheckDescriptor;
import org.apache.asterix.runtime.evaluators.functions.EditDistanceContainsDescriptor;
import org.apache.asterix.runtime.evaluators.functions.EditDistanceDescriptor;
-import org.apache.asterix.runtime.evaluators.functions.EditDistanceListIsFilterable;
-import org.apache.asterix.runtime.evaluators.functions.EditDistanceStringIsFilterable;
-import org.apache.asterix.runtime.evaluators.functions.EmbedTypeDescriptor;
-import org.apache.asterix.runtime.evaluators.functions.FlowRecordDescriptor;
-import org.apache.asterix.runtime.evaluators.functions.FuzzyEqDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.EditDistanceListIsFilterableDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.EditDistanceStringIsFilterableDescriptor;
import org.apache.asterix.runtime.evaluators.functions.GetItemDescriptor;
import org.apache.asterix.runtime.evaluators.functions.GramTokensDescriptor;
import org.apache.asterix.runtime.evaluators.functions.HashedGramTokensDescriptor;
import org.apache.asterix.runtime.evaluators.functions.HashedWordTokensDescriptor;
import org.apache.asterix.runtime.evaluators.functions.InjectFailureDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.IsMissingDescriptor;
import org.apache.asterix.runtime.evaluators.functions.IsNullDescriptor;
import org.apache.asterix.runtime.evaluators.functions.IsSystemNullDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.IsUnknownDescriptor;
import org.apache.asterix.runtime.evaluators.functions.LenDescriptor;
import org.apache.asterix.runtime.evaluators.functions.NotDescriptor;
-import org.apache.asterix.runtime.evaluators.functions.NotNullDescriptor;
import org.apache.asterix.runtime.evaluators.functions.NumericAbsDescriptor;
import org.apache.asterix.runtime.evaluators.functions.NumericAddDescriptor;
import org.apache.asterix.runtime.evaluators.functions.NumericCaretDescriptor;
@@ -235,7 +240,8 @@
import org.apache.asterix.runtime.evaluators.functions.temporal.DatetimeFromUnixTimeInMsDescriptor;
import org.apache.asterix.runtime.evaluators.functions.temporal.DatetimeFromUnixTimeInSecsDescriptor;
import org.apache.asterix.runtime.evaluators.functions.temporal.DayOfWeekDescriptor;
-import org.apache.asterix.runtime.evaluators.functions.temporal.DayTimeDurationComparatorDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.temporal.DayTimeDurationGreaterThanComparatorDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.temporal.DayTimeDurationLessThanComparatorDescriptor;
import org.apache.asterix.runtime.evaluators.functions.temporal.DurationEqualDescriptor;
import org.apache.asterix.runtime.evaluators.functions.temporal.DurationFromIntervalDescriptor;
import org.apache.asterix.runtime.evaluators.functions.temporal.DurationFromMillisecondsDescriptor;
@@ -249,7 +255,7 @@
import org.apache.asterix.runtime.evaluators.functions.temporal.IntervalCoveredByDescriptor;
import org.apache.asterix.runtime.evaluators.functions.temporal.IntervalCoversDescriptor;
import org.apache.asterix.runtime.evaluators.functions.temporal.IntervalEndedByDescriptor;
-import org.apache.asterix.runtime.evaluators.functions.temporal.IntervalEndsDecriptor;
+import org.apache.asterix.runtime.evaluators.functions.temporal.IntervalEndsDescriptor;
import org.apache.asterix.runtime.evaluators.functions.temporal.IntervalMeetsDescriptor;
import org.apache.asterix.runtime.evaluators.functions.temporal.IntervalMetByDescriptor;
import org.apache.asterix.runtime.evaluators.functions.temporal.IntervalOverlappedByDescriptor;
@@ -268,7 +274,8 @@
import org.apache.asterix.runtime.evaluators.functions.temporal.PrintTimeDescriptor;
import org.apache.asterix.runtime.evaluators.functions.temporal.TimeFromDatetimeDescriptor;
import org.apache.asterix.runtime.evaluators.functions.temporal.TimeFromUnixTimeInMsDescriptor;
-import org.apache.asterix.runtime.evaluators.functions.temporal.YearMonthDurationComparatorDecriptor;
+import org.apache.asterix.runtime.evaluators.functions.temporal.YearMonthDurationGreaterThanComparatorDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.temporal.YearMonthDurationLessThanComparatorDescriptor;
import org.apache.asterix.runtime.evaluators.staticcodegen.CodeGenUtil;
import org.apache.asterix.runtime.runningaggregates.std.TidRunningAggregateDescriptor;
import org.apache.asterix.runtime.unnestingfunctions.std.RangeDescriptor;
@@ -281,85 +288,16 @@
public class FunctionCollection {
private static final String FACTORY = "FACTORY";
- private static final List<IFunctionDescriptorFactory> temp = new ArrayList<IFunctionDescriptorFactory>();
+ private static final List<IFunctionDescriptorFactory> temp = new ArrayList<>();
static {
- // format-independent
+ // unnesting function
temp.add(TidRunningAggregateDescriptor.FACTORY);
-
- // format-dependent
- temp.add(AndDescriptor.FACTORY);
- temp.add(OrDescriptor.FACTORY);
- temp.add(StringLikeDescriptor.FACTORY);
temp.add(ScanCollectionDescriptor.FACTORY);
- temp.add(AnyCollectionMemberDescriptor.FACTORY);
- temp.add(ClosedRecordConstructorDescriptor.FACTORY);
- temp.add(FieldAccessByIndexDescriptor.FACTORY);
- temp.add(FieldAccessByNameDescriptor.FACTORY);
- temp.add(FieldAccessNestedDescriptor.FACTORY);
- temp.add(GetRecordFieldsDescriptor.FACTORY);
- temp.add(GetRecordFieldValueDescriptor.FACTORY);
- temp.add(FieldAccessByNameDescriptor.FACTORY);
- temp.add(GetItemDescriptor.FACTORY);
- temp.add(NumericUnaryMinusDescriptor.FACTORY);
- temp.add(OpenRecordConstructorDescriptor.FACTORY);
- temp.add(OrderedListConstructorDescriptor.FACTORY);
- temp.add(UnorderedListConstructorDescriptor.FACTORY);
- temp.add(EmbedTypeDescriptor.FACTORY);
-
- temp.add(NumericAddDescriptor.FACTORY);
- temp.add(NumericDivideDescriptor.FACTORY);
- temp.add(NumericMultiplyDescriptor.FACTORY);
- temp.add(NumericSubDescriptor.FACTORY);
- temp.add(NumericModuloDescriptor.FACTORY);
- temp.add(NumericCaretDescriptor.FACTORY);
- temp.add(IsNullDescriptor.FACTORY);
- temp.add(IsSystemNullDescriptor.FACTORY);
- temp.add(NotDescriptor.FACTORY);
- temp.add(LenDescriptor.FACTORY);
- temp.add(EmptyStreamAggregateDescriptor.FACTORY);
- temp.add(NonEmptyStreamAggregateDescriptor.FACTORY);
temp.add(RangeDescriptor.FACTORY);
+ temp.add(SubsetCollectionDescriptor.FACTORY);
- temp.add(NumericAbsDescriptor.FACTORY);
- temp.add(getGeneratedFunctionDescriptorFactory(NumericCeilingDescriptor.class));
- temp.add(NumericFloorDescriptor.FACTORY);
- temp.add(NumericRoundDescriptor.FACTORY);
- temp.add(NumericRoundHalfToEvenDescriptor.FACTORY);
- temp.add(NumericRoundHalfToEven2Descriptor.FACTORY);
-
- // Binary functions
- temp.add(BinaryLengthDescriptor.FACTORY);
- temp.add(ParseBinaryDescriptor.FACTORY);
- temp.add(PrintBinaryDescriptor.FACTORY);
- temp.add(BinaryConcatDescriptor.FACTORY);
- temp.add(SubBinaryFromDescriptor.FACTORY);
- temp.add(SubBinaryFromToDescriptor.FACTORY);
- temp.add(FindBinaryDescriptor.FACTORY);
- temp.add(FindBinaryFromDescriptor.FACTORY);
-
- // String functions
- temp.add(StringContainsDescriptor.FACTORY);
- temp.add(StringEndsWithDescriptor.FACTORY);
- temp.add(StringStartsWithDescriptor.FACTORY);
- temp.add(getGeneratedFunctionDescriptorFactory(SubstringDescriptor.class));
- temp.add(StringEqualDescriptor.FACTORY);
- temp.add(StringMatchesDescriptor.FACTORY);
- temp.add(getGeneratedFunctionDescriptorFactory(StringLowerCaseDescriptor.class));
- temp.add(getGeneratedFunctionDescriptorFactory(StringUpperCaseDescriptor.class));
- temp.add(StringMatchesWithFlagDescriptor.FACTORY);
- temp.add(StringReplaceDescriptor.FACTORY);
- temp.add(StringReplaceWithFlagsDescriptor.FACTORY);
- temp.add(getGeneratedFunctionDescriptorFactory(StringLengthDescriptor.class));
- temp.add(getGeneratedFunctionDescriptorFactory(Substring2Descriptor.class));
- temp.add(SubstringBeforeDescriptor.FACTORY);
- temp.add(SubstringAfterDescriptor.FACTORY);
- temp.add(StringToCodePointDescriptor.FACTORY);
- temp.add(CodePointToStringDescriptor.FACTORY);
- temp.add(StringConcatDescriptor.FACTORY);
- temp.add(StringJoinDescriptor.FACTORY);
-
- // aggregates
+ // aggregate functions
temp.add(ListifyAggregateDescriptor.FACTORY);
temp.add(CountAggregateDescriptor.FACTORY);
temp.add(AvgAggregateDescriptor.FACTORY);
@@ -388,6 +326,8 @@
temp.add(ScalarSumAggregateDescriptor.FACTORY);
temp.add(ScalarMaxAggregateDescriptor.FACTORY);
temp.add(ScalarMinAggregateDescriptor.FACTORY);
+ temp.add(EmptyStreamAggregateDescriptor.FACTORY);
+ temp.add(NonEmptyStreamAggregateDescriptor.FACTORY);
// SQL aggregates
temp.add(SqlCountAggregateDescriptor.FACTORY);
@@ -418,164 +358,258 @@
temp.add(ScalarSqlMaxAggregateDescriptor.FACTORY);
temp.add(ScalarSqlMinAggregateDescriptor.FACTORY);
- // new functions - constructors
- temp.add(ABooleanConstructorDescriptor.FACTORY);
- temp.add(ANullConstructorDescriptor.FACTORY);
- temp.add(ABinaryHexStringConstructorDescriptor.FACTORY);
- temp.add(ABinaryBase64StringConstructorDescriptor.FACTORY);
- temp.add(AStringConstructorDescriptor.FACTORY);
- temp.add(AInt8ConstructorDescriptor.FACTORY);
- temp.add(AInt16ConstructorDescriptor.FACTORY);
- temp.add(AInt32ConstructorDescriptor.FACTORY);
- temp.add(AInt64ConstructorDescriptor.FACTORY);
- temp.add(AFloatConstructorDescriptor.FACTORY);
- temp.add(ADoubleConstructorDescriptor.FACTORY);
- temp.add(APointConstructorDescriptor.FACTORY);
- temp.add(APoint3DConstructorDescriptor.FACTORY);
- temp.add(ALineConstructorDescriptor.FACTORY);
- temp.add(APolygonConstructorDescriptor.FACTORY);
- temp.add(ACircleConstructorDescriptor.FACTORY);
- temp.add(ARectangleConstructorDescriptor.FACTORY);
- temp.add(ATimeConstructorDescriptor.FACTORY);
- temp.add(ADateConstructorDescriptor.FACTORY);
- temp.add(ADateTimeConstructorDescriptor.FACTORY);
- temp.add(ADurationConstructorDescriptor.FACTORY);
- temp.add(AYearMonthDurationConstructorDescriptor.FACTORY);
- temp.add(ADayTimeDurationConstructorDescriptor.FACTORY);
- temp.add(AUUIDFromStringConstructorDescriptor.FACTORY);
+ // boolean functions
+ temp.add(AndDescriptor.FACTORY);
+ temp.add(OrDescriptor.FACTORY);
- temp.add(DeepEqualityDescriptor.FACTORY);
+ // Record constructors
+ temp.add(ClosedRecordConstructorDescriptor.FACTORY);
+ temp.add(OpenRecordConstructorDescriptor.FACTORY);
- temp.add(CreateUUIDDescriptor.FACTORY);
- temp.add(CreateQueryUIDDescriptor.FACTORY);
- // Spatial
- temp.add(CreatePointDescriptor.FACTORY);
- temp.add(CreateLineDescriptor.FACTORY);
- temp.add(CreatePolygonDescriptor.FACTORY);
- temp.add(CreateCircleDescriptor.FACTORY);
- temp.add(CreateRectangleDescriptor.FACTORY);
- temp.add(SpatialAreaDescriptor.FACTORY);
- temp.add(SpatialDistanceDescriptor.FACTORY);
- temp.add(SpatialIntersectDescriptor.FACTORY);
- temp.add(CreateMBRDescriptor.FACTORY);
- temp.add(SpatialCellDescriptor.FACTORY);
- temp.add(PointXCoordinateAccessor.FACTORY);
- temp.add(PointYCoordinateAccessor.FACTORY);
- temp.add(CircleRadiusAccessor.FACTORY);
- temp.add(CircleCenterAccessor.FACTORY);
- temp.add(LineRectanglePolygonAccessor.FACTORY);
+ // List constructors
+ temp.add(OrderedListConstructorDescriptor.FACTORY);
+ temp.add(UnorderedListConstructorDescriptor.FACTORY);
- // fuzzyjoin function
- temp.add(FuzzyEqDescriptor.FACTORY);
- temp.add(SubsetCollectionDescriptor.FACTORY);
- temp.add(PrefixLenJaccardDescriptor.FACTORY);
-
- temp.add(WordTokensDescriptor.FACTORY);
- temp.add(HashedWordTokensDescriptor.FACTORY);
- temp.add(CountHashedWordTokensDescriptor.FACTORY);
-
- temp.add(GramTokensDescriptor.FACTORY);
- temp.add(HashedGramTokensDescriptor.FACTORY);
- temp.add(CountHashedGramTokensDescriptor.FACTORY);
-
- temp.add(EditDistanceDescriptor.FACTORY);
- temp.add(EditDistanceCheckDescriptor.FACTORY);
- temp.add(EditDistanceStringIsFilterable.FACTORY);
- temp.add(EditDistanceListIsFilterable.FACTORY);
- temp.add(EditDistanceContainsDescriptor.FACTORY);
-
- temp.add(SimilarityJaccardDescriptor.FACTORY);
- temp.add(SimilarityJaccardCheckDescriptor.FACTORY);
- temp.add(SimilarityJaccardSortedDescriptor.FACTORY);
- temp.add(SimilarityJaccardSortedCheckDescriptor.FACTORY);
- temp.add(SimilarityJaccardPrefixDescriptor.FACTORY);
- temp.add(SimilarityJaccardPrefixCheckDescriptor.FACTORY);
-
- //Record functions
- temp.add(RecordMergeDescriptor.FACTORY);
- temp.add(RecordAddFieldsDescriptor.FACTORY);
- temp.add(RecordRemoveFieldsDescriptor.FACTORY);
- temp.add(SwitchCaseDescriptor.FACTORY);
- temp.add(RegExpDescriptor.FACTORY);
+ // Cast functions
temp.add(InjectFailureDescriptor.FACTORY);
temp.add(CastListDescriptor.FACTORY);
temp.add(CastRecordDescriptor.FACTORY);
- temp.add(FlowRecordDescriptor.FACTORY);
- temp.add(NotNullDescriptor.FACTORY);
- // Spatial and temporal type accessors
- temp.add(TemporalYearAccessor.FACTORY);
- temp.add(TemporalMonthAccessor.FACTORY);
- temp.add(TemporalDayAccessor.FACTORY);
- temp.add(TemporalHourAccessor.FACTORY);
- temp.add(TemporalMinuteAccessor.FACTORY);
- temp.add(TemporalSecondAccessor.FACTORY);
- temp.add(TemporalMillisecondAccessor.FACTORY);
- temp.add(TemporalIntervalStartAccessor.FACTORY);
- temp.add(TemporalIntervalEndAccessor.FACTORY);
- temp.add(TemporalIntervalStartDateAccessor.FACTORY);
- temp.add(TemporalIntervalEndDateAccessor.FACTORY);
- temp.add(TemporalIntervalStartTimeAccessor.FACTORY);
- temp.add(TemporalIntervalEndTimeAccessor.FACTORY);
- temp.add(TemporalIntervalStartDatetimeAccessor.FACTORY);
- temp.add(TemporalIntervalEndDatetimeAccessor.FACTORY);
+ // Switch case
+ temp.add(SwitchCaseDescriptor.FACTORY);
- // Temporal functions
- temp.add(DateFromUnixTimeInDaysDescriptor.FACTORY);
- temp.add(DateFromDatetimeDescriptor.FACTORY);
- temp.add(TimeFromUnixTimeInMsDescriptor.FACTORY);
- temp.add(TimeFromDatetimeDescriptor.FACTORY);
- temp.add(DatetimeFromUnixTimeInMsDescriptor.FACTORY);
- temp.add(DatetimeFromUnixTimeInSecsDescriptor.FACTORY);
- temp.add(DatetimeFromDateAndTimeDescriptor.FACTORY);
- temp.add(CalendarDurationFromDateTimeDescriptor.FACTORY);
- temp.add(CalendarDuartionFromDateDescriptor.FACTORY);
- temp.add(AdjustDateTimeForTimeZoneDescriptor.FACTORY);
- temp.add(AdjustTimeForTimeZoneDescriptor.FACTORY);
- temp.add(IntervalBeforeDescriptor.FACTORY);
- temp.add(IntervalAfterDescriptor.FACTORY);
- temp.add(IntervalMeetsDescriptor.FACTORY);
- temp.add(IntervalMetByDescriptor.FACTORY);
- temp.add(IntervalOverlapsDescriptor.FACTORY);
- temp.add(IntervalOverlappedByDescriptor.FACTORY);
- temp.add(OverlapDescriptor.FACTORY);
- temp.add(IntervalStartsDescriptor.FACTORY);
- temp.add(IntervalStartedByDescriptor.FACTORY);
- temp.add(IntervalCoversDescriptor.FACTORY);
- temp.add(IntervalCoveredByDescriptor.FACTORY);
- temp.add(IntervalEndsDecriptor.FACTORY);
- temp.add(IntervalEndedByDescriptor.FACTORY);
+ // null functions
+ temp.add(IsMissingDescriptor.FACTORY);
+ temp.add(IsNullDescriptor.FACTORY);
+ temp.add(IsUnknownDescriptor.FACTORY);
+ temp.add(IsSystemNullDescriptor.FACTORY);
+ temp.add(CheckUnknownDescriptor.FACTORY);
+
+ // uuid generators (zero independent functions)
+ temp.add(CreateUUIDDescriptor.FACTORY);
+ temp.add(CreateQueryUIDDescriptor.FACTORY);
temp.add(CurrentDateDescriptor.FACTORY);
temp.add(CurrentTimeDescriptor.FACTORY);
temp.add(CurrentDateTimeDescriptor.FACTORY);
- temp.add(DurationFromMillisecondsDescriptor.FACTORY);
- temp.add(DurationFromMonthsDescriptor.FACTORY);
- temp.add(YearMonthDurationComparatorDecriptor.GREATER_THAN_FACTORY);
- temp.add(YearMonthDurationComparatorDecriptor.LESS_THAN_FACTORY);
- temp.add(DayTimeDurationComparatorDescriptor.GREATER_THAN_FACTORY);
- temp.add(DayTimeDurationComparatorDescriptor.LESS_THAN_FACTORY);
- temp.add(MonthsFromYearMonthDurationDescriptor.FACTORY);
- temp.add(MillisecondsFromDayTimeDurationDescriptor.FACTORY);
- temp.add(DurationEqualDescriptor.FACTORY);
- temp.add(GetYearMonthDurationDescriptor.FACTORY);
- temp.add(GetDayTimeDurationDescriptor.FACTORY);
- temp.add(IntervalBinDescriptor.FACTORY);
- temp.add(OverlapBinsDescriptor.FACTORY);
- temp.add(DayOfWeekDescriptor.FACTORY);
- temp.add(ParseDateDescriptor.FACTORY);
- temp.add(ParseTimeDescriptor.FACTORY);
- temp.add(ParseDateTimeDescriptor.FACTORY);
- temp.add(PrintDateDescriptor.FACTORY);
- temp.add(PrintTimeDescriptor.FACTORY);
- temp.add(PrintDateTimeDescriptor.FACTORY);
- temp.add(GetOverlappingIntervalDescriptor.FACTORY);
- temp.add(DurationFromIntervalDescriptor.FACTORY);
- // Interval constructor
- temp.add(AIntervalConstructorDescriptor.FACTORY);
- temp.add(AIntervalStartFromDateConstructorDescriptor.FACTORY);
- temp.add(AIntervalStartFromDateTimeConstructorDescriptor.FACTORY);
- temp.add(AIntervalStartFromTimeConstructorDescriptor.FACTORY);
+ // TODO: decide how should we deal these two weird functions as
+ // the number of arguments of the function depend on the first few arguments.
+ temp.add(SimilarityJaccardPrefixDescriptor.FACTORY);
+ temp.add(SimilarityJaccardPrefixCheckDescriptor.FACTORY);
+
+ // functions that need generated class for null-handling.
+ List<IFunctionDescriptorFactory> functionsToInjectUnkownHandling = new ArrayList<>();
+
+ // Element accessors.
+ functionsToInjectUnkownHandling.add(FieldAccessByIndexDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(FieldAccessByNameDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(FieldAccessNestedDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(AnyCollectionMemberDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(GetItemDescriptor.FACTORY);
+
+ // Numeric functions
+ functionsToInjectUnkownHandling.add(NumericUnaryMinusDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(NumericAddDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(NumericDivideDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(NumericMultiplyDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(NumericSubDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(NumericModuloDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(NumericCaretDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(NotDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(LenDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(NumericAbsDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(NumericCeilingDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(NumericFloorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(NumericRoundDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(NumericRoundHalfToEvenDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(NumericRoundHalfToEven2Descriptor.FACTORY);
+
+ // Comparisons.
+ functionsToInjectUnkownHandling.add(EqualsDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(GreaterThanDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(GreaterThanOrEqualsDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(LessThanDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(LessThanOrEqualsDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(NotEqualsDescriptor.FACTORY);
+
+ // Binary functions
+ functionsToInjectUnkownHandling.add(BinaryLengthDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(ParseBinaryDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(PrintBinaryDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(BinaryConcatDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(SubBinaryFromDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(SubBinaryFromToDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(FindBinaryDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(FindBinaryFromDescriptor.FACTORY);
+
+ // String functions
+ functionsToInjectUnkownHandling.add(StringLikeDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(StringContainsDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(StringEndsWithDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(StringStartsWithDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(SubstringDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(StringEqualDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(StringMatchesDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(StringLowerCaseDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(StringUpperCaseDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(StringMatchesWithFlagDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(StringReplaceDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(StringReplaceWithFlagsDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(StringLengthDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(Substring2Descriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(SubstringBeforeDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(SubstringAfterDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(StringToCodePointDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(CodePointToStringDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(StringConcatDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(StringJoinDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(RegExpDescriptor.FACTORY);
+
+ // Constructors
+ functionsToInjectUnkownHandling.add(ABooleanConstructorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(ANullConstructorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(ABinaryHexStringConstructorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(ABinaryBase64StringConstructorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(AStringConstructorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(AInt8ConstructorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(AInt16ConstructorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(AInt32ConstructorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(AInt64ConstructorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(AFloatConstructorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(ADoubleConstructorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(APointConstructorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(APoint3DConstructorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(ALineConstructorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(APolygonConstructorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(ACircleConstructorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(ARectangleConstructorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(ATimeConstructorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(ADateConstructorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(ADateTimeConstructorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(ADurationConstructorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(AYearMonthDurationConstructorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(ADayTimeDurationConstructorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(AUUIDFromStringConstructorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(AIntervalConstructorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(AIntervalStartFromDateConstructorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(AIntervalStartFromDateTimeConstructorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(AIntervalStartFromTimeConstructorDescriptor.FACTORY);
+
+ // Spatial
+ functionsToInjectUnkownHandling.add(CreatePointDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(CreateLineDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(CreatePolygonDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(CreateCircleDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(CreateRectangleDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(SpatialAreaDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(SpatialDistanceDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(SpatialIntersectDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(CreateMBRDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(SpatialCellDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(PointXCoordinateAccessor.FACTORY);
+ functionsToInjectUnkownHandling.add(PointYCoordinateAccessor.FACTORY);
+ functionsToInjectUnkownHandling.add(CircleRadiusAccessor.FACTORY);
+ functionsToInjectUnkownHandling.add(CircleCenterAccessor.FACTORY);
+ functionsToInjectUnkownHandling.add(LineRectanglePolygonAccessor.FACTORY);
+
+ // fuzzyjoin function
+ functionsToInjectUnkownHandling.add(PrefixLenJaccardDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(WordTokensDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(HashedWordTokensDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(CountHashedWordTokensDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(GramTokensDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(HashedGramTokensDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(CountHashedGramTokensDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(EditDistanceDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(EditDistanceCheckDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(EditDistanceStringIsFilterableDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(EditDistanceListIsFilterableDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(EditDistanceContainsDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(SimilarityJaccardDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(SimilarityJaccardCheckDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(SimilarityJaccardSortedDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(SimilarityJaccardSortedCheckDescriptor.FACTORY);
+
+ // Record functions.
+ functionsToInjectUnkownHandling.add(GetRecordFieldsDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(GetRecordFieldValueDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(FieldAccessByNameDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(DeepEqualityDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(RecordMergeDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(RecordAddFieldsDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(RecordRemoveFieldsDescriptor.FACTORY);
+
+ // Spatial and temporal type accessors
+ functionsToInjectUnkownHandling.add(TemporalYearAccessor.FACTORY);
+ functionsToInjectUnkownHandling.add(TemporalMonthAccessor.FACTORY);
+ functionsToInjectUnkownHandling.add(TemporalDayAccessor.FACTORY);
+ functionsToInjectUnkownHandling.add(TemporalHourAccessor.FACTORY);
+ functionsToInjectUnkownHandling.add(TemporalMinuteAccessor.FACTORY);
+ functionsToInjectUnkownHandling.add(TemporalSecondAccessor.FACTORY);
+ functionsToInjectUnkownHandling.add(TemporalMillisecondAccessor.FACTORY);
+ functionsToInjectUnkownHandling.add(TemporalIntervalStartAccessor.FACTORY);
+ functionsToInjectUnkownHandling.add(TemporalIntervalEndAccessor.FACTORY);
+ functionsToInjectUnkownHandling.add(TemporalIntervalStartDateAccessor.FACTORY);
+ functionsToInjectUnkownHandling.add(TemporalIntervalEndDateAccessor.FACTORY);
+ functionsToInjectUnkownHandling.add(TemporalIntervalStartTimeAccessor.FACTORY);
+ functionsToInjectUnkownHandling.add(TemporalIntervalEndTimeAccessor.FACTORY);
+ functionsToInjectUnkownHandling.add(TemporalIntervalStartDatetimeAccessor.FACTORY);
+ functionsToInjectUnkownHandling.add(TemporalIntervalEndDatetimeAccessor.FACTORY);
+
+ // Temporal functions
+ functionsToInjectUnkownHandling.add(DateFromUnixTimeInDaysDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(DateFromDatetimeDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(TimeFromUnixTimeInMsDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(TimeFromDatetimeDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(DatetimeFromUnixTimeInMsDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(DatetimeFromUnixTimeInSecsDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(DatetimeFromDateAndTimeDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(CalendarDurationFromDateTimeDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(CalendarDuartionFromDateDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(AdjustDateTimeForTimeZoneDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(AdjustTimeForTimeZoneDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(IntervalBeforeDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(IntervalAfterDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(IntervalMeetsDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(IntervalMetByDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(IntervalOverlapsDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(IntervalOverlappedByDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(OverlapDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(IntervalStartsDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(IntervalStartedByDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(IntervalCoversDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(IntervalCoveredByDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(IntervalEndsDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(IntervalEndedByDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(DurationFromMillisecondsDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(DurationFromMonthsDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(YearMonthDurationGreaterThanComparatorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(YearMonthDurationLessThanComparatorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(DayTimeDurationGreaterThanComparatorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(DayTimeDurationLessThanComparatorDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(MonthsFromYearMonthDurationDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(MillisecondsFromDayTimeDurationDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(DurationEqualDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(GetYearMonthDurationDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(GetDayTimeDurationDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(IntervalBinDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(OverlapBinsDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(DayOfWeekDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(ParseDateDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(ParseTimeDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(ParseDateTimeDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(PrintDateDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(PrintTimeDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(PrintDateTimeDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(GetOverlappingIntervalDescriptor.FACTORY);
+ functionsToInjectUnkownHandling.add(DurationFromIntervalDescriptor.FACTORY);
+
+ List<IFunctionDescriptorFactory> generatedFactories = new ArrayList<>();
+ for (IFunctionDescriptorFactory factory : functionsToInjectUnkownHandling) {
+ generatedFactories
+ .add(getGeneratedFunctionDescriptorFactory(factory.createFunctionDescriptor().getClass()));
+ }
+ temp.addAll(generatedFactories);
}
public static List<IFunctionDescriptorFactory> getFunctionDescriptorFactories() {
@@ -592,7 +626,8 @@
*/
private static IFunctionDescriptorFactory getGeneratedFunctionDescriptorFactory(Class<?> cl) {
try {
- String className = cl.getName() + CodeGenUtil.DEFAULT_SUFFIX_FOR_GENERATED_CLASS;
+ String className = CodeGenUtil.getGeneratedFunctionDescriptorClassName(cl.getName(),
+ CodeGenUtil.DEFAULT_SUFFIX_FOR_GENERATED_CLASS);
Class<?> generatedCl = cl.getClassLoader().loadClass(className);
Field factory = generatedCl.getDeclaredField(FACTORY);
return (IFunctionDescriptorFactory) factory.get(null);
diff --git a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/util/ValidateUtil.java b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/util/ValidateUtil.java
index 03e3fe8..13153c2 100644
--- a/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/util/ValidateUtil.java
+++ b/asterixdb/asterix-algebra/src/main/java/org/apache/asterix/translator/util/ValidateUtil.java
@@ -160,14 +160,14 @@
List<String> fieldName = keyFieldNames.get(pos);
if (fieldType == null) {
fieldType = keyFieldTypes.get(pos);
- if (keyFieldTypes.get(pos) == BuiltinType.ANULL) {
+ if (keyFieldTypes.get(pos) == BuiltinType.AMISSING) {
throw new AsterixException("A field with this name \"" + fieldName + "\" could not be found.");
}
} else if (openFieldCompositeIdx) {
throw new AsterixException("A closed field \"" + fieldName
+ "\" could be only in a prefix part of the composite index, containing opened field.");
}
- if (keyFieldTypes.get(pos) != BuiltinType.ANULL
+ if (keyFieldTypes.get(pos) != BuiltinType.AMISSING
&& fieldType.getTypeTag() != keyFieldTypes.get(pos).getTypeTag()) {
throw new AsterixException(
"A field \"" + fieldName + "\" is already defined with the type \"" + fieldType + "\"");
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/APIFramework.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/APIFramework.java
index 42b1cc3..5cd049d 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/APIFramework.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/api/common/APIFramework.java
@@ -34,7 +34,7 @@
import org.apache.asterix.compiler.provider.ILangCompilationProvider;
import org.apache.asterix.dataflow.data.common.AqlExpressionTypeComputer;
import org.apache.asterix.dataflow.data.common.AqlMergeAggregationExpressionFactory;
-import org.apache.asterix.dataflow.data.common.AqlNullableTypeComputer;
+import org.apache.asterix.dataflow.data.common.AqlMissableTypeComputer;
import org.apache.asterix.dataflow.data.common.AqlPartialAggregationTypeComputer;
import org.apache.asterix.formats.base.IDataFormat;
import org.apache.asterix.jobgen.QueryLogicalExpressionJobGen;
@@ -64,7 +64,7 @@
import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionEvalSizeComputer;
import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionTypeComputer;
import org.apache.hyracks.algebricks.core.algebra.expressions.IMergeAggregationExpressionFactory;
-import org.apache.hyracks.algebricks.core.algebra.expressions.INullableTypeComputer;
+import org.apache.hyracks.algebricks.core.algebra.expressions.IMissableTypeComputer;
import org.apache.hyracks.algebricks.core.algebra.expressions.LogicalExpressionJobGenToExpressionRuntimeProviderAdapter;
import org.apache.hyracks.algebricks.core.algebra.prettyprint.LogicalOperatorPrettyPrintVisitor;
import org.apache.hyracks.algebricks.core.algebra.prettyprint.PlanPlotter;
@@ -160,10 +160,10 @@
public IOptimizationContext createOptimizationContext(int varCounter,
IExpressionEvalSizeComputer expressionEvalSizeComputer,
IMergeAggregationExpressionFactory mergeAggregationExpressionFactory,
- IExpressionTypeComputer expressionTypeComputer, INullableTypeComputer nullableTypeComputer,
+ IExpressionTypeComputer expressionTypeComputer, IMissableTypeComputer missableTypeComputer,
PhysicalOptimizationConfig physicalOptimizationConfig, AlgebricksPartitionConstraint clusterLocations) {
return new AlgebricksOptimizationContext(varCounter, expressionEvalSizeComputer,
- mergeAggregationExpressionFactory, expressionTypeComputer, nullableTypeComputer,
+ mergeAggregationExpressionFactory, expressionTypeComputer, missableTypeComputer,
physicalOptimizationConfig, clusterLocations);
}
@@ -282,7 +282,7 @@
builder.setIMergeAggregationExpressionFactory(new AqlMergeAggregationExpressionFactory());
builder.setPartialAggregationTypeComputer(new AqlPartialAggregationTypeComputer());
builder.setExpressionTypeComputer(AqlExpressionTypeComputer.INSTANCE);
- builder.setNullableTypeComputer(AqlNullableTypeComputer.INSTANCE);
+ builder.setMissableTypeComputer(AqlMissableTypeComputer.INSTANCE);
builder.setClusterLocations(queryMetadataProvider.getClusterLocations());
ICompiler compiler = compilerFactory.createCompiler(plan, queryMetadataProvider, t.getVarCounter());
@@ -330,7 +330,7 @@
new LogicalExpressionJobGenToExpressionRuntimeProviderAdapter(QueryLogicalExpressionJobGen.INSTANCE));
builder.setHashFunctionFactoryProvider(format.getBinaryHashFunctionFactoryProvider());
builder.setHashFunctionFamilyProvider(format.getBinaryHashFunctionFamilyProvider());
- builder.setNullWriterFactory(format.getNullWriterFactory());
+ builder.setMissingWriterFactory(format.getMissingWriterFactory());
builder.setPredicateEvaluatorFactoryProvider(format.getPredicateEvaluatorFactoryProvider());
switch (conf.fmt()) {
diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/file/SecondaryIndexOperationsHelper.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/file/SecondaryIndexOperationsHelper.java
index 2f017e5..65afe3c 100644
--- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/file/SecondaryIndexOperationsHelper.java
+++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/file/SecondaryIndexOperationsHelper.java
@@ -53,7 +53,7 @@
import org.apache.asterix.om.util.AsterixAppContextInfo;
import org.apache.asterix.runtime.evaluators.functions.AndDescriptor;
import org.apache.asterix.runtime.evaluators.functions.CastRecordDescriptor;
-import org.apache.asterix.runtime.evaluators.functions.IsNullDescriptor;
+import org.apache.asterix.runtime.evaluators.functions.IsUnknownDescriptor;
import org.apache.asterix.runtime.evaluators.functions.NotDescriptor;
import org.apache.asterix.runtime.job.listener.JobEventListenerFactory;
import org.apache.asterix.transaction.management.opcallbacks.PrimaryIndexInstantSearchOperationCallbackFactory;
@@ -436,11 +436,11 @@
RecordDescriptor secondaryRecDesc) throws AlgebricksException {
IScalarEvaluatorFactory[] andArgsEvalFactories = new IScalarEvaluatorFactory[numSecondaryKeyFields];
NotDescriptor notDesc = new NotDescriptor();
- IsNullDescriptor isNullDesc = new IsNullDescriptor();
+ IsUnknownDescriptor isUnknownDesc = new IsUnknownDescriptor();
for (int i = 0; i < numSecondaryKeyFields; i++) {
// Access column i, and apply 'is not null'.
ColumnAccessEvalFactory columnAccessEvalFactory = new ColumnAccessEvalFactory(i);
- IScalarEvaluatorFactory isNullEvalFactory = isNullDesc
+ IScalarEvaluatorFactory isNullEvalFactory = isUnknownDesc
.createEvaluatorFactory(new IScalarEvaluatorFactory[] { columnAccessEvalFactory });
IScalarEvaluatorFactory notEvalFactory = notDesc
.createEvaluatorFactory(new IScalarEvaluatorFactory[] { isNullEvalFactory });
diff --git a/asterixdb/asterix-app/src/test/java/org/apache/asterix/runtime/NullMissingTest.java b/asterixdb/asterix-app/src/test/java/org/apache/asterix/runtime/NullMissingTest.java
new file mode 100644
index 0000000..d4b50a4
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/java/org/apache/asterix/runtime/NullMissingTest.java
@@ -0,0 +1,105 @@
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime;
+
+import static org.mockito.Mockito.mock;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import org.apache.asterix.translator.util.FunctionCollection;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.evaluators.ConstantEvalFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.data.std.api.IPointable;
+import org.apache.hyracks.data.std.primitive.VoidPointable;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class NullMissingTest {
+
+ @Test
+ public void test() throws Exception {
+ List<IFunctionDescriptorFactory> functions = FunctionCollection.getFunctionDescriptorFactories();
+ for (IFunctionDescriptorFactory func : functions) {
+ String className = func.getClass().getName();
+ // We test all generated functions except
+ // record functions, which requires type settings (we test them in runtime tests);
+ if (className.contains("generated") && !className.contains("record")) {
+ testFunction(func);
+ }
+ }
+ }
+
+ private void testFunction(IFunctionDescriptorFactory funcFactory) throws Exception {
+ AbstractScalarFunctionDynamicDescriptor funcDesc = (AbstractScalarFunctionDynamicDescriptor) funcFactory
+ .createFunctionDescriptor();
+ int inputArity = funcDesc.getIdentifier().getArity();
+ Iterator<IScalarEvaluatorFactory[]> argEvalFactoryIterator = getArgCombinations(inputArity);
+ int index = 0;
+ while (argEvalFactoryIterator.hasNext()) {
+ IScalarEvaluatorFactory evalFactory = funcDesc.createEvaluatorFactory(argEvalFactoryIterator.next());
+ IHyracksTaskContext ctx = mock(IHyracksTaskContext.class);
+ IScalarEvaluator evaluator = evalFactory.createScalarEvaluator(ctx);
+ IPointable resultPointable = new VoidPointable();
+ evaluator.evaluate(null, resultPointable);
+ if (index != 0) {
+ Assert.assertTrue(resultPointable.getByteArray()[resultPointable
+ .getStartOffset()] == ATypeTag.SERIALIZED_MISSING_TYPE_TAG);
+ } else {
+ Assert.assertTrue(resultPointable.getByteArray()[resultPointable
+ .getStartOffset()] == ATypeTag.SERIALIZED_NULL_TYPE_TAG);
+ }
+ ++index;
+ }
+ }
+
+ private Iterator<IScalarEvaluatorFactory[]> getArgCombinations(int argSize) {
+ final int numCombinations = 1 << argSize;
+ return new Iterator<IScalarEvaluatorFactory[]>() {
+ private int index = 0;
+
+ @Override
+ public boolean hasNext() {
+ return index < numCombinations;
+ }
+
+ @Override
+ public IScalarEvaluatorFactory[] next() {
+ IScalarEvaluatorFactory[] scalarEvaluatorFactories = new IScalarEvaluatorFactory[argSize];
+ for (int j = 0; j < argSize; ++j) {
+ byte serializedTypeTag = (index & (1 << j)) != 0 ? ATypeTag.SERIALIZED_MISSING_TYPE_TAG
+ : ATypeTag.SERIALIZED_NULL_TYPE_TAG;
+ scalarEvaluatorFactories[j] = new ConstantEvalFactory(new byte[] { serializedTypeTag });
+ }
+ ++index;
+ return scalarEvaluatorFactories;
+ }
+
+ };
+
+ }
+
+}
diff --git a/asterixdb/asterix-app/src/test/resources/metadata/results/basic/metadata_datatype/metadata_datatype.1.adm b/asterixdb/asterix-app/src/test/resources/metadata/results/basic/metadata_datatype/metadata_datatype.1.adm
index 4a303ad..157270f 100644
--- a/asterixdb/asterix-app/src/test/resources/metadata/results/basic/metadata_datatype/metadata_datatype.1.adm
+++ b/asterixdb/asterix-app/src/test/resources/metadata/results/basic/metadata_datatype/metadata_datatype.1.adm
@@ -49,6 +49,7 @@
{ "DataverseName": "Metadata", "DatatypeName": "int8", "Derived": null, "Timestamp": "Thu Dec 17 12:12:59 PST 2015" }
{ "DataverseName": "Metadata", "DatatypeName": "interval", "Derived": null, "Timestamp": "Thu Dec 17 12:12:59 PST 2015" }
{ "DataverseName": "Metadata", "DatatypeName": "line", "Derived": null, "Timestamp": "Thu Dec 17 12:12:59 PST 2015" }
+{ "DataverseName": "Metadata", "DatatypeName": "missing", "Derived": null, "Timestamp": "Mon Apr 25 14:46:17 PDT 2016" }
{ "DataverseName": "Metadata", "DatatypeName": "null", "Derived": null, "Timestamp": "Thu Dec 17 12:12:59 PST 2015" }
{ "DataverseName": "Metadata", "DatatypeName": "point", "Derived": null, "Timestamp": "Thu Dec 17 12:12:59 PST 2015" }
{ "DataverseName": "Metadata", "DatatypeName": "point3d", "Derived": null, "Timestamp": "Thu Dec 17 12:12:59 PST 2015" }
@@ -58,4 +59,4 @@
{ "DataverseName": "Metadata", "DatatypeName": "string", "Derived": null, "Timestamp": "Thu Dec 17 12:12:59 PST 2015" }
{ "DataverseName": "Metadata", "DatatypeName": "time", "Derived": null, "Timestamp": "Thu Dec 17 12:12:59 PST 2015" }
{ "DataverseName": "Metadata", "DatatypeName": "uuid", "Derived": null, "Timestamp": "Thu Dec 17 12:12:59 PST 2015" }
-{ "DataverseName": "Metadata", "DatatypeName": "year-month-duration", "Derived": null, "Timestamp": "Thu Dec 17 12:12:59 PST 2015" }
\ No newline at end of file
+{ "DataverseName": "Metadata", "DatatypeName": "year-month-duration", "Derived": null, "Timestamp": "Thu Dec 17 12:12:59 PST 2015" }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries/semistructured/has-param1/has-param1.3.query.aql b/asterixdb/asterix-app/src/test/resources/runtimets/queries/semistructured/has-param1/has-param1.3.query.aql
index a4240fb..62f7690 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries/semistructured/has-param1/has-param1.3.query.aql
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries/semistructured/has-param1/has-param1.3.query.aql
@@ -20,6 +20,6 @@
set import-private-functions 'true';
for $o in dataset('Orders')
-where not(is-null($o.param1))
-order by $o.oid
+where not(is-missing($o.param1))
+order by $o.oid
return $o
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/lower/lower.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/array/array.1.query.sqlpp
similarity index 97%
rename from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/lower/lower.1.query.sqlpp
rename to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/array/array.1.query.sqlpp
index fbf98ef..dc01561 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/lower/lower.1.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/array/array.1.query.sqlpp
@@ -17,4 +17,4 @@
* under the License.
*/
-LOWER(null);
\ No newline at end of file
+[1, null, missing];
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/lower/lower.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/boolean/boolean.1.query.sqlpp
similarity index 67%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/lower/lower.1.query.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/boolean/boolean.1.query.sqlpp
index fbf98ef..ccb7d66 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/lower/lower.1.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/boolean/boolean.1.query.sqlpp
@@ -17,4 +17,21 @@
* under the License.
*/
-LOWER(null);
\ No newline at end of file
+{
+ '1': null and missing,
+ '2': null or missing,
+ '3': null and true,
+ '4': null and false,
+ '5': missing and true,
+ '6': missing and false,
+ '7': null or true,
+ '8': null or false,
+ '9': missing or true,
+ '10': missing or false,
+ '11': null and null,
+ '12': null or null,
+ '13': missing and missing,
+ '14': missing or missing,
+ '15': true and false,
+ '16': true or false
+};
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/lower/lower.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/ceil/ceil.1.query.sqlpp
similarity index 93%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/lower/lower.1.query.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/ceil/ceil.1.query.sqlpp
index fbf98ef..4896197 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/lower/lower.1.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/ceil/ceil.1.query.sqlpp
@@ -17,4 +17,7 @@
* under the License.
*/
-LOWER(null);
\ No newline at end of file
+{
+ 'null': CEIL(null),
+ 'missing': CEIL(missing)
+};
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/lower/lower.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/field-access/field-access.1.query.sqlpp
similarity index 92%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/lower/lower.1.query.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/field-access/field-access.1.query.sqlpp
index fbf98ef..9658700 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/lower/lower.1.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/field-access/field-access.1.query.sqlpp
@@ -17,4 +17,7 @@
* under the License.
*/
-LOWER(null);
\ No newline at end of file
+{
+ 'null': {'a': null}.a,
+ 'missing': {'b': missing}.b
+};
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/lower/lower.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/length/length.1.query.sqlpp
similarity index 93%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/lower/lower.1.query.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/length/length.1.query.sqlpp
index fbf98ef..7f8615a 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/lower/lower.1.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/length/length.1.query.sqlpp
@@ -17,4 +17,7 @@
* under the License.
*/
-LOWER(null);
\ No newline at end of file
+{
+ 'null': LENGTH(null),
+ 'missing': LENGTH(missing)
+};
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/lower/lower.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/lower/lower.1.query.sqlpp
similarity index 93%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/lower/lower.1.query.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/lower/lower.1.query.sqlpp
index fbf98ef..7c0e51e 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/lower/lower.1.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/lower/lower.1.query.sqlpp
@@ -17,4 +17,7 @@
* under the License.
*/
-LOWER(null);
\ No newline at end of file
+{
+ 'null': LOWER(null),
+ 'missing': LOWER(missing)
+};
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/lower/lower.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/scan-collection/scan-collection.1.query.sqlpp
similarity index 82%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/lower/lower.1.query.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/scan-collection/scan-collection.1.query.sqlpp
index fbf98ef..66c8960 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/lower/lower.1.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/scan-collection/scan-collection.1.query.sqlpp
@@ -17,4 +17,8 @@
* under the License.
*/
-LOWER(null);
\ No newline at end of file
+{
+ 'null': (SELECT ELEMENT item FROM null AS item),
+ 'missing': (SELECT ELEMENT item FROM missing AS item),
+ 'empty_list': (SELECT ELEMENT item FROM [] AS item)
+};
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/substr/substr.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/substr/substr.1.query.sqlpp
similarity index 70%
rename from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/substr/substr.1.query.sqlpp
rename to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/substr/substr.1.query.sqlpp
index bece63a..d6bb472 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/substr/substr.1.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/substr/substr.1.query.sqlpp
@@ -27,5 +27,17 @@
'g': SUBSTR(null, null, 2),
'h': substr(null, 1, null),
'i': SUBSTR(null, null, null),
- 'j': SUBSTR('abc', null, null)
+ 'j': SUBSTR('abc', null, null),
+ 'k': SUBSTR(missing, 1),
+ 'l': SUBSTR('abc', missing),
+ 'm': SUBSTR(missing, missing),
+ 'o': SUBSTR(missing, 1, 2),
+ 'p': substr('abc', missing, 2),
+ 'q': SUBSTR('abc', 1, missing),
+ 'r': SUBSTR(missing, missing, 2),
+ 's': substr(missing, 1, missing),
+ 't': SUBSTR(missing, missing, missing),
+ 'u': SUBSTR('abc', missing, missing),
+ 'v': SUBSTR(null, missing, missing),
+ 'w': SUBSTR(null, null, missing)
};
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/lower/lower.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/upper/upper.1.query.sqlpp
similarity index 93%
copy from asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/lower/lower.1.query.sqlpp
copy to asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/upper/upper.1.query.sqlpp
index fbf98ef..7c8e4f3 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/lower/lower.1.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null-missing/upper/upper.1.query.sqlpp
@@ -17,4 +17,7 @@
* under the License.
*/
-LOWER(null);
\ No newline at end of file
+{
+ 'null': UPPER(null),
+ 'missing': UPPER(missing)
+};
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/ceil/ceil.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/ceil/ceil.1.query.sqlpp
deleted file mode 100644
index c880e2d..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/ceil/ceil.1.query.sqlpp
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-CEIL(null);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/length/length.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/length/length.1.query.sqlpp
deleted file mode 100644
index 034ea1b..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/length/length.1.query.sqlpp
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-LENGTH(null);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/upper/upper.1.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/upper/upper.1.query.sqlpp
deleted file mode 100644
index 367ee62..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/null/upper/upper.1.query.sqlpp
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-UPPER(null);
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/has-param1/has-param1.3.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/has-param1/has-param1.3.query.sqlpp
index ba8ebd4..55123af 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/has-param1/has-param1.3.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/semistructured/has-param1/has-param1.3.query.sqlpp
@@ -24,6 +24,6 @@
select element o
from Orders as o
-where test.not(test."is-null"(o.param1))
+where not("is-missing"(o.param1))
order by o.oid
;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite-open/tinysocial-suite.12.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite-open/tinysocial-suite.12.query.sqlpp
index c4119f1..a8f49a9 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite-open/tinysocial-suite.12.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite-open/tinysocial-suite.12.query.sqlpp
@@ -25,6 +25,6 @@
select element fbu
from FacebookUsers as fbu
-where some e in fbu.employment satisfies TinySocial."is-null"(e."end-date")
+where some e in fbu.employment satisfies TinySocial."is-missing"(e."end-date")
order by fbu.id
;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite-open/tinysocial-suite.13.query.sqlpp b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite-open/tinysocial-suite.13.query.sqlpp
index 5611b99..2de3e41 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite-open/tinysocial-suite.13.query.sqlpp
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/queries_sqlpp/tinysocial/tinysocial-suite-open/tinysocial-suite.13.query.sqlpp
@@ -25,6 +25,6 @@
select element fbu
from FacebookUsers as fbu
-where every e in fbu.employment satisfies TinySocial.not(TinySocial."is-null"(e."end-date"))
+where every e in fbu.employment satisfies TinySocial.not(TinySocial."is-missing"(e."end-date"))
order by fbu.id
;
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/custord/order_q_04/order_q_04.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/custord/order_q_04/order_q_04.1.adm
index aa5c557..fb2d326 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/custord/order_q_04/order_q_04.1.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/custord/order_q_04/order_q_04.1.adm
@@ -1,4 +1,4 @@
-{ "orderid": 1000, "ordertot": 97.20656f, "list": [ [ "1.0f", "yassser" ], [ 11, 14, "yasir", 1.6f ], point("10.1,11.1"), line("10.1,11.1 10.2,11.2"), polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), null ], "item1": [ "1.0f", "yassser" ], "item2": [ 11, 14, "yasir", 1.6f ], "item5": null, "item10": null }
-{ "orderid": 1, "ordertot": 7.206f, "list": [ [ 1.0f, "5.2f", "60" ], [ 13231, "foo", null, 13.25d, 13.2f ], point("10.1,11.1"), line("10.1,11.1 10.2,11.2"), polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), null ], "item1": [ 1.0f, "5.2f", "60" ], "item2": [ 13231, "foo", null, 13.25d, 13.2f ], "item5": null, "item10": null }
-{ "orderid": 100, "ordertot": 124.26f, "list": [ [ 1.3f, 5.2f, "60", 12.32f ], [ 10, 2.0f, 3.0d, 40 ], point("10.1,11.1"), line("10.1,11.1 10.2,11.2"), polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), null ], "item1": [ 1.3f, 5.2f, "60", 12.32f ], "item2": [ 10, 2.0f, 3.0d, 40 ], "item5": null, "item10": null }
-{ "orderid": 10, "ordertot": 14.2326f, "list": [ [ 2.4f, "15" ], [ 110 ], point("10.1,11.1"), line("10.1,11.1 10.2,11.2"), polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), { "oid": 75, "total": 87.61863f } ], "item1": [ 2.4f, "15" ], "item2": [ 110 ], "item5": { "oid": 75, "total": 87.61863f }, "item10": null }
+{ "orderid": 1000, "ordertot": 97.20656f, "list": [ [ "1.0f", "yassser" ], [ 11, 14, "yasir", 1.6f ], point("10.1,11.1"), line("10.1,11.1 10.2,11.2"), polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), null ], "item1": [ "1.0f", "yassser" ], "item2": [ 11, 14, "yasir", 1.6f ], "item5": null }
+{ "orderid": 1, "ordertot": 7.206f, "list": [ [ 1.0f, "5.2f", "60" ], [ 13231, "foo", null, 13.25d, 13.2f ], point("10.1,11.1"), line("10.1,11.1 10.2,11.2"), polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), null ], "item1": [ 1.0f, "5.2f", "60" ], "item2": [ 13231, "foo", null, 13.25d, 13.2f ], "item5": null }
+{ "orderid": 100, "ordertot": 124.26f, "list": [ [ 1.3f, 5.2f, "60", 12.32f ], [ 10, 2.0f, 3.0d, 40 ], point("10.1,11.1"), line("10.1,11.1 10.2,11.2"), polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), null ], "item1": [ 1.3f, 5.2f, "60", 12.32f ], "item2": [ 10, 2.0f, 3.0d, 40 ], "item5": null }
+{ "orderid": 10, "ordertot": 14.2326f, "list": [ [ 2.4f, "15" ], [ 110 ], point("10.1,11.1"), line("10.1,11.1 10.2,11.2"), polygon("1.2,1.3 2.1,2.5 3.5,3.6 4.6,4.8"), { "oid": 75, "total": 87.61863f } ], "item1": [ 2.4f, "15" ], "item2": [ 110 ], "item5": { "oid": 75, "total": 87.61863f } }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/custord/order_q_05/order_q_05.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/custord/order_q_05/order_q_05.1.adm
index 4d0e0c0..7314f94 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/custord/order_q_05/order_q_05.1.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/custord/order_q_05/order_q_05.1.adm
@@ -1,4 +1,4 @@
-{ "orderid": 1000, "ordertot": 97.20656f, "emptyorderedlist": [ ], "emptyunorderedlist": {{ }}, "olist_item1": null, "olist_item5": null, "ulist_item1": null }
-{ "orderid": 1, "ordertot": 7.206f, "emptyorderedlist": [ ], "emptyunorderedlist": {{ }}, "olist_item1": null, "olist_item5": null, "ulist_item1": null }
-{ "orderid": 100, "ordertot": 124.26f, "emptyorderedlist": [ ], "emptyunorderedlist": {{ }}, "olist_item1": null, "olist_item5": null, "ulist_item1": null }
-{ "orderid": 10, "ordertot": 14.2326f, "emptyorderedlist": [ ], "emptyunorderedlist": {{ }}, "olist_item1": null, "olist_item5": null, "ulist_item1": null }
+{ "orderid": 1000, "ordertot": 97.20656f, "emptyorderedlist": [ ], "emptyunorderedlist": {{ }} }
+{ "orderid": 1, "ordertot": 7.206f, "emptyorderedlist": [ ], "emptyunorderedlist": {{ }} }
+{ "orderid": 100, "ordertot": 124.26f, "emptyorderedlist": [ ], "emptyunorderedlist": {{ }} }
+{ "orderid": 10, "ordertot": 14.2326f, "emptyorderedlist": [ ], "emptyunorderedlist": {{ }} }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/array/array.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/array/array.1.adm
new file mode 100644
index 0000000..c239a54
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/array/array.1.adm
@@ -0,0 +1 @@
+[ 1, null, null ]
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/boolean/boolean.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/boolean/boolean.1.adm
new file mode 100644
index 0000000..feb539b
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/boolean/boolean.1.adm
@@ -0,0 +1 @@
+{ "2": null, "3": null, "4": false, "6": false, "7": true, "8": null, "9": true, "11": null, "12": null, "15": false, "16": true }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/ceil/ceil.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/ceil/ceil.1.adm
new file mode 100644
index 0000000..d7a20ef
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/ceil/ceil.1.adm
@@ -0,0 +1 @@
+{ "null": null }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/field-access/field-access.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/field-access/field-access.1.adm
new file mode 100644
index 0000000..d7a20ef
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/field-access/field-access.1.adm
@@ -0,0 +1 @@
+{ "null": null }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/length/length.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/length/length.1.adm
new file mode 100644
index 0000000..d7a20ef
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/length/length.1.adm
@@ -0,0 +1 @@
+{ "null": null }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/lower/lower.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/lower/lower.1.adm
new file mode 100644
index 0000000..d7a20ef
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/lower/lower.1.adm
@@ -0,0 +1 @@
+{ "null": null }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/scan-collection/scan-collection.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/scan-collection/scan-collection.1.adm
new file mode 100644
index 0000000..3a7ad17
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/scan-collection/scan-collection.1.adm
@@ -0,0 +1 @@
+{ "null": null, "empty_list": [ ] }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/null/substr/substr.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/substr/substr.1.adm
similarity index 100%
rename from asterixdb/asterix-app/src/test/resources/runtimets/results/null/substr/substr.1.adm
rename to asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/substr/substr.1.adm
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/upper/upper.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/upper/upper.1.adm
new file mode 100644
index 0000000..d7a20ef
--- /dev/null
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/null-missing/upper/upper.1.adm
@@ -0,0 +1 @@
+{ "null": null }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/null/ceil/ceil.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/null/ceil/ceil.1.adm
deleted file mode 100644
index ec747fa..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/null/ceil/ceil.1.adm
+++ /dev/null
@@ -1 +0,0 @@
-null
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/null/length/length.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/null/length/length.1.adm
deleted file mode 100644
index ec747fa..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/null/length/length.1.adm
+++ /dev/null
@@ -1 +0,0 @@
-null
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/null/lower/lower.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/null/lower/lower.1.adm
deleted file mode 100644
index ec747fa..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/null/lower/lower.1.adm
+++ /dev/null
@@ -1 +0,0 @@
-null
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/null/upper/upper.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/null/upper/upper.1.adm
deleted file mode 100644
index ec747fa..0000000
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/null/upper/upper.1.adm
+++ /dev/null
@@ -1 +0,0 @@
-null
\ No newline at end of file
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/tinysocial/tinysocial-suite-open/query-ASTERIXDB-1329.24.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/tinysocial/tinysocial-suite-open/query-ASTERIXDB-1329.24.adm
index 19da672..72e7ff3 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/tinysocial/tinysocial-suite-open/query-ASTERIXDB-1329.24.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/tinysocial/tinysocial-suite-open/query-ASTERIXDB-1329.24.adm
@@ -1,9 +1,9 @@
-{ "uname": "BramHatch", "alias": "Bram", "msg": "cemail-service is OMG:(" }
-{ "uname": "BramHatch", "alias": "Bram", "msg": "mand is bad:(" }
-{ "uname": "EmoryUnk", "alias": "Emory", "msg": "u is awesome:)" }
-{ "uname": "IsbelDull", "alias": "Isbel", "msg": "s mind-blowing" }
-{ "uname": "IsbelDull", "alias": "Isbel", "msg": "zing" }
-{ "uname": "MargaritaStoddard", "alias": "Margarita", "msg": " is horrible:(" }
-{ "uname": "MargaritaStoddard", "alias": "Margarita", "msg": " terrible" }
-{ "uname": "MargaritaStoddard", "alias": "Margarita", "msg": "een is horrible" }
-{ "uname": "WillisWynne", "alias": "Willis", "msg": "n is mind-blowing" }
+{ "msg": "cemail-service is OMG:(", "uname": "BramHatch", "alias": "Bram" }
+{ "msg": "mand is bad:(", "uname": "BramHatch", "alias": "Bram" }
+{ "msg": "u is awesome:)", "uname": "EmoryUnk", "alias": "Emory" }
+{ "msg": "s mind-blowing", "uname": "IsbelDull", "alias": "Isbel" }
+{ "msg": "zing", "uname": "IsbelDull", "alias": "Isbel" }
+{ "msg": " is horrible:(", "uname": "MargaritaStoddard", "alias": "Margarita" }
+{ "msg": " terrible", "uname": "MargaritaStoddard", "alias": "Margarita" }
+{ "msg": "een is horrible", "uname": "MargaritaStoddard", "alias": "Margarita" }
+{ "msg": "n is mind-blowing", "uname": "WillisWynne", "alias": "Willis" }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results/types/opentype_orderby_01/opentype_orderby_01.1.adm b/asterixdb/asterix-app/src/test/resources/runtimets/results/types/opentype_orderby_01/opentype_orderby_01.1.adm
index 3181666..3486483 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results/types/opentype_orderby_01/opentype_orderby_01.1.adm
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results/types/opentype_orderby_01/opentype_orderby_01.1.adm
@@ -1,49 +1,49 @@
-{ "emp.id": 1, "emp.supvrid": null }
+{ "emp.id": 1 }
{ "emp.id": 2, "emp.supvrid": 1 }
{ "emp.id": 3, "emp.supvrid": 1 }
{ "emp.id": 4, "emp.supvrid": "1" }
{ "emp.id": 5, "emp.supvrid": 1.0d }
-{ "emp.id": 6, "emp.supvrid": null }
+{ "emp.id": 6 }
{ "emp.id": 7, "emp.supvrid": 2 }
{ "emp.id": 8, "emp.supvrid": 2 }
{ "emp.id": 9, "emp.supvrid": "2" }
{ "emp.id": 10, "emp.supvrid": 2.0d }
-{ "emp.id": 11, "emp.supvrid": null }
+{ "emp.id": 11 }
{ "emp.id": 12, "emp.supvrid": 3 }
{ "emp.id": 13, "emp.supvrid": 3 }
{ "emp.id": 14, "emp.supvrid": "3" }
{ "emp.id": 15, "emp.supvrid": 3.0d }
-{ "emp.id": 16, "emp.supvrid": null }
+{ "emp.id": 16 }
{ "emp.id": 17, "emp.supvrid": 4 }
{ "emp.id": 18, "emp.supvrid": 4 }
{ "emp.id": 19, "emp.supvrid": "4" }
{ "emp.id": 20, "emp.supvrid": 4.0d }
-{ "emp.id": 21, "emp.supvrid": null }
+{ "emp.id": 21 }
{ "emp.id": 22, "emp.supvrid": 5 }
{ "emp.id": 23, "emp.supvrid": 5 }
{ "emp.id": 24, "emp.supvrid": "5" }
{ "emp.id": 25, "emp.supvrid": 5.0d }
-{ "emp.id": 26, "emp.supvrid": null }
+{ "emp.id": 26 }
{ "emp.id": 27, "emp.supvrid": 6 }
{ "emp.id": 28, "emp.supvrid": 6 }
{ "emp.id": 29, "emp.supvrid": "6" }
{ "emp.id": 30, "emp.supvrid": 6.0d }
-{ "emp.id": 31, "emp.supvrid": null }
+{ "emp.id": 31 }
{ "emp.id": 32, "emp.supvrid": 7 }
{ "emp.id": 33, "emp.supvrid": 7 }
{ "emp.id": 34, "emp.supvrid": "7" }
{ "emp.id": 35, "emp.supvrid": 7.0d }
-{ "emp.id": 36, "emp.supvrid": null }
+{ "emp.id": 36 }
{ "emp.id": 37, "emp.supvrid": 8 }
{ "emp.id": 38, "emp.supvrid": 8 }
{ "emp.id": 39, "emp.supvrid": "8" }
{ "emp.id": 40, "emp.supvrid": 8.0d }
-{ "emp.id": 41, "emp.supvrid": null }
+{ "emp.id": 41 }
{ "emp.id": 42, "emp.supvrid": 9 }
{ "emp.id": 43, "emp.supvrid": 9 }
{ "emp.id": 44, "emp.supvrid": "9" }
{ "emp.id": 45, "emp.supvrid": 9.0d }
-{ "emp.id": 46, "emp.supvrid": null }
+{ "emp.id": 46 }
{ "emp.id": 47, "emp.supvrid": 10 }
{ "emp.id": 48, "emp.supvrid": 10 }
{ "emp.id": 49, "emp.supvrid": "10" }
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/has-param1/has-param1.3.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/has-param1/has-param1.3.ast
index 5fb8fda..1bdd63d 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/has-param1/has-param1.3.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/semistructured/has-param1/has-param1.3.ast
@@ -11,7 +11,7 @@
]
Where
FunctionCall test.not@1[
- FunctionCall test.is-null@1[
+ FunctionCall test.is-missing@1[
FieldAccessor [
Variable [ Name=$o ]
Field=param1
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite-open/tinysocial-suite.12.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite-open/tinysocial-suite.12.ast
index c6a14c7..e4278c4 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite-open/tinysocial-suite.12.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite-open/tinysocial-suite.12.ast
@@ -18,7 +18,7 @@
]
]
Satifies [
- FunctionCall TinySocial.is-null@1[
+ FunctionCall TinySocial.is-missing@1[
FieldAccessor [
Variable [ Name=$e ]
Field=end-date
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite-open/tinysocial-suite.13.ast b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite-open/tinysocial-suite.13.ast
index 0bc18b9..d82f5bd 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite-open/tinysocial-suite.13.ast
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/results_parser_sqlpp/tinysocial/tinysocial-suite-open/tinysocial-suite.13.ast
@@ -19,7 +19,7 @@
]
Satifies [
FunctionCall TinySocial.not@1[
- FunctionCall TinySocial.is-null@1[
+ FunctionCall TinySocial.is-missing@1[
FieldAccessor [
Variable [ Name=$e ]
Field=end-date
diff --git a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
index b753974..86d5822 100644
--- a/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
+++ b/asterixdb/asterix-app/src/test/resources/runtimets/testsuite_sqlpp.xml
@@ -3582,28 +3582,48 @@
</compilation-unit>
</test-case>
</test-group>
- <test-group name="null">
- <test-case FilePath="null">
+ <test-group name="null-missing">
+ <test-case FilePath="null-missing">
+ <compilation-unit name="array">
+ <output-dir compare="Text">array</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="null-missing">
+ <compilation-unit name="boolean">
+ <output-dir compare="Text">boolean</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="null-missing">
<compilation-unit name="ceil">
<output-dir compare="Text">ceil</output-dir>
</compilation-unit>
</test-case>
- <test-case FilePath="null">
+ <test-case FilePath="null-missing">
+ <compilation-unit name="field-access">
+ <output-dir compare="Text">field-access</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="null-missing">
<compilation-unit name="length">
<output-dir compare="Text">length</output-dir>
</compilation-unit>
</test-case>
- <test-case FilePath="null">
+ <test-case FilePath="null-missing">
<compilation-unit name="lower">
<output-dir compare="Text">lower</output-dir>
</compilation-unit>
</test-case>
- <test-case FilePath="null">
+ <test-case FilePath="null-missing">
+ <compilation-unit name="scan-collection">
+ <output-dir compare="Text">scan-collection</output-dir>
+ </compilation-unit>
+ </test-case>
+ <test-case FilePath="null-missing">
<compilation-unit name="substr">
<output-dir compare="Text">substr</output-dir>
</compilation-unit>
</test-case>
- <test-case FilePath="null">
+ <test-case FilePath="null-missing">
<compilation-unit name="upper">
<output-dir compare="Text">upper</output-dir>
</compilation-unit>
diff --git a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/dataflow/AsterixLSMTreeInsertDeleteOperatorDescriptor.java b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/dataflow/AsterixLSMTreeInsertDeleteOperatorDescriptor.java
index c7304a1..d78abb6 100644
--- a/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/dataflow/AsterixLSMTreeInsertDeleteOperatorDescriptor.java
+++ b/asterixdb/asterix-common/src/main/java/org/apache/asterix/common/dataflow/AsterixLSMTreeInsertDeleteOperatorDescriptor.java
@@ -21,7 +21,7 @@
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.dataflow.IOperatorNodePushable;
import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.IRecordDescriptorProvider;
import org.apache.hyracks.api.dataflow.value.ITypeTraits;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
@@ -52,7 +52,8 @@
IBinaryComparatorFactory[] comparatorFactories, int[] bloomFilterKeyFields, int[] fieldPermutation,
IndexOperation op, IIndexDataflowHelperFactory dataflowHelperFactory,
ITupleFilterFactory tupleFilterFactory, boolean isPrimary, String indexName,
- INullWriterFactory nullWriterFactory, IModificationOperationCallbackFactory modificationOpCallbackProvider,
+ IMissingWriterFactory nullWriterFactory,
+ IModificationOperationCallbackFactory modificationOpCallbackProvider,
ISearchOperationCallbackFactory searchOpCallbackProvider) {
super(spec, recDesc, storageManager, lifecycleManagerProvider, fileSplitProvider, typeTraits,
comparatorFactories, bloomFilterKeyFields, fieldPermutation, op, dataflowHelperFactory,
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/adapter/factory/LookupAdapterFactory.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/adapter/factory/LookupAdapterFactory.java
index 49c5943..fa6897f 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/adapter/factory/LookupAdapterFactory.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/adapter/factory/LookupAdapterFactory.java
@@ -35,7 +35,7 @@
import org.apache.asterix.om.types.ARecordType;
import org.apache.hyracks.api.comm.IFrameWriter;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
import org.apache.hyracks.api.exceptions.HyracksDataException;
@@ -49,16 +49,16 @@
private final int[] ridFields;
private Map<String, String> configuration;
private final boolean retainInput;
- private final boolean retainNull;
- private final INullWriterFactory iNullWriterFactory;
+ private final boolean retainMissing;
+ private final IMissingWriterFactory isMissingWriterFactory;
public LookupAdapterFactory(ARecordType recordType, int[] ridFields, boolean retainInput, boolean retainNull,
- INullWriterFactory iNullWriterFactory) {
+ IMissingWriterFactory iNullWriterFactory) {
this.recordType = recordType;
this.ridFields = ridFields;
this.retainInput = retainInput;
- this.retainNull = retainNull;
- this.iNullWriterFactory = iNullWriterFactory;
+ this.retainMissing = retainNull;
+ this.isMissingWriterFactory = iNullWriterFactory;
}
public LookupAdapter<T> createAdapter(IHyracksTaskContext ctx, int partition, RecordDescriptor inRecDesc,
@@ -69,8 +69,8 @@
snapshotAccessor);
reader.configure(configuration);
RecordIdReader ridReader = RecordIdReaderFactory.create(configuration, ridFields);
- return new LookupAdapter<T>(dataParser, reader, inRecDesc, ridReader, retainInput, retainNull,
- iNullWriterFactory, ctx, writer);
+ return new LookupAdapter<>(dataParser, reader, inRecDesc, ridReader, retainInput, retainMissing,
+ isMissingWriterFactory, ctx, writer);
} catch (Exception e) {
throw new HyracksDataException(e);
}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataset/adapter/LookupAdapter.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataset/adapter/LookupAdapter.java
index 69cd063..baf5dba 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataset/adapter/LookupAdapter.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/dataset/adapter/LookupAdapter.java
@@ -31,8 +31,8 @@
import org.apache.hyracks.api.comm.IFrameWriter;
import org.apache.hyracks.api.comm.VSizeFrame;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.INullWriter;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriter;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder;
@@ -52,11 +52,11 @@
private FrameTupleAccessor tupleAccessor;
private IFrameWriter writer;
private FrameTupleReference frameTuple;
- private ArrayTupleBuilder nullTupleBuild;
+ private ArrayTupleBuilder missingTupleBuild;
public LookupAdapter(IRecordDataParser<T> dataParser, ILookupRecordReader<? extends T> recordReader,
RecordDescriptor inRecDesc, RecordIdReader ridReader, boolean propagateInput, boolean retainNull,
- INullWriterFactory iNullWriterFactory, IHyracksTaskContext ctx, IFrameWriter writer)
+ IMissingWriterFactory iNullWriterFactory, IHyracksTaskContext ctx, IFrameWriter writer)
throws HyracksDataException {
this.dataParser = dataParser;
this.recordReader = recordReader;
@@ -70,7 +70,7 @@
this.writer = writer;
}
- private void configurePropagation(INullWriterFactory iNullWriterFactory) {
+ private void configurePropagation(IMissingWriterFactory iNullWriterFactory) {
if (propagateInput) {
// This LookupAdapter generates an external record as its output.
// Thus, we add 1.
@@ -80,16 +80,16 @@
tb = new ArrayTupleBuilder(1);
}
if (retainNull) {
- INullWriter nullWriter = iNullWriterFactory.createNullWriter();
- nullTupleBuild = new ArrayTupleBuilder(1);
- DataOutput out = nullTupleBuild.getDataOutput();
+ IMissingWriter missingWriter = iNullWriterFactory.createMissingWriter();
+ missingTupleBuild = new ArrayTupleBuilder(1);
+ DataOutput out = missingTupleBuild.getDataOutput();
try {
- nullWriter.writeNull(out);
+ missingWriter.writeMissing(out);
} catch (IOException e) {
e.printStackTrace();
}
} else {
- nullTupleBuild = null;
+ missingTupleBuild = null;
}
}
@@ -131,7 +131,7 @@
tb.addFieldEndOffset();
DataflowUtils.addTupleToFrame(appender, tb, writer);
} else if (retainNull) {
- tb.getDataOutput().write(nullTupleBuild.getByteArray());
+ tb.getDataOutput().write(missingTupleBuild.getByteArray());
tb.addFieldEndOffset();
DataflowUtils.addTupleToFrame(appender, tb, writer);
}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/RecordIdReader.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/RecordIdReader.java
index 2b4cc9c..5de2d9d 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/RecordIdReader.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/indexing/RecordIdReader.java
@@ -31,7 +31,7 @@
public class RecordIdReader {
- private final static byte nullByte = ATypeTag.NULL.serialize();
+ private final static byte MISSING_BYTE = ATypeTag.SERIALIZED_MISSING_TYPE_TAG;
protected FrameTupleAccessor tupleAccessor;
protected int fieldSlotsLength;
protected int[] ridFields;
@@ -60,7 +60,7 @@
int fileNumberStartOffset = tupleAccessor.getFieldStartOffset(index,
ridFields[IndexingConstants.FILE_NUMBER_FIELD_INDEX]);
frameBuffer = tupleAccessor.getBuffer();
- if (frameBuffer.get(tupleStartOffset + fileNumberStartOffset) == nullByte) {
+ if (frameBuffer.get(tupleStartOffset + fileNumberStartOffset) == MISSING_BYTE) {
return null;
}
// Get file number
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalFunctionProvider.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalFunctionProvider.java
index df0ddc8..4f5242e 100755
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalFunctionProvider.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/ExternalFunctionProvider.java
@@ -77,12 +77,12 @@
((IExternalScalarFunction) externalFunction).evaluate(argumentProvider);
/*
* Make sure that if "setResult" is not called,
- * or the result object is null we let Hyracks storage manager know
- * we want to discard a null object
+ * or the result object is missing we let Hyracks storage manager know
+ * we want to discard a missing object
*/
byte byteOutput = resultBuffer.getByteArray()[0];
- if (!argumentProvider.isValidResult() || byteOutput == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- resultBuffer.getDataOutput().writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
+ if (!argumentProvider.isValidResult() || byteOutput == ATypeTag.SERIALIZED_MISSING_TYPE_TAG) {
+ resultBuffer.getDataOutput().writeByte(ATypeTag.SERIALIZED_MISSING_TYPE_TAG);
}
}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/JTypeObjectFactory.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/JTypeObjectFactory.java
index cdd29ff..e2ed092 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/JTypeObjectFactory.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/JTypeObjectFactory.java
@@ -18,8 +18,6 @@
*/
package org.apache.asterix.external.library;
-import java.util.List;
-
import org.apache.asterix.external.api.IJObject;
import org.apache.asterix.external.library.java.JObjects.JBoolean;
import org.apache.asterix.external.library.java.JObjects.JCircle;
@@ -43,7 +41,6 @@
import org.apache.asterix.external.library.java.JObjects.JUnorderedList;
import org.apache.asterix.om.types.AOrderedListType;
import org.apache.asterix.om.types.ARecordType;
-import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.AUnionType;
import org.apache.asterix.om.types.AUnorderedListType;
import org.apache.asterix.om.types.IAType;
@@ -135,18 +132,16 @@
break;
case UNION:
AUnionType unionType = (AUnionType) type;
- List<IAType> unionList = unionType.getUnionList();
IJObject itemObject = null;
- for (IAType elementType : unionList) {
- if (!elementType.getTypeTag().equals(ATypeTag.NULL)) {
- itemObject = create(elementType);
- break;
- }
+ if (unionType.isMissableType()) {
+ itemObject = create(unionType);
}
- return retValue = itemObject;
+ retValue = itemObject;
+ break;
default:
break;
}
return retValue;
}
+
}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjectUtil.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjectUtil.java
index ed3cd32..0630985 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjectUtil.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjectUtil.java
@@ -254,17 +254,18 @@
dis.readInt(); // list size
int numberOfitems;
numberOfitems = dis.readInt();
- if (numberOfitems > 0) {
- if (!fixedSize) {
- for (int i = 0; i < numberOfitems; i++)
- dis.readInt();
- }
+ if (numberOfitems <= 0) {
+ break;
+ }
+ if (!fixedSize) {
for (int i = 0; i < numberOfitems; i++) {
- IJObject v = getJType(elementType.getTypeTag(), elementType, dis, objectPool);
- ((JUnorderedList) jObject).add(v);
+ dis.readInt();
}
}
-
+ for (int i = 0; i < numberOfitems; i++) {
+ IJObject v = getJType(elementType.getTypeTag(), elementType, dis, objectPool);
+ ((JUnorderedList) jObject).add(v);
+ }
break;
}
case ORDEREDLIST: {
@@ -289,17 +290,18 @@
dis.readInt(); // list size
int numberOfitems;
numberOfitems = dis.readInt();
- if (numberOfitems > 0) {
- if (!fixedSize) {
- for (int i = 0; i < numberOfitems; i++)
- dis.readInt();
- }
+ if (numberOfitems <= 0) {
+ break;
+ }
+ if (!fixedSize) {
for (int i = 0; i < numberOfitems; i++) {
- IJObject v = getJType(elementType.getTypeTag(), elementType, dis, objectPool);
- ((JOrderedList) jObject).add(v);
+ dis.readInt();
}
}
-
+ for (int i = 0; i < numberOfitems; i++) {
+ IJObject v = getJType(elementType.getTypeTag(), elementType, dis, objectPool);
+ ((JOrderedList) jObject).add(v);
+ }
break;
}
case RECORD:
@@ -348,7 +350,7 @@
IAType fieldType = fieldTypes[fieldNumber];
if (fieldTypes[fieldNumber].getTypeTag() == ATypeTag.UNION) {
if (((AUnionType) fieldTypes[fieldNumber]).isNullableType()) {
- fieldType = ((AUnionType) fieldTypes[fieldNumber]).getNullableType();
+ fieldType = ((AUnionType) fieldTypes[fieldNumber]).getActualType();
fieldValueTypeTag = fieldType.getTypeTag();
}
} else {
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjects.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjects.java
index a0e66b1..ebda69c 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjects.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/library/java/JObjects.java
@@ -143,7 +143,7 @@
public void serialize(DataOutput dataOutput, boolean writeTypeTag) throws HyracksDataException {
if (writeTypeTag) {
try {
- dataOutput.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
+ dataOutput.writeByte(ATypeTag.SERIALIZED_MISSING_TYPE_TAG);
} catch (IOException e) {
throw new HyracksDataException(e);
}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalBTreeSearchOperatorDescriptor.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalBTreeSearchOperatorDescriptor.java
index 26c9c7d..c1903e0 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalBTreeSearchOperatorDescriptor.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalBTreeSearchOperatorDescriptor.java
@@ -21,7 +21,7 @@
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.dataflow.IOperatorNodePushable;
import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.IRecordDescriptorProvider;
import org.apache.hyracks.api.dataflow.value.ITypeTraits;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
@@ -42,11 +42,11 @@
IFileSplitProvider fileSplitProvider, ITypeTraits[] typeTraits,
IBinaryComparatorFactory[] comparatorFactories, int[] bloomFilterKeyFields, int[] lowKeyFields,
int[] highKeyFields, boolean lowKeyInclusive, boolean highKeyInclusive,
- IIndexDataflowHelperFactory dataflowHelperFactory, boolean retainInput, boolean retainNull,
- INullWriterFactory iNullWriterFactory, ISearchOperationCallbackFactory searchOpCallbackProvider) {
+ IIndexDataflowHelperFactory dataflowHelperFactory, boolean retainInput, boolean retainMissing,
+ IMissingWriterFactory missingWriterFactory, ISearchOperationCallbackFactory searchOpCallbackProvider) {
super(spec, recDesc, storageManager, lifecycleManagerProvider, fileSplitProvider, typeTraits,
comparatorFactories, bloomFilterKeyFields, lowKeyFields, highKeyFields, lowKeyInclusive,
- highKeyInclusive, dataflowHelperFactory, retainInput, retainNull, iNullWriterFactory,
+ highKeyInclusive, dataflowHelperFactory, retainInput, retainMissing, missingWriterFactory,
searchOpCallbackProvider, null, null);
}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalBTreeSearchOperatorNodePushable.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalBTreeSearchOperatorNodePushable.java
index 9435387..9b83a12 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalBTreeSearchOperatorNodePushable.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalBTreeSearchOperatorNodePushable.java
@@ -51,20 +51,20 @@
accessor = new FrameTupleAccessor(inputRecDesc);
dataFlowHelper.open();
index = indexHelper.getIndexInstance();
- if (retainNull) {
+ if (retainMissing) {
int fieldCount = getFieldCount();
- nullTupleBuild = new ArrayTupleBuilder(fieldCount);
- DataOutput out = nullTupleBuild.getDataOutput();
+ nonMatchTupleBuild = new ArrayTupleBuilder(fieldCount);
+ DataOutput out = nonMatchTupleBuild.getDataOutput();
for (int i = 0; i < fieldCount; i++) {
try {
- nullWriter.writeNull(out);
+ nonMatchWriter.writeMissing(out);
} catch (IOException e) {
e.printStackTrace();
}
- nullTupleBuild.addFieldEndOffset();
+ nonMatchTupleBuild.addFieldEndOffset();
}
} else {
- nullTupleBuild = null;
+ nonMatchTupleBuild = null;
}
ExternalBTreeWithBuddy externalIndex = (ExternalBTreeWithBuddy) index;
try {
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalLookupOperatorDescriptor.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalLookupOperatorDescriptor.java
index 2cab3a7..f4c7644 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalLookupOperatorDescriptor.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalLookupOperatorDescriptor.java
@@ -26,7 +26,7 @@
import org.apache.asterix.external.indexing.FilesIndexDescription;
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.dataflow.IOperatorNodePushable;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.IRecordDescriptorProvider;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
import org.apache.hyracks.api.exceptions.HyracksDataException;
@@ -52,19 +52,19 @@
boolean propagateInput, IIndexLifecycleManagerProvider lcManagerProvider,
IStorageManagerInterface storageManager, IFileSplitProvider fileSplitProvider, int datasetId,
double bloomFilterFalsePositiveRate, ISearchOperationCallbackFactory searchOpCallbackFactory,
- boolean retainNull, INullWriterFactory iNullWriterFactory) {
+ boolean retainMissing, IMissingWriterFactory missingWriterFactory) {
super(spec, 1, 1, outRecDesc, storageManager, lcManagerProvider, fileSplitProvider,
new FilesIndexDescription().EXTERNAL_FILE_INDEX_TYPE_TRAITS,
new FilesIndexDescription().FILES_INDEX_COMP_FACTORIES, FilesIndexDescription.BLOOM_FILTER_FIELDS,
- externalFilesIndexDataFlowHelperFactory, null, propagateInput, retainNull, iNullWriterFactory, null,
- searchOpCallbackFactory, null);
+ externalFilesIndexDataFlowHelperFactory, null, propagateInput, retainMissing, missingWriterFactory,
+ null, searchOpCallbackFactory, null);
this.adapterFactory = adapterFactory;
}
@Override
public IOperatorNodePushable createPushRuntime(final IHyracksTaskContext ctx,
final IRecordDescriptorProvider recordDescProvider, final int partition, int nPartitions)
- throws HyracksDataException {
+ throws HyracksDataException {
// Create a file index accessor to be used for files lookup operations
// Note that all file index accessors will use partition 0 since we only have 1 files index per NC
final ExternalFileIndexAccessor snapshotAccessor = new ExternalFileIndexAccessor(
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalRTreeSearchOperatorDescriptor.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalRTreeSearchOperatorDescriptor.java
index 306f75a..e217365 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalRTreeSearchOperatorDescriptor.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalRTreeSearchOperatorDescriptor.java
@@ -21,7 +21,7 @@
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.dataflow.IOperatorNodePushable;
import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.IRecordDescriptorProvider;
import org.apache.hyracks.api.dataflow.value.ITypeTraits;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
@@ -41,10 +41,10 @@
IStorageManagerInterface storageManager, IIndexLifecycleManagerProvider lifecycleManagerProvider,
IFileSplitProvider fileSplitProvider, ITypeTraits[] typeTraits,
IBinaryComparatorFactory[] comparatorFactories, int[] keyFields,
- ExternalRTreeDataflowHelperFactory dataflowHelperFactory, boolean retainInput, boolean retainNull,
- INullWriterFactory iNullWriterFactory, ISearchOperationCallbackFactory searchOpCallbackFactory) {
+ ExternalRTreeDataflowHelperFactory dataflowHelperFactory, boolean retainInput, boolean retainMissing,
+ IMissingWriterFactory missingWriterFactory, ISearchOperationCallbackFactory searchOpCallbackFactory) {
super(spec, recDesc, storageManager, lifecycleManagerProvider, fileSplitProvider, typeTraits,
- comparatorFactories, keyFields, dataflowHelperFactory, retainInput, retainNull, iNullWriterFactory,
+ comparatorFactories, keyFields, dataflowHelperFactory, retainInput, retainMissing, missingWriterFactory,
searchOpCallbackFactory, null, null);
}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalRTreeSearchOperatorNodePushable.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalRTreeSearchOperatorNodePushable.java
index 81e6b17..cda2985 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalRTreeSearchOperatorNodePushable.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/ExternalRTreeSearchOperatorNodePushable.java
@@ -50,20 +50,20 @@
indexHelper.open();
ExternalRTreeDataflowHelper rTreeDataflowHelper = (ExternalRTreeDataflowHelper) indexHelper;
index = indexHelper.getIndexInstance();
- if (retainNull) {
+ if (retainMissing) {
int fieldCount = getFieldCount();
- nullTupleBuild = new ArrayTupleBuilder(fieldCount);
- DataOutput out = nullTupleBuild.getDataOutput();
+ nonMatchTupleBuild = new ArrayTupleBuilder(fieldCount);
+ DataOutput out = nonMatchTupleBuild.getDataOutput();
for (int i = 0; i < fieldCount; i++) {
try {
- nullWriter.writeNull(out);
+ nonMatchWriter.writeMissing(out);
} catch (IOException e) {
e.printStackTrace();
}
- nullTupleBuild.addFieldEndOffset();
+ nonMatchTupleBuild.addFieldEndOffset();
}
} else {
- nullTupleBuild = null;
+ nonMatchTupleBuild = null;
}
ExternalRTree rTreeIndex = (ExternalRTree) index;
try {
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/IndexInfoOperatorDescriptor.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/IndexInfoOperatorDescriptor.java
index 2bc6043..63a3780 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/IndexInfoOperatorDescriptor.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/operators/IndexInfoOperatorDescriptor.java
@@ -21,7 +21,7 @@
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.dataflow.ActivityId;
import org.apache.hyracks.api.dataflow.IOperatorNodePushable;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.IRecordDescriptorProvider;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
import org.apache.hyracks.api.exceptions.HyracksDataException;
@@ -114,12 +114,12 @@
}
@Override
- public boolean getRetainNull() {
+ public boolean getRetainMissing() {
return false;
}
@Override
- public INullWriterFactory getNullWriterFactory() {
+ public IMissingWriterFactory getMissingWriterFactory() {
return null;
}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/ADMDataParser.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/ADMDataParser.java
index c273412..0ad7be1 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/ADMDataParser.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/ADMDataParser.java
@@ -464,11 +464,10 @@
}
if (aObjectType.getTypeTag() == ATypeTag.UNION) {
- List<IAType> unionList = ((AUnionType) aObjectType).getUnionList();
- for (int i = 0; i < unionList.size(); i++) {
- if (unionList.get(i).getTypeTag() == tag) {
- return unionList.get(i);
- }
+ AUnionType unionType = (AUnionType) aObjectType;
+ IAType type = unionType.getActualType();
+ if (type.getTypeTag() == tag) {
+ return type;
}
}
return null; // wont get here
@@ -490,7 +489,7 @@
} else { // union
List<IAType> unionList = ((AUnionType) aObjectType).getUnionList();
for (IAType t : unionList) {
- ATypeTag typeTag = t.getTypeTag();
+ final ATypeTag typeTag = t.getTypeTag();
if (ATypeHierarchy.canPromote(expectedTypeTag, typeTag)
|| ATypeHierarchy.canDemote(expectedTypeTag, typeTag)) {
return typeTag;
@@ -621,7 +620,6 @@
}
private int checkNullConstraints(ARecordType recType, BitSet nulls) {
- boolean isNull = false;
for (int i = 0; i < recType.getFieldTypes().length; i++) {
if (nulls.get(i) == false) {
IAType type = recType.getFieldTypes()[i];
@@ -629,17 +627,13 @@
return i;
}
- if (type.getTypeTag() == ATypeTag.UNION) { // union
- List<IAType> unionList = ((AUnionType) type).getUnionList();
- for (int j = 0; j < unionList.size(); j++) {
- if (unionList.get(j).getTypeTag() == ATypeTag.NULL) {
- isNull = true;
- break;
- }
- }
- if (!isNull) {
- return i;
- }
+ if (type.getTypeTag() != ATypeTag.UNION) {
+ continue;
+ }
+ // union
+ AUnionType unionType = (AUnionType) type;
+ if (!unionType.isNullableType()) {
+ return i;
}
}
}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/DelimitedDataParser.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/DelimitedDataParser.java
index 725ef22..28fd169 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/DelimitedDataParser.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/DelimitedDataParser.java
@@ -167,7 +167,9 @@
cursor = new FieldCursorForDelimitedDataParser(new InputStreamReader(in), fieldDelimiter, quote);
if (in != null && hasHeader) {
cursor.nextRecord();
- while (cursor.nextField());
+ while (cursor.nextField()) {
+ ;
+ }
}
}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/HiveRecordParser.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/HiveRecordParser.java
index 6e7e7f3..9723461 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/HiveRecordParser.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/HiveRecordParser.java
@@ -218,7 +218,7 @@
if (NonTaggedFormatUtil.isOptional(type)) {
throw new NotImplementedException("Non-optional UNION type is not supported.");
}
- tag = ((AUnionType) type).getNullableType().getTypeTag();
+ tag = ((AUnionType) type).getActualType().getTypeTag();
}
if (tag == null) {
throw new NotImplementedException("Failed to get the type information for field " + i + ".");
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/RecordWithMetadataParser.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/RecordWithMetadataParser.java
index 38932d3..5c46a42 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/RecordWithMetadataParser.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/parser/RecordWithMetadataParser.java
@@ -77,7 +77,7 @@
rwm = converter.convert(record);
if (rwm.getRecord().size() == 0) {
// null record
- out.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
+ out.writeByte(ATypeTag.SERIALIZED_MISSING_TYPE_TAG);
} else {
recordParser.parse(rwm.getRecord(), out);
}
@@ -90,7 +90,7 @@
public void parseMeta(DataOutput out) throws HyracksDataException {
try {
if (rwm.getRecord().size() == 0) {
- out.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
+ out.writeByte(ATypeTag.SERIALIZED_MISSING_TYPE_TAG);
} else {
metaBuilder.reset(metaType);
metaBuilder.init();
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/AdapterFactoryProvider.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/AdapterFactoryProvider.java
index f40cd15..e39e3bd 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/AdapterFactoryProvider.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/provider/AdapterFactoryProvider.java
@@ -30,7 +30,7 @@
import org.apache.asterix.external.util.ExternalDataCompatibilityUtils;
import org.apache.asterix.external.util.ExternalDataUtils;
import org.apache.asterix.om.types.ARecordType;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
/**
* This class represents the entry point to all things adapters
@@ -61,10 +61,10 @@
// Lookup Adapters
public static LookupAdapterFactory<?> getLookupAdapterFactory(Map<String, String> configuration,
- ARecordType recordType, int[] ridFields, boolean retainInput, boolean retainNull,
- INullWriterFactory iNullWriterFactory) throws AsterixException {
+ ARecordType recordType, int[] ridFields, boolean retainInput, boolean retainMissing,
+ IMissingWriterFactory missingWriterFactory) throws AsterixException {
LookupAdapterFactory<?> adapterFactory = new LookupAdapterFactory<>(recordType, ridFields, retainInput,
- retainNull, iNullWriterFactory);
+ retainMissing, missingWriterFactory);
adapterFactory.configure(configuration);
return adapterFactory;
}
diff --git a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataUtils.java b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataUtils.java
index 76898c2..1df4e42 100644
--- a/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataUtils.java
+++ b/asterixdb/asterix-external-data/src/main/java/org/apache/asterix/external/util/ExternalDataUtils.java
@@ -19,7 +19,6 @@
package org.apache.asterix.external.util;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
import org.apache.asterix.common.exceptions.AsterixException;
@@ -31,7 +30,6 @@
import org.apache.asterix.om.types.ARecordType;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.IAType;
import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
import org.apache.hyracks.dataflow.common.data.parsers.DoubleParserFactory;
import org.apache.hyracks.dataflow.common.data.parsers.FloatParserFactory;
@@ -164,11 +162,11 @@
for (int i = 0; i < n; i++) {
ATypeTag tag = null;
if (recordType.getFieldTypes()[i].getTypeTag() == ATypeTag.UNION) {
- List<IAType> unionTypes = ((AUnionType) recordType.getFieldTypes()[i]).getUnionList();
- if ((unionTypes.size() != 2) && (unionTypes.get(0).getTypeTag() != ATypeTag.NULL)) {
+ AUnionType unionType = (AUnionType) recordType.getFieldTypes()[i];
+ if (!unionType.isNullableType()) {
throw new NotImplementedException("Non-optional UNION type is not supported.");
}
- tag = unionTypes.get(1).getTypeTag();
+ tag = unionType.getActualType().getTypeTag();
} else {
tag = recordType.getFieldTypes()[i].getTypeTag();
}
diff --git a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParser.java b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParser.java
index 3c22241..923163f 100644
--- a/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParser.java
+++ b/asterixdb/asterix-external-data/src/test/java/org/apache/asterix/external/library/ClassAdParser.java
@@ -339,11 +339,11 @@
// add field value to value buffer
writeFieldValueToBuffer(fieldType, fieldValueBuffer.getDataOutput(), fldName, entry.getValue(), pAd);
if (openRecordField) {
- if (fieldValueBuffer.getByteArray()[0] != ATypeTag.NULL.serialize()) {
+ if (fieldValueBuffer.getByteArray()[0] != ATypeTag.MISSING.serialize()) {
recBuilder.addField(fieldNameBuffer, fieldValueBuffer);
}
} else if (NonTaggedFormatUtil.isOptional(fieldType)) {
- if (fieldValueBuffer.getByteArray()[0] != ATypeTag.NULL.serialize()) {
+ if (fieldValueBuffer.getByteArray()[0] != ATypeTag.MISSING.serialize()) {
recBuilder.addField(fieldId, fieldValueBuffer);
}
} else {
@@ -387,7 +387,7 @@
if (fieldType != null) {
if (NonTaggedFormatUtil.isOptional(fieldType)) {
- fieldType = ((AUnionType) fieldType).getNullableType();
+ fieldType = ((AUnionType) fieldType).getActualType();
}
}
switch (val.getValueType()) {
@@ -622,23 +622,16 @@
}
public static int checkNullConstraints(ARecordType recType, BitSet nulls) {
- boolean isNull = false;
for (int i = 0; i < recType.getFieldTypes().length; i++) {
if (nulls.get(i) == false) {
IAType type = recType.getFieldTypes()[i];
- if (type.getTypeTag() != ATypeTag.NULL && type.getTypeTag() != ATypeTag.UNION) {
+ if (type.getTypeTag() != ATypeTag.MISSING && type.getTypeTag() != ATypeTag.UNION) {
return i;
}
if (type.getTypeTag() == ATypeTag.UNION) { // union
- List<IAType> unionList = ((AUnionType) type).getUnionList();
- for (int j = 0; j < unionList.size(); j++) {
- if (unionList.get(j).getTypeTag() == ATypeTag.NULL) {
- isNull = true;
- break;
- }
- }
- if (!isNull) {
+ AUnionType unionType = (AUnionType) type;
+ if (!unionType.isNullableType()) {
return i;
}
}
@@ -685,7 +678,7 @@
case SLIST_VALUE:
return ATypeTag.UNORDEREDLIST;
case NULL_VALUE:
- return ATypeTag.NULL;
+ return ATypeTag.MISSING;
case REAL_VALUE:
return ATypeTag.DOUBLE;
case RELATIVE_TIME_VALUE:
diff --git a/asterixdb/asterix-lang-aql/src/main/javacc/AQL.jj b/asterixdb/asterix-lang-aql/src/main/javacc/AQL.jj
index 8205021..63b066e 100644
--- a/asterixdb/asterix-lang-aql/src/main/javacc/AQL.jj
+++ b/asterixdb/asterix-lang-aql/src/main/javacc/AQL.jj
@@ -88,6 +88,7 @@
import org.apache.asterix.lang.common.literal.FalseLiteral;
import org.apache.asterix.lang.common.literal.FloatLiteral;
import org.apache.asterix.lang.common.literal.LongIntegerLiteral;
+import org.apache.asterix.lang.common.literal.MissingLiteral;
import org.apache.asterix.lang.common.literal.NullLiteral;
import org.apache.asterix.lang.common.literal.StringLiteral;
import org.apache.asterix.lang.common.literal.TrueLiteral;
@@ -1907,6 +1908,10 @@
{
lit.setValue(new DoubleLiteral(new Double(token.image)));
}
+ | <MISSING>
+ {
+ lit.setValue(MissingLiteral.INSTANCE);
+ }
| <NULL>
{
lit.setValue(NullLiteral.INSTANCE);
@@ -2609,7 +2614,8 @@
<DEFAULT,IN_DBL_BRACE>
TOKEN :
{
- <NULL : "null">
+ < MISSING : "missing">
+ | <NULL : "null">
| <TRUE : "true">
| <FALSE : "false">
}
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/base/Literal.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/base/Literal.java
index 34e1363..1ca8ac46 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/base/Literal.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/base/Literal.java
@@ -29,6 +29,7 @@
public enum Type {
STRING,
INTEGER,
+ MISSING,
NULL,
TRUE,
FALSE,
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/literal/MissingLiteral.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/literal/MissingLiteral.java
new file mode 100644
index 0000000..2c2fa8e
--- /dev/null
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/literal/MissingLiteral.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.lang.common.literal;
+
+import org.apache.asterix.lang.common.base.Literal;
+
+public class MissingLiteral extends Literal {
+ private static final long serialVersionUID = 1L;
+
+ private MissingLiteral() {
+ }
+
+ public final static MissingLiteral INSTANCE = new MissingLiteral();
+
+ @Override
+ public Type getLiteralType() {
+ return Type.MISSING;
+ }
+
+ @Override
+ public String getStringValue() {
+ return "missing";
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return obj == INSTANCE;
+ }
+
+ @Override
+ public int hashCode() {
+ return (int) serialVersionUID;
+ }
+
+ @Override
+ public Object getValue() {
+ return null;
+ }
+}
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/FormatPrintVisitor.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/FormatPrintVisitor.java
index a1e6363..b332df3 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/FormatPrintVisitor.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/FormatPrintVisitor.java
@@ -27,9 +27,9 @@
import java.util.Map;
import java.util.Set;
-import org.apache.asterix.common.config.MetadataConstants;
import org.apache.asterix.common.config.DatasetConfig.DatasetType;
import org.apache.asterix.common.config.DatasetConfig.IndexType;
+import org.apache.asterix.common.config.MetadataConstants;
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.common.functions.FunctionSignature;
import org.apache.asterix.lang.common.base.Expression;
@@ -158,7 +158,7 @@
public Void visit(LiteralExpr l, Integer step) {
Literal lc = l.getValue();
if (lc.getLiteralType().equals(Literal.Type.TRUE) || lc.getLiteralType().equals(Literal.Type.FALSE)
- || lc.getLiteralType().equals(Literal.Type.NULL)) {
+ || lc.getLiteralType().equals(Literal.Type.NULL) || lc.getLiteralType().equals(Literal.Type.MISSING)) {
out.print(lc.getLiteralType().toString().toLowerCase());
} else if (lc.getLiteralType().equals(Literal.Type.STRING)) {
out.print(revertStringToLiteral(lc.getStringValue()));
@@ -455,7 +455,8 @@
if (dd.getDatasetType() == DatasetType.INTERNAL) {
String temp = dd.getDatasetDetailsDecl().isTemp() ? "temporary" : "";
out.print(skip(step) + "create " + temp + datasetSymbol + generateFullName(dd.getDataverse(), dd.getName())
- + generateIfNotExists(dd.getIfNotExists()) + "(" + dd.getQualifiedTypeName() + ")" + " primary key ");
+ + generateIfNotExists(dd.getIfNotExists()) + "(" + dd.getQualifiedTypeName() + ")"
+ + " primary key ");
printDelimitedKeys(((InternalDetailsDecl) dd.getDatasetDetailsDecl()).getPartitioningExprs(), ",");
if (((InternalDetailsDecl) dd.getDatasetDetailsDecl()).isAutogenerated()) {
out.print(" autogenerated ");
diff --git a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/QueryPrintVisitor.java b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/QueryPrintVisitor.java
index c635403..ceb45bb 100644
--- a/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/QueryPrintVisitor.java
+++ b/asterixdb/asterix-lang-common/src/main/java/org/apache/asterix/lang/common/visitor/QueryPrintVisitor.java
@@ -98,7 +98,7 @@
public Void visit(LiteralExpr l, Integer step) {
Literal lc = l.getValue();
if (lc.getLiteralType().equals(Literal.Type.TRUE) || lc.getLiteralType().equals(Literal.Type.FALSE)
- || lc.getLiteralType().equals(Literal.Type.NULL)) {
+ || lc.getLiteralType().equals(Literal.Type.NULL) || lc.getLiteralType().equals(Literal.Type.MISSING)) {
out.println(skip(step) + "LiteralExpr [" + l.getValue().getLiteralType() + "]");
} else {
out.println(skip(step) + "LiteralExpr [" + l.getValue().getLiteralType() + "] ["
diff --git a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
index 3c81cff..c26edc1 100644
--- a/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
+++ b/asterixdb/asterix-lang-sqlpp/src/main/javacc/SQLPP.jj
@@ -83,6 +83,7 @@
import org.apache.asterix.lang.common.literal.FalseLiteral;
import org.apache.asterix.lang.common.literal.FloatLiteral;
import org.apache.asterix.lang.common.literal.LongIntegerLiteral;
+import org.apache.asterix.lang.common.literal.MissingLiteral;
import org.apache.asterix.lang.common.literal.NullLiteral;
import org.apache.asterix.lang.common.literal.StringLiteral;
import org.apache.asterix.lang.common.literal.TrueLiteral;
@@ -1896,6 +1897,10 @@
{
lit.setValue(new DoubleLiteral(new Double(token.image)));
}
+ | <MISSING>
+ {
+ lit.setValue(MissingLiteral.INSTANCE);
+ }
| <NULL>
{
lit.setValue(NullLiteral.INSTANCE);
@@ -2854,7 +2859,8 @@
<DEFAULT,IN_DBL_BRACE>
TOKEN :
{
- <NULL : "null">
+ <MISSING : "missing">
+ | <NULL : "null">
| <TRUE : "true">
| <FALSE : "false">
}
diff --git a/asterixdb/asterix-maven-plugins/asterix-evaluator-generator-maven-plugin/src/main/java/org/apache/asterix/runtime/evaluators/plugin/EvaluatorGeneratorMojo.java b/asterixdb/asterix-maven-plugins/asterix-evaluator-generator-maven-plugin/src/main/java/org/apache/asterix/runtime/evaluators/plugin/EvaluatorGeneratorMojo.java
index d001bb0..888df55 100644
--- a/asterixdb/asterix-maven-plugins/asterix-evaluator-generator-maven-plugin/src/main/java/org/apache/asterix/runtime/evaluators/plugin/EvaluatorGeneratorMojo.java
+++ b/asterixdb/asterix-maven-plugins/asterix-evaluator-generator-maven-plugin/src/main/java/org/apache/asterix/runtime/evaluators/plugin/EvaluatorGeneratorMojo.java
@@ -90,4 +90,5 @@
outputStream.write(classDefinitionBinary, 0, classDefinitionBinary.length);
}
}
+
}
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataRecordTypes.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataRecordTypes.java
index 55a5f3d..620461b 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataRecordTypes.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/bootstrap/MetadataRecordTypes.java
@@ -227,7 +227,7 @@
"DatasourceAdapter", "Properties", "Function", "Status", "CompactionPolicy",
"CompactionPolicyProperties" };
- AUnionType feedFunctionUnion = AUnionType.createNullableType(BuiltinType.ASTRING);
+ IAType feedFunctionUnion = AUnionType.createNullableType(BuiltinType.ASTRING);
IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.ASTRING, orderedListType, orderedListType,
BuiltinType.ASTRING, BuiltinType.ASTRING, orderedListOfPropertiesType, feedFunctionUnion,
@@ -257,8 +257,8 @@
"GroupName", "CompactionPolicy", "CompactionPolicyProperties", "InternalDetails", "ExternalDetails",
"Hints", "Timestamp", "DatasetId", "PendingOp" };
- AUnionType internalRecordUnion = AUnionType.createNullableType(INTERNAL_DETAILS_RECORDTYPE);
- AUnionType externalRecordUnion = AUnionType.createNullableType(EXTERNAL_DETAILS_RECORDTYPE);
+ IAType internalRecordUnion = AUnionType.createNullableType(INTERNAL_DETAILS_RECORDTYPE);
+ IAType externalRecordUnion = AUnionType.createNullableType(EXTERNAL_DETAILS_RECORDTYPE);
AOrderedListType compactionPolicyPropertyListType = new AOrderedListType(
COMPACTION_POLICY_PROPERTIES_RECORDTYPE, null);
@@ -305,8 +305,8 @@
private static final ARecordType createDerivedTypeRecordType() throws AsterixException {
String[] fieldNames = { "Tag", "IsAnonymous", "Record", "UnorderedList", "OrderedList" };
- AUnionType recordUnion = AUnionType.createNullableType(RECORD_RECORDTYPE);
- AUnionType collectionUnion = AUnionType.createNullableType(BuiltinType.ASTRING);
+ IAType recordUnion = AUnionType.createNullableType(RECORD_RECORDTYPE);
+ IAType collectionUnion = AUnionType.createNullableType(BuiltinType.ASTRING);
IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.ABOOLEAN, recordUnion, collectionUnion,
collectionUnion };
@@ -322,7 +322,7 @@
private static final ARecordType createDatatypeRecordType() throws AsterixException {
String[] fieldNames = { "DataverseName", "DatatypeName", "Derived", "Timestamp" };
- AUnionType recordUnion = AUnionType.createNullableType(DERIVEDTYPE_RECORDTYPE);
+ IAType recordUnion = AUnionType.createNullableType(DERIVEDTYPE_RECORDTYPE);
IAType[] fieldTypes = { BuiltinType.ASTRING, BuiltinType.ASTRING, recordUnion, BuiltinType.ASTRING };
return new ARecordType("DatatypeRecordType", fieldNames, fieldTypes, true);
};
@@ -435,9 +435,9 @@
private static ARecordType createFeedRecordType() throws AsterixException, HyracksDataException {
- AUnionType feedFunctionUnion = AUnionType.createNullableType(BuiltinType.ASTRING);
- AUnionType primaryRecordUnion = AUnionType.createNullableType(PRIMARY_FEED_DETAILS_RECORDTYPE);
- AUnionType secondaryRecordUnion = AUnionType.createNullableType(SECONDARY_FEED_DETAILS_RECORDTYPE);
+ IAType feedFunctionUnion = AUnionType.createNullableType(BuiltinType.ASTRING);
+ IAType primaryRecordUnion = AUnionType.createNullableType(PRIMARY_FEED_DETAILS_RECORDTYPE);
+ IAType secondaryRecordUnion = AUnionType.createNullableType(SECONDARY_FEED_DETAILS_RECORDTYPE);
String[] fieldNames = { "DataverseName", "FeedName", "Function", "FeedType", "PrimaryTypeDetails",
"SecondaryTypeDetails", "Timestamp" };
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/AsterixBuiltinTypeMap.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/AsterixBuiltinTypeMap.java
index 7bb212c..8cd3d05 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/AsterixBuiltinTypeMap.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/AsterixBuiltinTypeMap.java
@@ -60,6 +60,7 @@
_builtinTypeMap.put("polygon", BuiltinType.APOLYGON);
_builtinTypeMap.put("circle", BuiltinType.ACIRCLE);
_builtinTypeMap.put("rectangle", BuiltinType.ARECTANGLE);
+ _builtinTypeMap.put("missing", BuiltinType.AMISSING);
_builtinTypeMap.put("null", BuiltinType.ANULL);
_builtinTypeMap.put("uuid", BuiltinType.AUUID);
_builtinTypeMap.put("shortwithouttypeinfo", BuiltinType.SHORTWITHOUTTYPEINFO);
@@ -80,8 +81,9 @@
throw new MetadataException(e);
}
}
- if (isNullable)
+ if (isNullable) {
type = AUnionType.createNullableType(type);
+ }
return type;
}
}
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/Index.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/Index.java
index 3ff9a57..949e6ca 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/Index.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entities/Index.java
@@ -131,11 +131,12 @@
public static Pair<IAType, Boolean> getNonNullableType(IAType keyType) throws AsterixException {
boolean nullable = false;
+ IAType actualKeyType = keyType;
if (NonTaggedFormatUtil.isOptional(keyType)) {
- keyType = ((AUnionType) keyType).getNullableType();
+ actualKeyType = ((AUnionType) keyType).getActualType();
nullable = true;
}
- return new Pair<IAType, Boolean>(keyType, nullable);
+ return new Pair<>(actualKeyType, nullable);
}
public static Pair<IAType, Boolean> getNonNullableOpenFieldType(IAType fieldType, List<String> fieldName,
diff --git a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/DatatypeTupleTranslator.java b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/DatatypeTupleTranslator.java
index a1b23d6..0604fff 100644
--- a/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/DatatypeTupleTranslator.java
+++ b/asterixdb/asterix-metadata/src/main/java/org/apache/asterix/metadata/entitytupletranslators/DatatypeTupleTranslator.java
@@ -201,7 +201,7 @@
IAType fieldType = dataType.getDatatype();
//unwrap nullable type out of the union
if (fieldType.getTypeTag() == ATypeTag.UNION) {
- fieldType = ((AUnionType) dataType.getDatatype()).getNullableType();
+ fieldType = ((AUnionType) dataType.getDatatype()).getActualType();
}
// write field 3
@@ -310,11 +310,12 @@
boolean fieldIsNullable = false;
if (NonTaggedFormatUtil.isOptional(fieldType)) {
fieldIsNullable = true;
- fieldType = ((AUnionType) fieldType).getNullableType();
+ fieldType = ((AUnionType) fieldType).getActualType();
}
- if (fieldType.getTypeTag().isDerivedType())
+ if (fieldType.getTypeTag().isDerivedType()) {
handleNestedDerivedType(fieldType.getTypeName(), (AbstractComplexType) fieldType, instance,
instance.getDataverseName(), instance.getDatatypeName());
+ }
itemValue.reset();
fieldRecordBuilder.reset(MetadataRecordTypes.FIELD_RECORDTYPE);
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/builders/AbstractListBuilder.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/builders/AbstractListBuilder.java
index 59e669a..a2b16dd 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/builders/AbstractListBuilder.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/builders/AbstractListBuilder.java
@@ -71,23 +71,35 @@
}
headerSize = 2;
metadataInfoSize = 8;
- // 8 = 4 (# of items) + 4 (the size of the list)
+ if (itemTypeTag == ATypeTag.MISSING) {
+ itemTypeTag = ATypeTag.NULL;
+ }
}
@Override
public void addItem(IValueReference item) throws HyracksDataException {
try {
- if (!fixedSize && (item.getByteArray()[item.getStartOffset()] != ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || itemTypeTag == ATypeTag.ANY)) {
+ byte[] data = item.getByteArray();
+ int start = item.getStartOffset();
+ int len = item.getLength();
+
+ byte serializedTypeTag = data[start];
+ if (serializedTypeTag == ATypeTag.SERIALIZED_MISSING_TYPE_TAG) {
+ // NULL in a list is MISSING.
+ serializedTypeTag = ATypeTag.SERIALIZED_NULL_TYPE_TAG;
+ }
+
+ if (!fixedSize && (serializedTypeTag != ATypeTag.SERIALIZED_NULL_TYPE_TAG || itemTypeTag == ATypeTag.ANY)) {
this.offsets.add(outputStorage.getLength());
}
- if (itemTypeTag == ATypeTag.ANY || (itemTypeTag == ATypeTag.NULL
- && item.getByteArray()[item.getStartOffset()] == ATypeTag.SERIALIZED_NULL_TYPE_TAG)) {
+ if (itemTypeTag == ATypeTag.ANY
+ || (itemTypeTag == ATypeTag.NULL && serializedTypeTag == ATypeTag.SERIALIZED_NULL_TYPE_TAG)) {
this.numberOfItems++;
- this.outputStream.write(item.getByteArray(), item.getStartOffset(), item.getLength());
- } else if (item.getByteArray()[item.getStartOffset()] != ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
+ this.outputStream.write(serializedTypeTag);
+ this.outputStream.write(data, start + 1, len - 1);
+ } else if (serializedTypeTag != ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
this.numberOfItems++;
- this.outputStream.write(item.getByteArray(), item.getStartOffset() + 1, item.getLength() - 1);
+ this.outputStream.write(data, start + 1, len - 1);
}
} catch (IOException e) {
throw new HyracksDataException(e);
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/builders/RecordBuilder.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/builders/RecordBuilder.java
index 65caf40..bfe08da 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/builders/RecordBuilder.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/builders/RecordBuilder.java
@@ -131,22 +131,25 @@
headerSize = 5;
// this is the record tag (1) + record size (4)
- if (isOpen)
+ if (isOpen) {
// to tell whether the record has an open part or not.
headerSize += 1;
+ }
if (numberOfSchemaFields > 0) {
// there is a schema associated with the record.
headerSize += 4;
// 4 = four bytes to store the number of closed fields.
- if (closedPartOffsets == null || closedPartOffsets.length < numberOfSchemaFields)
+ if (closedPartOffsets == null || closedPartOffsets.length < numberOfSchemaFields) {
closedPartOffsets = new int[numberOfSchemaFields];
+ }
if (isNullable) {
nullBitMapSize = (int) Math.ceil(numberOfSchemaFields / 8.0);
- if (nullBitMap == null || nullBitMap.length < nullBitMapSize)
+ if (nullBitMap == null || nullBitMap.length < nullBitMapSize) {
this.nullBitMap = new byte[nullBitMapSize];
+ }
Arrays.fill(nullBitMap, 0, nullBitMapSize, (byte) 0);
headerSize += nullBitMap.length;
}
@@ -183,11 +186,10 @@
openFieldNameLengths.length + DEFAULT_NUM_OPEN_FIELDS);
}
int fieldNameHashCode = utf8HashFunction.hash(name.getByteArray(), name.getStartOffset() + 1,
- name.getLength() - 1);
+ name.getLength() - 1);
if (recType != null) {
int cFieldPos;
- cFieldPos = recTypeInfo.getFieldIndex(name.getByteArray(), name.getStartOffset() + 1,
- name.getLength() - 1);
+ cFieldPos = recTypeInfo.getFieldIndex(name.getByteArray(), name.getStartOffset() + 1, name.getLength() - 1);
if (cFieldPos >= 0) {
throw new HyracksDataException("Open field \"" + recType.getFieldNames()[cFieldPos]
+ "\" has the same field name as closed field at index " + cFieldPos);
@@ -210,8 +212,9 @@
h += 4;
// 4 = four bytes to store the offset to the open part.
openPartOffsetArraySize = numberOfOpenFields * 8;
- if (openPartOffsetArray == null || openPartOffsetArray.length < openPartOffsetArraySize)
+ if (openPartOffsetArray == null || openPartOffsetArray.length < openPartOffsetArraySize) {
openPartOffsetArray = new byte[openPartOffsetArraySize];
+ }
Arrays.sort(this.openPartOffsets, 0, numberOfOpenFields);
if (numberOfOpenFields > 1) {
@@ -256,17 +259,20 @@
if (this.numberOfOpenFields > 0) {
out.writeBoolean(true);
out.writeInt(openPartOffset);
- } else
+ } else {
out.writeBoolean(false);
+ }
}
// write the closed part
if (numberOfSchemaFields > 0) {
out.writeInt(numberOfClosedFields);
- if (isNullable)
+ if (isNullable) {
out.write(nullBitMap, 0, nullBitMapSize);
- for (int i = 0; i < numberOfSchemaFields; i++)
+ }
+ for (int i = 0; i < numberOfSchemaFields; i++) {
out.writeInt(closedPartOffsets[i] + headerSize + (numberOfSchemaFields * 4));
+ }
out.write(closedPartOutputStream.toByteArray());
}
@@ -284,8 +290,9 @@
@Override
public int getFieldId(String fieldName) {
for (int i = 0; i < recType.getFieldNames().length; i++) {
- if (recType.getFieldNames()[i].equals(fieldName))
+ if (recType.getFieldNames()[i].equals(fieldName)) {
return i;
+ }
}
return -1;
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlExpressionTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlExpressionTypeComputer.java
index 66008f4..4cd3015 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlExpressionTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlExpressionTypeComputer.java
@@ -70,7 +70,7 @@
FunctionIdentifier fi = expr.getFunctionIdentifier();
ComparisonKind ck = AlgebricksBuiltinFunctions.getComparisonType(fi);
if (ck != null) {
- return AUnionType.createNullableType(BuiltinType.ABOOLEAN, "OptionalBoolean");
+ return AUnionType.createUnknownableType(BuiltinType.ABOOLEAN, "OptionalBoolean");
}
// Note: built-in functions + udfs
IResultTypeComputer rtc = null;
@@ -90,6 +90,8 @@
IAlgebricksConstantValue acv = expr.getValue();
if (acv.isFalse() || acv.isTrue()) {
return BuiltinType.ABOOLEAN;
+ } else if (acv.isMissing()) {
+ return BuiltinType.AMISSING;
} else if (acv.isNull()) {
return BuiltinType.ANULL;
} else {
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlNullableTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlMissableTypeComputer.java
similarity index 68%
rename from asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlNullableTypeComputer.java
rename to asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlMissableTypeComputer.java
index ab5119b..aa88ec9 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlNullableTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlMissableTypeComputer.java
@@ -18,38 +18,35 @@
*/
package org.apache.asterix.dataflow.data.common;
+import org.apache.asterix.om.typecomputer.impl.TypeComputeUtils;
import org.apache.asterix.om.types.AUnionType;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.om.types.TypeHelper;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.expressions.INullableTypeComputer;
+import org.apache.hyracks.algebricks.core.algebra.expressions.IMissableTypeComputer;
-public class AqlNullableTypeComputer implements INullableTypeComputer {
+public class AqlMissableTypeComputer implements IMissableTypeComputer {
- public static final AqlNullableTypeComputer INSTANCE = new AqlNullableTypeComputer();
+ public static final AqlMissableTypeComputer INSTANCE = new AqlMissableTypeComputer();
- private AqlNullableTypeComputer() {
+ private AqlMissableTypeComputer() {
}
@Override
- public IAType makeNullableType(Object type) throws AlgebricksException {
+ public IAType makeMissableType(Object type) throws AlgebricksException {
IAType t = (IAType) type;
- if (TypeHelper.canBeNull(t)) {
- return t;
- } else {
- return AUnionType.createNullableType(t);
- }
+ return AUnionType.createMissableType(t);
}
@Override
- public boolean canBeNull(Object type) {
+ public boolean canBeMissing(Object type) {
IAType t = (IAType) type;
- return TypeHelper.canBeNull(t);
+ return TypeHelper.canBeMissing(t);
}
@Override
public Object getNonOptionalType(Object type) {
IAType t = (IAType) type;
- return TypeHelper.getNonOptionalType(t);
+ return TypeComputeUtils.getActualType(t);
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlPartialAggregationTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlPartialAggregationTypeComputer.java
index 3913588..fe5a3e0 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlPartialAggregationTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/common/AqlPartialAggregationTypeComputer.java
@@ -19,16 +19,12 @@
package org.apache.asterix.dataflow.data.common;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
import org.apache.hyracks.algebricks.core.algebra.expressions.AggregateFunctionCallExpression;
import org.apache.hyracks.algebricks.core.algebra.expressions.IPartialAggregationTypeComputer;
import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.functions.AlgebricksBuiltinFunctions;
-import org.apache.hyracks.algebricks.core.algebra.functions.AlgebricksBuiltinFunctions.ComparisonKind;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
@@ -42,18 +38,14 @@
if (partialFid.equals(AsterixBuiltinFunctions.SERIAL_GLOBAL_AVG)) {
partialFid = AsterixBuiltinFunctions.SERIAL_LOCAL_AVG;
}
- AggregateFunctionCallExpression partialAgg = AsterixBuiltinFunctions.makeAggregateFunctionExpression(
- partialFid, agg.getArguments());
- return getTypeForFunction((AbstractFunctionCallExpression) partialAgg, env, metadataProvider);
+ AggregateFunctionCallExpression partialAgg = AsterixBuiltinFunctions.makeAggregateFunctionExpression(partialFid,
+ agg.getArguments());
+ return getTypeForFunction(partialAgg, env, metadataProvider);
}
private Object getTypeForFunction(AbstractFunctionCallExpression expr, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- FunctionIdentifier fi = expr.getFunctionIdentifier();
- ComparisonKind ck = AlgebricksBuiltinFunctions.getComparisonType(fi);
- if (ck != null) {
- return AUnionType.createNullableType(BuiltinType.ABOOLEAN, "OptionalBoolean");
- }
- return AsterixBuiltinFunctions.getResultTypeComputer(fi).computeType(expr, env, metadataProvider);
+ return AsterixBuiltinFunctions.getResultTypeComputer(expr.getFunctionIdentifier()).computeType(expr, env,
+ metadataProvider);
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/AqlNullWriterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/AqlMissingWriterFactory.java
similarity index 60%
rename from asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/AqlNullWriterFactory.java
rename to asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/AqlMissingWriterFactory.java
index 8fa881a..313f821 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/AqlNullWriterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/AqlMissingWriterFactory.java
@@ -22,32 +22,29 @@
import java.io.IOException;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.hyracks.api.dataflow.value.INullWriter;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriter;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.exceptions.HyracksDataException;
-public class AqlNullWriterFactory implements INullWriterFactory {
+public class AqlMissingWriterFactory implements IMissingWriterFactory {
private static final long serialVersionUID = 1L;
- public static final AqlNullWriterFactory INSTANCE = new AqlNullWriterFactory();
+ public static final AqlMissingWriterFactory INSTANCE = new AqlMissingWriterFactory();
- private AqlNullWriterFactory() {
+ private AqlMissingWriterFactory() {
}
@Override
- public INullWriter createNullWriter() {
+ public IMissingWriter createMissingWriter() {
+ return out -> writeMissing(out);
+ }
- return new INullWriter() {
-
- @Override
- public void writeNull(DataOutput out) throws HyracksDataException {
- try {
- out.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
- } catch (IOException e) {
- throw new HyracksDataException(e);
- }
- }
- };
+ private static void writeMissing(DataOutput out) throws HyracksDataException {
+ try {
+ out.writeByte(ATypeTag.SERIALIZED_MISSING_TYPE_TAG);
+ } catch (IOException e) {
+ throw new HyracksDataException(e);
+ }
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ABinaryComparator.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ABinaryComparator.java
index 05ffb3a..6afc9d8 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ABinaryComparator.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ABinaryComparator.java
@@ -18,10 +18,6 @@
*/
package org.apache.asterix.dataflow.data.nontagged.comparators;
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.EnumDeserializer;
-import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
-import org.apache.hyracks.api.dataflow.value.BinaryComparatorConstant.ComparableResultCode;
import org.apache.hyracks.api.dataflow.value.IBinaryComparator;
import org.apache.hyracks.api.exceptions.HyracksDataException;
@@ -30,26 +26,6 @@
*/
public abstract class ABinaryComparator implements IBinaryComparator {
- public static ComparableResultCode isComparable(byte tag1,byte tag2) {
- // NULL Check. If one type is NULL, then we return NULL
- if (tag1 == ATypeTag.SERIALIZED_NULL_TYPE_TAG || tag2 == ATypeTag.SERIALIZED_NULL_TYPE_TAG || tag1 == 0
- || tag2 == 0) {
- return ComparableResultCode.UNKNOWN;
- }
-
- // Checks whether two types are comparable or not
- ATypeTag typeTag1 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(tag1);
- ATypeTag typeTag2 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(tag2);
-
- // Are two types compatible, meaning that they can be compared? (e.g., compare between numeric types
- if (ATypeHierarchy.isCompatible(typeTag1, typeTag2)) {
- return ComparableResultCode.TRUE;
- } else {
- return ComparableResultCode.FALSE;
- }
-
- }
-
@Override
public abstract int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) throws HyracksDataException;
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AObjectAscBinaryComparatorFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AObjectAscBinaryComparatorFactory.java
index 4ce9617..e7a6b77 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AObjectAscBinaryComparatorFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/AObjectAscBinaryComparatorFactory.java
@@ -110,17 +110,26 @@
@Override
public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) throws HyracksDataException {
- // Normally, comparing between NULL and non-NULL values should return UNKNOWN as the result.
- // However, at this point, we assume that NULL check between two types is already done.
+ // Normally, comparing between MISSING and non-MISSING values should return MISSING as the result.
+ // However, this comparator is used by order-by/group-by/distinct-by.
+ // Therefore, inside this method, we return an order between two values even if one value is MISSING.
+ if (b1[s1] == ATypeTag.SERIALIZED_MISSING_TYPE_TAG) {
+ return b2[s2] == ATypeTag.SERIALIZED_MISSING_TYPE_TAG ? 0 : -1;
+ } else {
+ if (b2[s2] == ATypeTag.SERIALIZED_MISSING_TYPE_TAG) {
+ return 1;
+ }
+ }
+
+ // Normally, comparing between NULL and non-NULL/MISSING values should return NULL as the result.
+ // However, this comparator is used by order-by/group-by/distinct-by.
// Therefore, inside this method, we return an order between two values even if one value is NULL.
if (b1[s1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- if (b2[s2] == ATypeTag.SERIALIZED_NULL_TYPE_TAG)
- return 0;
- else
- return -1;
+ return b2[s2] == ATypeTag.SERIALIZED_NULL_TYPE_TAG ? 0 : -1;
} else {
- if (b2[s2] == ATypeTag.SERIALIZED_NULL_TYPE_TAG)
+ if (b2[s2] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
return 1;
+ }
}
ATypeTag tag1 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(b1[s1]);
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ListItemBinaryComparatorFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ListItemBinaryComparatorFactory.java
index 8907bca..c4a82ee 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ListItemBinaryComparatorFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/comparators/ListItemBinaryComparatorFactory.java
@@ -43,7 +43,7 @@
@Override
public IBinaryComparator createBinaryComparator() {
- return createBinaryComparator(ATypeTag.NULL, ATypeTag.NULL, false);
+ return createBinaryComparator(ATypeTag.MISSING, ATypeTag.MISSING, false);
}
public IBinaryComparator createBinaryComparator(final ATypeTag firstItemTypeTag, final ATypeTag secondItemTypeTag,
@@ -83,15 +83,17 @@
@Override
public int compare(byte[] b1, int s1, int l1, byte[] b2, int s2, int l2) throws HyracksDataException {
-
+ // A list item cannot be MISSING.
if (b1[s1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- if (b2[s2] == ATypeTag.SERIALIZED_NULL_TYPE_TAG)
+ if (b2[s2] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
return 0;
- else
+ } else {
return -1;
+ }
} else {
- if (b2[s2] == ATypeTag.SERIALIZED_NULL_TYPE_TAG)
+ if (b2[s2] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
return 1;
+ }
}
ATypeTag tag1 = firstItemTypeTag;
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ANullableFieldPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ANullableFieldPrinterFactory.java
index f063d82..010e968 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ANullableFieldPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/ANullableFieldPrinterFactory.java
@@ -48,14 +48,14 @@
public void init() throws HyracksDataException {
nullPrinter = (AqlADMPrinterFactoryProvider.INSTANCE.getPrinterFactory(BuiltinType.ANULL))
.createPrinter();
- fieldPrinter = (AqlADMPrinterFactoryProvider.INSTANCE.getPrinterFactory(unionType.getNullableType()))
+ fieldPrinter = (AqlADMPrinterFactoryProvider.INSTANCE.getPrinterFactory(unionType.getActualType()))
.createPrinter();
}
@Override
public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
fieldPrinter.init();
- if (b[s] == ATypeTag.NULL.serialize()) {
+ if (b[s] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
nullPrinter.print(b, s, l, ps);
} else {
fieldPrinter.print(b, s, l, ps);
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AObjectPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AObjectPrinter.java
index 6527032..27aa754 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AObjectPrinter.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/adm/AObjectPrinter.java
@@ -58,6 +58,7 @@
AInt64Printer.INSTANCE.print(b, s, l, ps);
break;
}
+ case MISSING:
case NULL: {
ANullPrinter.INSTANCE.print(b, s, l, ps);
break;
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ANullableFieldPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ANullableFieldPrinterFactory.java
index 3d76087..f920080 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ANullableFieldPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/ANullableFieldPrinterFactory.java
@@ -46,16 +46,16 @@
@Override
public void init() throws HyracksDataException {
- nullPrinter = (AqlCSVPrinterFactoryProvider.INSTANCE.getPrinterFactory(BuiltinType.ANULL))
+ nullPrinter = (AqlCSVPrinterFactoryProvider.INSTANCE.getPrinterFactory(BuiltinType.AMISSING))
.createPrinter();
- fieldPrinter = (AqlCSVPrinterFactoryProvider.INSTANCE.getPrinterFactory(unionType.getNullableType()))
+ fieldPrinter = (AqlCSVPrinterFactoryProvider.INSTANCE.getPrinterFactory(unionType.getActualType()))
.createPrinter();
}
@Override
public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
fieldPrinter.init();
- if (b[s] == ATypeTag.NULL.serialize()) {
+ if (b[s] == ATypeTag.MISSING.serialize()) {
nullPrinter.print(b, s, l, ps);
} else {
fieldPrinter.print(b, s, l, ps);
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AObjectPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AObjectPrinter.java
index 6587d52..09cd5ac 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AObjectPrinter.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/csv/AObjectPrinter.java
@@ -56,6 +56,7 @@
AInt64Printer.INSTANCE.print(b, s, l, ps);
break;
}
+ case MISSING:
case NULL: {
ANullPrinter.INSTANCE.print(b, s, l, ps);
break;
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ANullableFieldPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ANullableFieldPrinterFactory.java
index b1319c8..24c8903 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ANullableFieldPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/ANullableFieldPrinterFactory.java
@@ -46,16 +46,16 @@
@Override
public void init() throws HyracksDataException {
- nullPrinter = (AqlCleanJSONPrinterFactoryProvider.INSTANCE.getPrinterFactory(BuiltinType.ANULL))
+ nullPrinter = (AqlCleanJSONPrinterFactoryProvider.INSTANCE.getPrinterFactory(BuiltinType.AMISSING))
.createPrinter();
fieldPrinter = (AqlCleanJSONPrinterFactoryProvider.INSTANCE
- .getPrinterFactory(unionType.getNullableType())).createPrinter();
+ .getPrinterFactory(unionType.getActualType())).createPrinter();
}
@Override
public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
fieldPrinter.init();
- if (b[s] == ATypeTag.NULL.serialize()) {
+ if (b[s] == ATypeTag.MISSING.serialize()) {
nullPrinter.print(b, s, l, ps);
} else {
fieldPrinter.print(b, s, l, ps);
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AObjectPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AObjectPrinter.java
index d4183f6..ee94187 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AObjectPrinter.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/clean/AObjectPrinter.java
@@ -58,6 +58,7 @@
AInt64Printer.INSTANCE.print(b, s, l, ps);
break;
}
+ case MISSING:
case NULL: {
ANullPrinter.INSTANCE.print(b, s, l, ps);
break;
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ANullableFieldPrinterFactory.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ANullableFieldPrinterFactory.java
index 1d495b1..a4f4200 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ANullableFieldPrinterFactory.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/ANullableFieldPrinterFactory.java
@@ -46,16 +46,16 @@
@Override
public void init() throws HyracksDataException {
- nullPrinter = (AqlLosslessJSONPrinterFactoryProvider.INSTANCE.getPrinterFactory(BuiltinType.ANULL))
+ nullPrinter = (AqlLosslessJSONPrinterFactoryProvider.INSTANCE.getPrinterFactory(BuiltinType.AMISSING))
.createPrinter();
fieldPrinter = (AqlLosslessJSONPrinterFactoryProvider.INSTANCE
- .getPrinterFactory(unionType.getNullableType())).createPrinter();
+ .getPrinterFactory(unionType.getActualType())).createPrinter();
}
@Override
public void print(byte[] b, int s, int l, PrintStream ps) throws HyracksDataException {
fieldPrinter.init();
- if (b[s] == ATypeTag.NULL.serialize()) {
+ if (b[s] == ATypeTag.MISSING.serialize()) {
nullPrinter.print(b, s, l, ps);
} else {
fieldPrinter.print(b, s, l, ps);
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AObjectPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AObjectPrinter.java
index 534a95a..1acbc06 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AObjectPrinter.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/printers/json/lossless/AObjectPrinter.java
@@ -58,6 +58,7 @@
AInt64Printer.INSTANCE.print(b, s, l, ps);
break;
}
+ case MISSING:
case NULL: {
ANullPrinter.INSTANCE.print(b, s, l, ps);
break;
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/AMissingSerializerDeserializer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/AMissingSerializerDeserializer.java
new file mode 100644
index 0000000..3ffc7a1
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/AMissingSerializerDeserializer.java
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.dataflow.data.nontagged.serde;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+
+import org.apache.asterix.om.base.AMissing;
+import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+
+public class AMissingSerializerDeserializer implements ISerializerDeserializer<AMissing> {
+
+ private static final long serialVersionUID = 1L;
+
+ public static final AMissingSerializerDeserializer INSTANCE = new AMissingSerializerDeserializer();
+
+ private AMissingSerializerDeserializer() {
+ }
+
+ @Override
+ public AMissing deserialize(DataInput in) throws HyracksDataException {
+ return AMissing.MISSING;
+ }
+
+ @Override
+ public void serialize(AMissing instance, DataOutput out) throws HyracksDataException {
+ // A missing value only has a typetag in its serialized form.
+ }
+
+}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/ANullSerializerDeserializer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/ANullSerializerDeserializer.java
index fb387a8..738284f 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/ANullSerializerDeserializer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/ANullSerializerDeserializer.java
@@ -22,10 +22,11 @@
import java.io.DataOutput;
import org.apache.asterix.om.base.ANull;
+import org.apache.asterix.om.base.IAObject;
import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.api.exceptions.HyracksDataException;
-public class ANullSerializerDeserializer implements ISerializerDeserializer<ANull> {
+public class ANullSerializerDeserializer implements ISerializerDeserializer<IAObject> {
private static final long serialVersionUID = 1L;
@@ -40,7 +41,8 @@
}
@Override
- public void serialize(ANull instance, DataOutput out) throws HyracksDataException {
+ public void serialize(IAObject instance, DataOutput out) throws HyracksDataException {
+ // A null value only has a typetag in its serialized form.
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/AObjectSerializerDeserializer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/AObjectSerializerDeserializer.java
index 6c754f1..3994d6d 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/AObjectSerializerDeserializer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/AObjectSerializerDeserializer.java
@@ -36,7 +36,7 @@
import org.apache.asterix.om.base.AInt8;
import org.apache.asterix.om.base.AInterval;
import org.apache.asterix.om.base.ALine;
-import org.apache.asterix.om.base.ANull;
+import org.apache.asterix.om.base.AMissing;
import org.apache.asterix.om.base.AOrderedList;
import org.apache.asterix.om.base.APoint;
import org.apache.asterix.om.base.APoint3D;
@@ -66,6 +66,8 @@
public IAObject deserialize(DataInput in) throws HyracksDataException {
ATypeTag typeTag = SerializerDeserializerUtil.deserializeTag(in);
switch (typeTag) {
+ case MISSING:
+ return AMissingSerializerDeserializer.INSTANCE.deserialize(in);
case NULL:
return ANullSerializerDeserializer.INSTANCE.deserialize(in);
case BOOLEAN:
@@ -133,8 +135,11 @@
throw new HyracksDataException(e);
}
switch (tag) {
+ case MISSING:
+ AMissingSerializerDeserializer.INSTANCE.serialize((AMissing) instance, out);
+ break;
case NULL:
- ANullSerializerDeserializer.INSTANCE.serialize((ANull) instance, out);
+ ANullSerializerDeserializer.INSTANCE.serialize(instance, out);
break;
case BOOLEAN:
ABooleanSerializerDeserializer.INSTANCE.serialize((ABoolean) instance, out);
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/ARecordSerializerDeserializer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/ARecordSerializerDeserializer.java
index d49ad29..0312ec0 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/ARecordSerializerDeserializer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/dataflow/data/nontagged/serde/ARecordSerializerDeserializer.java
@@ -72,14 +72,7 @@
IAType t = recordType.getFieldTypes()[i];
IAType t2;
if (t.getTypeTag() == ATypeTag.UNION) {
- if (((AUnionType) t).isNullableType()) {
- t2 = ((AUnionType) recordType.getFieldTypes()[i]).getNullableType();
- serializers[i] = AqlSerializerDeserializerProvider.INSTANCE.getSerializerDeserializer(
- ((AUnionType) recordType.getFieldTypes()[i]).getNullableType());
- } else {
- // union .. the general case
- throw new NotImplementedException();
- }
+ t2 = ((AUnionType) t).getActualType();
} else {
t2 = t;
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/base/IDataFormat.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/base/IDataFormat.java
index f87681f..3c31f00 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/base/IDataFormat.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/base/IDataFormat.java
@@ -41,7 +41,7 @@
import org.apache.hyracks.algebricks.data.ISerializerDeserializerProvider;
import org.apache.hyracks.algebricks.data.ITypeTraitProvider;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.IPredicateEvaluatorFactoryProvider;
public interface IDataFormat {
@@ -68,7 +68,7 @@
public IPrinterFactoryProvider getCleanJSONPrinterFactoryProvider();
- public INullWriterFactory getNullWriterFactory();
+ public IMissingWriterFactory getMissingWriterFactory();
public Triple<IScalarEvaluatorFactory, ScalarFunctionCallExpression, IAType> partitioningEvaluatorFactory(
ARecordType recType, List<String> fldName) throws AlgebricksException;
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlADMPrinterFactoryProvider.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlADMPrinterFactoryProvider.java
index c29e18f..d9db6de 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlADMPrinterFactoryProvider.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlADMPrinterFactoryProvider.java
@@ -54,7 +54,6 @@
import org.apache.asterix.om.types.AUnionType;
import org.apache.asterix.om.types.AUnorderedListType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
import org.apache.hyracks.algebricks.data.IPrinterFactoryProvider;
@@ -79,6 +78,7 @@
return AInt32PrinterFactory.INSTANCE;
case INT64:
return AInt64PrinterFactory.INSTANCE;
+ case MISSING:
case NULL:
return ANullPrinterFactory.INSTANCE;
case BOOLEAN:
@@ -124,10 +124,11 @@
case UNORDEREDLIST:
return new AUnorderedlistPrinterFactory((AUnorderedListType) aqlType);
case UNION: {
- if (((AUnionType) aqlType).isNullableType())
+ if (((AUnionType) aqlType).isUnknownableType()) {
return new ANullableFieldPrinterFactory((AUnionType) aqlType);
- else
+ } else {
return new AUnionPrinterFactory((AUnionType) aqlType);
+ }
}
case UUID: {
return AUUIDPrinterFactory.INSTANCE;
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlBinaryBooleanInspectorImpl.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlBinaryBooleanInspectorImpl.java
index 247e6fd..6729a28 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlBinaryBooleanInspectorImpl.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlBinaryBooleanInspectorImpl.java
@@ -39,10 +39,13 @@
@Override
public boolean getBooleanValue(byte[] bytes, int offset, int length) {
- if (bytes[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG)
+ byte serializedTypeTag = bytes[offset];
+ if (serializedTypeTag == ATypeTag.SERIALIZED_MISSING_TYPE_TAG
+ || serializedTypeTag == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
return false;
+ }
/** check if the runtime type is boolean */
- ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]);
+ ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serializedTypeTag);
if (typeTag != ATypeTag.BOOLEAN) {
throw new IllegalStateException("Runtime error: the select condition should be of the boolean type!");
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlBinaryComparatorFactoryProvider.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlBinaryComparatorFactoryProvider.java
index 44851e3..feb3228 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlBinaryComparatorFactoryProvider.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlBinaryComparatorFactoryProvider.java
@@ -105,7 +105,8 @@
case UNION: { // we could do smth better for nullable fields
return anyBinaryComparatorFactory(ascending);
}
- case NULL: {
+ case NULL:
+ case MISSING:
return new IBinaryComparatorFactory() {
private static final long serialVersionUID = 1L;
@@ -121,7 +122,6 @@
};
}
};
- }
case BOOLEAN: {
return addOffset(BooleanBinaryComparatorFactory.INSTANCE, ascending);
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlCSVPrinterFactoryProvider.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlCSVPrinterFactoryProvider.java
index d57445b..d197e52 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlCSVPrinterFactoryProvider.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlCSVPrinterFactoryProvider.java
@@ -49,7 +49,6 @@
import org.apache.asterix.om.types.ARecordType;
import org.apache.asterix.om.types.AUnionType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
import org.apache.hyracks.algebricks.data.IPrinterFactoryProvider;
@@ -75,6 +74,7 @@
return AInt32PrinterFactory.INSTANCE;
case INT64:
return AInt64PrinterFactory.INSTANCE;
+ case MISSING:
case NULL:
return ANullPrinterFactory.INSTANCE;
case BOOLEAN:
@@ -118,10 +118,11 @@
case UNORDEREDLIST:
throw new NotImplementedException("'Unorderedlist' type unsupported for CSV output");
case UNION: {
- if (((AUnionType) aqlType).isNullableType())
+ if (((AUnionType) aqlType).isUnknownableType()) {
return new ANullableFieldPrinterFactory((AUnionType) aqlType);
- else
+ } else {
return new AUnionPrinterFactory((AUnionType) aqlType);
+ }
}
case UUID: {
return AUUIDPrinterFactory.INSTANCE;
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlCleanJSONPrinterFactoryProvider.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlCleanJSONPrinterFactoryProvider.java
index c1eb434..6220dde 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlCleanJSONPrinterFactoryProvider.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlCleanJSONPrinterFactoryProvider.java
@@ -54,7 +54,6 @@
import org.apache.asterix.om.types.AUnionType;
import org.apache.asterix.om.types.AUnorderedListType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
import org.apache.hyracks.algebricks.data.IPrinterFactoryProvider;
@@ -79,6 +78,7 @@
return AInt32PrinterFactory.INSTANCE;
case INT64:
return AInt64PrinterFactory.INSTANCE;
+ case MISSING:
case NULL:
return ANullPrinterFactory.INSTANCE;
case BOOLEAN:
@@ -124,10 +124,11 @@
case UNORDEREDLIST:
return new AUnorderedlistPrinterFactory((AUnorderedListType) aqlType);
case UNION: {
- if (((AUnionType) aqlType).isNullableType())
+ if (((AUnionType) aqlType).isUnknownableType()) {
return new ANullableFieldPrinterFactory((AUnionType) aqlType);
- else
+ } else {
return new AUnionPrinterFactory((AUnionType) aqlType);
+ }
}
case UUID: {
return AUUIDPrinterFactory.INSTANCE;
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlLosslessJSONPrinterFactoryProvider.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlLosslessJSONPrinterFactoryProvider.java
index aad912c..1950685 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlLosslessJSONPrinterFactoryProvider.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlLosslessJSONPrinterFactoryProvider.java
@@ -54,7 +54,6 @@
import org.apache.asterix.om.types.AUnionType;
import org.apache.asterix.om.types.AUnorderedListType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.data.IPrinterFactory;
import org.apache.hyracks.algebricks.data.IPrinterFactoryProvider;
@@ -79,6 +78,7 @@
return AInt32PrinterFactory.INSTANCE;
case INT64:
return AInt64PrinterFactory.INSTANCE;
+ case MISSING:
case NULL:
return ANullPrinterFactory.INSTANCE;
case BOOLEAN:
@@ -124,10 +124,11 @@
case UNORDEREDLIST:
return new AUnorderedlistPrinterFactory((AUnorderedListType) aqlType);
case UNION: {
- if (((AUnionType) aqlType).isNullableType())
+ if (((AUnionType) aqlType).isUnknownableType()) {
return new ANullableFieldPrinterFactory((AUnionType) aqlType);
- else
+ } else {
return new AUnionPrinterFactory((AUnionType) aqlType);
+ }
}
case UUID: {
return AUUIDPrinterFactory.INSTANCE;
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlPredicateEvaluatorFactoryProvider.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlPredicateEvaluatorFactoryProvider.java
index c6f7495..a30bada 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlPredicateEvaluatorFactoryProvider.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlPredicateEvaluatorFactoryProvider.java
@@ -46,16 +46,17 @@
return new IPredicateEvaluator() {
@Override
- public boolean evaluate(IFrameTupleAccessor fta0, int tupId0, IFrameTupleAccessor fta1, int tupId1) {
+ public boolean evaluate(IFrameTupleAccessor fta0, int tupId0, IFrameTupleAccessor fta1,
+ int tupId1) {
int tStart0 = fta0.getTupleStartOffset(tupId0);
int fStartOffset0 = fta0.getFieldSlotsLength() + tStart0;
for (int k0 : keys0) {
int fieldStartIx = fta0.getFieldStartOffset(tupId0, k0);
- ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(fta0.getBuffer()
- .array()[fieldStartIx + fStartOffset0]);
- if (typeTag == ATypeTag.NULL) {
+ ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(fta0.getBuffer().array()[fieldStartIx + fStartOffset0]);
+ if (typeTag == ATypeTag.MISSING || typeTag == ATypeTag.NULL) {
return false;
}
}
@@ -65,9 +66,9 @@
for (int k1 : keys1) {
int fieldStartIx = fta1.getFieldStartOffset(tupId1, k1);
- ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(fta1.getBuffer()
- .array()[fieldStartIx + fStartOffset1]);
- if (typeTag == ATypeTag.NULL) {
+ ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(fta1.getBuffer().array()[fieldStartIx + fStartOffset1]);
+ if (typeTag == ATypeTag.MISSING || typeTag == ATypeTag.NULL) {
return false;
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlSerializerDeserializerProvider.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlSerializerDeserializerProvider.java
index 5b41535..4f1f9a3 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlSerializerDeserializerProvider.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/formats/nontagged/AqlSerializerDeserializerProvider.java
@@ -38,6 +38,7 @@
import org.apache.asterix.dataflow.data.nontagged.serde.AInt8SerializerDeserializer;
import org.apache.asterix.dataflow.data.nontagged.serde.AIntervalSerializerDeserializer;
import org.apache.asterix.dataflow.data.nontagged.serde.ALineSerializerDeserializer;
+import org.apache.asterix.dataflow.data.nontagged.serde.AMissingSerializerDeserializer;
import org.apache.asterix.dataflow.data.nontagged.serde.ANullSerializerDeserializer;
import org.apache.asterix.dataflow.data.nontagged.serde.AObjectSerializerDeserializer;
import org.apache.asterix.dataflow.data.nontagged.serde.AOrderedListSerializerDeserializer;
@@ -52,6 +53,7 @@
import org.apache.asterix.dataflow.data.nontagged.serde.AUnorderedListSerializerDeserializer;
import org.apache.asterix.dataflow.data.nontagged.serde.AYearMonthDurationSerializerDeserializer;
import org.apache.asterix.dataflow.data.nontagged.serde.SerializerDeserializerUtil;
+import org.apache.asterix.om.base.AMissing;
import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.IAObject;
import org.apache.asterix.om.types.AOrderedListType;
@@ -136,6 +138,8 @@
case LINE: {
return ALineSerializerDeserializer.INSTANCE;
}
+ case MISSING:
+ return AMissingSerializerDeserializer.INSTANCE;
case NULL: {
return ANullSerializerDeserializer.INSTANCE;
}
@@ -203,8 +207,12 @@
@Override
public IAObject deserialize(DataInput in) throws HyracksDataException {
try {
+ ATypeTag tag = SerializerDeserializerUtil.deserializeTag(in);
//deserialize the tag (move input cursor forward) and check if it's not NULL tag
- if (SerializerDeserializerUtil.deserializeTag(in) == ATypeTag.NULL) {
+ if (tag == ATypeTag.MISSING) {
+ return AMissing.MISSING;
+ }
+ if (tag == ATypeTag.NULL) {
return ANull.NULL;
}
} catch (IOException e) {
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/base/AMissing.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/base/AMissing.java
new file mode 100644
index 0000000..6c357e6
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/base/AMissing.java
@@ -0,0 +1,69 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.om.base;
+
+import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.om.types.BuiltinType;
+import org.apache.asterix.om.types.IAType;
+import org.apache.asterix.om.visitors.IOMVisitor;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+// This class represents a MISSING object.
+public class AMissing implements IAObject {
+
+ private AMissing() {
+ }
+
+ public final static AMissing MISSING = new AMissing();
+
+ @Override
+ public void accept(IOMVisitor visitor) throws AsterixException {
+ visitor.visitAMissing(this);
+ }
+
+ @Override
+ public IAType getType() {
+ return BuiltinType.AMISSING;
+ }
+
+ @Override
+ public boolean deepEqual(IAObject obj) {
+ return obj == this;
+ }
+
+ @Override
+ public int hash() {
+ return 0;
+ }
+
+ @Override
+ public String toString() {
+ return "missing";
+ }
+
+ @Override
+ public JSONObject toJSON() throws JSONException {
+ JSONObject json = new JSONObject();
+
+ json.put("AMissing", "missing");
+
+ return json;
+ }
+}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/base/ANull.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/base/ANull.java
index 9f5f83b..859ebb3 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/base/ANull.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/base/ANull.java
@@ -16,18 +16,16 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.asterix.om.base;
-import org.json.JSONException;
-import org.json.JSONObject;
+package org.apache.asterix.om.base;
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.om.visitors.IOMVisitor;
+import org.json.JSONException;
+import org.json.JSONObject;
-// We should avoid representing nulls explicitly. This class is for cases when it is
-// harder not to.
public class ANull implements IAObject {
private ANull() {
@@ -63,9 +61,8 @@
@Override
public JSONObject toJSON() throws JSONException {
JSONObject json = new JSONObject();
-
json.put("ANull", "null");
-
return json;
}
+
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/constants/AsterixConstantValue.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/constants/AsterixConstantValue.java
index 6458384..fa0a74e 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/constants/AsterixConstantValue.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/constants/AsterixConstantValue.java
@@ -19,6 +19,7 @@
package org.apache.asterix.om.constants;
import org.apache.asterix.om.base.ABoolean;
+import org.apache.asterix.om.base.AMissing;
import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.IAObject;
import org.apache.hyracks.algebricks.core.algebra.expressions.IAlgebricksConstantValue;
@@ -37,6 +38,11 @@
}
@Override
+ public boolean isMissing() {
+ return object == AMissing.MISSING;
+ }
+
+ @Override
public boolean isNull() {
return object == ANull.NULL;
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/AsterixBuiltinFunctions.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/AsterixBuiltinFunctions.java
index d604f35..0b1eaca 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/AsterixBuiltinFunctions.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/functions/AsterixBuiltinFunctions.java
@@ -29,68 +29,54 @@
import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
import org.apache.asterix.om.typecomputer.impl.ABinaryTypeComputer;
import org.apache.asterix.om.typecomputer.impl.ABooleanTypeComputer;
+import org.apache.asterix.om.typecomputer.impl.ACircleTypeComputer;
import org.apache.asterix.om.typecomputer.impl.ADateTimeTypeComputer;
import org.apache.asterix.om.typecomputer.impl.ADateTypeComputer;
+import org.apache.asterix.om.typecomputer.impl.ADayTimeDurationTypeComputer;
import org.apache.asterix.om.typecomputer.impl.ADoubleTypeComputer;
+import org.apache.asterix.om.typecomputer.impl.ADurationTypeComputer;
import org.apache.asterix.om.typecomputer.impl.AFloatTypeComputer;
+import org.apache.asterix.om.typecomputer.impl.AInt16TypeComputer;
import org.apache.asterix.om.typecomputer.impl.AInt32TypeComputer;
import org.apache.asterix.om.typecomputer.impl.AInt64TypeComputer;
-import org.apache.asterix.om.typecomputer.impl.ANullTypeComputer;
+import org.apache.asterix.om.typecomputer.impl.AInt8TypeComputer;
+import org.apache.asterix.om.typecomputer.impl.AIntervalTypeComputer;
+import org.apache.asterix.om.typecomputer.impl.ALineTypeComputer;
+import org.apache.asterix.om.typecomputer.impl.AMissingTypeComputer;
+import org.apache.asterix.om.typecomputer.impl.APoint3DTypeComputer;
import org.apache.asterix.om.typecomputer.impl.APointTypeComputer;
+import org.apache.asterix.om.typecomputer.impl.APolygonTypeComputer;
import org.apache.asterix.om.typecomputer.impl.ARectangleTypeComputer;
import org.apache.asterix.om.typecomputer.impl.AStringTypeComputer;
+import org.apache.asterix.om.typecomputer.impl.ATemporalInstanceTypeComputer;
import org.apache.asterix.om.typecomputer.impl.ATimeTypeComputer;
import org.apache.asterix.om.typecomputer.impl.AUUIDTypeComputer;
+import org.apache.asterix.om.typecomputer.impl.AYearMonthDurationTypeComputer;
import org.apache.asterix.om.typecomputer.impl.AnyTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.BinaryBooleanOrNullFunctionTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.BinaryStringBoolOrNullTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.BinaryStringStringOrNullTypeComputer;
+import org.apache.asterix.om.typecomputer.impl.BooleanFunctionTypeComputer;
+import org.apache.asterix.om.typecomputer.impl.BooleanOnlyTypeComputer;
import org.apache.asterix.om.typecomputer.impl.CastListResultTypeComputer;
import org.apache.asterix.om.typecomputer.impl.CastRecordResultTypeComputer;
import org.apache.asterix.om.typecomputer.impl.ClosedRecordConstructorResultType;
+import org.apache.asterix.om.typecomputer.impl.CollectionMemberResultType;
import org.apache.asterix.om.typecomputer.impl.CollectionToSequenceTypeComputer;
import org.apache.asterix.om.typecomputer.impl.ConcatNonNullTypeComputer;
import org.apache.asterix.om.typecomputer.impl.FieldAccessByIndexResultType;
+import org.apache.asterix.om.typecomputer.impl.FieldAccessByNameResultType;
import org.apache.asterix.om.typecomputer.impl.FieldAccessNestedResultType;
import org.apache.asterix.om.typecomputer.impl.GetOverlappingInvervalTypeComputer;
import org.apache.asterix.om.typecomputer.impl.InjectFailureTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.NonTaggedCollectionMemberResultType;
-import org.apache.asterix.om.typecomputer.impl.NonTaggedFieldAccessByNameResultType;
+import org.apache.asterix.om.typecomputer.impl.LocalAvgTypeComputer;
+import org.apache.asterix.om.typecomputer.impl.MinMaxAggTypeComputer;
import org.apache.asterix.om.typecomputer.impl.NonTaggedGetItemResultType;
-import org.apache.asterix.om.typecomputer.impl.NonTaggedLocalAvgTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.NonTaggedMinMaxAggTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.NonTaggedNumericAddSubMulDivTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.NonTaggedNumericAggTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.NonTaggedNumericRoundHalfToEven2TypeComputer;
-import org.apache.asterix.om.typecomputer.impl.NonTaggedNumericUnaryFunctionTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.NonTaggedSwitchCaseComputer;
-import org.apache.asterix.om.typecomputer.impl.NonTaggedUnaryMinusTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.NotNullTypeComputer;
+import org.apache.asterix.om.typecomputer.impl.NotMissingTypeComputer;
+import org.apache.asterix.om.typecomputer.impl.NullableDoubleTypeComputer;
+import org.apache.asterix.om.typecomputer.impl.NumericAddSubMulDivTypeComputer;
+import org.apache.asterix.om.typecomputer.impl.NumericAggTypeComputer;
+import org.apache.asterix.om.typecomputer.impl.NumericRoundHalfToEven2TypeComputer;
+import org.apache.asterix.om.typecomputer.impl.NumericUnaryFunctionTypeComputer;
+import org.apache.asterix.om.typecomputer.impl.OpenARecordTypeComputer;
import org.apache.asterix.om.typecomputer.impl.OpenRecordConstructorResultType;
-import org.apache.asterix.om.typecomputer.impl.OptionalABinaryTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.OptionalABooleanTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.OptionalACircleTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.OptionalADateTimeTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.OptionalADateTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.OptionalADayTimeDurationTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.OptionalADoubleTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.OptionalADurationTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.OptionalAFloatTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.OptionalAInt16TypeComputer;
-import org.apache.asterix.om.typecomputer.impl.OptionalAInt32TypeComputer;
-import org.apache.asterix.om.typecomputer.impl.OptionalAInt64TypeComputer;
-import org.apache.asterix.om.typecomputer.impl.OptionalAInt8TypeComputer;
-import org.apache.asterix.om.typecomputer.impl.OptionalAIntervalTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.OptionalALineTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.OptionalAPoint3DTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.OptionalAPointTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.OptionalAPolygonTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.OptionalARectangleTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.OptionalAStringTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.OptionalATemporalInstanceTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.OptionalATimeTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.OptionalAYearMonthDurationTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.OptionalOpenARecordTypeComputer;
import org.apache.asterix.om.typecomputer.impl.OrderedListConstructorResultType;
import org.apache.asterix.om.typecomputer.impl.OrderedListOfAInt32TypeComputer;
import org.apache.asterix.om.typecomputer.impl.OrderedListOfAInt64TypeComputer;
@@ -98,20 +84,19 @@
import org.apache.asterix.om.typecomputer.impl.OrderedListOfAPointTypeComputer;
import org.apache.asterix.om.typecomputer.impl.OrderedListOfAStringTypeComputer;
import org.apache.asterix.om.typecomputer.impl.OrderedListOfAnyTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.QuadStringStringOrNullTypeComputer;
import org.apache.asterix.om.typecomputer.impl.RecordAddFieldsTypeComputer;
import org.apache.asterix.om.typecomputer.impl.RecordMergeTypeComputer;
import org.apache.asterix.om.typecomputer.impl.RecordRemoveFieldsTypeComputer;
import org.apache.asterix.om.typecomputer.impl.ScalarVersionOfAggregateResultType;
+import org.apache.asterix.om.typecomputer.impl.StringBooleanTypeComputer;
+import org.apache.asterix.om.typecomputer.impl.StringStringTypeComputer;
import org.apache.asterix.om.typecomputer.impl.SubsetCollectionTypeComputer;
import org.apache.asterix.om.typecomputer.impl.Substring2TypeComputer;
import org.apache.asterix.om.typecomputer.impl.SubstringTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.TripleStringBoolOrNullTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.TripleStringStringOrNullTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.UnaryBinaryInt64OrNullTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.UnaryBooleanOrNullFunctionTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.UnaryStringInt64OrNullTypeComputer;
-import org.apache.asterix.om.typecomputer.impl.UnaryStringOrNullTypeComputer;
+import org.apache.asterix.om.typecomputer.impl.SwitchCaseComputer;
+import org.apache.asterix.om.typecomputer.impl.UnaryBinaryInt64TypeComputer;
+import org.apache.asterix.om.typecomputer.impl.UnaryMinusTypeComputer;
+import org.apache.asterix.om.typecomputer.impl.UnaryStringInt64TypeComputer;
import org.apache.asterix.om.typecomputer.impl.UnorderedListConstructorResultType;
import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
import org.apache.commons.lang3.mutable.Mutable;
@@ -154,8 +139,6 @@
"get-handle", 2);
public final static FunctionIdentifier GET_DATA = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "get-data",
2);
- public final static FunctionIdentifier EMBED_TYPE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
- "embed-type", 1);
public final static FunctionIdentifier GET_ITEM = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "get-item",
2);
@@ -712,12 +695,15 @@
public static final FunctionIdentifier OR = AlgebricksBuiltinFunctions.OR;
public static final FunctionIdentifier NOT = AlgebricksBuiltinFunctions.NOT;
public static final FunctionIdentifier NUMERIC_ADD = AlgebricksBuiltinFunctions.NUMERIC_ADD;
+ public static final FunctionIdentifier IS_MISSING = AlgebricksBuiltinFunctions.IS_MISSING;
public static final FunctionIdentifier IS_NULL = AlgebricksBuiltinFunctions.IS_NULL;
+ public static final FunctionIdentifier IS_UNKOWN = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
+ "is-unknown", 1);
public static final FunctionIdentifier IS_SYSTEM_NULL = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
"is-system-null", 1);
- public static final FunctionIdentifier NOT_NULL = new FunctionIdentifier(FunctionConstants.ASTERIX_NS, "not-null",
- 1);
+ public static final FunctionIdentifier CHECK_UNKNOWN = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
+ "check-unknown", 1);
public static final FunctionIdentifier COLLECTION_TO_SEQUENCE = new FunctionIdentifier(FunctionConstants.ASTERIX_NS,
"" + "collection-to-sequence", 1);
@@ -740,163 +726,147 @@
static {
// first, take care of Algebricks builtin functions
- addFunction(IS_NULL, ABooleanTypeComputer.INSTANCE, true);
- addFunction(IS_SYSTEM_NULL, ABooleanTypeComputer.INSTANCE, true);
- addFunction(NOT, UnaryBooleanOrNullFunctionTypeComputer.INSTANCE, true);
+ addFunction(IS_MISSING, BooleanOnlyTypeComputer.INSTANCE, true);
+ addFunction(IS_NULL, BooleanOnlyTypeComputer.INSTANCE, true);
+ addFunction(IS_UNKOWN, BooleanOnlyTypeComputer.INSTANCE, true);
+ addFunction(IS_SYSTEM_NULL, BooleanOnlyTypeComputer.INSTANCE, true);
+ addFunction(NOT, BooleanFunctionTypeComputer.INSTANCE, true);
- addPrivateFunction(EQ, BinaryBooleanOrNullFunctionTypeComputer.INSTANCE, true);
- addPrivateFunction(LE, BinaryBooleanOrNullFunctionTypeComputer.INSTANCE, true);
- addPrivateFunction(GE, BinaryBooleanOrNullFunctionTypeComputer.INSTANCE, true);
- addPrivateFunction(LT, BinaryBooleanOrNullFunctionTypeComputer.INSTANCE, true);
- addPrivateFunction(GT, BinaryBooleanOrNullFunctionTypeComputer.INSTANCE, true);
- addPrivateFunction(AND, BinaryBooleanOrNullFunctionTypeComputer.INSTANCE, true);
- addPrivateFunction(NEQ, BinaryBooleanOrNullFunctionTypeComputer.INSTANCE, true);
- addPrivateFunction(OR, BinaryBooleanOrNullFunctionTypeComputer.INSTANCE, true);
- addPrivateFunction(NUMERIC_ADD, NonTaggedNumericAddSubMulDivTypeComputer.INSTANCE, true);
+ addPrivateFunction(EQ, BooleanFunctionTypeComputer.INSTANCE, true);
+ addPrivateFunction(LE, BooleanFunctionTypeComputer.INSTANCE, true);
+ addPrivateFunction(GE, BooleanFunctionTypeComputer.INSTANCE, true);
+ addPrivateFunction(LT, BooleanFunctionTypeComputer.INSTANCE, true);
+ addPrivateFunction(GT, BooleanFunctionTypeComputer.INSTANCE, true);
+ addPrivateFunction(AND, BooleanFunctionTypeComputer.INSTANCE, true);
+ addPrivateFunction(NEQ, BooleanFunctionTypeComputer.INSTANCE, true);
+ addPrivateFunction(OR, BooleanFunctionTypeComputer.INSTANCE, true);
+ addPrivateFunction(NUMERIC_ADD, NumericAddSubMulDivTypeComputer.INSTANCE, true);
// Deep equality
- addFunction(DEEP_EQUAL, BinaryBooleanOrNullFunctionTypeComputer.INSTANCE, true);
+ addFunction(DEEP_EQUAL, BooleanFunctionTypeComputer.INSTANCE, true);
// and then, Asterix builtin functions
- addPrivateFunction(NOT_NULL, NotNullTypeComputer.INSTANCE, true);
- addPrivateFunction(ANY_COLLECTION_MEMBER, NonTaggedCollectionMemberResultType.INSTANCE, true);
- addFunction(AVG, OptionalADoubleTypeComputer.INSTANCE, true);
- addFunction(BOOLEAN_CONSTRUCTOR, UnaryBooleanOrNullFunctionTypeComputer.INSTANCE, true);
- addPrivateFunction(CARET, NonTaggedNumericAddSubMulDivTypeComputer.INSTANCE, true);
- addFunction(CIRCLE_CONSTRUCTOR, OptionalACircleTypeComputer.INSTANCE, true);
+ addPrivateFunction(CHECK_UNKNOWN, NotMissingTypeComputer.INSTANCE, true);
+ addPrivateFunction(ANY_COLLECTION_MEMBER, CollectionMemberResultType.INSTANCE, true);
+ addFunction(BOOLEAN_CONSTRUCTOR, StringBooleanTypeComputer.INSTANCE, true);
+ addPrivateFunction(CARET, NumericAddSubMulDivTypeComputer.INSTANCE, true);
+ addFunction(CIRCLE_CONSTRUCTOR, ACircleTypeComputer.INSTANCE, true);
addPrivateFunction(CONCAT_NON_NULL, ConcatNonNullTypeComputer.INSTANCE, true);
- addFunction(COUNT, AInt64TypeComputer.INSTANCE, true);
addPrivateFunction(COUNTHASHED_GRAM_TOKENS, OrderedListOfAInt32TypeComputer.INSTANCE, true);
addPrivateFunction(COUNTHASHED_WORD_TOKENS, OrderedListOfAInt32TypeComputer.INSTANCE, true);
- addFunction(CREATE_CIRCLE, OptionalACircleTypeComputer.INSTANCE, true);
- addFunction(CREATE_LINE, OptionalALineTypeComputer.INSTANCE, true);
- addPrivateFunction(CREATE_MBR, OptionalADoubleTypeComputer.INSTANCE, true);
- addFunction(CREATE_POINT, OptionalAPointTypeComputer.INSTANCE, true);
- addFunction(CREATE_POLYGON, OptionalAPolygonTypeComputer.INSTANCE, true);
- addFunction(CREATE_RECTANGLE, OptionalARectangleTypeComputer.INSTANCE, true);
+ addFunction(CREATE_CIRCLE, ACircleTypeComputer.INSTANCE, true);
+ addFunction(CREATE_LINE, ALineTypeComputer.INSTANCE, true);
+ addPrivateFunction(CREATE_MBR, ADoubleTypeComputer.INSTANCE, true);
+ addFunction(CREATE_POINT, APointTypeComputer.INSTANCE, true);
+ addFunction(CREATE_POLYGON, APolygonTypeComputer.INSTANCE, true);
+ addFunction(CREATE_RECTANGLE, ARectangleTypeComputer.INSTANCE, true);
addFunction(CREATE_UUID, AUUIDTypeComputer.INSTANCE, false);
addFunction(CREATE_QUERY_UID, ABinaryTypeComputer.INSTANCE, false);
addFunction(UUID_CONSTRUCTOR, AUUIDTypeComputer.INSTANCE, true);
- addFunction(DATE_CONSTRUCTOR, OptionalADateTypeComputer.INSTANCE, true);
- addFunction(DATETIME_CONSTRUCTOR, OptionalADateTimeTypeComputer.INSTANCE, true);
- addFunction(DOUBLE_CONSTRUCTOR, OptionalADoubleTypeComputer.INSTANCE, true);
- addFunction(DURATION_CONSTRUCTOR, OptionalADurationTypeComputer.INSTANCE, true);
- addFunction(YEAR_MONTH_DURATION_CONSTRUCTOR, OptionalAYearMonthDurationTypeComputer.INSTANCE, true);
- addFunction(DAY_TIME_DURATION_CONSTRUCTOR, OptionalADayTimeDurationTypeComputer.INSTANCE, true);
+ addFunction(DATE_CONSTRUCTOR, ADateTypeComputer.INSTANCE, true);
+ addFunction(DATETIME_CONSTRUCTOR, ADateTimeTypeComputer.INSTANCE, true);
+ addFunction(DOUBLE_CONSTRUCTOR, ADoubleTypeComputer.INSTANCE, true);
+ addFunction(DURATION_CONSTRUCTOR, ADurationTypeComputer.INSTANCE, true);
+ addFunction(YEAR_MONTH_DURATION_CONSTRUCTOR, AYearMonthDurationTypeComputer.INSTANCE, true);
+ addFunction(DAY_TIME_DURATION_CONSTRUCTOR, ADayTimeDurationTypeComputer.INSTANCE, true);
addFunction(EDIT_DISTANCE, AInt64TypeComputer.INSTANCE, true);
addFunction(EDIT_DISTANCE_CHECK, OrderedListOfAnyTypeComputer.INSTANCE, true);
addPrivateFunction(EDIT_DISTANCE_STRING_IS_FILTERABLE, ABooleanTypeComputer.INSTANCE, true);
addPrivateFunction(EDIT_DISTANCE_LIST_IS_FILTERABLE, ABooleanTypeComputer.INSTANCE, true);
- addPrivateFunction(EMBED_TYPE, AnyTypeComputer.INSTANCE, true);
addPrivateFunction(EMPTY_STREAM, ABooleanTypeComputer.INSTANCE, true);
- // add(FIELD_ACCESS, NonTaggedFieldAccessByNameResultType.INSTANCE);
- addFunction(FLOAT_CONSTRUCTOR, OptionalAFloatTypeComputer.INSTANCE, true);
- addPrivateFunction(FUZZY_EQ, BinaryBooleanOrNullFunctionTypeComputer.INSTANCE, true);
+ addFunction(FLOAT_CONSTRUCTOR, AFloatTypeComputer.INSTANCE, true);
+ addPrivateFunction(FUZZY_EQ, BooleanFunctionTypeComputer.INSTANCE, true);
addPrivateFunction(GET_HANDLE, null, true); // TODO
addPrivateFunction(GET_ITEM, NonTaggedGetItemResultType.INSTANCE, true);
addPrivateFunction(GET_DATA, null, true); // TODO
- addPrivateFunction(GLOBAL_AVG, OptionalADoubleTypeComputer.INSTANCE, true);
addPrivateFunction(GRAM_TOKENS, OrderedListOfAStringTypeComputer.INSTANCE, true);
addPrivateFunction(HASHED_GRAM_TOKENS, OrderedListOfAInt32TypeComputer.INSTANCE, true);
addPrivateFunction(HASHED_WORD_TOKENS, OrderedListOfAInt32TypeComputer.INSTANCE, true);
addPrivateFunction(INDEX_SEARCH, AnyTypeComputer.INSTANCE, true);
- addFunction(INT8_CONSTRUCTOR, OptionalAInt8TypeComputer.INSTANCE, true);
- addFunction(INT16_CONSTRUCTOR, OptionalAInt16TypeComputer.INSTANCE, true);
- addFunction(INT32_CONSTRUCTOR, OptionalAInt32TypeComputer.INSTANCE, true);
- addFunction(INT64_CONSTRUCTOR, OptionalAInt64TypeComputer.INSTANCE, true);
- addFunction(LEN, OptionalAInt64TypeComputer.INSTANCE, true);
- addFunction(LINE_CONSTRUCTOR, OptionalALineTypeComputer.INSTANCE, true);
+ addFunction(INT8_CONSTRUCTOR, AInt8TypeComputer.INSTANCE, true);
+ addFunction(INT16_CONSTRUCTOR, AInt16TypeComputer.INSTANCE, true);
+ addFunction(INT32_CONSTRUCTOR, AInt32TypeComputer.INSTANCE, true);
+ addFunction(INT64_CONSTRUCTOR, AInt64TypeComputer.INSTANCE, true);
+ addFunction(LEN, AInt64TypeComputer.INSTANCE, true);
+ addFunction(LINE_CONSTRUCTOR, ALineTypeComputer.INSTANCE, true);
addPrivateFunction(LISTIFY, OrderedListConstructorResultType.INSTANCE, true);
- addPrivateFunction(LOCAL_AVG, NonTaggedLocalAvgTypeComputer.INSTANCE, true);
addPrivateFunction(MAKE_FIELD_INDEX_HANDLE, null, true); // TODO
addPrivateFunction(MAKE_FIELD_NAME_HANDLE, null, true); // TODO
- addFunction(MAX, NonTaggedMinMaxAggTypeComputer.INSTANCE, true);
- addPrivateFunction(LOCAL_MAX, NonTaggedMinMaxAggTypeComputer.INSTANCE, true);
- addFunction(MIN, NonTaggedMinMaxAggTypeComputer.INSTANCE, true);
- addPrivateFunction(LOCAL_MIN, NonTaggedMinMaxAggTypeComputer.INSTANCE, true);
- addPrivateFunction(NON_EMPTY_STREAM, ABooleanTypeComputer.INSTANCE, true);
- addFunction(NULL_CONSTRUCTOR, ANullTypeComputer.INSTANCE, true);
+ addFunction(NULL_CONSTRUCTOR, AMissingTypeComputer.INSTANCE, true);
- addPrivateFunction(NUMERIC_UNARY_MINUS, NonTaggedUnaryMinusTypeComputer.INSTANCE, true);
- addPrivateFunction(NUMERIC_SUBTRACT, NonTaggedNumericAddSubMulDivTypeComputer.INSTANCE, true);
- addPrivateFunction(NUMERIC_MULTIPLY, NonTaggedNumericAddSubMulDivTypeComputer.INSTANCE, true);
- addPrivateFunction(NUMERIC_DIVIDE, NonTaggedNumericAddSubMulDivTypeComputer.INSTANCE, true);
- addPrivateFunction(NUMERIC_MOD, NonTaggedNumericAddSubMulDivTypeComputer.INSTANCE, true);
+ addPrivateFunction(NUMERIC_UNARY_MINUS, UnaryMinusTypeComputer.INSTANCE, true);
+ addPrivateFunction(NUMERIC_SUBTRACT, NumericAddSubMulDivTypeComputer.INSTANCE, true);
+ addPrivateFunction(NUMERIC_MULTIPLY, NumericAddSubMulDivTypeComputer.INSTANCE, true);
+ addPrivateFunction(NUMERIC_DIVIDE, NumericAddSubMulDivTypeComputer.INSTANCE, true);
+ addPrivateFunction(NUMERIC_MOD, NumericAddSubMulDivTypeComputer.INSTANCE, true);
addPrivateFunction(NUMERIC_IDIV, AInt64TypeComputer.INSTANCE, true);
- addFunction(NUMERIC_ABS, NonTaggedNumericUnaryFunctionTypeComputer.INSTANCE, true);
- addFunction(NUMERIC_CEILING, NonTaggedNumericUnaryFunctionTypeComputer.INSTANCE, true);
- addFunction(NUMERIC_FLOOR, NonTaggedNumericUnaryFunctionTypeComputer.INSTANCE, true);
- addFunction(NUMERIC_ROUND, NonTaggedNumericUnaryFunctionTypeComputer.INSTANCE, true);
- addFunction(NUMERIC_ROUND_HALF_TO_EVEN, NonTaggedNumericUnaryFunctionTypeComputer.INSTANCE, true);
- addFunction(NUMERIC_ROUND_HALF_TO_EVEN2, NonTaggedNumericRoundHalfToEven2TypeComputer.INSTANCE, true);
+ addFunction(NUMERIC_ABS, NumericUnaryFunctionTypeComputer.INSTANCE, true);
+ addFunction(NUMERIC_CEILING, NumericUnaryFunctionTypeComputer.INSTANCE, true);
+ addFunction(NUMERIC_FLOOR, NumericUnaryFunctionTypeComputer.INSTANCE, true);
+ addFunction(NUMERIC_ROUND, NumericUnaryFunctionTypeComputer.INSTANCE, true);
+ addFunction(NUMERIC_ROUND_HALF_TO_EVEN, NumericUnaryFunctionTypeComputer.INSTANCE, true);
+ addFunction(NUMERIC_ROUND_HALF_TO_EVEN2, NumericRoundHalfToEven2TypeComputer.INSTANCE, true);
- addFunction(BINARY_LENGTH, UnaryBinaryInt64OrNullTypeComputer.INSTANCE, true);
- addFunction(PARSE_BINARY, OptionalABinaryTypeComputer.INSTANCE, true);
- addFunction(PRINT_BINARY, OptionalAStringTypeComputer.INSTANCE, true);
- addFunction(BINARY_CONCAT, OptionalABinaryTypeComputer.INSTANCE, true);
- addFunction(SUBBINARY_FROM, OptionalABinaryTypeComputer.INSTANCE, true);
- addFunction(SUBBINARY_FROM_TO, OptionalABinaryTypeComputer.INSTANCE, true);
- addFunction(FIND_BINARY, OptionalAInt64TypeComputer.INSTANCE, true);
- addFunction(FIND_BINARY_FROM, OptionalAInt64TypeComputer.INSTANCE, true);
+ addFunction(BINARY_LENGTH, UnaryBinaryInt64TypeComputer.INSTANCE, true);
+ addFunction(PARSE_BINARY, ABinaryTypeComputer.INSTANCE, true);
+ addFunction(PRINT_BINARY, AStringTypeComputer.INSTANCE, true);
+ addFunction(BINARY_CONCAT, ABinaryTypeComputer.INSTANCE, true);
+ addFunction(SUBBINARY_FROM, ABinaryTypeComputer.INSTANCE, true);
+ addFunction(SUBBINARY_FROM_TO, ABinaryTypeComputer.INSTANCE, true);
+ addFunction(FIND_BINARY, AInt64TypeComputer.INSTANCE, true);
+ addFunction(FIND_BINARY_FROM, AInt64TypeComputer.INSTANCE, true);
- addFunction(STRING_LIKE, BinaryBooleanOrNullFunctionTypeComputer.INSTANCE, true);
+ addFunction(STRING_LIKE, BooleanFunctionTypeComputer.INSTANCE, true);
addFunction(STRING_CONTAINS, ABooleanTypeComputer.INSTANCE, true);
addFunction(STRING_TO_CODEPOINT, OrderedListOfAInt64TypeComputer.INSTANCE, true);
addFunction(CODEPOINT_TO_STRING, AStringTypeComputer.INSTANCE, true);
- addFunction(STRING_CONCAT, OptionalAStringTypeComputer.INSTANCE, true);
+ addFunction(STRING_CONCAT, AStringTypeComputer.INSTANCE, true);
addFunction(SUBSTRING2, Substring2TypeComputer.INSTANCE, true);
- addFunction(STRING_LENGTH, UnaryStringInt64OrNullTypeComputer.INSTANCE, true);
- addFunction(STRING_LOWERCASE, UnaryStringOrNullTypeComputer.INSTANCE, true);
- addFunction(STRING_UPPERCASE, UnaryStringOrNullTypeComputer.INSTANCE, true);
- addFunction(STRING_STARTS_WITH, BinaryStringBoolOrNullTypeComputer.INSTANCE, true);
- addFunction(STRING_ENDS_WITH, BinaryStringBoolOrNullTypeComputer.INSTANCE, true);
- addFunction(STRING_MATCHES, BinaryStringBoolOrNullTypeComputer.INSTANCE, true);
- addFunction(STRING_MATCHES_WITH_FLAG, TripleStringBoolOrNullTypeComputer.INSTANCE, true);
- addFunction(STRING_REPLACE, TripleStringStringOrNullTypeComputer.INSTANCE, true);
- addFunction(STRING_REPLACE_WITH_FLAG, QuadStringStringOrNullTypeComputer.INSTANCE, true);
- addFunction(SUBSTRING_BEFORE, BinaryStringStringOrNullTypeComputer.INSTANCE, true);
- addFunction(SUBSTRING_AFTER, BinaryStringStringOrNullTypeComputer.INSTANCE, true);
- addPrivateFunction(STRING_EQUAL, BinaryStringBoolOrNullTypeComputer.INSTANCE, true);
+ addFunction(STRING_LENGTH, UnaryStringInt64TypeComputer.INSTANCE, true);
+ addFunction(STRING_LOWERCASE, StringStringTypeComputer.INSTANCE, true);
+ addFunction(STRING_UPPERCASE, StringStringTypeComputer.INSTANCE, true);
+ addFunction(STRING_STARTS_WITH, StringBooleanTypeComputer.INSTANCE, true);
+ addFunction(STRING_ENDS_WITH, StringBooleanTypeComputer.INSTANCE, true);
+ addFunction(STRING_MATCHES, StringBooleanTypeComputer.INSTANCE, true);
+ addFunction(STRING_MATCHES_WITH_FLAG, StringBooleanTypeComputer.INSTANCE, true);
+ addFunction(STRING_REPLACE, StringStringTypeComputer.INSTANCE, true);
+ addFunction(STRING_REPLACE_WITH_FLAG, StringStringTypeComputer.INSTANCE, true);
+ addFunction(SUBSTRING_BEFORE, StringStringTypeComputer.INSTANCE, true);
+ addFunction(SUBSTRING_AFTER, StringStringTypeComputer.INSTANCE, true);
+ addPrivateFunction(STRING_EQUAL, StringBooleanTypeComputer.INSTANCE, true);
addFunction(STRING_JOIN, AStringTypeComputer.INSTANCE, true);
addPrivateFunction(ORDERED_LIST_CONSTRUCTOR, OrderedListConstructorResultType.INSTANCE, true);
- addFunction(POINT_CONSTRUCTOR, OptionalAPointTypeComputer.INSTANCE, true);
- addFunction(POINT3D_CONSTRUCTOR, OptionalAPoint3DTypeComputer.INSTANCE, true);
- addFunction(POLYGON_CONSTRUCTOR, OptionalAPolygonTypeComputer.INSTANCE, true);
+ addFunction(POINT_CONSTRUCTOR, APointTypeComputer.INSTANCE, true);
+ addFunction(POINT3D_CONSTRUCTOR, APoint3DTypeComputer.INSTANCE, true);
+ addFunction(POLYGON_CONSTRUCTOR, APolygonTypeComputer.INSTANCE, true);
addPrivateFunction(PREFIX_LEN_JACCARD, AInt32TypeComputer.INSTANCE, true);
addFunction(RANGE, AInt64TypeComputer.INSTANCE, true);
- addFunction(RECTANGLE_CONSTRUCTOR, OptionalARectangleTypeComputer.INSTANCE, true);
+ addFunction(RECTANGLE_CONSTRUCTOR, ARectangleTypeComputer.INSTANCE, true);
- // SQL Aggregate Functions
- addFunction(SQL_AVG, OptionalADoubleTypeComputer.INSTANCE, true);
- addFunction(SQL_COUNT, AInt64TypeComputer.INSTANCE, true);
- addFunction(SQL_MAX, NonTaggedMinMaxAggTypeComputer.INSTANCE, true);
- addPrivateFunction(LOCAL_SQL_MAX, NonTaggedMinMaxAggTypeComputer.INSTANCE, true);
- addFunction(SQL_MIN, NonTaggedMinMaxAggTypeComputer.INSTANCE, true);
- addPrivateFunction(LOCAL_SQL_MIN, NonTaggedMinMaxAggTypeComputer.INSTANCE, true);
- addFunction(SQL_SUM, NonTaggedNumericAggTypeComputer.INSTANCE, true);
- addPrivateFunction(LOCAL_SQL_SUM, NonTaggedNumericAggTypeComputer.INSTANCE, true);
- addFunction(SCALAR_SQL_AVG, ScalarVersionOfAggregateResultType.INSTANCE, true);
- addFunction(SCALAR_SQL_COUNT, AInt64TypeComputer.INSTANCE, true);
- addPrivateFunction(SCALAR_GLOBAL_SQL_AVG, ScalarVersionOfAggregateResultType.INSTANCE, true);
- addPrivateFunction(SCALAR_LOCAL_SQL_AVG, ScalarVersionOfAggregateResultType.INSTANCE, true);
- addFunction(SCALAR_SQL_MAX, ScalarVersionOfAggregateResultType.INSTANCE, true);
- addFunction(SCALAR_SQL_MIN, ScalarVersionOfAggregateResultType.INSTANCE, true);
- addFunction(SCALAR_SQL_SUM, ScalarVersionOfAggregateResultType.INSTANCE, true);
- addPrivateFunction(SERIAL_SQL_AVG, OptionalADoubleTypeComputer.INSTANCE, true);
+ // Aggregate Functions
+ addFunction(MAX, MinMaxAggTypeComputer.INSTANCE, true);
+ addPrivateFunction(LOCAL_MAX, MinMaxAggTypeComputer.INSTANCE, true);
+ addFunction(MIN, MinMaxAggTypeComputer.INSTANCE, true);
+ addPrivateFunction(LOCAL_MIN, MinMaxAggTypeComputer.INSTANCE, true);
+ addPrivateFunction(NON_EMPTY_STREAM, ABooleanTypeComputer.INSTANCE, true);
+ addFunction(COUNT, AInt64TypeComputer.INSTANCE, true);
+ addPrivateFunction(LOCAL_AVG, LocalAvgTypeComputer.INSTANCE, true);
+ addFunction(AVG, NullableDoubleTypeComputer.INSTANCE, true);
+ addFunction(SUM, NumericAggTypeComputer.INSTANCE, true);
+ addPrivateFunction(LOCAL_SUM, NumericAggTypeComputer.INSTANCE, true);
+ addPrivateFunction(GLOBAL_AVG, NullableDoubleTypeComputer.INSTANCE, true);
+
+ addPrivateFunction(SERIAL_SQL_AVG, NullableDoubleTypeComputer.INSTANCE, true);
addPrivateFunction(SERIAL_SQL_COUNT, AInt64TypeComputer.INSTANCE, true);
- addPrivateFunction(SERIAL_GLOBAL_SQL_AVG, OptionalADoubleTypeComputer.INSTANCE, true);
- addPrivateFunction(SERIAL_LOCAL_SQL_AVG, NonTaggedLocalAvgTypeComputer.INSTANCE, true);
- addPrivateFunction(SERIAL_INTERMEDIATE_SQL_AVG, NonTaggedLocalAvgTypeComputer.INSTANCE, true);
- addPrivateFunction(SERIAL_SQL_SUM, NonTaggedNumericAggTypeComputer.INSTANCE, true);
- addPrivateFunction(SERIAL_LOCAL_SQL_SUM, NonTaggedNumericAggTypeComputer.INSTANCE, true);
-
- addPrivateFunction(INTERMEDIATE_AVG, NonTaggedLocalAvgTypeComputer.INSTANCE, true);
- addPrivateFunction(INTERMEDIATE_SQL_AVG, NonTaggedLocalAvgTypeComputer.INSTANCE, true);
-
+ addPrivateFunction(SERIAL_GLOBAL_SQL_AVG, NullableDoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(SERIAL_LOCAL_SQL_AVG, LocalAvgTypeComputer.INSTANCE, true);
+ addPrivateFunction(SERIAL_INTERMEDIATE_SQL_AVG, LocalAvgTypeComputer.INSTANCE, true);
+ addPrivateFunction(SERIAL_SQL_SUM, NumericAggTypeComputer.INSTANCE, true);
+ addPrivateFunction(SERIAL_LOCAL_SQL_SUM, NumericAggTypeComputer.INSTANCE, true);
addFunction(SCALAR_AVG, ScalarVersionOfAggregateResultType.INSTANCE, true);
addFunction(SCALAR_COUNT, AInt64TypeComputer.INSTANCE, true);
addPrivateFunction(SCALAR_GLOBAL_AVG, ScalarVersionOfAggregateResultType.INSTANCE, true);
@@ -904,14 +874,34 @@
addFunction(SCALAR_MAX, ScalarVersionOfAggregateResultType.INSTANCE, true);
addFunction(SCALAR_MIN, ScalarVersionOfAggregateResultType.INSTANCE, true);
addFunction(SCALAR_SUM, ScalarVersionOfAggregateResultType.INSTANCE, true);
- addPrivateFunction(SCAN_COLLECTION, NonTaggedCollectionMemberResultType.INSTANCE, true);
- addPrivateFunction(SERIAL_AVG, OptionalADoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(INTERMEDIATE_AVG, LocalAvgTypeComputer.INSTANCE, true);
+
+ addFunction(SQL_AVG, NullableDoubleTypeComputer.INSTANCE, true);
+ addFunction(SQL_COUNT, AInt64TypeComputer.INSTANCE, true);
+ addFunction(SQL_MAX, MinMaxAggTypeComputer.INSTANCE, true);
+ addPrivateFunction(LOCAL_SQL_MAX, MinMaxAggTypeComputer.INSTANCE, true);
+ addFunction(SQL_MIN, MinMaxAggTypeComputer.INSTANCE, true);
+ addPrivateFunction(LOCAL_SQL_MIN, MinMaxAggTypeComputer.INSTANCE, true);
+ addFunction(SQL_SUM, NumericAggTypeComputer.INSTANCE, true);
+ addPrivateFunction(LOCAL_SQL_SUM, NumericAggTypeComputer.INSTANCE, true);
+ addFunction(SCALAR_SQL_AVG, ScalarVersionOfAggregateResultType.INSTANCE, true);
+ addFunction(SCALAR_SQL_COUNT, AInt64TypeComputer.INSTANCE, true);
+ addPrivateFunction(SCALAR_GLOBAL_SQL_AVG, ScalarVersionOfAggregateResultType.INSTANCE, true);
+ addPrivateFunction(SCALAR_LOCAL_SQL_AVG, ScalarVersionOfAggregateResultType.INSTANCE, true);
+ addFunction(SCALAR_SQL_MAX, ScalarVersionOfAggregateResultType.INSTANCE, true);
+ addFunction(SCALAR_SQL_MIN, ScalarVersionOfAggregateResultType.INSTANCE, true);
+ addFunction(SCALAR_SQL_SUM, ScalarVersionOfAggregateResultType.INSTANCE, true);
+ addPrivateFunction(INTERMEDIATE_SQL_AVG, LocalAvgTypeComputer.INSTANCE, true);
+
+ addPrivateFunction(SERIAL_AVG, ADoubleTypeComputer.INSTANCE, true);
addPrivateFunction(SERIAL_COUNT, AInt64TypeComputer.INSTANCE, true);
- addPrivateFunction(SERIAL_GLOBAL_AVG, OptionalADoubleTypeComputer.INSTANCE, true);
- addPrivateFunction(SERIAL_LOCAL_AVG, NonTaggedLocalAvgTypeComputer.INSTANCE, true);
- addPrivateFunction(SERIAL_INTERMEDIATE_AVG, NonTaggedLocalAvgTypeComputer.INSTANCE, true);
- addPrivateFunction(SERIAL_SUM, NonTaggedNumericAggTypeComputer.INSTANCE, true);
- addPrivateFunction(SERIAL_LOCAL_SUM, NonTaggedNumericAggTypeComputer.INSTANCE, true);
+ addPrivateFunction(SERIAL_GLOBAL_AVG, ADoubleTypeComputer.INSTANCE, true);
+ addPrivateFunction(SERIAL_LOCAL_AVG, LocalAvgTypeComputer.INSTANCE, true);
+ addPrivateFunction(SERIAL_INTERMEDIATE_AVG, LocalAvgTypeComputer.INSTANCE, true);
+ addPrivateFunction(SERIAL_SUM, NumericAggTypeComputer.INSTANCE, true);
+ addPrivateFunction(SERIAL_LOCAL_SUM, NumericAggTypeComputer.INSTANCE, true);
+
+ // Similarity functions
addFunction(EDIT_DISTANCE_CONTAINS, OrderedListOfAnyTypeComputer.INSTANCE, true);
addFunction(SIMILARITY_JACCARD, AFloatTypeComputer.INSTANCE, true);
addFunction(SIMILARITY_JACCARD_CHECK, OrderedListOfAnyTypeComputer.INSTANCE, true);
@@ -919,6 +909,8 @@
addPrivateFunction(SIMILARITY_JACCARD_SORTED_CHECK, OrderedListOfAnyTypeComputer.INSTANCE, true);
addPrivateFunction(SIMILARITY_JACCARD_PREFIX, AFloatTypeComputer.INSTANCE, true);
addPrivateFunction(SIMILARITY_JACCARD_PREFIX_CHECK, OrderedListOfAnyTypeComputer.INSTANCE, true);
+
+ // Spatial functions
addFunction(SPATIAL_AREA, ADoubleTypeComputer.INSTANCE, true);
addFunction(SPATIAL_CELL, ARectangleTypeComputer.INSTANCE, true);
addFunction(SPATIAL_DISTANCE, ADoubleTypeComputer.INSTANCE, true);
@@ -928,22 +920,22 @@
addFunction(GET_CIRCLE_RADIUS_ACCESSOR, ADoubleTypeComputer.INSTANCE, true);
addFunction(GET_CIRCLE_CENTER_ACCESSOR, APointTypeComputer.INSTANCE, true);
addFunction(GET_POINTS_LINE_RECTANGLE_POLYGON_ACCESSOR, OrderedListOfAPointTypeComputer.INSTANCE, true);
- addFunction(STRING_CONSTRUCTOR, OptionalAStringTypeComputer.INSTANCE, true);
- addFunction(BINARY_HEX_CONSTRUCTOR, OptionalABinaryTypeComputer.INSTANCE, true);
- addFunction(BINARY_BASE64_CONSTRUCTOR, OptionalABinaryTypeComputer.INSTANCE, true);
+ addFunction(STRING_CONSTRUCTOR, AStringTypeComputer.INSTANCE, true);
+
+ // Binary functions
+ addFunction(BINARY_HEX_CONSTRUCTOR, ABinaryTypeComputer.INSTANCE, true);
+ addFunction(BINARY_BASE64_CONSTRUCTOR, ABinaryTypeComputer.INSTANCE, true);
addPrivateFunction(SUBSET_COLLECTION, SubsetCollectionTypeComputer.INSTANCE, true);
addFunction(SUBSTRING, SubstringTypeComputer.INSTANCE, true);
- addFunction(SUM, NonTaggedNumericAggTypeComputer.INSTANCE, true);
- addPrivateFunction(LOCAL_SUM, NonTaggedNumericAggTypeComputer.INSTANCE, true);
- addFunction(SWITCH_CASE, NonTaggedSwitchCaseComputer.INSTANCE, true);
+ addFunction(SWITCH_CASE, SwitchCaseComputer.INSTANCE, true);
addPrivateFunction(REG_EXP, ABooleanTypeComputer.INSTANCE, true);
addPrivateFunction(INJECT_FAILURE, InjectFailureTypeComputer.INSTANCE, true);
addPrivateFunction(CAST_RECORD, CastRecordResultTypeComputer.INSTANCE, true);
addPrivateFunction(CAST_LIST, CastListResultTypeComputer.INSTANCE, true);
addFunction(TID, AInt64TypeComputer.INSTANCE, true);
- addFunction(TIME_CONSTRUCTOR, OptionalATimeTypeComputer.INSTANCE, true);
+ addFunction(TIME_CONSTRUCTOR, ATimeTypeComputer.INSTANCE, true);
addPrivateFunction(TYPE_OF, null, true);
addPrivateFunction(UNORDERED_LIST_CONSTRUCTOR, UnorderedListConstructorResultType.INSTANCE, true);
addFunction(WORD_TOKENS, OrderedListOfAStringTypeComputer.INSTANCE, true);
@@ -956,86 +948,86 @@
addPrivateFunction(OPEN_RECORD_CONSTRUCTOR, OpenRecordConstructorResultType.INSTANCE, true);
addPrivateFunction(FIELD_ACCESS_BY_INDEX, FieldAccessByIndexResultType.INSTANCE, true);
addPrivateFunction(FIELD_ACCESS_NESTED, FieldAccessNestedResultType.INSTANCE, true);
- addPrivateFunction(FIELD_ACCESS_BY_NAME, NonTaggedFieldAccessByNameResultType.INSTANCE, true);
+ addPrivateFunction(FIELD_ACCESS_BY_NAME, FieldAccessByNameResultType.INSTANCE, true);
addFunction(GET_RECORD_FIELDS, OrderedListOfAnyTypeComputer.INSTANCE, true);
addFunction(GET_RECORD_FIELD_VALUE, FieldAccessNestedResultType.INSTANCE, true);
// temporal type accessors
- addFunction(ACCESSOR_TEMPORAL_YEAR, OptionalAInt64TypeComputer.INSTANCE, true);
- addFunction(ACCESSOR_TEMPORAL_MONTH, OptionalAInt64TypeComputer.INSTANCE, true);
- addFunction(ACCESSOR_TEMPORAL_DAY, OptionalAInt64TypeComputer.INSTANCE, true);
- addFunction(ACCESSOR_TEMPORAL_HOUR, OptionalAInt64TypeComputer.INSTANCE, true);
- addFunction(ACCESSOR_TEMPORAL_MIN, OptionalAInt64TypeComputer.INSTANCE, true);
- addFunction(ACCESSOR_TEMPORAL_SEC, OptionalAInt64TypeComputer.INSTANCE, true);
- addFunction(ACCESSOR_TEMPORAL_MILLISEC, OptionalAInt64TypeComputer.INSTANCE, true);
- addFunction(ACCESSOR_TEMPORAL_INTERVAL_START, OptionalATemporalInstanceTypeComputer.INSTANCE, true);
- addFunction(ACCESSOR_TEMPORAL_INTERVAL_END, OptionalATemporalInstanceTypeComputer.INSTANCE, true);
- addFunction(ACCESSOR_TEMPORAL_INTERVAL_START_DATETIME, OptionalADateTimeTypeComputer.INSTANCE, true);
- addFunction(ACCESSOR_TEMPORAL_INTERVAL_END_DATETIME, OptionalADateTimeTypeComputer.INSTANCE, true);
- addFunction(ACCESSOR_TEMPORAL_INTERVAL_START_DATE, OptionalADateTypeComputer.INSTANCE, true);
- addFunction(ACCESSOR_TEMPORAL_INTERVAL_END_DATE, OptionalADateTypeComputer.INSTANCE, true);
- addFunction(ACCESSOR_TEMPORAL_INTERVAL_START_TIME, OptionalATimeTypeComputer.INSTANCE, true);
- addFunction(ACCESSOR_TEMPORAL_INTERVAL_END_TIME, OptionalATimeTypeComputer.INSTANCE, true);
+ addFunction(ACCESSOR_TEMPORAL_YEAR, AInt64TypeComputer.INSTANCE, true);
+ addFunction(ACCESSOR_TEMPORAL_MONTH, AInt64TypeComputer.INSTANCE, true);
+ addFunction(ACCESSOR_TEMPORAL_DAY, AInt64TypeComputer.INSTANCE, true);
+ addFunction(ACCESSOR_TEMPORAL_HOUR, AInt64TypeComputer.INSTANCE, true);
+ addFunction(ACCESSOR_TEMPORAL_MIN, AInt64TypeComputer.INSTANCE, true);
+ addFunction(ACCESSOR_TEMPORAL_SEC, AInt64TypeComputer.INSTANCE, true);
+ addFunction(ACCESSOR_TEMPORAL_MILLISEC, AInt64TypeComputer.INSTANCE, true);
+ addFunction(ACCESSOR_TEMPORAL_INTERVAL_START, ATemporalInstanceTypeComputer.INSTANCE, true);
+ addFunction(ACCESSOR_TEMPORAL_INTERVAL_END, ATemporalInstanceTypeComputer.INSTANCE, true);
+ addFunction(ACCESSOR_TEMPORAL_INTERVAL_START_DATETIME, ADateTimeTypeComputer.INSTANCE, true);
+ addFunction(ACCESSOR_TEMPORAL_INTERVAL_END_DATETIME, ADateTimeTypeComputer.INSTANCE, true);
+ addFunction(ACCESSOR_TEMPORAL_INTERVAL_START_DATE, ADateTypeComputer.INSTANCE, true);
+ addFunction(ACCESSOR_TEMPORAL_INTERVAL_END_DATE, ADateTypeComputer.INSTANCE, true);
+ addFunction(ACCESSOR_TEMPORAL_INTERVAL_START_TIME, ATimeTypeComputer.INSTANCE, true);
+ addFunction(ACCESSOR_TEMPORAL_INTERVAL_END_TIME, ATimeTypeComputer.INSTANCE, true);
// temporal functions
- addFunction(DATE_FROM_UNIX_TIME_IN_DAYS, OptionalADateTypeComputer.INSTANCE, true);
- addFunction(DATE_FROM_DATETIME, OptionalADateTypeComputer.INSTANCE, true);
- addFunction(TIME_FROM_UNIX_TIME_IN_MS, OptionalATimeTypeComputer.INSTANCE, true);
- addFunction(TIME_FROM_DATETIME, OptionalATimeTypeComputer.INSTANCE, true);
- addFunction(DATETIME_FROM_DATE_TIME, OptionalADateTimeTypeComputer.INSTANCE, true);
- addFunction(DATETIME_FROM_UNIX_TIME_IN_MS, OptionalADateTimeTypeComputer.INSTANCE, true);
- addFunction(DATETIME_FROM_UNIX_TIME_IN_SECS, OptionalADateTimeTypeComputer.INSTANCE, true);
- addFunction(CALENDAR_DURATION_FROM_DATETIME, OptionalADurationTypeComputer.INSTANCE, true);
- addFunction(CALENDAR_DURATION_FROM_DATE, OptionalADurationTypeComputer.INSTANCE, true);
- addFunction(ADJUST_DATETIME_FOR_TIMEZONE, OptionalAStringTypeComputer.INSTANCE, true);
- addFunction(ADJUST_TIME_FOR_TIMEZONE, OptionalAStringTypeComputer.INSTANCE, true);
- addFunction(INTERVAL_BEFORE, OptionalABooleanTypeComputer.INSTANCE, true);
- addFunction(INTERVAL_AFTER, OptionalABooleanTypeComputer.INSTANCE, true);
- addFunction(INTERVAL_MEETS, OptionalABooleanTypeComputer.INSTANCE, true);
- addFunction(INTERVAL_MET_BY, OptionalABooleanTypeComputer.INSTANCE, true);
- addFunction(INTERVAL_OVERLAPS, OptionalABooleanTypeComputer.INSTANCE, true);
- addFunction(INTERVAL_OVERLAPPED_BY, OptionalABooleanTypeComputer.INSTANCE, true);
- addFunction(INTERVAL_OVERLAPPING, OptionalABooleanTypeComputer.INSTANCE, true);
- addFunction(INTERVAL_STARTS, OptionalABooleanTypeComputer.INSTANCE, true);
- addFunction(INTERVAL_STARTED_BY, OptionalABooleanTypeComputer.INSTANCE, true);
- addFunction(INTERVAL_COVERS, OptionalABooleanTypeComputer.INSTANCE, true);
- addFunction(INTERVAL_COVERED_BY, OptionalABooleanTypeComputer.INSTANCE, true);
- addFunction(INTERVAL_ENDS, OptionalABooleanTypeComputer.INSTANCE, true);
- addFunction(INTERVAL_ENDED_BY, OptionalABooleanTypeComputer.INSTANCE, true);
+ addFunction(DATE_FROM_UNIX_TIME_IN_DAYS, ADateTypeComputer.INSTANCE, true);
+ addFunction(DATE_FROM_DATETIME, ADateTypeComputer.INSTANCE, true);
+ addFunction(TIME_FROM_UNIX_TIME_IN_MS, ATimeTypeComputer.INSTANCE, true);
+ addFunction(TIME_FROM_DATETIME, ATimeTypeComputer.INSTANCE, true);
+ addFunction(DATETIME_FROM_DATE_TIME, ADateTimeTypeComputer.INSTANCE, true);
+ addFunction(DATETIME_FROM_UNIX_TIME_IN_MS, ADateTimeTypeComputer.INSTANCE, true);
+ addFunction(DATETIME_FROM_UNIX_TIME_IN_SECS, ADateTimeTypeComputer.INSTANCE, true);
+ addFunction(CALENDAR_DURATION_FROM_DATETIME, ADurationTypeComputer.INSTANCE, true);
+ addFunction(CALENDAR_DURATION_FROM_DATE, ADurationTypeComputer.INSTANCE, true);
+ addFunction(ADJUST_DATETIME_FOR_TIMEZONE, AStringTypeComputer.INSTANCE, true);
+ addFunction(ADJUST_TIME_FOR_TIMEZONE, AStringTypeComputer.INSTANCE, true);
+ addFunction(INTERVAL_BEFORE, ABooleanTypeComputer.INSTANCE, true);
+ addFunction(INTERVAL_AFTER, ABooleanTypeComputer.INSTANCE, true);
+ addFunction(INTERVAL_MEETS, ABooleanTypeComputer.INSTANCE, true);
+ addFunction(INTERVAL_MET_BY, ABooleanTypeComputer.INSTANCE, true);
+ addFunction(INTERVAL_OVERLAPS, ABooleanTypeComputer.INSTANCE, true);
+ addFunction(INTERVAL_OVERLAPPED_BY, ABooleanTypeComputer.INSTANCE, true);
+ addFunction(INTERVAL_OVERLAPPING, ABooleanTypeComputer.INSTANCE, true);
+ addFunction(INTERVAL_STARTS, ABooleanTypeComputer.INSTANCE, true);
+ addFunction(INTERVAL_STARTED_BY, ABooleanTypeComputer.INSTANCE, true);
+ addFunction(INTERVAL_COVERS, ABooleanTypeComputer.INSTANCE, true);
+ addFunction(INTERVAL_COVERED_BY, ABooleanTypeComputer.INSTANCE, true);
+ addFunction(INTERVAL_ENDS, ABooleanTypeComputer.INSTANCE, true);
+ addFunction(INTERVAL_ENDED_BY, ABooleanTypeComputer.INSTANCE, true);
addFunction(CURRENT_DATE, ADateTypeComputer.INSTANCE, false);
addFunction(CURRENT_TIME, ATimeTypeComputer.INSTANCE, false);
addFunction(CURRENT_DATETIME, ADateTimeTypeComputer.INSTANCE, false);
- addPrivateFunction(DAY_TIME_DURATION_GREATER_THAN, OptionalABooleanTypeComputer.INSTANCE, true);
- addPrivateFunction(DAY_TIME_DURATION_LESS_THAN, OptionalABooleanTypeComputer.INSTANCE, true);
- addPrivateFunction(YEAR_MONTH_DURATION_GREATER_THAN, OptionalABooleanTypeComputer.INSTANCE, true);
- addPrivateFunction(YEAR_MONTH_DURATION_LESS_THAN, OptionalABooleanTypeComputer.INSTANCE, true);
- addPrivateFunction(DURATION_EQUAL, OptionalABooleanTypeComputer.INSTANCE, true);
- addFunction(DURATION_FROM_MONTHS, OptionalADurationTypeComputer.INSTANCE, true);
- addFunction(DURATION_FROM_MILLISECONDS, OptionalADurationTypeComputer.INSTANCE, true);
- addFunction(MONTHS_FROM_YEAR_MONTH_DURATION, OptionalAInt64TypeComputer.INSTANCE, true);
- addFunction(MILLISECONDS_FROM_DAY_TIME_DURATION, OptionalAInt64TypeComputer.INSTANCE, true);
- addFunction(GET_DAY_TIME_DURATION, OptionalADayTimeDurationTypeComputer.INSTANCE, true);
- addFunction(GET_YEAR_MONTH_DURATION, OptionalAYearMonthDurationTypeComputer.INSTANCE, true);
- addFunction(INTERVAL_BIN, OptionalAIntervalTypeComputer.INSTANCE, true);
- addFunction(DAY_OF_WEEK, OptionalAInt64TypeComputer.INSTANCE, true);
- addFunction(PARSE_DATE, OptionalADateTypeComputer.INSTANCE, true);
- addFunction(PARSE_TIME, OptionalATimeTypeComputer.INSTANCE, true);
- addFunction(PARSE_DATETIME, OptionalADateTimeTypeComputer.INSTANCE, true);
- addFunction(PRINT_DATE, OptionalAStringTypeComputer.INSTANCE, true);
- addFunction(PRINT_TIME, OptionalAStringTypeComputer.INSTANCE, true);
- addFunction(PRINT_DATETIME, OptionalAStringTypeComputer.INSTANCE, true);
+ addPrivateFunction(DAY_TIME_DURATION_GREATER_THAN, ABooleanTypeComputer.INSTANCE, true);
+ addPrivateFunction(DAY_TIME_DURATION_LESS_THAN, ABooleanTypeComputer.INSTANCE, true);
+ addPrivateFunction(YEAR_MONTH_DURATION_GREATER_THAN, ABooleanTypeComputer.INSTANCE, true);
+ addPrivateFunction(YEAR_MONTH_DURATION_LESS_THAN, ABooleanTypeComputer.INSTANCE, true);
+ addPrivateFunction(DURATION_EQUAL, ABooleanTypeComputer.INSTANCE, true);
+ addFunction(DURATION_FROM_MONTHS, ADurationTypeComputer.INSTANCE, true);
+ addFunction(DURATION_FROM_MILLISECONDS, ADurationTypeComputer.INSTANCE, true);
+ addFunction(MONTHS_FROM_YEAR_MONTH_DURATION, AInt64TypeComputer.INSTANCE, true);
+ addFunction(MILLISECONDS_FROM_DAY_TIME_DURATION, AInt64TypeComputer.INSTANCE, true);
+ addFunction(GET_DAY_TIME_DURATION, ADayTimeDurationTypeComputer.INSTANCE, true);
+ addFunction(GET_YEAR_MONTH_DURATION, AYearMonthDurationTypeComputer.INSTANCE, true);
+ addFunction(INTERVAL_BIN, AIntervalTypeComputer.INSTANCE, true);
+ addFunction(DAY_OF_WEEK, AInt64TypeComputer.INSTANCE, true);
+ addFunction(PARSE_DATE, ADateTypeComputer.INSTANCE, true);
+ addFunction(PARSE_TIME, ATimeTypeComputer.INSTANCE, true);
+ addFunction(PARSE_DATETIME, ADateTimeTypeComputer.INSTANCE, true);
+ addFunction(PRINT_DATE, AStringTypeComputer.INSTANCE, true);
+ addFunction(PRINT_TIME, AStringTypeComputer.INSTANCE, true);
+ addFunction(PRINT_DATETIME, AStringTypeComputer.INSTANCE, true);
addFunction(OVERLAP_BINS, OrderedListOfAIntervalTypeComputer.INSTANCE, true);
addFunction(GET_OVERLAPPING_INTERVAL, GetOverlappingInvervalTypeComputer.INSTANCE, true);
- addFunction(DURATION_FROM_INTERVAL, OptionalADayTimeDurationTypeComputer.INSTANCE, true);
+ addFunction(DURATION_FROM_INTERVAL, ADayTimeDurationTypeComputer.INSTANCE, true);
// interval constructors
- addFunction(INTERVAL_CONSTRUCTOR, OptionalAIntervalTypeComputer.INSTANCE, true);
- addFunction(INTERVAL_CONSTRUCTOR_START_FROM_DATE, OptionalAIntervalTypeComputer.INSTANCE, true);
- addFunction(INTERVAL_CONSTRUCTOR_START_FROM_DATETIME, OptionalAIntervalTypeComputer.INSTANCE, true);
- addFunction(INTERVAL_CONSTRUCTOR_START_FROM_TIME, OptionalAIntervalTypeComputer.INSTANCE, true);
+ addFunction(INTERVAL_CONSTRUCTOR, AIntervalTypeComputer.INSTANCE, true);
+ addFunction(INTERVAL_CONSTRUCTOR_START_FROM_DATE, AIntervalTypeComputer.INSTANCE, true);
+ addFunction(INTERVAL_CONSTRUCTOR_START_FROM_DATETIME, AIntervalTypeComputer.INSTANCE, true);
+ addFunction(INTERVAL_CONSTRUCTOR_START_FROM_TIME, AIntervalTypeComputer.INSTANCE, true);
// meta() function
- addFunction(META, OptionalOpenARecordTypeComputer.INSTANCE, true);
+ addFunction(META, OpenARecordTypeComputer.INSTANCE, true);
addPrivateFunction(META_KEY, AnyTypeComputer.INSTANCE, false);
addPrivateFunction(COLLECTION_TO_SEQUENCE, CollectionToSequenceTypeComputer.INSTANCE, true);
@@ -1043,6 +1035,9 @@
// external lookup
addPrivateFunction(EXTERNAL_LOOKUP, AnyTypeComputer.INSTANCE, false);
+ // unnesting function
+ addPrivateFunction(SCAN_COLLECTION, CollectionMemberResultType.INSTANCE, true);
+
String metadataFunctionLoaderClassName = "org.apache.asterix.metadata.functions.MetadataBuiltinFunctions";
try {
Class.forName(metadataFunctionLoaderClassName);
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/ARecordVisitablePointable.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/ARecordVisitablePointable.java
index 67b62d6..ca4a5be 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/ARecordVisitablePointable.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/ARecordVisitablePointable.java
@@ -25,7 +25,6 @@
import java.util.List;
import org.apache.asterix.common.exceptions.AsterixException;
-import org.apache.asterix.dataflow.data.nontagged.AqlNullWriterFactory;
import org.apache.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
import org.apache.asterix.om.pointables.base.IVisitablePointable;
import org.apache.asterix.om.pointables.visitor.IVisitablePointableVisitor;
@@ -37,7 +36,6 @@
import org.apache.asterix.om.util.NonTaggedFormatUtil;
import org.apache.asterix.om.util.ResettableByteArrayOutputStream;
import org.apache.asterix.om.util.container.IObjectFactory;
-import org.apache.hyracks.api.dataflow.value.INullWriter;
import org.apache.hyracks.util.string.UTF8StringWriter;
/**
@@ -101,9 +99,10 @@
for (int i = 0; i < numberOfSchemaFields; i++) {
ATypeTag ftypeTag = fieldTypes[i].getTypeTag();
- if (NonTaggedFormatUtil.isOptional(fieldTypes[i]))
+ if (NonTaggedFormatUtil.isOptional(fieldTypes[i])) {
// optional field: add the embedded non-null type tag
- ftypeTag = ((AUnionType) fieldTypes[i]).getNullableType().getTypeTag();
+ ftypeTag = ((AUnionType) fieldTypes[i]).getActualType().getTypeTag();
+ }
// add type tag Reference
int tagStart = typeBos.size();
@@ -125,8 +124,7 @@
// initialize a constant: null value bytes reference
int nullFieldStart = typeBos.size();
- INullWriter nullWriter = AqlNullWriterFactory.INSTANCE.createNullWriter();
- nullWriter.writeNull(typeDos);
+ typeDos.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
int nullFieldEnd = typeBos.size();
nullReference.set(typeBos.getByteArray(), nullFieldStart, nullFieldEnd - nullFieldStart);
} catch (IOException e) {
@@ -143,10 +141,12 @@
allocator.reset();
// clean up the returned containers
- for (int i = fieldNames.size() - 1; i >= numberOfSchemaFields; i--)
+ for (int i = fieldNames.size() - 1; i >= numberOfSchemaFields; i--) {
fieldNames.remove(i);
- for (int i = fieldTypeTags.size() - 1; i >= numberOfSchemaFields; i--)
+ }
+ for (int i = fieldTypeTags.size() - 1; i >= numberOfSchemaFields; i--) {
fieldTypeTags.remove(i);
+ }
fieldValues.clear();
}
@@ -208,8 +208,8 @@
IAType fieldType = fieldTypes[fieldNumber];
if (fieldTypes[fieldNumber].getTypeTag() == ATypeTag.UNION) {
- if (((AUnionType) fieldTypes[fieldNumber]).isNullableType()) {
- fieldType = ((AUnionType) fieldTypes[fieldNumber]).getNullableType();
+ if (((AUnionType) fieldTypes[fieldNumber]).isUnknownableType()) {
+ fieldType = ((AUnionType) fieldTypes[fieldNumber]).getActualType();
typeTag = fieldType.getTypeTag();
fieldValueLength = NonTaggedFormatUtil.getFieldValueLength(b, fieldOffsets[fieldNumber],
typeTag, false);
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/ARecordCaster.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/ARecordCaster.java
index 15f6c4a..960d7ea 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/ARecordCaster.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/cast/ARecordCaster.java
@@ -30,7 +30,6 @@
import org.apache.asterix.builders.RecordBuilder;
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.common.exceptions.TypeException;
-import org.apache.asterix.dataflow.data.nontagged.AqlNullWriterFactory;
import org.apache.asterix.om.pointables.ARecordVisitablePointable;
import org.apache.asterix.om.pointables.PointableAllocator;
import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
@@ -39,6 +38,7 @@
import org.apache.asterix.om.types.ARecordType;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.AUnionType;
+import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
@@ -47,7 +47,6 @@
import org.apache.hyracks.algebricks.common.utils.Pair;
import org.apache.hyracks.algebricks.common.utils.Triple;
import org.apache.hyracks.api.dataflow.value.IBinaryComparator;
-import org.apache.hyracks.api.dataflow.value.INullWriter;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.accessors.PointableBinaryComparatorFactory;
import org.apache.hyracks.data.std.api.IValueReference;
@@ -74,6 +73,7 @@
private final RecordBuilder recBuilder = new RecordBuilder();
private final IVisitablePointable nullReference = allocator.allocateEmpty();
private final IVisitablePointable nullTypeTag = allocator.allocateEmpty();
+ private final IVisitablePointable missingTypeTag = allocator.allocateEmpty();
private final IBinaryComparator fieldNameComparator = PointableBinaryComparatorFactory
.of(UTF8StringPointable.FACTORY).createBinaryComparator();
@@ -102,11 +102,14 @@
try {
bos.reset();
int start = bos.size();
- INullWriter nullWriter = AqlNullWriterFactory.INSTANCE.createNullWriter();
- nullWriter.writeNull(dos);
+ dos.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
int end = bos.size();
nullReference.set(bos.getByteArray(), start, end - start);
start = bos.size();
+ dos.write(ATypeTag.SERIALIZED_MISSING_TYPE_TAG);
+ end = bos.size();
+ missingTypeTag.set(bos.getByteArray(), start, end - start);
+ start = bos.size();
dos.write(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
end = bos.size();
nullTypeTag.set(bos.getByteArray(), start, end - start);
@@ -142,12 +145,15 @@
}
private void reset() {
- for (int i = 0; i < numInputFields; i++)
+ for (int i = 0; i < numInputFields; i++) {
openFields[i] = true;
- for (int i = 0; i < fieldPermutation.length; i++)
+ }
+ for (int i = 0; i < fieldPermutation.length; i++) {
fieldPermutation[i] = -1;
- for (int i = 0; i < numInputFields; i++)
+ }
+ for (int i = 0; i < numInputFields; i++) {
fieldNamesSortedIndex[i] = i;
+ }
outputBos.reset();
}
@@ -161,8 +167,9 @@
String[] fieldNames = reqType.getFieldNames();
fieldPermutation = new int[numSchemaFields];
optionalFields = new boolean[numSchemaFields];
- for (int i = 0; i < optionalFields.length; i++)
+ for (int i = 0; i < optionalFields.length; i++) {
optionalFields[i] = false;
+ }
bos.reset(nullTypeTag.getStartOffset() + nullTypeTag.getLength());
for (int i = 0; i < numSchemaFields; i++) {
@@ -172,7 +179,7 @@
// add type tag pointable
if (NonTaggedFormatUtil.isOptional(fieldTypes[i])) {
// optional field: add the embedded non-null type tag
- ftypeTag = ((AUnionType) fieldTypes[i]).getNullableType().getTypeTag();
+ ftypeTag = ((AUnionType) fieldTypes[i]).getActualType().getTypeTag();
optionalFields[i] = true;
}
int tagStart = bos.size();
@@ -193,8 +200,9 @@
}
reqFieldNamesSortedIndex = new int[reqFieldNames.size()];
- for (int i = 0; i < reqFieldNamesSortedIndex.length; i++)
+ for (int i = 0; i < reqFieldNamesSortedIndex.length; i++) {
reqFieldNamesSortedIndex[i] = i;
+ }
// sort the field name index
quickSort(reqFieldNamesSortedIndex, reqFieldNames, 0, reqFieldNamesSortedIndex.length - 1);
}
@@ -214,7 +222,8 @@
IVisitablePointable reqFieldTypeTag = reqFieldTypeTags.get(reqFnPos);
if (fieldTypeTag.equals(reqFieldTypeTag) || (
// match the null type of optional field
- optionalFields[reqFnPos] && fieldTypeTag.equals(nullTypeTag))) {
+ optionalFields[reqFnPos] && (fieldTypeTag.equals(nullTypeTag))
+ || fieldTypeTag.equals(missingTypeTag))) {
fieldPermutation[reqFnPos] = fnPos;
openFields[fnPos] = false;
} else {
@@ -233,10 +242,12 @@
fnStart++;
reqFnStart++;
}
- if (c > 0)
+ if (c > 0) {
reqFnStart++;
- if (c < 0)
+ }
+ if (c < 0) {
fnStart++;
+ }
}
// check unmatched fields in the input type
@@ -282,7 +293,7 @@
private void writeOutput(List<IVisitablePointable> fieldNames, List<IVisitablePointable> fieldTypeTags,
List<IVisitablePointable> fieldValues, DataOutput output, ACastVisitor visitor)
- throws IOException, AsterixException {
+ throws IOException, AsterixException {
// reset the states of the record builder
recBuilder.reset(cachedReqType);
recBuilder.init();
@@ -297,11 +308,12 @@
// recursively casting, the result of casting can always be thought
// as flat
if (optionalFields[i]) {
- if (pos == -1 || fieldTypeTags.get(pos) == null || fieldTypeTags.get(pos).equals(nullTypeTag)) {
+ if (pos == -1 || fieldTypeTags.get(pos) == null || fieldTypeTags.get(pos).equals(nullTypeTag)
+ || fieldTypeTags.get(pos).equals(missingTypeTag)) {
//the field is optional in the input record
- nestedVisitorArg.second = ((AUnionType) fType).getUnionList().get(0);
+ nestedVisitorArg.second = BuiltinType.ANULL;
} else {
- nestedVisitorArg.second = ((AUnionType) fType).getNullableType();
+ nestedVisitorArg.second = ((AUnionType) fType).getActualType();
}
}
field.accept(visitor, nestedVisitorArg);
@@ -327,8 +339,9 @@
private void quickSort(int[] index, List<IVisitablePointable> names, int start, int end)
throws HyracksDataException {
- if (end <= start)
+ if (end <= start) {
return;
+ }
int i = partition(index, names, start, end);
quickSort(index, names, start, i - 1);
quickSort(index, names, i + 1, end);
@@ -340,13 +353,18 @@
int j = right;
while (true) {
// grow from the left
- while (compare(names.get(index[++i]), names.get(index[right])) < 0);
+ while (compare(names.get(index[++i]), names.get(index[right])) < 0) {
+ ;
+ }
// lower from the right
- while (compare(names.get(index[right]), names.get(index[--j])) < 0)
- if (j == left)
+ while (compare(names.get(index[right]), names.get(index[--j])) < 0) {
+ if (j == left) {
break;
- if (i >= j)
+ }
+ }
+ if (i >= j) {
break;
+ }
// swap i and j
swap(index, i, j);
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/nonvisitor/ARecordPointable.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/nonvisitor/ARecordPointable.java
index e3e09d8..257914c 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/nonvisitor/ARecordPointable.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/nonvisitor/ARecordPointable.java
@@ -231,7 +231,7 @@
IAType aType = recordType.getFieldTypes()[fieldId];
if (NonTaggedFormatUtil.isOptional(aType)) {
// optional field: add the embedded non-null type tag
- aType = ((AUnionType) aType).getNullableType();
+ aType = ((AUnionType) aType).getActualType();
}
return aType;
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/adm/AListPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/adm/AListPrinter.java
index c5964b4..afa3fb7 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/adm/AListPrinter.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/adm/AListPrinter.java
@@ -52,8 +52,8 @@
}
}
- public void printList(AListVisitablePointable listAccessor, PrintStream ps, APrintVisitor visitor) throws IOException,
- AsterixException {
+ public void printList(AListVisitablePointable listAccessor, PrintStream ps, APrintVisitor visitor)
+ throws IOException, AsterixException {
List<IVisitablePointable> itemTags = listAccessor.getItemTags();
List<IVisitablePointable> items = listAccessor.getItems();
itemVisitorArg.first = ps;
@@ -81,8 +81,8 @@
int i) throws AsterixException {
IVisitablePointable itemTypeTag = itemTags.get(i);
IVisitablePointable item = items.get(i);
- ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(itemTypeTag.getByteArray()[itemTypeTag
- .getStartOffset()]);
+ ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(itemTypeTag.getByteArray()[itemTypeTag.getStartOffset()]);
itemVisitorArg.second = item.getLength() <= 1 ? ATypeTag.NULL : typeTag;
item.accept(visitor, itemVisitorArg);
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/adm/APrintVisitor.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/adm/APrintVisitor.java
index 7e2b4b8..cd91c09 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/adm/APrintVisitor.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/adm/APrintVisitor.java
@@ -19,6 +19,11 @@
package org.apache.asterix.om.pointables.printer.adm;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.dataflow.data.nontagged.printers.adm.ABinaryHexPrinter;
import org.apache.asterix.dataflow.data.nontagged.printers.adm.ABooleanPrinter;
@@ -54,11 +59,6 @@
import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
import org.apache.hyracks.algebricks.common.utils.Pair;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.HashMap;
-import java.util.Map;
-
/**
* This class is a IVisitablePointableVisitor implementation which recursively
* visit a given record, list or flat value of a given type, and print it to a
@@ -124,6 +124,7 @@
AInt64Printer.INSTANCE.print(b, s, l, ps);
break;
}
+ case MISSING:
case NULL: {
ANullPrinter.INSTANCE.print(b, s, l, ps);
break;
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/adm/ARecordPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/adm/ARecordPrinter.java
index 4cbcf71..ef14e3e 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/adm/ARecordPrinter.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/adm/ARecordPrinter.java
@@ -19,6 +19,10 @@
package org.apache.asterix.om.pointables.printer.adm;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.List;
+
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.om.pointables.ARecordVisitablePointable;
import org.apache.asterix.om.pointables.base.IVisitablePointable;
@@ -26,10 +30,6 @@
import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.hyracks.algebricks.common.utils.Pair;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.List;
-
/**
* This class is to print the content of a record. It is ONLY visible to
* APrintVisitor.
@@ -47,8 +47,8 @@
}
- public void printRecord(ARecordVisitablePointable recordAccessor, PrintStream ps, APrintVisitor visitor) throws IOException,
- AsterixException {
+ public void printRecord(ARecordVisitablePointable recordAccessor, PrintStream ps, APrintVisitor visitor)
+ throws IOException, AsterixException {
List<IVisitablePointable> fieldNames = recordAccessor.getFieldNames();
List<IVisitablePointable> fieldTags = recordAccessor.getFieldTypeTags();
List<IVisitablePointable> fieldValues = recordAccessor.getFieldValues();
@@ -79,8 +79,8 @@
List<IVisitablePointable> fieldTags, List<IVisitablePointable> fieldValues, int i) throws AsterixException {
IVisitablePointable itemTypeTag = fieldTags.get(i);
IVisitablePointable item = fieldValues.get(i);
- ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(itemTypeTag.getByteArray()[itemTypeTag
- .getStartOffset()]);
+ ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(itemTypeTag.getByteArray()[itemTypeTag.getStartOffset()]);
itemVisitorArg.second = item.getLength() <= 1 ? ATypeTag.NULL : typeTag;
// print field name
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/csv/APrintVisitor.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/csv/APrintVisitor.java
index 0254ef6..306ed99 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/csv/APrintVisitor.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/csv/APrintVisitor.java
@@ -19,6 +19,11 @@
package org.apache.asterix.om.pointables.printer.csv;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.dataflow.data.nontagged.printers.adm.ShortWithoutTypeInfoPrinter;
import org.apache.asterix.dataflow.data.nontagged.printers.csv.ABinaryHexPrinter;
@@ -53,11 +58,6 @@
import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
import org.apache.hyracks.algebricks.common.utils.Pair;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.HashMap;
-import java.util.Map;
-
/**
* This class is a IVisitablePointableVisitor implementation which recursively
* visit a given record, list or flat value of a given type, and print it to a
@@ -120,6 +120,7 @@
AInt64Printer.INSTANCE.print(b, s, l, ps);
break;
}
+ case MISSING:
case NULL: {
ANullPrinter.INSTANCE.print(b, s, l, ps);
break;
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/csv/ARecordPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/csv/ARecordPrinter.java
index e6eb12c..5388837 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/csv/ARecordPrinter.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/csv/ARecordPrinter.java
@@ -45,8 +45,8 @@
}
- public void printRecord(ARecordVisitablePointable recordAccessor, PrintStream ps, APrintVisitor visitor) throws IOException,
- AsterixException {
+ public void printRecord(ARecordVisitablePointable recordAccessor, PrintStream ps, APrintVisitor visitor)
+ throws IOException, AsterixException {
List<IVisitablePointable> fieldNames = recordAccessor.getFieldNames();
List<IVisitablePointable> fieldTags = recordAccessor.getFieldTypeTags();
List<IVisitablePointable> fieldValues = recordAccessor.getFieldValues();
@@ -71,8 +71,8 @@
List<IVisitablePointable> fieldTags, List<IVisitablePointable> fieldValues, int i) throws AsterixException {
IVisitablePointable itemTypeTag = fieldTags.get(i);
IVisitablePointable item = fieldValues.get(i);
- ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(itemTypeTag.getByteArray()[itemTypeTag
- .getStartOffset()]);
+ ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(itemTypeTag.getByteArray()[itemTypeTag.getStartOffset()]);
itemVisitorArg.second = item.getLength() <= 1 ? ATypeTag.NULL : typeTag;
// print field value
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/clean/AListPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/clean/AListPrinter.java
index 892a8b68..826c465 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/clean/AListPrinter.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/clean/AListPrinter.java
@@ -44,8 +44,8 @@
public AListPrinter(boolean ordered) {
}
- public void printList(AListVisitablePointable listAccessor, PrintStream ps, APrintVisitor visitor) throws IOException,
- AsterixException {
+ public void printList(AListVisitablePointable listAccessor, PrintStream ps, APrintVisitor visitor)
+ throws IOException, AsterixException {
List<IVisitablePointable> itemTags = listAccessor.getItemTags();
List<IVisitablePointable> items = listAccessor.getItems();
itemVisitorArg.first = ps;
@@ -73,8 +73,8 @@
int i) throws AsterixException {
IVisitablePointable itemTypeTag = itemTags.get(i);
IVisitablePointable item = items.get(i);
- ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(itemTypeTag.getByteArray()[itemTypeTag
- .getStartOffset()]);
+ ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(itemTypeTag.getByteArray()[itemTypeTag.getStartOffset()]);
itemVisitorArg.second = item.getLength() <= 1 ? ATypeTag.NULL : typeTag;
item.accept(visitor, itemVisitorArg);
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/clean/APrintVisitor.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/clean/APrintVisitor.java
index ac0b73a..81677f1 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/clean/APrintVisitor.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/clean/APrintVisitor.java
@@ -19,6 +19,11 @@
package org.apache.asterix.om.pointables.printer.json.clean;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.dataflow.data.nontagged.printers.adm.ShortWithoutTypeInfoPrinter;
import org.apache.asterix.dataflow.data.nontagged.printers.json.clean.ABinaryHexPrinter;
@@ -54,11 +59,6 @@
import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
import org.apache.hyracks.algebricks.common.utils.Pair;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.HashMap;
-import java.util.Map;
-
/**
* This class is a IVisitablePointableVisitor implementation which recursively
* visit a given record, list or flat value of a given type, and print it to a
@@ -124,6 +124,7 @@
AInt64Printer.INSTANCE.print(b, s, l, ps);
break;
}
+ case MISSING:
case NULL: {
ANullPrinter.INSTANCE.print(b, s, l, ps);
break;
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/clean/ARecordPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/clean/ARecordPrinter.java
index 24815b0..6644f3a 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/clean/ARecordPrinter.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/clean/ARecordPrinter.java
@@ -47,8 +47,8 @@
}
- public void printRecord(ARecordVisitablePointable recordAccessor, PrintStream ps, APrintVisitor visitor) throws IOException,
- AsterixException {
+ public void printRecord(ARecordVisitablePointable recordAccessor, PrintStream ps, APrintVisitor visitor)
+ throws IOException, AsterixException {
List<IVisitablePointable> fieldNames = recordAccessor.getFieldNames();
List<IVisitablePointable> fieldTags = recordAccessor.getFieldTypeTags();
List<IVisitablePointable> fieldValues = recordAccessor.getFieldValues();
@@ -79,8 +79,8 @@
List<IVisitablePointable> fieldTags, List<IVisitablePointable> fieldValues, int i) throws AsterixException {
IVisitablePointable itemTypeTag = fieldTags.get(i);
IVisitablePointable item = fieldValues.get(i);
- ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(itemTypeTag.getByteArray()[itemTypeTag
- .getStartOffset()]);
+ ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(itemTypeTag.getByteArray()[itemTypeTag.getStartOffset()]);
itemVisitorArg.second = item.getLength() <= 1 ? ATypeTag.NULL : typeTag;
// print field name
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/lossless/AListPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/lossless/AListPrinter.java
index 435a674..3b6310a 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/lossless/AListPrinter.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/lossless/AListPrinter.java
@@ -49,8 +49,8 @@
}
}
- public void printList(AListVisitablePointable listAccessor, PrintStream ps, APrintVisitor visitor) throws IOException,
- AsterixException {
+ public void printList(AListVisitablePointable listAccessor, PrintStream ps, APrintVisitor visitor)
+ throws IOException, AsterixException {
List<IVisitablePointable> itemTags = listAccessor.getItemTags();
List<IVisitablePointable> items = listAccessor.getItems();
itemVisitorArg.first = ps;
@@ -78,8 +78,8 @@
int i) throws AsterixException {
IVisitablePointable itemTypeTag = itemTags.get(i);
IVisitablePointable item = items.get(i);
- ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(itemTypeTag.getByteArray()[itemTypeTag
- .getStartOffset()]);
+ ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(itemTypeTag.getByteArray()[itemTypeTag.getStartOffset()]);
itemVisitorArg.second = item.getLength() <= 1 ? ATypeTag.NULL : typeTag;
item.accept(visitor, itemVisitorArg);
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/lossless/APrintVisitor.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/lossless/APrintVisitor.java
index 6a96fcd..c0f3d59 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/lossless/APrintVisitor.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/lossless/APrintVisitor.java
@@ -19,6 +19,11 @@
package org.apache.asterix.om.pointables.printer.json.lossless;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.HashMap;
+import java.util.Map;
+
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.dataflow.data.nontagged.printers.adm.ShortWithoutTypeInfoPrinter;
import org.apache.asterix.dataflow.data.nontagged.printers.json.lossless.ABinaryHexPrinter;
@@ -54,11 +59,6 @@
import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
import org.apache.hyracks.algebricks.common.utils.Pair;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.util.HashMap;
-import java.util.Map;
-
/**
* This class is a IVisitablePointableVisitor implementation which recursively
* visit a given record, list or flat value of a given type, and print it to a
@@ -124,6 +124,7 @@
AInt64Printer.INSTANCE.print(b, s, l, ps);
break;
}
+ case MISSING:
case NULL: {
ANullPrinter.INSTANCE.print(b, s, l, ps);
break;
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/lossless/ARecordPrinter.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/lossless/ARecordPrinter.java
index e111f76..fb7d6e1 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/lossless/ARecordPrinter.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/pointables/printer/json/lossless/ARecordPrinter.java
@@ -47,8 +47,8 @@
}
- public void printRecord(ARecordVisitablePointable recordAccessor, PrintStream ps, APrintVisitor visitor) throws IOException,
- AsterixException {
+ public void printRecord(ARecordVisitablePointable recordAccessor, PrintStream ps, APrintVisitor visitor)
+ throws IOException, AsterixException {
List<IVisitablePointable> fieldNames = recordAccessor.getFieldNames();
List<IVisitablePointable> fieldTags = recordAccessor.getFieldTypeTags();
List<IVisitablePointable> fieldValues = recordAccessor.getFieldValues();
@@ -79,8 +79,8 @@
List<IVisitablePointable> fieldTags, List<IVisitablePointable> fieldValues, int i) throws AsterixException {
IVisitablePointable itemTypeTag = fieldTags.get(i);
IVisitablePointable item = fieldValues.get(i);
- ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(itemTypeTag.getByteArray()[itemTypeTag
- .getStartOffset()]);
+ ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(itemTypeTag.getByteArray()[itemTypeTag.getStartOffset()]);
itemVisitorArg.second = item.getLength() <= 1 ? ATypeTag.NULL : typeTag;
// print field name
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/base/AbstractResultTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/base/AbstractResultTypeComputer.java
new file mode 100644
index 0000000..f3e0472
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/base/AbstractResultTypeComputer.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.om.typecomputer.base;
+
+import org.apache.asterix.om.typecomputer.impl.TypeComputeUtils;
+import org.apache.asterix.om.types.IAType;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
+import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
+
+/**
+ * This abstract class takes care of the handling of optional types.
+ * If a subclass follows the MISSING-in-MISSING-out and NULL-in-NULL-out semantics,
+ * then it only needs to think of non-optional types and this abstract class
+ * will strip the input types and wrap the output type.
+ */
+public abstract class AbstractResultTypeComputer implements IResultTypeComputer {
+
+ @Override
+ public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
+ IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+ return TypeComputeUtils.resolveResultType(expression, env, (index, type) -> checkArgType(index, type),
+ types -> getResultType(types), true);
+ }
+
+ /**
+ * Checks whether an input type violates the requirement.
+ *
+ * @param argIndex,
+ * the index of the argument to consider.
+ * @param type,
+ * the type of the input argument.
+ * @throws AlgebricksException
+ */
+ protected void checkArgType(int argIndex, IAType type) throws AlgebricksException {
+
+ }
+
+ /**
+ * Returns the result type without considering optional types.
+ *
+ * @param strippedInputTypes,
+ * the stripped input types.
+ * @return the result type without considering optional types.
+ */
+ protected abstract IAType getResultType(IAType... strippedInputTypes);
+}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/base/TypeCastUtils.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/base/TypeCastUtils.java
new file mode 100644
index 0000000..04883e4
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/base/TypeCastUtils.java
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.om.typecomputer.base;
+
+import org.apache.asterix.om.types.IAType;
+import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
+
+public class TypeCastUtils {
+
+ private TypeCastUtils() {
+ }
+
+ public static boolean setRequiredAndInputTypes(AbstractFunctionCallExpression expr, IAType requiredRecordType,
+ IAType inputRecordType) {
+ boolean changed = false;
+ Object[] opaqueParameters = expr.getOpaqueParameters();
+ if (opaqueParameters == null) {
+ opaqueParameters = new Object[2];
+ opaqueParameters[0] = requiredRecordType;
+ opaqueParameters[1] = inputRecordType;
+ expr.setOpaqueParameters(opaqueParameters);
+ changed = true;
+ }
+ return changed;
+ }
+
+ public static void resetRequiredAndInputTypes(AbstractFunctionCallExpression expr) {
+ expr.setOpaqueParameters(null);
+ }
+
+ public static IAType getRequiredType(AbstractFunctionCallExpression expr) {
+ Object[] type = expr.getOpaqueParameters();
+ if (type != null) {
+ IAType returnType = (IAType) type[0];
+ return returnType;
+ } else {
+ return null;
+ }
+ }
+}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/base/TypeComputerUtilities.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/base/TypeComputerUtilities.java
deleted file mode 100644
index a3d8003..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/base/TypeComputerUtilities.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.asterix.om.typecomputer.base;
-
-import java.util.List;
-
-import org.apache.commons.lang3.mutable.Mutable;
-
-import org.apache.asterix.om.types.ARecordType;
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.AbstractCollectionType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.expressions.ScalarFunctionCallExpression;
-
-public class TypeComputerUtilities {
-
- public static boolean setRequiredAndInputTypes(AbstractFunctionCallExpression expr, IAType requiredRecordType,
- IAType inputRecordType) {
- boolean changed = false;
- Object[] opaqueParameters = expr.getOpaqueParameters();
- if (opaqueParameters == null) {
- opaqueParameters = new Object[2];
- opaqueParameters[0] = requiredRecordType;
- opaqueParameters[1] = inputRecordType;
- expr.setOpaqueParameters(opaqueParameters);
- changed = true;
- }
- return changed;
- }
-
- public static void resetRequiredAndInputTypes(AbstractFunctionCallExpression expr) {
- expr.setOpaqueParameters(null);
- }
-
- public static IAType getRequiredType(AbstractFunctionCallExpression expr) {
- Object[] type = expr.getOpaqueParameters();
- if (type != null) {
- IAType returnType = (IAType) type[0];
- return returnType;
- } else
- return null;
- }
-
- public static IAType getInputType(AbstractFunctionCallExpression expr) {
- Object[] type = expr.getOpaqueParameters();
- if (type != null) {
- IAType returnType = (IAType) type[1];
- return returnType;
- } else
- return null;
- }
-
- public static boolean inputInferednullableType(ILogicalExpression expression, IVariableTypeEnvironment env)
- throws AlgebricksException {
- AbstractFunctionCallExpression func = (AbstractFunctionCallExpression) expression;
- if (!(func instanceof ScalarFunctionCallExpression)) {
- return true;
- }
- List<Mutable<ILogicalExpression>> args = func.getArguments();
- for (Mutable<ILogicalExpression> arg : args) {
- IAType type = (IAType) env.getType(arg.getValue());
- if (type.getTypeTag() == ATypeTag.UNION || type.getTypeTag() == ATypeTag.NULL
- || type.getTypeTag() == ATypeTag.ANY) {
- return true;
- }
- if (type.getTypeTag() == ATypeTag.RECORD || type.getTypeTag() == ATypeTag.UNORDEREDLIST
- || type.getTypeTag() == ATypeTag.ORDEREDLIST) {
- if (nullableCompositeType(type)) {
- return true;
- }
- }
- }
- return false;
- }
-
- private static boolean nullableCompositeType(IAType type) {
- if (type.getTypeTag() == ATypeTag.UNION || type.getTypeTag() == ATypeTag.NULL
- || type.getTypeTag() == ATypeTag.ANY) {
- return true;
- } else if (type.getTypeTag() == ATypeTag.RECORD) {
- ARecordType recordType = (ARecordType) type;
- IAType[] fieldTypes = recordType.getFieldTypes();
- for (IAType fieldType : fieldTypes) {
- boolean nullable = nullableCompositeType(fieldType);
- if (nullable) {
- return true;
- }
- }
- return false;
- } else if (type.getTypeTag() == ATypeTag.UNORDEREDLIST || type.getTypeTag() == ATypeTag.ORDEREDLIST) {
- AbstractCollectionType collectionType = (AbstractCollectionType) type;
- IAType itemType = collectionType.getItemType();
- boolean nullable = nullableCompositeType(itemType);
- if (nullable) {
- return true;
- } else {
- return false;
- }
- } else {
- return false;
- }
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ABinaryTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ABinaryTypeComputer.java
index 311c54f..7f47961 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ABinaryTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ABinaryTypeComputer.java
@@ -19,23 +19,19 @@
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class ABinaryTypeComputer implements IResultTypeComputer {
+public class ABinaryTypeComputer extends AbstractResultTypeComputer {
public static final ABinaryTypeComputer INSTANCE = new ABinaryTypeComputer();
private ABinaryTypeComputer() {
}
- @Override public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+ @Override
+ protected IAType getResultType(IAType... strippedInputTypes) {
return BuiltinType.ABINARY;
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ABooleanTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ABooleanTypeComputer.java
index a855fd2..89ffd4c 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ABooleanTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ABooleanTypeComputer.java
@@ -18,15 +18,11 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class ABooleanTypeComputer implements IResultTypeComputer {
+public class ABooleanTypeComputer extends AbstractResultTypeComputer {
public static final ABooleanTypeComputer INSTANCE = new ABooleanTypeComputer();
@@ -34,8 +30,7 @@
}
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+ protected IAType getResultType(IAType... strippedInputTypes) {
return BuiltinType.ABOOLEAN;
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ACircleTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ACircleTypeComputer.java
index ab178df..e81d2f4 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ACircleTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ACircleTypeComputer.java
@@ -18,15 +18,11 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class ACircleTypeComputer implements IResultTypeComputer {
+public class ACircleTypeComputer extends AbstractResultTypeComputer {
public static final ACircleTypeComputer INSTANCE = new ACircleTypeComputer();
@@ -34,8 +30,7 @@
}
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+ protected IAType getResultType(IAType... strippedInputTypes) {
return BuiltinType.ACIRCLE;
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ADateTimeTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ADateTimeTypeComputer.java
index 319de99..2f4d0d1 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ADateTimeTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ADateTimeTypeComputer.java
@@ -18,15 +18,11 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class ADateTimeTypeComputer implements IResultTypeComputer {
+public class ADateTimeTypeComputer extends AbstractResultTypeComputer {
public static final ADateTimeTypeComputer INSTANCE = new ADateTimeTypeComputer();
@@ -34,8 +30,7 @@
}
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+ protected IAType getResultType(IAType... strippedInputTypes) {
return BuiltinType.ADATETIME;
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ADateTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ADateTypeComputer.java
index 8be058c..dd892cd 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ADateTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ADateTypeComputer.java
@@ -18,15 +18,11 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class ADateTypeComputer implements IResultTypeComputer {
+public class ADateTypeComputer extends AbstractResultTypeComputer {
public static final ADateTypeComputer INSTANCE = new ADateTypeComputer();
@@ -34,8 +30,7 @@
}
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+ protected IAType getResultType(IAType... strippedInputTypes) {
return BuiltinType.ADATE;
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryStringStringOrNullTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ADayTimeDurationTypeComputer.java
similarity index 64%
copy from asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryStringStringOrNullTypeComputer.java
copy to asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ADayTimeDurationTypeComputer.java
index 55df1e3..6139b0d 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryStringStringOrNullTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ADayTimeDurationTypeComputer.java
@@ -18,26 +18,21 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.types.AUnionType;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-/**
- * @author Xiaoyu Ma
- */
-public class BinaryStringStringOrNullTypeComputer extends AbstractBinaryStringTypeComputer {
+public class ADayTimeDurationTypeComputer extends AbstractResultTypeComputer {
- public static final BinaryStringStringOrNullTypeComputer INSTANCE = new BinaryStringStringOrNullTypeComputer();
+ public static final ADayTimeDurationTypeComputer INSTANCE = new ADayTimeDurationTypeComputer();
- private BinaryStringStringOrNullTypeComputer() {
+ private ADayTimeDurationTypeComputer() {
+
}
@Override
- public IAType getResultType(IAType t0, IAType t1, boolean nullable) {
- if (nullable) {
- return AUnionType.createNullableType(BuiltinType.ASTRING);
- }
- return BuiltinType.ASTRING;
+ protected IAType getResultType(IAType... strippedInputTypes) {
+ return BuiltinType.ADAYTIMEDURATION;
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ADoubleTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ADoubleTypeComputer.java
index 9e468bd..eb3de27 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ADoubleTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ADoubleTypeComputer.java
@@ -18,15 +18,11 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class ADoubleTypeComputer implements IResultTypeComputer {
+public class ADoubleTypeComputer extends AbstractResultTypeComputer {
public static final ADoubleTypeComputer INSTANCE = new ADoubleTypeComputer();
@@ -34,8 +30,7 @@
}
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+ protected IAType getResultType(IAType... strippedInputTypes) {
return BuiltinType.ADOUBLE;
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryStringStringOrNullTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ADurationTypeComputer.java
similarity index 64%
copy from asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryStringStringOrNullTypeComputer.java
copy to asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ADurationTypeComputer.java
index 55df1e3..9021284 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryStringStringOrNullTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ADurationTypeComputer.java
@@ -18,26 +18,20 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.types.AUnionType;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-/**
- * @author Xiaoyu Ma
- */
-public class BinaryStringStringOrNullTypeComputer extends AbstractBinaryStringTypeComputer {
+public class ADurationTypeComputer extends AbstractResultTypeComputer {
- public static final BinaryStringStringOrNullTypeComputer INSTANCE = new BinaryStringStringOrNullTypeComputer();
+ public static final ADurationTypeComputer INSTANCE = new ADurationTypeComputer();
- private BinaryStringStringOrNullTypeComputer() {
+ private ADurationTypeComputer() {
}
@Override
- public IAType getResultType(IAType t0, IAType t1, boolean nullable) {
- if (nullable) {
- return AUnionType.createNullableType(BuiltinType.ASTRING);
- }
- return BuiltinType.ASTRING;
+ protected IAType getResultType(IAType... strippedInputTypes) {
+ return BuiltinType.ADURATION;
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AFloatTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AFloatTypeComputer.java
index 052a5a9..d2fd672 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AFloatTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AFloatTypeComputer.java
@@ -18,14 +18,11 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class AFloatTypeComputer implements IResultTypeComputer {
+public class AFloatTypeComputer extends AbstractResultTypeComputer {
public static final AFloatTypeComputer INSTANCE = new AFloatTypeComputer();
@@ -33,8 +30,7 @@
}
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) {
+ protected IAType getResultType(IAType... strippedInputTypes) {
return BuiltinType.AFLOAT;
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryStringStringOrNullTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AInt16TypeComputer.java
similarity index 64%
copy from asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryStringStringOrNullTypeComputer.java
copy to asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AInt16TypeComputer.java
index 55df1e3..ed9d785 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryStringStringOrNullTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AInt16TypeComputer.java
@@ -18,26 +18,20 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.types.AUnionType;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-/**
- * @author Xiaoyu Ma
- */
-public class BinaryStringStringOrNullTypeComputer extends AbstractBinaryStringTypeComputer {
+public class AInt16TypeComputer extends AbstractResultTypeComputer {
- public static final BinaryStringStringOrNullTypeComputer INSTANCE = new BinaryStringStringOrNullTypeComputer();
+ public static final AInt16TypeComputer INSTANCE = new AInt16TypeComputer();
- private BinaryStringStringOrNullTypeComputer() {
+ private AInt16TypeComputer() {
}
@Override
- public IAType getResultType(IAType t0, IAType t1, boolean nullable) {
- if (nullable) {
- return AUnionType.createNullableType(BuiltinType.ASTRING);
- }
- return BuiltinType.ASTRING;
+ protected IAType getResultType(IAType... strippedInputTypes) {
+ return BuiltinType.AINT16;
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AInt32TypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AInt32TypeComputer.java
index 782e246..f0c8f89 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AInt32TypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AInt32TypeComputer.java
@@ -18,15 +18,11 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class AInt32TypeComputer implements IResultTypeComputer {
+public class AInt32TypeComputer extends AbstractResultTypeComputer {
public static final AInt32TypeComputer INSTANCE = new AInt32TypeComputer();
@@ -34,8 +30,7 @@
}
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+ protected IAType getResultType(IAType... strippedInputTypes) {
return BuiltinType.AINT32;
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AInt64TypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AInt64TypeComputer.java
index c6468ca..7c43d67 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AInt64TypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AInt64TypeComputer.java
@@ -18,15 +18,11 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class AInt64TypeComputer implements IResultTypeComputer {
+public class AInt64TypeComputer extends AbstractResultTypeComputer {
public static final AInt64TypeComputer INSTANCE = new AInt64TypeComputer();
@@ -34,8 +30,7 @@
}
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+ protected IAType getResultType(IAType... strippedInputTypes) {
return BuiltinType.AINT64;
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryStringStringOrNullTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AInt8TypeComputer.java
similarity index 64%
copy from asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryStringStringOrNullTypeComputer.java
copy to asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AInt8TypeComputer.java
index 55df1e3..021e514 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryStringStringOrNullTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AInt8TypeComputer.java
@@ -18,26 +18,20 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.types.AUnionType;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-/**
- * @author Xiaoyu Ma
- */
-public class BinaryStringStringOrNullTypeComputer extends AbstractBinaryStringTypeComputer {
+public class AInt8TypeComputer extends AbstractResultTypeComputer {
- public static final BinaryStringStringOrNullTypeComputer INSTANCE = new BinaryStringStringOrNullTypeComputer();
+ public static final AInt8TypeComputer INSTANCE = new AInt8TypeComputer();
- private BinaryStringStringOrNullTypeComputer() {
+ private AInt8TypeComputer() {
}
@Override
- public IAType getResultType(IAType t0, IAType t1, boolean nullable) {
- if (nullable) {
- return AUnionType.createNullableType(BuiltinType.ASTRING);
- }
- return BuiltinType.ASTRING;
+ protected IAType getResultType(IAType... strippedInputTypes) {
+ return BuiltinType.AINT8;
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AIntervalTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AIntervalTypeComputer.java
index f6e3183..93d5a9a 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AIntervalTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AIntervalTypeComputer.java
@@ -18,27 +18,19 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class AIntervalTypeComputer implements IResultTypeComputer {
+public class AIntervalTypeComputer extends AbstractResultTypeComputer {
public static final AIntervalTypeComputer INSTANCE = new AIntervalTypeComputer();
private AIntervalTypeComputer() {
}
- /* (non-Javadoc)
- * @see org.apache.asterix.om.typecomputer.base.IResultTypeComputer#computeType(org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression, org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment, org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider)
- */
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+ protected IAType getResultType(IAType... strippedInputTypes) {
return BuiltinType.AINTERVAL;
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ALineTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ALineTypeComputer.java
index 4250c3a..6c93088 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ALineTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ALineTypeComputer.java
@@ -18,15 +18,11 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class ALineTypeComputer implements IResultTypeComputer {
+public class ALineTypeComputer extends AbstractResultTypeComputer {
public static final ALineTypeComputer INSTANCE = new ALineTypeComputer();
@@ -34,8 +30,7 @@
}
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+ protected IAType getResultType(IAType... strippedInputTypes) {
return BuiltinType.ALINE;
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ANullTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AMissingTypeComputer.java
similarity index 87%
rename from asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ANullTypeComputer.java
rename to asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AMissingTypeComputer.java
index 7803760..bf262c3 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ANullTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AMissingTypeComputer.java
@@ -26,17 +26,17 @@
import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class ANullTypeComputer implements IResultTypeComputer {
+public class AMissingTypeComputer implements IResultTypeComputer {
- public static final ANullTypeComputer INSTANCE = new ANullTypeComputer();
+ public static final AMissingTypeComputer INSTANCE = new AMissingTypeComputer();
- private ANullTypeComputer() {
+ private AMissingTypeComputer() {
}
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- return BuiltinType.ANULL;
+ return BuiltinType.AMISSING;
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/APoint3DTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/APoint3DTypeComputer.java
index cc7be44..74dc67b 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/APoint3DTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/APoint3DTypeComputer.java
@@ -18,15 +18,11 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class APoint3DTypeComputer implements IResultTypeComputer {
+public class APoint3DTypeComputer extends AbstractResultTypeComputer {
public static final APoint3DTypeComputer INSTANCE = new APoint3DTypeComputer();
@@ -34,8 +30,7 @@
}
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+ protected IAType getResultType(IAType... strippedInputTypes) {
return BuiltinType.APOINT3D;
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/APointTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/APointTypeComputer.java
index 133c845..d6cd6f7 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/APointTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/APointTypeComputer.java
@@ -18,15 +18,11 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class APointTypeComputer implements IResultTypeComputer {
+public class APointTypeComputer extends AbstractResultTypeComputer {
public static final APointTypeComputer INSTANCE = new APointTypeComputer();
@@ -34,8 +30,7 @@
}
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+ protected IAType getResultType(IAType... strippedInputTypes) {
return BuiltinType.APOINT;
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/APolygonTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/APolygonTypeComputer.java
index 69a9640..3c7e383 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/APolygonTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/APolygonTypeComputer.java
@@ -18,15 +18,11 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class APolygonTypeComputer implements IResultTypeComputer {
+public class APolygonTypeComputer extends AbstractResultTypeComputer {
public static final APolygonTypeComputer INSTANCE = new APolygonTypeComputer();
@@ -34,8 +30,7 @@
}
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+ protected IAType getResultType(IAType... strippedInputTypes) {
return BuiltinType.APOLYGON;
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ARectangleTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ARectangleTypeComputer.java
index 03c80b2..f308b81 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ARectangleTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ARectangleTypeComputer.java
@@ -18,15 +18,11 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class ARectangleTypeComputer implements IResultTypeComputer {
+public class ARectangleTypeComputer extends AbstractResultTypeComputer {
public static final ARectangleTypeComputer INSTANCE = new ARectangleTypeComputer();
@@ -34,8 +30,7 @@
}
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+ protected IAType getResultType(IAType... strippedInputTypes) {
return BuiltinType.ARECTANGLE;
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AStringTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AStringTypeComputer.java
index 82c22b8..f900b77 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AStringTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AStringTypeComputer.java
@@ -18,15 +18,11 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class AStringTypeComputer implements IResultTypeComputer {
+public class AStringTypeComputer extends AbstractResultTypeComputer {
public static final AStringTypeComputer INSTANCE = new AStringTypeComputer();
@@ -34,8 +30,7 @@
}
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+ protected IAType getResultType(IAType... strippedInputTypes) {
return BuiltinType.ASTRING;
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalATemporalInstanceTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ATemporalInstanceTypeComputer.java
similarity index 74%
rename from asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalATemporalInstanceTypeComputer.java
rename to asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ATemporalInstanceTypeComputer.java
index 0414bb9..7d20bd3 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalATemporalInstanceTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ATemporalInstanceTypeComputer.java
@@ -30,24 +30,22 @@
import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class OptionalATemporalInstanceTypeComputer implements IResultTypeComputer {
+public class ATemporalInstanceTypeComputer implements IResultTypeComputer {
- public static final OptionalATemporalInstanceTypeComputer INSTANCE = new OptionalATemporalInstanceTypeComputer();
+ public static final ATemporalInstanceTypeComputer INSTANCE = new ATemporalInstanceTypeComputer();
- private OptionalATemporalInstanceTypeComputer() {
+ private ATemporalInstanceTypeComputer() {
}
- /* (non-Javadoc)
- * @see org.apache.asterix.om.typecomputer.base.IResultTypeComputer#computeType(org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression, org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment, org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider)
- */
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- List<IAType> unionList = new ArrayList<IAType>();
- unionList.add(BuiltinType.ANULL);
+ List<IAType> unionList = new ArrayList<>();
unionList.add(BuiltinType.ADATE);
unionList.add(BuiltinType.ATIME);
unionList.add(BuiltinType.ADATETIME);
+ unionList.add(BuiltinType.AMISSING);
+ unionList.add(BuiltinType.ANULL);
return new AUnionType(unionList, "OptionalTemporalInstance");
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ATimeTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ATimeTypeComputer.java
index 1897244..a6950e1 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ATimeTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ATimeTypeComputer.java
@@ -18,15 +18,11 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class ATimeTypeComputer implements IResultTypeComputer {
+public class ATimeTypeComputer extends AbstractResultTypeComputer {
public static final ATimeTypeComputer INSTANCE = new ATimeTypeComputer();
@@ -34,8 +30,7 @@
}
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+ protected IAType getResultType(IAType... strippedInputTypes) {
return BuiltinType.ATIME;
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AUUIDTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AUUIDTypeComputer.java
index d5d324c..0a0c923 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AUUIDTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AUUIDTypeComputer.java
@@ -19,15 +19,11 @@
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class AUUIDTypeComputer implements IResultTypeComputer {
+public class AUUIDTypeComputer extends AbstractResultTypeComputer {
public static final AUUIDTypeComputer INSTANCE = new AUUIDTypeComputer();
@@ -35,8 +31,7 @@
}
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+ protected IAType getResultType(IAType... strippedInputTypes) {
return BuiltinType.AUUID;
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryStringStringOrNullTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AYearMonthDurationTypeComputer.java
similarity index 64%
copy from asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryStringStringOrNullTypeComputer.java
copy to asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AYearMonthDurationTypeComputer.java
index 55df1e3..6360f11 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryStringStringOrNullTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AYearMonthDurationTypeComputer.java
@@ -18,26 +18,21 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.types.AUnionType;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-/**
- * @author Xiaoyu Ma
- */
-public class BinaryStringStringOrNullTypeComputer extends AbstractBinaryStringTypeComputer {
+public class AYearMonthDurationTypeComputer extends AbstractResultTypeComputer {
- public static final BinaryStringStringOrNullTypeComputer INSTANCE = new BinaryStringStringOrNullTypeComputer();
+ public static final AYearMonthDurationTypeComputer INSTANCE = new AYearMonthDurationTypeComputer();
- private BinaryStringStringOrNullTypeComputer() {
+ private AYearMonthDurationTypeComputer() {
+
}
@Override
- public IAType getResultType(IAType t0, IAType t1, boolean nullable) {
- if (nullable) {
- return AUnionType.createNullableType(BuiltinType.ASTRING);
- }
- return BuiltinType.ASTRING;
+ protected IAType getResultType(IAType... strippedInputTypes) {
+ return BuiltinType.AYEARMONTHDURATION;
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AbstractBinaryStringTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AbstractBinaryStringTypeComputer.java
deleted file mode 100644
index 522218e..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AbstractBinaryStringTypeComputer.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.util.NonTaggedFormatUtil;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-/**
- * @author Xiaoyu Ma
- */
-abstract public class AbstractBinaryStringTypeComputer implements IResultTypeComputer {
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
- if (fce.getArguments().size() < 2) {
- throw new AlgebricksException("Wrong Argument Number.");
- }
- ILogicalExpression arg0 = fce.getArguments().get(0).getValue();
- ILogicalExpression arg1 = fce.getArguments().get(1).getValue();
- IAType t0 = (IAType) env.getType(arg0);
- IAType t1 = (IAType) env.getType(arg1);
-
- boolean nullable = false;
- ATypeTag tag0, tag1;
- if (NonTaggedFormatUtil.isOptional(t0)) {
- tag0 = ((AUnionType) t0).getNullableType().getTypeTag();
- nullable = true;
- } else {
- tag0 = t0.getTypeTag();
- }
-
- if (NonTaggedFormatUtil.isOptional(t1)) {
- tag1 = ((AUnionType) t1).getNullableType().getTypeTag();
- nullable = true;
- } else {
- tag1 = t1.getTypeTag();
- }
-
- if (tag0 == ATypeTag.NULL && tag1 == ATypeTag.NULL) {
- return BuiltinType.ANULL;
- }
-
- if (tag0 == ATypeTag.NULL || tag1 == ATypeTag.NULL) {
- nullable = true;
- }
-
- // Allow substring to work with ANY types, i.e., types that are unknown at compile time.
- if (tag0 == ATypeTag.ANY || tag1 == ATypeTag.ANY) {
- return BuiltinType.ANY;
- }
-
- if (tag0 != ATypeTag.NULL && tag0 != ATypeTag.STRING) {
- throw new AlgebricksException("First argument should be String Type, but it is " + tag0);
- }
-
- if (tag1 != ATypeTag.NULL && tag1 != ATypeTag.STRING) {
- throw new AlgebricksException("Second argument should be String Type, but it is " + tag1);
- }
- return getResultType(t0, t1, nullable);
- }
-
- public abstract IAType getResultType(IAType t0, IAType t1, boolean nullable);
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AbstractQuadStringTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AbstractQuadStringTypeComputer.java
deleted file mode 100644
index 2abdf08..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AbstractQuadStringTypeComputer.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-/**
- * @author Xiaoyu Ma
- */
-public abstract class AbstractQuadStringTypeComputer implements IResultTypeComputer {
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
- if (fce.getArguments().size() < 4)
- throw new AlgebricksException("Wrong Argument Number.");
- ILogicalExpression arg0 = fce.getArguments().get(0).getValue();
- ILogicalExpression arg1 = fce.getArguments().get(1).getValue();
- ILogicalExpression arg2 = fce.getArguments().get(2).getValue();
- ILogicalExpression arg3 = fce.getArguments().get(3).getValue();
- IAType t0, t1, t2, t3;
- try {
- t0 = (IAType) env.getType(arg0);
- t1 = (IAType) env.getType(arg1);
- t2 = (IAType) env.getType(arg2);
- t3 = (IAType) env.getType(arg3);
- } catch (AlgebricksException e) {
- throw new AlgebricksException(e);
- }
- if ((t0.getTypeTag() != ATypeTag.NULL && t0.getTypeTag() != ATypeTag.STRING)
- || (t1.getTypeTag() != ATypeTag.NULL && t1.getTypeTag() != ATypeTag.STRING)
- || (t2.getTypeTag() != ATypeTag.NULL && t2.getTypeTag() != ATypeTag.STRING)
- || (t3.getTypeTag() != ATypeTag.NULL && t3.getTypeTag() != ATypeTag.STRING)) {
- throw new NotImplementedException("Expects String Type.");
- }
-
- return getResultType(t0, t1, t2, t3);
- }
-
- public abstract IAType getResultType(IAType t0, IAType t1, IAType t2, IAType t3);
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AbstractStringTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AbstractStringTypeComputer.java
new file mode 100644
index 0000000..e45c4cc
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AbstractStringTypeComputer.java
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.om.typecomputer.impl;
+
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.IAType;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+
+abstract public class AbstractStringTypeComputer extends AbstractResultTypeComputer {
+
+ @Override
+ protected void checkArgType(int argIndex, IAType type) throws AlgebricksException {
+ if (type.getTypeTag() != ATypeTag.STRING) {
+ throw new AlgebricksException("The input type for input argument " + argIndex + "(" + type.getDisplayName()
+ + ")" + " is not expected.");
+ }
+ }
+
+ @Override
+ protected abstract IAType getResultType(IAType... strippedInputTypes);
+}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AbstractTripleStringTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AbstractTripleStringTypeComputer.java
deleted file mode 100644
index a322ef9..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/AbstractTripleStringTypeComputer.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-/**
- * @author Xiaoyu Ma
- */
-public abstract class AbstractTripleStringTypeComputer implements IResultTypeComputer {
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
- if (fce.getArguments().size() < 3)
- throw new AlgebricksException("Wrong Argument Number.");
- ILogicalExpression arg0 = fce.getArguments().get(0).getValue();
- ILogicalExpression arg1 = fce.getArguments().get(1).getValue();
- ILogicalExpression arg2 = fce.getArguments().get(2).getValue();
- IAType t0, t1, t2;
- try {
- t0 = (IAType) env.getType(arg0);
- t1 = (IAType) env.getType(arg1);
- t2 = (IAType) env.getType(arg2);
- } catch (AlgebricksException e) {
- throw new AlgebricksException(e);
- }
- if ((t0.getTypeTag() != ATypeTag.NULL && t0.getTypeTag() != ATypeTag.STRING)
- || (t1.getTypeTag() != ATypeTag.NULL && t1.getTypeTag() != ATypeTag.STRING)
- || (t2.getTypeTag() != ATypeTag.NULL && t2.getTypeTag() != ATypeTag.STRING)) {
- throw new AlgebricksException("Expects String Type.");
- }
-
- return getResultType(t0, t1, t2);
- }
-
- public abstract IAType getResultType(IAType t0, IAType t1, IAType t2);
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAStringTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BooleanFunctionTypeComputer.java
similarity index 68%
rename from asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAStringTypeComputer.java
rename to asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BooleanFunctionTypeComputer.java
index 29be8c3..fa944c6 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAStringTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BooleanFunctionTypeComputer.java
@@ -18,9 +18,7 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
-import org.apache.asterix.om.types.AUnionType;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -28,21 +26,23 @@
import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class OptionalAStringTypeComputer implements IResultTypeComputer {
+public class BooleanFunctionTypeComputer extends AbstractResultTypeComputer {
- public static final OptionalAStringTypeComputer INSTANCE = new OptionalAStringTypeComputer();
+ public static final BooleanFunctionTypeComputer INSTANCE = new BooleanFunctionTypeComputer();
- private OptionalAStringTypeComputer() {
+ private BooleanFunctionTypeComputer() {
}
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
- return AUnionType.createNullableType(BuiltinType.ASTRING, "OptionalString");
- } else {
- return BuiltinType.ASTRING;
- }
+ // Boolean type computer doesn't follow the null/missing-in/out semantics.
+ return TypeComputeUtils.resolveResultType(expression, env, (index, type) -> checkArgType(index, type),
+ types -> getResultType(types), false);
}
+ @Override
+ protected IAType getResultType(IAType... strippedInputTypes) {
+ return BuiltinType.ABOOLEAN;
+ }
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ANullTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BooleanOnlyTypeComputer.java
similarity index 86%
copy from asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ANullTypeComputer.java
copy to asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BooleanOnlyTypeComputer.java
index 7803760..27bf16c 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ANullTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BooleanOnlyTypeComputer.java
@@ -26,17 +26,17 @@
import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class ANullTypeComputer implements IResultTypeComputer {
+public class BooleanOnlyTypeComputer implements IResultTypeComputer {
- public static final ANullTypeComputer INSTANCE = new ANullTypeComputer();
+ public static final BooleanOnlyTypeComputer INSTANCE = new BooleanOnlyTypeComputer();
- private ANullTypeComputer() {
+ private BooleanOnlyTypeComputer() {
}
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- return BuiltinType.ANULL;
+ return BuiltinType.ABOOLEAN;
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CastListResultTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CastListResultTypeComputer.java
index 2a65d60..fc4242d 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CastListResultTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CastListResultTypeComputer.java
@@ -20,7 +20,7 @@
package org.apache.asterix.om.typecomputer.impl;
import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
+import org.apache.asterix.om.typecomputer.base.TypeCastUtils;
import org.apache.asterix.om.types.IAType;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
@@ -41,6 +41,6 @@
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
ScalarFunctionCallExpression funcExpr = (ScalarFunctionCallExpression) expression;
- return TypeComputerUtilities.getRequiredType(funcExpr);
+ return TypeCastUtils.getRequiredType(funcExpr);
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CastRecordResultTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CastRecordResultTypeComputer.java
index 039b35f..e95571b 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CastRecordResultTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CastRecordResultTypeComputer.java
@@ -19,7 +19,7 @@
package org.apache.asterix.om.typecomputer.impl;
import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
+import org.apache.asterix.om.typecomputer.base.TypeCastUtils;
import org.apache.asterix.om.types.IAType;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
@@ -35,6 +35,6 @@
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
ScalarFunctionCallExpression funcExpr = (ScalarFunctionCallExpression) expression;
- return TypeComputerUtilities.getRequiredType(funcExpr);
+ return TypeCastUtils.getRequiredType(funcExpr);
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ClosedRecordConstructorResultType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ClosedRecordConstructorResultType.java
index a435f7a..cccc13f 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ClosedRecordConstructorResultType.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ClosedRecordConstructorResultType.java
@@ -24,8 +24,11 @@
import org.apache.asterix.om.base.AString;
import org.apache.asterix.om.constants.AsterixConstantValue;
import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
+import org.apache.asterix.om.typecomputer.base.TypeCastUtils;
import org.apache.asterix.om.types.ARecordType;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.AUnionType;
+import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
import org.apache.commons.lang3.mutable.Mutable;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -48,9 +51,10 @@
/**
* if type has been top-down propagated, use the enforced type
*/
- ARecordType type = (ARecordType) TypeComputerUtilities.getRequiredType(f);
- if (type != null)
+ ARecordType type = (ARecordType) TypeCastUtils.getRequiredType(f);
+ if (type != null) {
return type;
+ }
int n = f.getArguments().size() / 2;
String[] fieldNames = new String[n];
@@ -59,6 +63,16 @@
Iterator<Mutable<ILogicalExpression>> argIter = f.getArguments().iterator();
while (argIter.hasNext()) {
ILogicalExpression e1 = argIter.next().getValue();
+ ILogicalExpression e2 = argIter.next().getValue();
+ IAType e2Type = (IAType) env.getType(e2);
+ if (e2Type.getTypeTag() == ATypeTag.MISSING) {
+ // Converts missing to null for a closed field.
+ e2Type = BuiltinType.ANULL;
+ } else if (e2Type.getTypeTag() == ATypeTag.UNION) {
+ AUnionType unionType = (AUnionType) e2Type;
+ e2Type = AUnionType.createNullableType(unionType.getActualType());
+ }
+ fieldTypes[i] = e2Type;
if (e1.getExpressionTag() == LogicalExpressionTag.CONSTANT) {
ConstantExpression nameExpr = (ConstantExpression) e1;
fieldNames[i] = ((AString) ((AsterixConstantValue) nameExpr.getValue()).getObject()).getStringValue();
@@ -66,8 +80,6 @@
throw new AlgebricksException(
"Field name " + i + "(" + e1 + ") in call to closed-record-constructor is not a constant.");
}
- ILogicalExpression e2 = argIter.next().getValue();
- fieldTypes[i] = (IAType) env.getType(e2);
i++;
}
return new ARecordType(null, fieldNames, fieldTypes, false);
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CollectionMemberResultType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CollectionMemberResultType.java
new file mode 100644
index 0000000..ecdb1d0
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CollectionMemberResultType.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.om.typecomputer.impl;
+
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.AbstractCollectionType;
+import org.apache.asterix.om.types.BuiltinType;
+import org.apache.asterix.om.types.IAType;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+
+public class CollectionMemberResultType extends AbstractResultTypeComputer {
+
+ public static final CollectionMemberResultType INSTANCE = new CollectionMemberResultType();
+
+ protected CollectionMemberResultType() {
+
+ }
+
+ @Override
+ protected void checkArgType(int argIndex, IAType type) throws AlgebricksException {
+ if (type.getTypeTag() != ATypeTag.UNORDEREDLIST && type.getTypeTag() != ATypeTag.ORDEREDLIST) {
+ throw new AlgebricksException("The input type for input argument " + argIndex + "(" + type.getDisplayName()
+ + ")" + " is not expected.");
+ }
+ }
+
+ @Override
+ protected IAType getResultType(IAType... strippedInputTypes) {
+ IAType type = strippedInputTypes[0];
+ if (type.getTypeTag() == ATypeTag.ANY) {
+ return BuiltinType.ANY;
+ }
+ IAType itemType = ((AbstractCollectionType) type).getItemType();
+ return itemType;
+ }
+
+}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CollectionToSequenceTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CollectionToSequenceTypeComputer.java
index 753f9b7..9e93b71 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CollectionToSequenceTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/CollectionToSequenceTypeComputer.java
@@ -18,16 +18,10 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.AbstractCollectionType;
import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.types.TypeHelper;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
/**
* This function is to make a sequence of records and a singleton collection of records
@@ -35,26 +29,13 @@
*
* @author yingyib
*/
-public class CollectionToSequenceTypeComputer implements IResultTypeComputer {
+public class CollectionToSequenceTypeComputer extends AbstractResultTypeComputer {
public static final CollectionToSequenceTypeComputer INSTANCE = new CollectionToSequenceTypeComputer();
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- AbstractFunctionCallExpression func = (AbstractFunctionCallExpression) expression;
- ILogicalExpression arg = func.getArguments().get(0).getValue();
-
- IAType argType = (IAType) env.getType(arg);
- if (TypeHelper.canBeNull(argType)) {
- IAType nonOptionalType = TypeHelper.getNonOptionalType(argType);
- if (nonOptionalType.getTypeTag() == ATypeTag.ORDEREDLIST
- || nonOptionalType.getTypeTag() == ATypeTag.UNORDEREDLIST) {
- /** if the collection is null, that corresponds to an empty sequence */
- argType = nonOptionalType;
- }
- }
-
+ protected IAType getResultType(IAType... strippedInputTypes) {
+ IAType argType = strippedInputTypes[0];
ATypeTag argTypeTag = argType.getTypeTag();
if (argTypeTag == ATypeTag.ORDEREDLIST || argTypeTag == ATypeTag.UNORDEREDLIST) {
/** if the input is a singleton list, return it's item type if any */
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ConcatNonNullTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ConcatNonNullTypeComputer.java
index cd68827..d6fc75d 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ConcatNonNullTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ConcatNonNullTypeComputer.java
@@ -19,14 +19,9 @@
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
/**
* The type computer for concat-not-null.
@@ -34,29 +29,21 @@
*
* @author yingyib
*/
-public class ConcatNonNullTypeComputer implements IResultTypeComputer {
+public class ConcatNonNullTypeComputer extends AbstractResultTypeComputer {
public static final ConcatNonNullTypeComputer INSTANCE = new ConcatNonNullTypeComputer();
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expression;
- if (f.getArguments().size() < 1) {
- return BuiltinType.ANULL;
+ protected IAType getResultType(IAType... strippedInputTypes) {
+ boolean any = false;
+ IAType currentType = null;
+ for (IAType type : strippedInputTypes) {
+ if (currentType != null && !type.equals(currentType)) {
+ any = true;
+ break;
+ }
+ currentType = type;
}
-
- TypeCompatibilityChecker tcc = new TypeCompatibilityChecker();
- for (int i = 0; i < f.getArguments().size(); i++) {
- ILogicalExpression arg = f.getArguments().get(i).getValue();
- IAType type = (IAType) env.getType(arg);
- tcc.addPossibleType(type);
- }
-
- IAType result = tcc.getCompatibleType();
- if (result == null) {
- throw new AlgebricksException("The two branches of the if-else clause should return the same type.");
- }
- return result;
+ return any ? BuiltinType.ANY : currentType;
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessByIndexResultType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessByIndexResultType.java
index 68bb4e1..0cdbb27 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessByIndexResultType.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessByIndexResultType.java
@@ -55,7 +55,7 @@
return null;
}
IAType type0 = (IAType) obj;
- ARecordType t0 = NonTaggedFieldAccessByNameResultType.getRecordTypeFromType(type0, expression);
+ ARecordType t0 = FieldAccessByNameResultType.getRecordTypeFromType(type0, expression);
if (t0 == null) {
return BuiltinType.ANY;
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedFieldAccessByNameResultType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessByNameResultType.java
similarity index 78%
rename from asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedFieldAccessByNameResultType.java
rename to asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessByNameResultType.java
index bc3792f..2e43316 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedFieldAccessByNameResultType.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessByNameResultType.java
@@ -36,11 +36,11 @@
import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class NonTaggedFieldAccessByNameResultType implements IResultTypeComputer {
+public class FieldAccessByNameResultType implements IResultTypeComputer {
- public static final NonTaggedFieldAccessByNameResultType INSTANCE = new NonTaggedFieldAccessByNameResultType();
+ public static final FieldAccessByNameResultType INSTANCE = new FieldAccessByNameResultType();
- private NonTaggedFieldAccessByNameResultType() {
+ private FieldAccessByNameResultType() {
}
@Override
@@ -60,7 +60,7 @@
AbstractLogicalExpression arg1 = (AbstractLogicalExpression) f.getArguments().get(1).getValue();
if (arg1.getExpressionTag() != LogicalExpressionTag.CONSTANT) {
- return null; // BuiltinType.UNKNOWN;
+ return null;
}
ConstantExpression ce = (ConstantExpression) arg1;
@@ -75,28 +75,24 @@
static ARecordType getRecordTypeFromType(IAType type0, ILogicalExpression expression) throws AlgebricksException {
switch (type0.getTypeTag()) {
- case RECORD: {
+ case RECORD:
return (ARecordType) type0;
- }
- case ANY: {
+ case ANY:
return DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE;
- }
- case UNION: {
+ case UNION:
AUnionType u = (AUnionType) type0;
- if (u.isNullableType()) {
- IAType t1 = u.getNullableType();
- if (t1.getTypeTag() == ATypeTag.RECORD) {
- return (ARecordType) t1;
- }
- if (t1.getTypeTag() == ATypeTag.ANY) {
- return DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE;
- }
+ IAType t1 = u.getActualType();
+ if (t1.getTypeTag() == ATypeTag.RECORD) {
+ return (ARecordType) t1;
+ } else if (t1.getTypeTag() == ATypeTag.ANY) {
+ return DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE;
+ } else {
+ throw new AlgebricksException(
+ "Unsupported type " + type0 + " for field access expression: " + expression);
}
- }
- default: {
- throw new AlgebricksException("Unsupported type " + type0 + " for field access expression: "
- + expression);
- }
+ default:
+ throw new AlgebricksException(
+ "Unsupported type " + type0 + " for field access expression: " + expression);
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessNestedResultType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessNestedResultType.java
index d8164b7..6e7dca8 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessNestedResultType.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FieldAccessNestedResultType.java
@@ -54,7 +54,7 @@
return null;
}
IAType type0 = (IAType) obj;
- ARecordType t0 = NonTaggedFieldAccessByNameResultType.getRecordTypeFromType(type0, expression);
+ ARecordType t0 = FieldAccessByNameResultType.getRecordTypeFromType(type0, expression);
if (t0 == null) {
return BuiltinType.ANY;
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FlowRecordResultTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FlowRecordResultTypeComputer.java
index fe0d1ab..27e8a3d 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FlowRecordResultTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/FlowRecordResultTypeComputer.java
@@ -20,7 +20,7 @@
package org.apache.asterix.om.typecomputer.impl;
import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
+import org.apache.asterix.om.typecomputer.base.TypeCastUtils;
import org.apache.asterix.om.types.IAType;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
@@ -36,7 +36,7 @@
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
ScalarFunctionCallExpression funcExpr = (ScalarFunctionCallExpression) expression;
- IAType type = TypeComputerUtilities.getRequiredType(funcExpr);
+ IAType type = TypeCastUtils.getRequiredType(funcExpr);
if (type == null) {
type = (IAType) env.getType(funcExpr.getArguments().get(0).getValue());
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/GetItemResultType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/GetItemResultType.java
deleted file mode 100644
index 97b8654..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/GetItemResultType.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.types.AbstractCollectionType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class GetItemResultType implements IResultTypeComputer {
-
- public static final GetItemResultType INSTANCE = new GetItemResultType();
-
- private GetItemResultType() {
- }
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expression;
- Object type0;
- try {
- type0 = env.getType(f.getArguments().get(0).getValue());
- } catch (AlgebricksException e) {
- throw new AlgebricksException(e);
- }
- if (type0 == null) {
- return null;
- }
- AbstractCollectionType t0 = (AbstractCollectionType) type0;
- return t0.getItemType();
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/GetOverlappingInvervalTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/GetOverlappingInvervalTypeComputer.java
index 46cd97a..1f8c95d 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/GetOverlappingInvervalTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/GetOverlappingInvervalTypeComputer.java
@@ -18,16 +18,12 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.AUnionType;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class GetOverlappingInvervalTypeComputer implements IResultTypeComputer {
+public class GetOverlappingInvervalTypeComputer extends AbstractResultTypeComputer {
public static final GetOverlappingInvervalTypeComputer INSTANCE = new GetOverlappingInvervalTypeComputer();
@@ -35,8 +31,8 @@
}
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+ @Override
+ protected IAType getResultType(IAType... strippedInputTypes) {
return AUnionType.createNullableType(BuiltinType.AINTERVAL, "IntervalOrNullResult");
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/InjectFailureTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/InjectFailureTypeComputer.java
index 8293e18..5d14716 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/InjectFailureTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/InjectFailureTypeComputer.java
@@ -47,7 +47,7 @@
IAType t1 = (IAType) env.getType(fce.getArguments().get(0).getValue());
ATypeTag tag1 = t1.getTypeTag();
if (NonTaggedFormatUtil.isOptional(t1))
- tag1 = ((AUnionType) t1).getNullableType().getTypeTag();
+ tag1 = ((AUnionType) t1).getActualType().getTypeTag();
if (tag1 != ATypeTag.BOOLEAN)
throw new AlgebricksException(errMsg2);
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedLocalAvgTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/LocalAvgTypeComputer.java
similarity index 91%
rename from asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedLocalAvgTypeComputer.java
rename to asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/LocalAvgTypeComputer.java
index 5947b5f..a5858d7 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedLocalAvgTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/LocalAvgTypeComputer.java
@@ -29,9 +29,9 @@
import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class NonTaggedLocalAvgTypeComputer implements IResultTypeComputer {
+public class LocalAvgTypeComputer implements IResultTypeComputer {
- public static final NonTaggedLocalAvgTypeComputer INSTANCE = new NonTaggedLocalAvgTypeComputer();
+ public static final LocalAvgTypeComputer INSTANCE = new LocalAvgTypeComputer();
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/MinMaxAggTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/MinMaxAggTypeComputer.java
new file mode 100644
index 0000000..e484cb4
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/MinMaxAggTypeComputer.java
@@ -0,0 +1,63 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.om.typecomputer.impl;
+
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.AUnionType;
+import org.apache.asterix.om.types.IAType;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
+
+public class MinMaxAggTypeComputer extends AbstractResultTypeComputer {
+ private static final String ERR_MSG = "Aggregator is not implemented for ";
+
+ public static final MinMaxAggTypeComputer INSTANCE = new MinMaxAggTypeComputer();
+
+ private MinMaxAggTypeComputer() {
+ }
+
+ @Override
+ protected void checkArgType(int argIndex, IAType type) throws AlgebricksException {
+ ATypeTag tag = type.getTypeTag();
+ switch (tag) {
+ case DOUBLE:
+ case FLOAT:
+ case INT64:
+ case INT32:
+ case INT16:
+ case INT8:
+ case STRING:
+ case DATE:
+ case TIME:
+ case DATETIME:
+ case YEARMONTHDURATION:
+ case DAYTIMEDURATION:
+ case ANY:
+ return;
+ default:
+ throw new NotImplementedException(ERR_MSG + tag);
+ }
+ }
+
+ @Override
+ protected IAType getResultType(IAType... strippedInputTypes) {
+ return AUnionType.createNullableType(strippedInputTypes[0]);
+ }
+}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedCollectionMemberResultType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedCollectionMemberResultType.java
deleted file mode 100644
index 9eeeafa..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedCollectionMemberResultType.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.AbstractCollectionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.util.NonTaggedFormatUtil;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class NonTaggedCollectionMemberResultType implements IResultTypeComputer {
-
- public static final NonTaggedCollectionMemberResultType INSTANCE = new NonTaggedCollectionMemberResultType();
-
- private NonTaggedCollectionMemberResultType() {
- }
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expression;
- IAType type = (IAType) env.getType(f.getArguments().get(0).getValue());
- if (NonTaggedFormatUtil.isOptional(type)) {
- type = ((AUnionType) type).getNullableType();
- }
- if (type.getTypeTag() == ATypeTag.ANY) {
- return BuiltinType.ANY;
- }
- return ((AbstractCollectionType) type).getItemType();
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedGetItemResultType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedGetItemResultType.java
index 996ed9c..c2c1d1a 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedGetItemResultType.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedGetItemResultType.java
@@ -18,20 +18,16 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.types.AOrderedListType;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.AUnionType;
+import org.apache.asterix.om.types.AbstractCollectionType;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.util.NonTaggedFormatUtil;
+import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class NonTaggedGetItemResultType implements IResultTypeComputer {
+public class NonTaggedGetItemResultType extends AbstractResultTypeComputer {
public static final NonTaggedGetItemResultType INSTANCE = new NonTaggedGetItemResultType();
@@ -39,19 +35,32 @@
}
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expression;
- IAType type = (IAType) env.getType(f.getArguments().get(0).getValue());
- if (NonTaggedFormatUtil.isOptional(type))
- type = ((AUnionType) type).getNullableType();
- if (type.getTypeTag() == ATypeTag.ANY)
- return BuiltinType.ANY;
- else {
- if (((AOrderedListType) type).getItemType().getTypeTag() == ATypeTag.NULL)
- return BuiltinType.ANULL;
- return AUnionType.createNullableType(((AOrderedListType) type).getItemType(), "GetItemResult");
+ protected void checkArgType(int argIndex, IAType type) throws AlgebricksException {
+ if (argIndex == 0) {
+ if (type.getTypeTag() != ATypeTag.UNORDEREDLIST && type.getTypeTag() != ATypeTag.ORDEREDLIST) {
+ throw new AlgebricksException("The input type for input argument " + argIndex + "("
+ + type.getDisplayName() + ")" + " is not expected.");
+ }
+ } else {
+ if (!ATypeHierarchy.isCompatible(type.getTypeTag(), ATypeTag.INT32)) {
+ throw new AlgebricksException("The input type for input argument " + argIndex + "("
+ + type.getDisplayName() + ")" + " is not expected.");
+ }
}
}
+ @Override
+ protected IAType getResultType(IAType... strippedInputTypes) {
+ IAType type = strippedInputTypes[0];
+ if (type.getTypeTag() == ATypeTag.ANY) {
+ return BuiltinType.ANY;
+ }
+ IAType itemType = ((AbstractCollectionType) type).getItemType();
+ if (itemType.getTypeTag() == ATypeTag.ANY) {
+ return itemType;
+ }
+ // Could have out-of-bound access or null elements.
+ return AUnionType.createUnknownableType(itemType);
+ }
+
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedMinMaxAggTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedMinMaxAggTypeComputer.java
deleted file mode 100644
index 138bd8f..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedMinMaxAggTypeComputer.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.util.NonTaggedFormatUtil;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class NonTaggedMinMaxAggTypeComputer implements IResultTypeComputer {
- private static final String errMsg = "Aggregator is not implemented for ";
-
- public static final NonTaggedMinMaxAggTypeComputer INSTANCE = new NonTaggedMinMaxAggTypeComputer();
-
- private NonTaggedMinMaxAggTypeComputer() {
- }
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
- ILogicalExpression arg1 = fce.getArguments().get(0).getValue();
- IAType t1 = (IAType) env.getType(arg1);
- if (t1 == null) {
- return null;
- }
-
- ATypeTag tag1;
- if (NonTaggedFormatUtil.isOptional(t1)) {
- tag1 = ((AUnionType) t1).getNullableType().getTypeTag();
- } else {
- tag1 = t1.getTypeTag();
- }
-
- IAType type;
-
- switch (tag1) {
- case DOUBLE:
- type = BuiltinType.ADOUBLE;
- break;
- case FLOAT:
- type = BuiltinType.AFLOAT;
- break;
- case INT64:
- type = BuiltinType.AINT64;
- break;
- case INT32:
- type = BuiltinType.AINT32;
- break;
- case INT16:
- type = BuiltinType.AINT16;
- break;
- case INT8:
- type = BuiltinType.AINT8;
- break;
- case STRING:
- type = BuiltinType.ASTRING;
- break;
- case DATE:
- type = BuiltinType.ADATE;
- break;
- case TIME:
- type = BuiltinType.ATIME;
- break;
- case DATETIME:
- type = BuiltinType.ADATETIME;
- break;
- case YEARMONTHDURATION:
- type = BuiltinType.AYEARMONTHDURATION;
- break;
- case DAYTIMEDURATION:
- type = BuiltinType.ADAYTIMEDURATION;
- break;
- case ANY:
- return BuiltinType.ANY;
- default: {
- throw new NotImplementedException(errMsg + tag1);
- }
- }
- return AUnionType.createNullableType(type, "SumResult");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedNumericAggTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedNumericAggTypeComputer.java
deleted file mode 100644
index 1642293..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedNumericAggTypeComputer.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.util.NonTaggedFormatUtil;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class NonTaggedNumericAggTypeComputer implements IResultTypeComputer {
-
- private static final String errMsg = "Aggregator is not implemented for ";
-
- public static final NonTaggedNumericAggTypeComputer INSTANCE = new NonTaggedNumericAggTypeComputer();
-
- private NonTaggedNumericAggTypeComputer() {
- }
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
- ILogicalExpression arg1 = fce.getArguments().get(0).getValue();
- IAType t1 = (IAType) env.getType(arg1);
- if (t1 == null) {
- return null;
- }
-
- ATypeTag tag1;
- if (NonTaggedFormatUtil.isOptional(t1)) {
- tag1 = ((AUnionType) t1).getNullableType().getTypeTag();
- } else {
- tag1 = t1.getTypeTag();
- }
-
- IAType type;
- switch (tag1) {
- case DOUBLE:
- type = BuiltinType.ADOUBLE;
- break;
- case FLOAT:
- type = BuiltinType.AFLOAT;
- break;
- case INT64:
- type = BuiltinType.AINT64;
- break;
- case INT32:
- type = BuiltinType.AINT32;
- break;
- case INT16:
- type = BuiltinType.AINT16;
- break;
- case INT8:
- type = BuiltinType.AINT8;
- break;
- case ANY:
- return BuiltinType.ANY;
- default: {
- throw new NotImplementedException(errMsg + tag1);
- }
- }
- return AUnionType.createNullableType(type, "SumResult");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedNumericRoundHalfToEven2TypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedNumericRoundHalfToEven2TypeComputer.java
deleted file mode 100644
index aed28c9..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedNumericRoundHalfToEven2TypeComputer.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/*
- * Numeric round half to even
- * Author : Xiaoyu Ma@UC Irvine
- * 01/30/2012
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.util.NonTaggedFormatUtil;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class NonTaggedNumericRoundHalfToEven2TypeComputer implements IResultTypeComputer {
-
- public static final NonTaggedNumericRoundHalfToEven2TypeComputer INSTANCE = new NonTaggedNumericRoundHalfToEven2TypeComputer();
-
- private NonTaggedNumericRoundHalfToEven2TypeComputer() {
- }
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
- if (fce.getArguments().size() < 2)
- throw new AlgebricksException("Argument number invalid.");
-
- ILogicalExpression arg1 = fce.getArguments().get(0).getValue();
- ILogicalExpression arg2 = fce.getArguments().get(1).getValue();
-
- IAType t1 = (IAType) env.getType(arg1);
- IAType t2 = (IAType) env.getType(arg2);
-
- List<IAType> unionList = new ArrayList<IAType>();
- unionList.add(BuiltinType.ANULL);
-
- ATypeTag tag1, tag2;
- if (NonTaggedFormatUtil.isOptional(t1))
- tag1 = ((AUnionType) t1).getNullableType().getTypeTag();
- else
- tag1 = t1.getTypeTag();
-
- if (NonTaggedFormatUtil.isOptional(t2))
- tag2 = ((AUnionType) t2).getNullableType().getTypeTag();
- else
- tag2 = t2.getTypeTag();
-
- switch (tag2) {
- case INT8:
- case INT16:
- case INT32:
- case INT64:
- break;
- default:
- throw new AlgebricksException("Argument $precision cannot be type " + t2.getTypeName());
- }
-
- IAType type;
- switch (tag1) {
- case INT8:
- type = BuiltinType.AINT8;
- break;
- case INT16:
- type = BuiltinType.AINT16;
- break;
- case INT32:
- type = BuiltinType.AINT32;
- break;
- case INT64:
- type = BuiltinType.AINT64;
- break;
- case FLOAT:
- type = BuiltinType.AFLOAT;
- break;
- case DOUBLE:
- type = BuiltinType.ADOUBLE;
- break;
- case NULL:
- return BuiltinType.ANULL;
- default: {
- throw new NotImplementedException("Arithmetic operations are not implemented for " + t1.getTypeName());
- }
- }
-
- return AUnionType.createNullableType(type, "NumericFuncionsResult");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedNumericUnaryFunctionTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedNumericUnaryFunctionTypeComputer.java
deleted file mode 100644
index 40e13ac..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedNumericUnaryFunctionTypeComputer.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-/*
- * Numeric Unary Functions like abs
- * Author : Xiaoyu Ma@UC Irvine
- * 01/30/2012
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.util.NonTaggedFormatUtil;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class NonTaggedNumericUnaryFunctionTypeComputer implements IResultTypeComputer {
-
- private static final String errMsg = "Arithmetic operations are not implemented for ";
- public static final NonTaggedNumericUnaryFunctionTypeComputer INSTANCE = new NonTaggedNumericUnaryFunctionTypeComputer();
-
- private NonTaggedNumericUnaryFunctionTypeComputer() {
- }
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
- if (fce.getArguments().isEmpty())
- throw new AlgebricksException("Wrong Argument Number.");
-
- ILogicalExpression arg1 = fce.getArguments().get(0).getValue();
-
- IAType t = (IAType) env.getType(arg1);
-
- if (NonTaggedFormatUtil.isOptional(t)) {
- return (IAType) env.getType(arg1);
- }
-
- IAType type;
- switch (t.getTypeTag()) {
- case INT8:
- type = BuiltinType.AINT8;
- break;
- case INT16:
- type = BuiltinType.AINT16;
- break;
- case INT32:
- type = BuiltinType.AINT32;
- break;
- case INT64:
- type = BuiltinType.AINT64;
- break;
- case FLOAT:
- type = BuiltinType.AFLOAT;
- break;
- case DOUBLE:
- type = BuiltinType.ADOUBLE;
- break;
- case NULL:
- return BuiltinType.ANULL;
- case ANY:
- return BuiltinType.ANY;
- default: {
- throw new NotImplementedException(errMsg + t.getTypeName());
- }
- }
-
- return AUnionType.createNullableType(type, "NumericUnaryFuncionsResult");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedSwitchCaseComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedSwitchCaseComputer.java
deleted file mode 100644
index cef24c4..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedSwitchCaseComputer.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class NonTaggedSwitchCaseComputer implements IResultTypeComputer {
-
- private static final String errMsg1 = "switch case should have at least 3 parameters ";
- private static final String errMsg2 = "every case expression should have the same return type";
- private static final String errMsg3 = "swith conditon type should be compatible with each case type";
-
- public static IResultTypeComputer INSTANCE = new NonTaggedSwitchCaseComputer();
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
- if (fce.getArguments().size() < 3)
- throw new AlgebricksException(errMsg1);
-
- TypeCompatibilityChecker tcc = new TypeCompatibilityChecker();
- for (int i = 2; i < fce.getArguments().size(); i += 2) {
- IAType ti = (IAType) env.getType(fce.getArguments().get(i).getValue());
- tcc.addPossibleType(ti);
- }
- IAType valueType = tcc.getCompatibleType();
- if (valueType == null) {
- throw new AlgebricksException(errMsg2);
- }
-
- IAType switchType = (IAType) env.getType(fce.getArguments().get(0).getValue());
- tcc.reset();
- tcc.addPossibleType(switchType);
- for (int i = 1; i < fce.getArguments().size(); i += 2) {
- IAType ti = (IAType) env.getType(fce.getArguments().get(i).getValue());
- tcc.addPossibleType(ti);
- }
- IAType caseType = tcc.getCompatibleType();
- if (caseType == null) {
- throw new AlgebricksException(errMsg3);
- }
- return valueType;
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedUnaryMinusTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedUnaryMinusTypeComputer.java
deleted file mode 100644
index 446953a..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedUnaryMinusTypeComputer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.util.NonTaggedFormatUtil;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class NonTaggedUnaryMinusTypeComputer implements IResultTypeComputer {
-
- public static final NonTaggedUnaryMinusTypeComputer INSTANCE = new NonTaggedUnaryMinusTypeComputer();
-
- private NonTaggedUnaryMinusTypeComputer() {
- }
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
- ILogicalExpression arg1 = fce.getArguments().get(0).getValue();
- IAType envType = (IAType) env.getType(arg1);
- if (NonTaggedFormatUtil.isOptional(envType))
- return envType;
- return AUnionType.createNullableType(envType, "UnaryMinusResult");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NotNullTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NotMissingTypeComputer.java
similarity index 82%
rename from asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NotNullTypeComputer.java
rename to asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NotMissingTypeComputer.java
index 0fd169c..68444c4 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NotNullTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NotMissingTypeComputer.java
@@ -33,15 +33,16 @@
import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
/**
- * This class is the type computer for not-null function.
+ * This class is the type computer for not-missing function.
* If the input type is not a union, we just return it.
* If the input type is a union,
- * case 1: we return a new union without null if the new union still has more than one types;
- * case 2: we return the non-null item type in the original union if there are only null and it in the original union.
+ * case 1: we return a new union without missing if the new union still has more than one types;
+ * case 2: we return the non-missing item type in the original union if there are only missing
+ * and it in the original union.
*/
-public class NotNullTypeComputer implements IResultTypeComputer {
+public class NotMissingTypeComputer implements IResultTypeComputer {
- public static final NotNullTypeComputer INSTANCE = new NotNullTypeComputer();
+ public static final NotMissingTypeComputer INSTANCE = new NotMissingTypeComputer();
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
@@ -54,14 +55,14 @@
}
AUnionType unionType = (AUnionType) type;
- List<IAType> items = new ArrayList<IAType>();
+ List<IAType> items = new ArrayList<>();
// copy the item types
items.addAll(unionType.getUnionList());
- // remove null
+ // remove missing
for (int i = items.size() - 1; i >= 0; i--) {
IAType itemType = items.get(i);
- if (itemType.getTypeTag() == ATypeTag.NULL) {
+ if (itemType.getTypeTag() == ATypeTag.MISSING) {
items.remove(i);
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ANullTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NullableDoubleTypeComputer.java
similarity index 81%
copy from asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ANullTypeComputer.java
copy to asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NullableDoubleTypeComputer.java
index 7803760..94c75d2 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ANullTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NullableDoubleTypeComputer.java
@@ -19,6 +19,7 @@
package org.apache.asterix.om.typecomputer.impl;
import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.types.AUnionType;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -26,17 +27,16 @@
import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class ANullTypeComputer implements IResultTypeComputer {
+public class NullableDoubleTypeComputer implements IResultTypeComputer {
- public static final ANullTypeComputer INSTANCE = new ANullTypeComputer();
+ public static final NullableDoubleTypeComputer INSTANCE = new NullableDoubleTypeComputer();
- private ANullTypeComputer() {
+ private NullableDoubleTypeComputer() {
}
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- return BuiltinType.ANULL;
+ return AUnionType.createMissableType(BuiltinType.ADOUBLE, "OptionalDouble");
}
-
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedNumericAddSubMulDivTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAddSubMulDivTypeComputer.java
similarity index 61%
rename from asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedNumericAddSubMulDivTypeComputer.java
rename to asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAddSubMulDivTypeComputer.java
index c0c595d..f9223e4 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NonTaggedNumericAddSubMulDivTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAddSubMulDivTypeComputer.java
@@ -18,65 +18,31 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.AUnionType;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.util.NonTaggedFormatUtil;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class NonTaggedNumericAddSubMulDivTypeComputer implements IResultTypeComputer {
+public class NumericAddSubMulDivTypeComputer extends AbstractResultTypeComputer {
- private static final String errMsg = "Arithmetic operations are not implemented for ";
+ private static final String ERR_MSG = "Arithmetic operations are not implemented for ";
- public static final NonTaggedNumericAddSubMulDivTypeComputer INSTANCE = new NonTaggedNumericAddSubMulDivTypeComputer();
+ public static final NumericAddSubMulDivTypeComputer INSTANCE = new NumericAddSubMulDivTypeComputer();
- private NonTaggedNumericAddSubMulDivTypeComputer() {
+ private NumericAddSubMulDivTypeComputer() {
}
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
- ILogicalExpression arg1 = fce.getArguments().get(0).getValue();
- ILogicalExpression arg2 = fce.getArguments().get(1).getValue();
- IAType t1;
- IAType t2;
- try {
- t1 = (IAType) env.getType(arg1);
- t2 = (IAType) env.getType(arg2);
- } catch (AlgebricksException e) {
- throw new AlgebricksException(e);
- }
- if (t1 == null || t2 == null) {
- return null;
- }
-
- ATypeTag tag1, tag2;
- if (NonTaggedFormatUtil.isOptional(t1))
- tag1 = ((AUnionType) t1).getNullableType().getTypeTag();
- else
- tag1 = t1.getTypeTag();
-
- if (NonTaggedFormatUtil.isOptional(t2))
- tag2 = ((AUnionType) t2).getNullableType().getTypeTag();
- else
- tag2 = t2.getTypeTag();
-
- if (tag1 == ATypeTag.NULL || tag2 == ATypeTag.NULL) {
- return BuiltinType.ANULL;
- }
+ protected IAType getResultType(IAType... strippedInputTypes) {
+ IAType t1 = strippedInputTypes[0];
+ IAType t2 = strippedInputTypes[1];
+ ATypeTag tag1 = t1.getTypeTag();
+ ATypeTag tag2 = t2.getTypeTag();
IAType type;
-
switch (tag1) {
- case DOUBLE: {
+ case DOUBLE:
switch (tag2) {
case INT8:
case INT16:
@@ -87,14 +53,13 @@
type = BuiltinType.ADOUBLE;
break;
case ANY:
- return BuiltinType.ANY;
- default: {
- throw new NotImplementedException(errMsg + t2.getTypeName());
- }
+ type = BuiltinType.ANY;
+ break;
+ default:
+ throw new NotImplementedException(ERR_MSG + t2.getTypeName());
}
break;
- }
- case FLOAT: {
+ case FLOAT:
switch (tag2) {
case INT8:
case INT16:
@@ -107,14 +72,13 @@
type = BuiltinType.ADOUBLE;
break;
case ANY:
- return BuiltinType.ANY;
- default: {
- throw new NotImplementedException(errMsg + t2.getTypeName());
- }
+ type = BuiltinType.ANY;
+ break;
+ default:
+ throw new NotImplementedException(ERR_MSG + t2.getTypeName());
}
break;
- }
- case INT64: {
+ case INT64:
switch (tag2) {
case INT8:
case INT16:
@@ -129,14 +93,13 @@
type = BuiltinType.ADOUBLE;
break;
case ANY:
- return BuiltinType.ANY;
- default: {
- throw new NotImplementedException(errMsg + t2.getTypeName());
- }
+ type = BuiltinType.ANY;
+ break;
+ default:
+ throw new NotImplementedException(ERR_MSG + t2.getTypeName());
}
break;
- }
- case INT32: {
+ case INT32:
switch (tag2) {
case INT8:
case INT16:
@@ -153,14 +116,13 @@
type = BuiltinType.ADOUBLE;
break;
case ANY:
- return BuiltinType.ANY;
- default: {
- throw new NotImplementedException(errMsg + tag2);
- }
+ type = BuiltinType.ANY;
+ break;
+ default:
+ throw new NotImplementedException(ERR_MSG + tag2);
}
break;
- }
- case INT16: {
+ case INT16:
switch (tag2) {
case INT8:
case INT16:
@@ -179,14 +141,13 @@
type = BuiltinType.ADOUBLE;
break;
case ANY:
- return BuiltinType.ANY;
- default: {
- throw new NotImplementedException(errMsg + tag2);
- }
+ type = BuiltinType.ANY;
+ break;
+ default:
+ throw new NotImplementedException(ERR_MSG + tag2);
}
break;
- }
- case INT8: {
+ case INT8:
switch (tag2) {
case INT8:
type = BuiltinType.AINT8;
@@ -207,14 +168,13 @@
type = BuiltinType.ADOUBLE;
break;
case ANY:
- return BuiltinType.ANY;
- default: {
- throw new NotImplementedException(errMsg + tag2);
- }
+ type = BuiltinType.ANY;
+ break;
+ default:
+ throw new NotImplementedException(ERR_MSG + tag2);
}
break;
- }
- case ANY: {
+ case ANY:
switch (tag2) {
case INT8:
case INT16:
@@ -223,13 +183,13 @@
case FLOAT:
case ANY:
case DOUBLE:
- return BuiltinType.ANY;
- default: {
- throw new NotImplementedException(errMsg + tag2);
- }
+ type = BuiltinType.ANY;
+ break;
+ default:
+ throw new NotImplementedException(ERR_MSG + tag2);
}
- }
- case DATE: {
+ break;
+ case DATE:
switch (tag2) {
case DATE:
type = BuiltinType.ADURATION;
@@ -239,13 +199,14 @@
case DURATION:
type = BuiltinType.ADATE;
break;
- default: {
- throw new NotImplementedException(errMsg + tag2);
- }
+ case ANY:
+ type = BuiltinType.ANY;
+ break;
+ default:
+ throw new NotImplementedException(ERR_MSG + tag2);
}
break;
- }
- case TIME: {
+ case TIME:
switch (tag2) {
case TIME:
type = BuiltinType.ADURATION;
@@ -255,13 +216,14 @@
case DURATION:
type = BuiltinType.ATIME;
break;
- default: {
- throw new NotImplementedException(errMsg + tag2);
- }
+ case ANY:
+ type = BuiltinType.ANY;
+ break;
+ default:
+ throw new NotImplementedException(ERR_MSG + tag2);
}
break;
- }
- case DATETIME: {
+ case DATETIME:
switch (tag2) {
case DATETIME:
type = BuiltinType.ADURATION;
@@ -271,13 +233,11 @@
case DURATION:
type = BuiltinType.ADATETIME;
break;
- default: {
- throw new NotImplementedException(errMsg + tag2);
- }
+ default:
+ throw new NotImplementedException(ERR_MSG + tag2);
}
break;
- }
- case DURATION: {
+ case DURATION:
switch (tag2) {
case DATE:
type = BuiltinType.ADATE;
@@ -288,13 +248,14 @@
case DATETIME:
type = BuiltinType.ADATETIME;
break;
- default: {
- throw new NotImplementedException(errMsg + tag2);
- }
+ case ANY:
+ type = BuiltinType.ANY;
+ break;
+ default:
+ throw new NotImplementedException(ERR_MSG + tag2);
}
break;
- }
- case YEARMONTHDURATION: {
+ case YEARMONTHDURATION:
switch (tag2) {
case DATE:
type = BuiltinType.ADATE;
@@ -308,13 +269,14 @@
case YEARMONTHDURATION:
type = BuiltinType.AYEARMONTHDURATION;
break;
- default: {
- throw new NotImplementedException(errMsg + tag2);
- }
+ case ANY:
+ type = BuiltinType.ANY;
+ break;
+ default:
+ throw new NotImplementedException(ERR_MSG + tag2);
}
break;
- }
- case DAYTIMEDURATION: {
+ case DAYTIMEDURATION:
switch (tag2) {
case DATE:
type = BuiltinType.ADATE;
@@ -328,16 +290,16 @@
case DAYTIMEDURATION:
type = BuiltinType.ADAYTIMEDURATION;
break;
- default: {
- throw new NotImplementedException(errMsg + tag2);
- }
+ case ANY:
+ type = BuiltinType.ANY;
+ break;
+ default:
+ throw new NotImplementedException(ERR_MSG + tag2);
}
break;
- }
- default: {
- throw new NotImplementedException(errMsg + tag1);
- }
+ default:
+ throw new NotImplementedException(ERR_MSG + tag1);
}
- return AUnionType.createNullableType(type, "ArithemitcResult");
+ return type;
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAddSubMulTypeDescriptor.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAddSubMulTypeDescriptor.java
deleted file mode 100644
index 2796022..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAddSubMulTypeDescriptor.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class NumericAddSubMulTypeDescriptor implements IResultTypeComputer {
-
- private static final String errMsg = "Arithmetic operations are only implemented for AINT32 and ADOUBLE.";
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
- ILogicalExpression arg1 = fce.getArguments().get(0).getValue();
- ILogicalExpression arg2 = fce.getArguments().get(1).getValue();
- IAType t1;
- IAType t2;
- try {
- t1 = (IAType) env.getType(arg1);
- t2 = (IAType) env.getType(arg2);
- } catch (AlgebricksException e) {
- throw new AlgebricksException(e);
- }
- if (t1 == null || t2 == null) {
- return null;
- }
- switch (t1.getTypeTag()) {
- case INT32: {
- switch (t2.getTypeTag()) {
- case INT32: {
- return BuiltinType.AINT32;
- }
- case DOUBLE: {
- return BuiltinType.ADOUBLE;
- }
- default: {
- throw new NotImplementedException(errMsg);
- }
- }
- }
- case DOUBLE: {
- switch (t2.getTypeTag()) {
- case INT32:
- case DOUBLE: {
- return BuiltinType.ADOUBLE;
- }
- default: {
- throw new NotImplementedException(errMsg);
- }
- }
- }
- default: {
- throw new NotImplementedException(errMsg);
- }
- }
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAggTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAggTypeComputer.java
new file mode 100644
index 0000000..691ee7a
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericAggTypeComputer.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.om.typecomputer.impl;
+
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.AUnionType;
+import org.apache.asterix.om.types.IAType;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
+
+public class NumericAggTypeComputer extends AbstractResultTypeComputer {
+
+ private static final String ERR_MSG = "Aggregator is not implemented for ";
+
+ public static final NumericAggTypeComputer INSTANCE = new NumericAggTypeComputer();
+
+ private NumericAggTypeComputer() {
+ }
+
+ @Override
+ protected void checkArgType(int argIndex, IAType type) throws AlgebricksException {
+ ATypeTag tag = type.getTypeTag();
+ switch (tag) {
+ case DOUBLE:
+ case FLOAT:
+ case INT64:
+ case INT32:
+ case INT16:
+ case INT8:
+ case ANY:
+ break;
+ default:
+ throw new NotImplementedException(ERR_MSG + tag);
+ }
+ }
+
+ @Override
+ protected IAType getResultType(IAType... strippedInputTypes) {
+ ATypeTag tag = strippedInputTypes[0].getTypeTag();
+ IAType type;
+ switch (tag) {
+ case DOUBLE:
+ case FLOAT:
+ case INT64:
+ case INT32:
+ case INT16:
+ case INT8:
+ case ANY:
+ type = strippedInputTypes[0];
+ break;
+ default:
+ throw new NotImplementedException(ERR_MSG + tag);
+ }
+ return AUnionType.createNullableType(type, "AggResult");
+ }
+}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericRoundHalfToEven2TypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericRoundHalfToEven2TypeComputer.java
new file mode 100644
index 0000000..675d1f0
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericRoundHalfToEven2TypeComputer.java
@@ -0,0 +1,86 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Numeric round half to even
+ * Author : Xiaoyu Ma@UC Irvine
+ * 01/30/2012
+ */
+package org.apache.asterix.om.typecomputer.impl;
+
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.IAType;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
+
+public class NumericRoundHalfToEven2TypeComputer extends AbstractResultTypeComputer {
+
+ public static final NumericRoundHalfToEven2TypeComputer INSTANCE = new NumericRoundHalfToEven2TypeComputer();
+
+ private NumericRoundHalfToEven2TypeComputer() {
+
+ }
+
+ @Override
+ protected void checkArgType(int argIndex, IAType type) throws AlgebricksException {
+ ATypeTag tag = type.getTypeTag();
+ if (argIndex == 0) {
+ switch (tag) {
+ case INT8:
+ case INT16:
+ case INT32:
+ case INT64:
+ case FLOAT:
+ case DOUBLE:
+ break;
+ default:
+ throw new NotImplementedException(
+ "Arithmetic operations are not implemented for " + type.getDisplayName());
+ }
+ }
+ if (argIndex == 1) {
+ switch (tag) {
+ case INT8:
+ case INT16:
+ case INT32:
+ case INT64:
+ break;
+ default:
+ throw new AlgebricksException("Argument $precision cannot be type " + type.getDisplayName());
+ }
+ }
+ }
+
+ @Override
+ protected IAType getResultType(IAType... strippedInputTypes) {
+ ATypeTag tag = strippedInputTypes[0].getTypeTag();
+ switch (tag) {
+ case INT8:
+ case INT16:
+ case INT32:
+ case INT64:
+ case FLOAT:
+ case DOUBLE:
+ case ANY:
+ return strippedInputTypes[0];
+ default:
+ return null;
+ }
+ }
+}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericUnaryFunctionTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericUnaryFunctionTypeComputer.java
new file mode 100644
index 0000000..017e178
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/NumericUnaryFunctionTypeComputer.java
@@ -0,0 +1,72 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+/*
+ * Numeric Unary Functions like abs
+ * Author : Xiaoyu Ma@UC Irvine
+ * 01/30/2012
+ */
+package org.apache.asterix.om.typecomputer.impl;
+
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.IAType;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+
+public class NumericUnaryFunctionTypeComputer extends AbstractResultTypeComputer {
+
+ private static final String ERR_MSG = "Arithmetic operations are not implemented for ";
+ public static final NumericUnaryFunctionTypeComputer INSTANCE = new NumericUnaryFunctionTypeComputer();
+
+ private NumericUnaryFunctionTypeComputer() {
+ }
+
+ @Override
+ protected void checkArgType(int argIndex, IAType type) throws AlgebricksException {
+ ATypeTag tag = type.getTypeTag();
+ switch (tag) {
+ case INT8:
+ case INT16:
+ case INT32:
+ case INT64:
+ case FLOAT:
+ case DOUBLE:
+ case ANY:
+ break;
+ default:
+ throw new AlgebricksException(ERR_MSG + type.getDisplayName());
+ }
+ }
+
+ @Override
+ protected IAType getResultType(IAType... strippedInputTypes) {
+ ATypeTag tag = strippedInputTypes[0].getTypeTag();
+ switch (tag) {
+ case INT8:
+ case INT16:
+ case INT32:
+ case INT64:
+ case FLOAT:
+ case DOUBLE:
+ case ANY:
+ return strippedInputTypes[0];
+ default:
+ return null;
+ }
+ }
+}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalOpenARecordTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OpenARecordTypeComputer.java
similarity index 82%
rename from asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalOpenARecordTypeComputer.java
rename to asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OpenARecordTypeComputer.java
index b630f44..4a041d4 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalOpenARecordTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OpenARecordTypeComputer.java
@@ -27,17 +27,17 @@
import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class OptionalOpenARecordTypeComputer implements IResultTypeComputer {
+public class OpenARecordTypeComputer implements IResultTypeComputer {
- public static final OptionalOpenARecordTypeComputer INSTANCE = new OptionalOpenARecordTypeComputer();
+ public static final OpenARecordTypeComputer INSTANCE = new OpenARecordTypeComputer();
- private OptionalOpenARecordTypeComputer() {
+ private OpenARecordTypeComputer() {
}
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- return AUnionType.createNullableType(DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE, "OptionalOpenRecord");
+ return AUnionType.createUnknownableType(DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE, "UnknownableOpenRecord");
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OpenRecordConstructorResultType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OpenRecordConstructorResultType.java
index 862d1cd..3e1955d 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OpenRecordConstructorResultType.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OpenRecordConstructorResultType.java
@@ -26,7 +26,7 @@
import org.apache.asterix.om.base.AString;
import org.apache.asterix.om.constants.AsterixConstantValue;
import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
+import org.apache.asterix.om.typecomputer.base.TypeCastUtils;
import org.apache.asterix.om.types.ARecordType;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.om.types.TypeHelper;
@@ -51,7 +51,7 @@
/**
* if type has been top-down propagated, use the enforced type
*/
- ARecordType type = (ARecordType) TypeComputerUtilities.getRequiredType(f);
+ ARecordType type = (ARecordType) TypeCastUtils.getRequiredType(f);
if (type != null)
return type;
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalABinaryTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalABinaryTypeComputer.java
deleted file mode 100644
index 9831665..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalABinaryTypeComputer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class OptionalABinaryTypeComputer implements IResultTypeComputer {
- public static final OptionalABinaryTypeComputer INSTANCE = new OptionalABinaryTypeComputer();
-
- private OptionalABinaryTypeComputer() {
-
- }
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
- return AUnionType.createNullableType(BuiltinType.ABINARY, "OptionalBinary");
- } else {
- return BuiltinType.ABINARY;
- }
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalABooleanTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalABooleanTypeComputer.java
deleted file mode 100644
index 3e91d23..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalABooleanTypeComputer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class OptionalABooleanTypeComputer implements IResultTypeComputer {
-
- public static final OptionalABooleanTypeComputer INSTANCE = new OptionalABooleanTypeComputer();
-
- private OptionalABooleanTypeComputer() {
- }
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
- return AUnionType.createNullableType(BuiltinType.ABOOLEAN, "OptionalBoolean");
- } else {
- return BuiltinType.ABOOLEAN;
- }
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalACircleTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalACircleTypeComputer.java
deleted file mode 100644
index 244156d..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalACircleTypeComputer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class OptionalACircleTypeComputer implements IResultTypeComputer {
-
- public static final OptionalACircleTypeComputer INSTANCE = new OptionalACircleTypeComputer();
-
- private OptionalACircleTypeComputer() {
- }
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
- return AUnionType.createNullableType(BuiltinType.ACIRCLE, "OptionalCircle");
- } else {
- return BuiltinType.ACIRCLE;
- }
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalADateTimeTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalADateTimeTypeComputer.java
deleted file mode 100644
index 04729bf..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalADateTimeTypeComputer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class OptionalADateTimeTypeComputer implements IResultTypeComputer {
-
- public static final OptionalADateTimeTypeComputer INSTANCE = new OptionalADateTimeTypeComputer();
-
- private OptionalADateTimeTypeComputer() {
- }
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
- return AUnionType.createNullableType(BuiltinType.ADATETIME, "OptionalDatetime");
- } else {
- return BuiltinType.ADATETIME;
- }
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalADateTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalADateTypeComputer.java
deleted file mode 100644
index 1d2fb77..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalADateTypeComputer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class OptionalADateTypeComputer implements IResultTypeComputer {
-
- public static final OptionalADateTypeComputer INSTANCE = new OptionalADateTypeComputer();
-
- private OptionalADateTypeComputer() {
- }
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
- return AUnionType.createNullableType(BuiltinType.ADATE, "OptionalDate");
- } else {
- return BuiltinType.ADATE;
- }
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalADayTimeDurationTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalADayTimeDurationTypeComputer.java
deleted file mode 100644
index c6a2790..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalADayTimeDurationTypeComputer.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class OptionalADayTimeDurationTypeComputer implements IResultTypeComputer {
-
- public static final OptionalADayTimeDurationTypeComputer INSTANCE = new OptionalADayTimeDurationTypeComputer();
-
- private OptionalADayTimeDurationTypeComputer() {
-
- }
-
- /* (non-Javadoc)
- * @see org.apache.asterix.om.typecomputer.base.IResultTypeComputer#computeType(org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression, org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment, org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider)
- */
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
- return AUnionType.createNullableType(BuiltinType.ADAYTIMEDURATION, "OptionalDayTimeDuration");
- } else {
- return BuiltinType.ADAYTIMEDURATION;
- }
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalADoubleTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalADoubleTypeComputer.java
deleted file mode 100644
index c6a1c6d..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalADoubleTypeComputer.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class OptionalADoubleTypeComputer implements IResultTypeComputer {
-
- public static final OptionalADoubleTypeComputer INSTANCE = new OptionalADoubleTypeComputer();
-
- private OptionalADoubleTypeComputer() {
- }
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
- return AUnionType.createNullableType(BuiltinType.ADOUBLE, "OptionalDouble");
- } else {
- return BuiltinType.ADOUBLE;
- }
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalADurationTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalADurationTypeComputer.java
deleted file mode 100644
index eb24b80..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalADurationTypeComputer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class OptionalADurationTypeComputer implements IResultTypeComputer {
-
- public static final OptionalADurationTypeComputer INSTANCE = new OptionalADurationTypeComputer();
-
- private OptionalADurationTypeComputer() {
- }
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
- return AUnionType.createNullableType(BuiltinType.ADURATION, "OptionalDuration");
- } else {
- return BuiltinType.ADURATION;
- }
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAFloatTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAFloatTypeComputer.java
deleted file mode 100644
index 0bdd280..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAFloatTypeComputer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class OptionalAFloatTypeComputer implements IResultTypeComputer {
-
- public static final OptionalAFloatTypeComputer INSTANCE = new OptionalAFloatTypeComputer();
-
- private OptionalAFloatTypeComputer() {
- }
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
- return AUnionType.createNullableType(BuiltinType.AFLOAT, "OptionalFloat");
- } else {
- return BuiltinType.AFLOAT;
- }
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAInt16TypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAInt16TypeComputer.java
deleted file mode 100644
index feeb1ce..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAInt16TypeComputer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class OptionalAInt16TypeComputer implements IResultTypeComputer {
-
- public static final OptionalAInt16TypeComputer INSTANCE = new OptionalAInt16TypeComputer();
-
- private OptionalAInt16TypeComputer() {
- }
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
- return AUnionType.createNullableType(BuiltinType.AINT16, "OptionalInt16");
- } else {
- return BuiltinType.AINT16;
- }
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAInt32TypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAInt32TypeComputer.java
deleted file mode 100644
index cdb3cd0..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAInt32TypeComputer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class OptionalAInt32TypeComputer implements IResultTypeComputer {
-
- public static final OptionalAInt32TypeComputer INSTANCE = new OptionalAInt32TypeComputer();
-
- private OptionalAInt32TypeComputer() {
- }
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
- return AUnionType.createNullableType(BuiltinType.AINT32, "OptionalInt32");
- } else {
- return BuiltinType.AINT32;
- }
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAInt64TypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAInt64TypeComputer.java
deleted file mode 100644
index 07ca80e..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAInt64TypeComputer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class OptionalAInt64TypeComputer implements IResultTypeComputer {
-
- public static final OptionalAInt64TypeComputer INSTANCE = new OptionalAInt64TypeComputer();
-
- private OptionalAInt64TypeComputer() {
- }
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
- return AUnionType.createNullableType(BuiltinType.AINT64, "OptionalInt64");
- } else {
- return BuiltinType.AINT64;
- }
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAInt8TypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAInt8TypeComputer.java
deleted file mode 100644
index 0adf222..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAInt8TypeComputer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class OptionalAInt8TypeComputer implements IResultTypeComputer {
-
- public static final OptionalAInt8TypeComputer INSTANCE = new OptionalAInt8TypeComputer();
-
- private OptionalAInt8TypeComputer() {
- }
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
- return AUnionType.createNullableType(BuiltinType.AINT8, "OptionalInt8");
- } else {
- return BuiltinType.AINT8;
- }
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAIntervalTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAIntervalTypeComputer.java
deleted file mode 100644
index 8cb8ca4..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAIntervalTypeComputer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class OptionalAIntervalTypeComputer implements IResultTypeComputer {
-
- public static final OptionalAIntervalTypeComputer INSTANCE = new OptionalAIntervalTypeComputer();
-
- private OptionalAIntervalTypeComputer() {
-
- }
-
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
- return AUnionType.createNullableType(BuiltinType.AINTERVAL, "OptionalInterval");
- } else {
- return BuiltinType.AINTERVAL;
- }
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalALineTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalALineTypeComputer.java
deleted file mode 100644
index 7d6aa4c..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalALineTypeComputer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class OptionalALineTypeComputer implements IResultTypeComputer {
-
- public static final OptionalALineTypeComputer INSTANCE = new OptionalALineTypeComputer();
-
- private OptionalALineTypeComputer() {
- }
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
- return AUnionType.createNullableType(BuiltinType.ALINE, "OptionalLine");
- } else {
- return BuiltinType.ALINE;
- }
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAPoint3DTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAPoint3DTypeComputer.java
deleted file mode 100644
index 40c5ae8..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAPoint3DTypeComputer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class OptionalAPoint3DTypeComputer implements IResultTypeComputer {
-
- public static final OptionalAPoint3DTypeComputer INSTANCE = new OptionalAPoint3DTypeComputer();
-
- private OptionalAPoint3DTypeComputer() {
- }
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
- return AUnionType.createNullableType(BuiltinType.APOINT3D, "OptionalPoint3d");
- } else {
- return BuiltinType.APOINT3D;
- }
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAPointTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAPointTypeComputer.java
deleted file mode 100644
index 4bcccd9..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAPointTypeComputer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class OptionalAPointTypeComputer implements IResultTypeComputer {
-
- public static final OptionalAPointTypeComputer INSTANCE = new OptionalAPointTypeComputer();
-
- private OptionalAPointTypeComputer() {
- }
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
- return AUnionType.createNullableType(BuiltinType.APOINT, "OptionalPoint");
- } else {
- return BuiltinType.APOINT;
- }
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAPolygonTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAPolygonTypeComputer.java
deleted file mode 100644
index 7fb16cd..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAPolygonTypeComputer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class OptionalAPolygonTypeComputer implements IResultTypeComputer {
-
- public static final OptionalAPolygonTypeComputer INSTANCE = new OptionalAPolygonTypeComputer();
-
- private OptionalAPolygonTypeComputer() {
- }
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
- return AUnionType.createNullableType(BuiltinType.APOLYGON, "OptionalPolygon");
- } else {
- return BuiltinType.APOLYGON;
- }
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalARectangleTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalARectangleTypeComputer.java
deleted file mode 100644
index a5f954f..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalARectangleTypeComputer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class OptionalARectangleTypeComputer implements IResultTypeComputer {
-
- public static final OptionalARectangleTypeComputer INSTANCE = new OptionalARectangleTypeComputer();
-
- private OptionalARectangleTypeComputer() {
- }
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
- return AUnionType.createNullableType(BuiltinType.ARECTANGLE, "OptionalRectangle");
- } else {
- return BuiltinType.ARECTANGLE;
- }
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalATimeTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalATimeTypeComputer.java
deleted file mode 100644
index f8c175a..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalATimeTypeComputer.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class OptionalATimeTypeComputer implements IResultTypeComputer {
-
- public static final OptionalATimeTypeComputer INSTANCE = new OptionalATimeTypeComputer();
-
- private OptionalATimeTypeComputer() {
- }
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
- return AUnionType.createNullableType(BuiltinType.ATIME, "OptionalTime");
- } else {
- return BuiltinType.ATIME;
- }
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAYearMonthDurationTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAYearMonthDurationTypeComputer.java
deleted file mode 100644
index df0e46d..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OptionalAYearMonthDurationTypeComputer.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class OptionalAYearMonthDurationTypeComputer implements IResultTypeComputer {
-
- public static final OptionalAYearMonthDurationTypeComputer INSTANCE = new OptionalAYearMonthDurationTypeComputer();
-
- private OptionalAYearMonthDurationTypeComputer() {
-
- }
-
- /* (non-Javadoc)
- * @see org.apache.asterix.om.typecomputer.base.IResultTypeComputer#computeType(org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression, org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment, org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider)
- */
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- if (TypeComputerUtilities.inputInferednullableType(expression, env)) {
- return AUnionType.createNullableType(BuiltinType.AYEARMONTHDURATION, "OptionalYearMonthDuration");
- } else {
- return BuiltinType.AYEARMONTHDURATION;
- }
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListConstructorResultType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListConstructorResultType.java
index f8c0a2a..70a0ca5 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListConstructorResultType.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListConstructorResultType.java
@@ -19,15 +19,13 @@
package org.apache.asterix.om.typecomputer.impl;
-import java.util.ArrayList;
-
import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
+import org.apache.asterix.om.typecomputer.base.TypeCastUtils;
import org.apache.asterix.om.types.AOrderedListType;
+import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.AUnionType;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.util.NonTaggedFormatUtil;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
@@ -46,23 +44,28 @@
/**
* if type has been top-down propagated, use the enforced type
*/
- AOrderedListType reqType = (AOrderedListType) TypeComputerUtilities.getRequiredType(f);
- if (reqType != null)
+ AOrderedListType reqType = (AOrderedListType) TypeCastUtils.getRequiredType(f);
+ if (reqType != null) {
return reqType;
+ }
- ArrayList<IAType> types = new ArrayList<IAType>();
+ IAType currentType = null;
+ boolean any = false;
for (int k = 0; k < f.getArguments().size(); k++) {
IAType type = (IAType) env.getType(f.getArguments().get(k).getValue());
- if (NonTaggedFormatUtil.isOptional(type))
- type = ((AUnionType) type).getNullableType();
- if (types.indexOf(type) < 0) {
- types.add(type);
+ if (type.getTypeTag() == ATypeTag.UNION) {
+ type = ((AUnionType) type).getActualType();
}
+ if (currentType != null && !currentType.equals(type)) {
+ any = true;
+ break;
+ }
+ currentType = type;
}
- if (types.size() == 1) {
- return new AOrderedListType(types.get(0), null);
- } else {
+ if (any || currentType == null) {
return new AOrderedListType(BuiltinType.ANY, null);
+ } else {
+ return new AOrderedListType(currentType, null);
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAInt32TypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAInt32TypeComputer.java
index 3297cca..a0ea2a5 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAInt32TypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAInt32TypeComputer.java
@@ -18,16 +18,12 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.AOrderedListType;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class OrderedListOfAInt32TypeComputer implements IResultTypeComputer {
+public class OrderedListOfAInt32TypeComputer extends AbstractResultTypeComputer {
public static final OrderedListOfAInt32TypeComputer INSTANCE = new OrderedListOfAInt32TypeComputer();
@@ -35,8 +31,7 @@
}
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+ protected IAType getResultType(IAType... strippedInputTypes) {
return new AOrderedListType(BuiltinType.AINT32, null);
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAInt64TypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAInt64TypeComputer.java
index c88336f..1aec3c7 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAInt64TypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAInt64TypeComputer.java
@@ -18,16 +18,12 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.AOrderedListType;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class OrderedListOfAInt64TypeComputer implements IResultTypeComputer {
+public class OrderedListOfAInt64TypeComputer extends AbstractResultTypeComputer {
public static final OrderedListOfAInt64TypeComputer INSTANCE = new OrderedListOfAInt64TypeComputer();
@@ -35,8 +31,7 @@
}
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+ protected IAType getResultType(IAType... strippedInputTypes) {
return new AOrderedListType(BuiltinType.AINT64, null);
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAIntervalTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAIntervalTypeComputer.java
index d6474a1..f3892dd 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAIntervalTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAIntervalTypeComputer.java
@@ -18,16 +18,12 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.AOrderedListType;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class OrderedListOfAIntervalTypeComputer implements IResultTypeComputer {
+public class OrderedListOfAIntervalTypeComputer extends AbstractResultTypeComputer {
public static final OrderedListOfAIntervalTypeComputer INSTANCE = new OrderedListOfAIntervalTypeComputer();
@@ -35,8 +31,7 @@
}
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+ protected IAType getResultType(IAType... strippedInputTypes) {
return new AOrderedListType(BuiltinType.AINTERVAL, null);
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAPointTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAPointTypeComputer.java
index 36ec846..2d99a09 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAPointTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAPointTypeComputer.java
@@ -18,16 +18,12 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.AOrderedListType;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class OrderedListOfAPointTypeComputer implements IResultTypeComputer {
+public class OrderedListOfAPointTypeComputer extends AbstractResultTypeComputer {
public static final OrderedListOfAPointTypeComputer INSTANCE = new OrderedListOfAPointTypeComputer();
@@ -35,8 +31,7 @@
}
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+ protected IAType getResultType(IAType... strippedInputTypes) {
return new AOrderedListType(BuiltinType.APOINT, null);
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAStringTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAStringTypeComputer.java
index 3106171..977b7e4 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAStringTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAStringTypeComputer.java
@@ -18,16 +18,12 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.AOrderedListType;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class OrderedListOfAStringTypeComputer implements IResultTypeComputer {
+public class OrderedListOfAStringTypeComputer extends AbstractResultTypeComputer {
public static final OrderedListOfAStringTypeComputer INSTANCE = new OrderedListOfAStringTypeComputer();
@@ -35,8 +31,7 @@
}
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+ protected IAType getResultType(IAType... strippedInputTypes) {
return new AOrderedListType(BuiltinType.ASTRING, null);
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAnyTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAnyTypeComputer.java
index 48bec4f..e88e80b 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAnyTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/OrderedListOfAnyTypeComputer.java
@@ -18,16 +18,12 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.AOrderedListType;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class OrderedListOfAnyTypeComputer implements IResultTypeComputer {
+public class OrderedListOfAnyTypeComputer extends AbstractResultTypeComputer {
public static final OrderedListOfAnyTypeComputer INSTANCE = new OrderedListOfAnyTypeComputer();
@@ -35,8 +31,7 @@
}
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
+ protected IAType getResultType(IAType... strippedInputTypes) {
return new AOrderedListType(BuiltinType.ANY, null);
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/QuadStringStringOrNullTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/QuadStringStringOrNullTypeComputer.java
deleted file mode 100644
index f238125..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/QuadStringStringOrNullTypeComputer.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.types.TypeHelper;
-
-/**
- * @author Xiaoyu Ma
- */
-public class QuadStringStringOrNullTypeComputer extends AbstractQuadStringTypeComputer {
- public static final QuadStringStringOrNullTypeComputer INSTANCE = new QuadStringStringOrNullTypeComputer();
-
- private QuadStringStringOrNullTypeComputer() {
- }
-
- @Override
- public IAType getResultType(IAType t0, IAType t1, IAType t2, IAType t3) {
- if (TypeHelper.canBeNull(t0) || TypeHelper.canBeNull(t1) || TypeHelper.canBeNull(t2)
- || TypeHelper.canBeNull(t3)) {
- return AUnionType.createNullableType(BuiltinType.ASTRING);
- }
- return BuiltinType.ASTRING;
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordAddFieldsTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordAddFieldsTypeComputer.java
index 05002a6..a77935e 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordAddFieldsTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordAddFieldsTypeComputer.java
@@ -63,19 +63,19 @@
AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expression;
IAType type0 = (IAType) env.getType(funcExpr.getArguments().get(0).getValue());
- ARecordType inputRecordType = TypeComputerUtils.extractRecordType(type0);
+ ARecordType inputRecordType = TypeComputeUtils.extractRecordType(type0);
if (inputRecordType == null) {
throw new AlgebricksException("Input record cannot be null");
}
AbstractLogicalExpression arg1 = (AbstractLogicalExpression) funcExpr.getArguments().get(1).getValue();
IAType type1 = (IAType) env.getType(arg1);
- AOrderedListType inputOrderedListType = TypeComputerUtils.extractOrderedListType(type1);
+ AOrderedListType inputOrderedListType = TypeComputeUtils.extractOrderedListType(type1);
if (inputOrderedListType == null) {
return inputRecordType;
}
- boolean nullable = TypeHelper.canBeNull(type0) || TypeHelper.canBeNull(type1);
+ boolean nullable = TypeHelper.canBeUnknown(type0) || TypeHelper.canBeUnknown(type1);
Map<String, IAType> additionalFields = new HashMap<>();
List<String> resultFieldNames = new ArrayList<>();
List<IAType> resultFieldTypes = new ArrayList<>();
@@ -103,7 +103,7 @@
// Iterating through the orderlist input
for (Mutable<ILogicalExpression> arg : args) {
AbstractFunctionCallExpression recConsExpr = (AbstractFunctionCallExpression) arg.getValue();
- ARecordType rtype = TypeComputerUtils.extractRecordType((IAType) env.getType(recConsExpr));
+ ARecordType rtype = TypeComputeUtils.extractRecordType((IAType) env.getType(recConsExpr));
if (rtype != null) {
String[] fn = rtype.getFieldNames();
IAType[] ft = rtype.getFieldTypes();
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordConstructorResultType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordConstructorResultType.java
index a9c7968..1a977db 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordConstructorResultType.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordConstructorResultType.java
@@ -24,7 +24,7 @@
import org.apache.asterix.om.base.AString;
import org.apache.asterix.om.constants.AsterixConstantValue;
import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
+import org.apache.asterix.om.typecomputer.base.TypeCastUtils;
import org.apache.asterix.om.types.ARecordType;
import org.apache.asterix.om.types.IAType;
import org.apache.commons.lang3.mutable.Mutable;
@@ -51,7 +51,7 @@
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expression;
- IAType reqType = TypeComputerUtilities.getRequiredType(f);
+ IAType reqType = TypeCastUtils.getRequiredType(f);
if (reqType != null)
return reqType;
int n = f.getArguments().size() / 2;
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordMergeTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordMergeTypeComputer.java
index 9611b9c..4a55924 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordMergeTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordMergeTypeComputer.java
@@ -49,9 +49,9 @@
AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expression;
IAType t0 = (IAType) env.getType(f.getArguments().get(0).getValue());
IAType t1 = (IAType) env.getType(f.getArguments().get(1).getValue());
- boolean nullable = TypeHelper.canBeNull(t0) || TypeHelper.canBeNull(t1);
- ARecordType recType0 = TypeComputerUtils.extractRecordType(t0);
- ARecordType recType1 = TypeComputerUtils.extractRecordType(t1);
+ boolean nullable = TypeHelper.canBeUnknown(t0) || TypeHelper.canBeUnknown(t1);
+ ARecordType recType0 = TypeComputeUtils.extractRecordType(t0);
+ ARecordType recType1 = TypeComputeUtils.extractRecordType(t1);
if (recType0 == null || recType1 == null) {
throw new AlgebricksException(
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordRemoveFieldsTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordRemoveFieldsTypeComputer.java
index ea84c95..2323f95 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordRemoveFieldsTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/RecordRemoveFieldsTypeComputer.java
@@ -154,14 +154,14 @@
Set<String> fieldNameSet = new HashSet<>();
Deque<String> fieldPathStack = new ArrayDeque<>();
- ARecordType inputRecordType = NonTaggedFieldAccessByNameResultType.getRecordTypeFromType(type0, expression);
+ ARecordType inputRecordType = FieldAccessByNameResultType.getRecordTypeFromType(type0, expression);
if (inputRecordType == null) {
return BuiltinType.ANY;
}
AbstractLogicalExpression arg1 = (AbstractLogicalExpression) funcExpr.getArguments().get(1).getValue();
IAType inputListType = (IAType) env.getType(arg1);
- AOrderedListType inputOrderedListType = TypeComputerUtils.extractOrderedListType(inputListType);
+ AOrderedListType inputOrderedListType = TypeComputeUtils.extractOrderedListType(inputListType);
if (inputOrderedListType == null) {
throw new AlgebricksException(
"The function 'remove-fields' expects an ordered list as the second argument, but got "
@@ -209,7 +209,6 @@
private IAType buildOutputType(Deque<String> fieldPathStack, ARecordType inputRecordType, Set<String> fieldNameSet,
List<List<String>> pathList) throws AlgebricksException {
- IAType resultType;
List<String> resultFieldNames = new ArrayList<>();
List<IAType> resultFieldTypes = new ArrayList<>();
@@ -247,11 +246,13 @@
* Note: l2 uses a LIFO insert and removal.
*/
private <E> boolean isEqualPaths(List<E> l1, Deque<E> l2) {
- if ((l1 == null) || (l2 == null))
+ if ((l1 == null) || (l2 == null)) {
return false;
+ }
- if (l1.size() != l2.size())
+ if (l1.size() != l2.size()) {
return false;
+ }
Iterator<E> it2 = l2.iterator();
@@ -259,8 +260,9 @@
for (int i = len - 1; i >= 0; i--) {
E o1 = l1.get(i);
E o2 = it2.next();
- if (!o1.equals(o2))
+ if (!o1.equals(o2)) {
return false;
+ }
}
return true;
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ScalarVersionOfAggregateResultType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ScalarVersionOfAggregateResultType.java
index 69d4beb..3fecfd9 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ScalarVersionOfAggregateResultType.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/ScalarVersionOfAggregateResultType.java
@@ -18,19 +18,15 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.AUnionType;
import org.apache.asterix.om.types.AbstractCollectionType;
+import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.types.TypeHelper;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class ScalarVersionOfAggregateResultType implements IResultTypeComputer {
+public class ScalarVersionOfAggregateResultType extends AbstractResultTypeComputer {
public static final ScalarVersionOfAggregateResultType INSTANCE = new ScalarVersionOfAggregateResultType();
@@ -38,24 +34,22 @@
}
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
- ILogicalExpression arg1 = fce.getArguments().get(0).getValue();
- IAType t1 = (IAType) env.getType(arg1);
- IAType nonOpt = TypeHelper.getNonOptionalType(t1);
- ATypeTag tag1 = nonOpt.getTypeTag();
- if (tag1 != ATypeTag.ORDEREDLIST && tag1 != ATypeTag.UNORDEREDLIST) {
- throw new AlgebricksException("Type of argument in " + expression
- + " should be a collection type instead of " + t1);
- }
- AbstractCollectionType act = (AbstractCollectionType) nonOpt;
- IAType t = act.getItemType();
- if (TypeHelper.canBeNull(t)) {
- return t;
- } else {
- return AUnionType.createNullableType(t);
+ public void checkArgType(int argIndex, IAType type) throws AlgebricksException {
+ ATypeTag tag = type.getTypeTag();
+ if (tag != ATypeTag.ANY && tag != ATypeTag.ORDEREDLIST && tag != ATypeTag.UNORDEREDLIST) {
+ throw new AlgebricksException(
+ "Type of argument in aggregation should be a collection type instead of " + type.getDisplayName());
}
}
+ @Override
+ protected IAType getResultType(IAType... strippedInputTypes) {
+ AbstractCollectionType act = (AbstractCollectionType) strippedInputTypes[0];
+ ATypeTag tag = act.getTypeTag();
+ if (tag == ATypeTag.ANY) {
+ return BuiltinType.ANY;
+ }
+ IAType t = act.getItemType();
+ return AUnionType.createNullableType(t);
+ }
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryStringBoolOrNullTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/StringBooleanTypeComputer.java
similarity index 66%
rename from asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryStringBoolOrNullTypeComputer.java
rename to asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/StringBooleanTypeComputer.java
index 6d46533..10b6888 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryStringBoolOrNullTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/StringBooleanTypeComputer.java
@@ -18,24 +18,17 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.types.AUnionType;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-/**
- * @author Xiaoyu Ma
- */
-public class BinaryStringBoolOrNullTypeComputer extends AbstractBinaryStringTypeComputer {
- public static final BinaryStringBoolOrNullTypeComputer INSTANCE = new BinaryStringBoolOrNullTypeComputer();
+public class StringBooleanTypeComputer extends AbstractStringTypeComputer {
+ public static final StringBooleanTypeComputer INSTANCE = new StringBooleanTypeComputer();
- private BinaryStringBoolOrNullTypeComputer() {
+ private StringBooleanTypeComputer() {
}
@Override
- public IAType getResultType(IAType t0, IAType t1, boolean nullable) {
- if (nullable) {
- return AUnionType.createNullableType(BuiltinType.ABOOLEAN);
- }
+ public IAType getResultType(IAType... types) {
return BuiltinType.ABOOLEAN;
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryStringStringOrNullTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/StringStringTypeComputer.java
similarity index 66%
rename from asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryStringStringOrNullTypeComputer.java
rename to asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/StringStringTypeComputer.java
index 55df1e3..bce0cef 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryStringStringOrNullTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/StringStringTypeComputer.java
@@ -18,25 +18,17 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.types.AUnionType;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-/**
- * @author Xiaoyu Ma
- */
-public class BinaryStringStringOrNullTypeComputer extends AbstractBinaryStringTypeComputer {
+public class StringStringTypeComputer extends AbstractStringTypeComputer {
+ public static final StringStringTypeComputer INSTANCE = new StringStringTypeComputer();
- public static final BinaryStringStringOrNullTypeComputer INSTANCE = new BinaryStringStringOrNullTypeComputer();
-
- private BinaryStringStringOrNullTypeComputer() {
+ private StringStringTypeComputer() {
}
@Override
- public IAType getResultType(IAType t0, IAType t1, boolean nullable) {
- if (nullable) {
- return AUnionType.createNullableType(BuiltinType.ASTRING);
- }
+ public IAType getResultType(IAType... inputTypes) {
return BuiltinType.ASTRING;
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/SubsetCollectionTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/SubsetCollectionTypeComputer.java
index 4ceec49..40c57a4 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/SubsetCollectionTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/SubsetCollectionTypeComputer.java
@@ -54,10 +54,10 @@
}
case UNION: {
AUnionType ut = (AUnionType) t;
- if (!ut.isNullableType()) {
+ if (!ut.isUnknownableType()) {
throw new AlgebricksException("Expecting collection type. Found " + t);
}
- IAType t2 = ut.getUnionList().get(1);
+ IAType t2 = ut.getActualType();
ATypeTag tag2 = t2.getTypeTag();
if (tag2 == ATypeTag.UNORDEREDLIST || tag2 == ATypeTag.ORDEREDLIST) {
AbstractCollectionType act = (AbstractCollectionType) t2;
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/Substring2TypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/Substring2TypeComputer.java
index 6cc2f6d..f1000b9 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/Substring2TypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/Substring2TypeComputer.java
@@ -18,65 +18,36 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.AUnionType;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.util.NonTaggedFormatUtil;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class Substring2TypeComputer implements IResultTypeComputer {
+public class Substring2TypeComputer extends AbstractResultTypeComputer {
public static final Substring2TypeComputer INSTANCE = new Substring2TypeComputer();
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
- if (fce.getArguments().size() < 2) {
- throw new AlgebricksException("Wrong Argument Number.");
+ public void checkArgType(int argIndex, IAType type) throws AlgebricksException {
+ ATypeTag tag = type.getTypeTag();
+ if (argIndex == 0 && tag != ATypeTag.STRING) {
+ throw new AlgebricksException("First argument should be string Type.");
}
- ILogicalExpression arg0 = fce.getArguments().get(0).getValue();
- ILogicalExpression arg1 = fce.getArguments().get(1).getValue();
- IAType t0, t1;
- try {
- t0 = (IAType) env.getType(arg0);
- t1 = (IAType) env.getType(arg1);
- } catch (AlgebricksException e) {
- throw new AlgebricksException(e);
+ if (argIndex == 1) {
+ switch (tag) {
+ case INT8:
+ case INT16:
+ case INT32:
+ case INT64:
+ break;
+ default:
+ throw new AlgebricksException("Second argument should be integer Type.");
+ }
}
+ }
- ATypeTag tag0, tag1;
- if (NonTaggedFormatUtil.isOptional(t0)) {
- tag0 = ((AUnionType) t0).getNullableType().getTypeTag();
- } else {
- tag0 = t0.getTypeTag();
- }
-
- if (NonTaggedFormatUtil.isOptional(t1)) {
- tag1 = ((AUnionType) t1).getNullableType().getTypeTag();
- } else {
- tag1 = t1.getTypeTag();
- }
-
- // Allow substring to work with ANY types, i.e., types that are unknown at compile time.
- if (tag0 == ATypeTag.ANY || tag1 == ATypeTag.ANY) {
- return BuiltinType.ANY;
- }
-
- if (tag0 != ATypeTag.NULL && tag0 != ATypeTag.STRING) {
- throw new AlgebricksException("First argument should be String Type.");
- }
-
- if (tag1 != ATypeTag.NULL && tag1 != ATypeTag.INT8 && tag1 != ATypeTag.INT16 && tag1 != ATypeTag.INT32
- && tag1 != ATypeTag.INT64) {
- throw new AlgebricksException("Second argument should be integer Type.");
- }
-
+ @Override
+ public IAType getResultType(IAType... types) {
return BuiltinType.ASTRING;
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/SubstringTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/SubstringTypeComputer.java
index b6c5394..537056a 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/SubstringTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/SubstringTypeComputer.java
@@ -18,72 +18,36 @@
*/
package org.apache.asterix.om.typecomputer.impl;
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.AUnionType;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.util.NonTaggedFormatUtil;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class SubstringTypeComputer implements IResultTypeComputer {
+public class SubstringTypeComputer extends AbstractResultTypeComputer {
public static final SubstringTypeComputer INSTANCE = new SubstringTypeComputer();
@Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
- if (fce.getArguments().size() < 3)
- throw new AlgebricksException("Wrong Argument Number.");
- ILogicalExpression arg0 = fce.getArguments().get(0).getValue();
- ILogicalExpression arg1 = fce.getArguments().get(1).getValue();
- ILogicalExpression arg2 = fce.getArguments().get(2).getValue();
- IAType t0, t1, t2;
- try {
- t0 = (IAType) env.getType(arg0);
- t1 = (IAType) env.getType(arg1);
- t2 = (IAType) env.getType(arg2);
- } catch (AlgebricksException e) {
- throw new AlgebricksException(e);
+ public void checkArgType(int argIndex, IAType type) throws AlgebricksException {
+ ATypeTag tag = type.getTypeTag();
+ if (argIndex == 0 && tag != ATypeTag.STRING) {
+ throw new AlgebricksException("First argument should be string Type.");
}
-
- ATypeTag tag0, tag1, tag2;
- if (NonTaggedFormatUtil.isOptional(t0))
- tag0 = ((AUnionType) t0).getNullableType().getTypeTag();
- else
- tag0 = t0.getTypeTag();
-
- if (NonTaggedFormatUtil.isOptional(t1))
- tag1 = ((AUnionType) t1).getNullableType().getTypeTag();
- else
- tag1 = t1.getTypeTag();
-
- if (NonTaggedFormatUtil.isOptional(t2))
- tag2 = ((AUnionType) t2).getNullableType().getTypeTag();
- else
- tag2 = t2.getTypeTag();
-
- if (tag0 == ATypeTag.ANY || tag1 == ATypeTag.ANY || tag2 == ATypeTag.ANY)
- return BuiltinType.ANY;
-
- if (tag0 != ATypeTag.NULL && tag0 != ATypeTag.STRING) {
- throw new AlgebricksException("First argument should be String Type.");
+ if (argIndex > 0 && argIndex <= 2) {
+ switch (tag) {
+ case INT8:
+ case INT16:
+ case INT32:
+ case INT64:
+ break;
+ default:
+ throw new AlgebricksException("Second argument should be integer Type.");
+ }
}
+ }
- if (tag1 != ATypeTag.NULL && tag1 != ATypeTag.INT8 && tag1 != ATypeTag.INT16 && tag1 != ATypeTag.INT32
- && tag1 != ATypeTag.INT64) {
- throw new AlgebricksException("Second argument should be integer Type.");
- }
-
- if (tag2 != ATypeTag.NULL && tag2 != ATypeTag.INT8 && tag2 != ATypeTag.INT16 && tag2 != ATypeTag.INT32
- && tag2 != ATypeTag.INT64) {
- throw new AlgebricksException("Third argument should be integer Type.");
- }
-
+ @Override
+ public IAType getResultType(IAType... types) {
return BuiltinType.ASTRING;
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryBooleanOrNullFunctionTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/SwitchCaseComputer.java
similarity index 63%
rename from asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryBooleanOrNullFunctionTypeComputer.java
rename to asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/SwitchCaseComputer.java
index 3c5f1e7..167cb44 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/BinaryBooleanOrNullFunctionTypeComputer.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/SwitchCaseComputer.java
@@ -23,39 +23,44 @@
import org.apache.asterix.om.types.AUnionType;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.types.TypeHelper;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-public class BinaryBooleanOrNullFunctionTypeComputer implements IResultTypeComputer {
+public class SwitchCaseComputer implements IResultTypeComputer {
- public static final BinaryBooleanOrNullFunctionTypeComputer INSTANCE = new BinaryBooleanOrNullFunctionTypeComputer();
+ private static final String ERR_MSG = "switch case should have at least 3 parameters";
- private BinaryBooleanOrNullFunctionTypeComputer() {
+ public static final IResultTypeComputer INSTANCE = new SwitchCaseComputer();
+
+ private SwitchCaseComputer() {
}
@Override
public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
- ILogicalExpression arg0 = fce.getArguments().get(0).getValue();
- ILogicalExpression arg1 = fce.getArguments().get(1).getValue();
- IAType t0, t1;
- try {
- t0 = (IAType) env.getType(arg0);
- t1 = (IAType) env.getType(arg1);
- } catch (AlgebricksException e) {
- throw new AlgebricksException(e);
+ if (fce.getArguments().size() < 3) {
+ throw new AlgebricksException(ERR_MSG);
}
- if (t0.getTypeTag() == ATypeTag.NULL && t1.getTypeTag() == ATypeTag.NULL) {
- return BuiltinType.ANULL;
+
+ IAType currentType = null;
+ boolean any = false;
+ boolean missable = false;
+ for (int i = 2; i < fce.getArguments().size(); i += 2) {
+ IAType type = (IAType) env.getType(fce.getArguments().get(i).getValue());
+ if (type.getTypeTag() == ATypeTag.UNION) {
+ type = ((AUnionType) type).getActualType();
+ missable = true;
+ }
+ if (currentType != null && !type.equals(currentType)) {
+ any = true;
+ break;
+ }
+ currentType = type;
}
- if (TypeHelper.canBeNull(t0) || TypeHelper.canBeNull(t1)) {
- return AUnionType.createNullableType(BuiltinType.ABOOLEAN);
- }
- return BuiltinType.ABOOLEAN;
+ return any ? BuiltinType.ANY : missable ? AUnionType.createMissableType(currentType) : currentType;
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/TripleStringBoolOrNullTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/TripleStringBoolOrNullTypeComputer.java
deleted file mode 100644
index 36c5d71..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/TripleStringBoolOrNullTypeComputer.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.types.TypeHelper;
-
-/**
- * @author Xiaoyu Ma
- */
-public class TripleStringBoolOrNullTypeComputer extends AbstractTripleStringTypeComputer {
- public static final TripleStringBoolOrNullTypeComputer INSTANCE = new TripleStringBoolOrNullTypeComputer();
-
- private TripleStringBoolOrNullTypeComputer() {
- }
-
- @Override
- public IAType getResultType(IAType t0, IAType t1, IAType t2) {
- if (TypeHelper.canBeNull(t0) || TypeHelper.canBeNull(t1) || TypeHelper.canBeNull(t2)) {
- return AUnionType.createNullableType(BuiltinType.ABOOLEAN);
- }
- return BuiltinType.ABOOLEAN;
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/TripleStringStringOrNullTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/TripleStringStringOrNullTypeComputer.java
deleted file mode 100644
index b00d474..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/TripleStringStringOrNullTypeComputer.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.types.TypeHelper;
-
-/**
- * @author Xiaoyu Ma
- */
-public class TripleStringStringOrNullTypeComputer extends AbstractTripleStringTypeComputer {
- public static final TripleStringStringOrNullTypeComputer INSTANCE = new TripleStringStringOrNullTypeComputer();
-
- private TripleStringStringOrNullTypeComputer() {
- }
-
- @Override
- public IAType getResultType(IAType t0, IAType t1, IAType t2) {
- if (TypeHelper.canBeNull(t0) || TypeHelper.canBeNull(t1) || TypeHelper.canBeNull(t2)) {
- return AUnionType.createNullableType(BuiltinType.ASTRING);
- }
- return BuiltinType.ASTRING;
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/TypeCompatibilityChecker.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/TypeCompatibilityChecker.java
deleted file mode 100644
index 565ed02..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/TypeCompatibilityChecker.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.asterix.om.typecomputer.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-
-class TypeCompatibilityChecker {
- private final List<IAType> possibleTypes;
- private boolean nullEncountered;
-
- public TypeCompatibilityChecker() {
- possibleTypes = new ArrayList<IAType>();
- nullEncountered = false;
- }
-
- public void reset() {
- possibleTypes.clear();
- nullEncountered = false;
- }
-
- public void addPossibleType(IAType type) {
- if (type.getTypeTag() == ATypeTag.UNION) {
- List<IAType> typeList = ((AUnionType) type).getUnionList();
- for (IAType t : typeList) {
- if (t.getTypeTag() != ATypeTag.NULL) {
- //CONCAT_NON_NULL cannot return null because it's only used for if-else construct
- if (!possibleTypes.contains(t)) {
- possibleTypes.add(t);
- }
- } else {
- nullEncountered = true;
- }
- }
- } else {
- if (type.getTypeTag() != ATypeTag.NULL) {
- if (!possibleTypes.contains(type)) {
- possibleTypes.add(type);
- }
- } else {
- nullEncountered = true;
- }
- }
- }
-
- public IAType getCompatibleType() {
- switch (possibleTypes.size()) {
- case 0:
- return BuiltinType.ANULL;
- case 1:
- if (nullEncountered) {
- return AUnionType.createNullableType(possibleTypes.get(0));
- } else {
- return possibleTypes.get(0);
- }
- }
- return BuiltinType.ANY;
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/TypeComputeUtils.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/TypeComputeUtils.java
new file mode 100644
index 0000000..f8cc9e6
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/TypeComputeUtils.java
@@ -0,0 +1,222 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.om.typecomputer.impl;
+
+import org.apache.asterix.om.types.AOrderedListType;
+import org.apache.asterix.om.types.ARecordType;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.AUnionType;
+import org.apache.asterix.om.types.AUnorderedListType;
+import org.apache.asterix.om.types.BuiltinType;
+import org.apache.asterix.om.types.IAType;
+import org.apache.commons.lang3.mutable.Mutable;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
+import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
+import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
+
+public class TypeComputeUtils {
+
+ private static final byte CERTAIN = 1;
+ private static final byte NULLABLE = 2;
+ private static final byte MISSABLE = 4;
+ private static final byte MISSING = 8;
+ private static final byte NULL = 16;
+
+ @FunctionalInterface
+ public static interface ArgTypeChecker {
+ public void checkArgTypes(int argIndex, IAType argType) throws AlgebricksException;
+ }
+
+ @FunctionalInterface
+ public static interface ResultTypeGenerator {
+ public IAType getResultType(IAType... knownInputTypes);
+ }
+
+ private TypeComputeUtils() {
+ }
+
+ /**
+ * Resolve the result type of an expression.
+ *
+ * @param expr,
+ * the expression to consider.
+ * @param env,
+ * the type environment.
+ * @param checker,
+ * the argument type checker.
+ * @param resultTypeGenerator,
+ * the result type generator.
+ * @param propagateNullAndMissing,
+ * whether the expression follows MISSING/NULL-in-MISSING/NULL-out semantics.
+ * @return the resolved result type with considering optional types.
+ * @throws AlgebricksException
+ */
+ public static IAType resolveResultType(ILogicalExpression expr, IVariableTypeEnvironment env,
+ ArgTypeChecker checker, ResultTypeGenerator resultTypeGenerator, boolean propagateNullAndMissing)
+ throws AlgebricksException {
+ AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expr;
+
+ IAType[] inputTypes = new IAType[fce.getArguments().size()];
+ int index = 0;
+ for (Mutable<ILogicalExpression> argRef : fce.getArguments()) {
+ ILogicalExpression arg = argRef.getValue();
+ inputTypes[index++] = (IAType) env.getType(arg);
+ }
+
+ // Checks input types and computes result types.
+ IAType[] knownInputTypes = TypeComputeUtils.getActualType(inputTypes);
+ boolean[] unknownable = TypeComputeUtils.isUnknownableType(inputTypes);
+ for (int argIndex = 0; argIndex < knownInputTypes.length; ++argIndex) {
+ ATypeTag argTypeTag = knownInputTypes[argIndex].getTypeTag();
+ if (unknownable[argIndex] || argTypeTag == ATypeTag.ANY || argTypeTag == ATypeTag.NULL
+ || argTypeTag == ATypeTag.MISSING) {
+ continue;
+ }
+ checker.checkArgTypes(argIndex, knownInputTypes[argIndex]);
+ }
+
+ // Computes the result type.
+ byte category = TypeComputeUtils.resolveCateogry(inputTypes);
+ if (propagateNullAndMissing) {
+ if (category == MISSING) {
+ return BuiltinType.AMISSING;
+ }
+ if (category == NULL) {
+ return BuiltinType.ANULL;
+ }
+ return TypeComputeUtils.getResultType(resultTypeGenerator.getResultType(knownInputTypes), category);
+ } else {
+ return resultTypeGenerator.getResultType(knownInputTypes);
+ }
+ }
+
+ private static byte resolveCateogry(IAType... inputTypes) {
+ byte category = CERTAIN;
+ boolean meetNull = false;
+ for (IAType inputType : inputTypes) {
+ ATypeTag inputTypeTag = inputType.getTypeTag();
+ if (inputTypeTag == ATypeTag.UNION) {
+ AUnionType unionType = (AUnionType) inputType;
+ if (unionType.isNullableType()) {
+ category |= NULLABLE;
+ }
+ if (unionType.isMissableType()) {
+ category |= MISSABLE;
+ }
+ } else if (inputTypeTag == ATypeTag.MISSING) {
+ return MISSING;
+ } else if (inputTypeTag == ATypeTag.NULL) {
+ meetNull = true;
+ }
+ }
+ if (meetNull) {
+ return NULL;
+ }
+ return category;
+ }
+
+ private static IAType getResultType(IAType type, byte category) {
+ if (category == CERTAIN) {
+ return type;
+ }
+ IAType resultType = type;
+ if ((category & NULLABLE) != 0 || (category & NULL) != 0) {
+ resultType = AUnionType.createNullableType(resultType);
+ }
+ if ((category & MISSABLE) != 0 || (category & MISSING) != 0) {
+ resultType = AUnionType.createMissableType(resultType);
+ }
+ return resultType;
+ }
+
+ private static IAType[] getActualType(IAType... inputTypes) {
+ IAType[] actualTypes = new IAType[inputTypes.length];
+ int index = 0;
+ for (IAType inputType : inputTypes) {
+ actualTypes[index++] = getActualType(inputType);
+ }
+ return actualTypes;
+ }
+
+ private static boolean[] isUnknownableType(IAType... inputTypes) {
+ boolean[] unknownable = new boolean[inputTypes.length];
+ for (int index = 0; index < unknownable.length; ++index) {
+ IAType type = inputTypes[index];
+ unknownable[index] = false;
+ if (type.getTypeTag() != ATypeTag.UNION) {
+ continue;
+ } else {
+ AUnionType unionType = (AUnionType) type;
+ unknownable[index] = unionType.isUnknownableType();
+ }
+ }
+ return unknownable;
+ }
+
+ public static IAType getActualType(IAType inputType) {
+ return inputType.getTypeTag() == ATypeTag.UNION ? ((AUnionType) inputType).getActualType() : inputType;
+ }
+
+ public static ARecordType extractRecordType(IAType t) {
+ switch (t.getTypeTag()) {
+ case RECORD:
+ return (ARecordType) t;
+ case UNION:
+ IAType innerType = ((AUnionType) t).getActualType();
+ if (innerType.getTypeTag() == ATypeTag.RECORD) {
+ return (ARecordType) innerType;
+ } else {
+ return null;
+ }
+ default:
+ return null;
+ }
+ }
+
+ public static AOrderedListType extractOrderedListType(IAType t) {
+ if (t.getTypeTag() == ATypeTag.ORDEREDLIST) {
+ return (AOrderedListType) t;
+ }
+
+ if (t.getTypeTag() == ATypeTag.UNION) {
+ IAType innerType = ((AUnionType) t).getActualType();
+ if (innerType.getTypeTag() == ATypeTag.ORDEREDLIST) {
+ return (AOrderedListType) innerType;
+ }
+ }
+ return null;
+ }
+
+ public static AUnorderedListType extractUnorderedListType(IAType t) {
+ if (t.getTypeTag() == ATypeTag.UNORDEREDLIST) {
+ return (AUnorderedListType) t;
+ }
+ if (t.getTypeTag() == ATypeTag.UNION) {
+ AUnionType unionType = (AUnionType) t;
+ IAType innerType = unionType.getActualType();
+ if (innerType.getTypeTag() == ATypeTag.UNORDEREDLIST) {
+ return (AUnorderedListType) innerType;
+ }
+ }
+
+ return null;
+ }
+
+}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/TypeComputerUtils.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/TypeComputerUtils.java
deleted file mode 100644
index cba988b..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/TypeComputerUtils.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.types.AOrderedListType;
-import org.apache.asterix.om.types.ARecordType;
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.AUnorderedListType;
-import org.apache.asterix.om.types.IAType;
-
-public class TypeComputerUtils {
-
- public static ARecordType extractRecordType(IAType t) {
- if (t.getTypeTag() == ATypeTag.RECORD) {
- return (ARecordType) t;
- }
-
- if (t.getTypeTag() == ATypeTag.UNION) {
- IAType innerType = ((AUnionType) t).getUnionList().get(1);
- if (innerType.getTypeTag() == ATypeTag.RECORD) {
- return (ARecordType) innerType;
- }
- }
-
- return null;
- }
-
- public static AOrderedListType extractOrderedListType(IAType t) {
- if (t.getTypeTag() == ATypeTag.ORDEREDLIST) {
- return (AOrderedListType) t;
- }
-
- if (t.getTypeTag() == ATypeTag.UNION) {
- IAType innerType = ((AUnionType) t).getUnionList().get(1);
- if (innerType.getTypeTag() == ATypeTag.ORDEREDLIST) {
- return (AOrderedListType) innerType;
- }
- }
-
- return null;
- }
-
- public static AUnorderedListType extractUnorderedListType(IAType t) {
- if (t.getTypeTag() == ATypeTag.UNORDEREDLIST) {
- return (AUnorderedListType) t;
- }
-
- if (t.getTypeTag() == ATypeTag.UNION) {
- IAType innerType = ((AUnionType) t).getUnionList().get(1);
- if (innerType.getTypeTag() == ATypeTag.UNORDEREDLIST) {
- return (AUnorderedListType) innerType;
- }
- }
-
- return null;
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryBinaryInt64OrNullTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryBinaryInt64OrNullTypeComputer.java
deleted file mode 100644
index ab94c4f..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryBinaryInt64OrNullTypeComputer.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class UnaryBinaryInt64OrNullTypeComputer implements IResultTypeComputer {
- public static final UnaryBinaryInt64OrNullTypeComputer INSTANCE = new UnaryBinaryInt64OrNullTypeComputer();
-
- private UnaryBinaryInt64OrNullTypeComputer() {
-
- }
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
- if (fce.getArguments().size() != 1) {
- throw new AlgebricksException("Wrong Argument Number.");
- }
- ILogicalExpression arg0 = fce.getArguments().get(0).getValue();
- IAType t0;
- t0 = (IAType) env.getType(arg0);
- if (t0.getTypeTag() != ATypeTag.NULL
- && t0.getTypeTag() != ATypeTag.BINARY
- && (t0.getTypeTag() == ATypeTag.UNION && !((AUnionType) t0).getUnionList()
- .contains(BuiltinType.ABINARY))) {
- throw new NotImplementedException("Expects Binary Type.");
- }
-
- if (t0.getTypeTag() == ATypeTag.NULL) {
- return BuiltinType.ANULL;
- }
-
- if (t0.getTypeTag() == ATypeTag.BINARY || t0.getTypeTag().equals(ATypeTag.UNION)) {
- return AUnionType.createNullableType(BuiltinType.AINT64, "binary-length-Result");
- }
- throw new AlgebricksException("Cannot compute type");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryBinaryInt64TypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryBinaryInt64TypeComputer.java
new file mode 100644
index 0000000..0105fe3
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryBinaryInt64TypeComputer.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.om.typecomputer.impl;
+
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.BuiltinType;
+import org.apache.asterix.om.types.IAType;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+
+public class UnaryBinaryInt64TypeComputer extends AbstractResultTypeComputer {
+ public static final UnaryBinaryInt64TypeComputer INSTANCE = new UnaryBinaryInt64TypeComputer();
+
+ private UnaryBinaryInt64TypeComputer() {
+ }
+
+ @Override
+ public void checkArgType(int argIndex, IAType type) throws AlgebricksException {
+ ATypeTag tag = type.getTypeTag();
+ if (argIndex == 0) {
+ if (tag != ATypeTag.BINARY) {
+ throw new AlgebricksException("The argument should be binary Type.");
+ }
+ } else {
+ throw new AlgebricksException("Wrong Argument Number.");
+ }
+ }
+
+ @Override
+ public IAType getResultType(IAType... types) {
+ return BuiltinType.AINT64;
+ }
+}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryBooleanOrNullFunctionTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryBooleanOrNullFunctionTypeComputer.java
deleted file mode 100644
index 6c0b53c..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryBooleanOrNullFunctionTypeComputer.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.types.TypeHelper;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-public class UnaryBooleanOrNullFunctionTypeComputer implements IResultTypeComputer {
-
- public static final UnaryBooleanOrNullFunctionTypeComputer INSTANCE = new UnaryBooleanOrNullFunctionTypeComputer();
-
- private UnaryBooleanOrNullFunctionTypeComputer() {
- }
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
- ILogicalExpression arg0 = fce.getArguments().get(0).getValue();
- IAType t0;
- try {
- t0 = (IAType) env.getType(arg0);
- } catch (AlgebricksException e) {
- throw new AlgebricksException(e);
- }
- if (t0.getTypeTag() == ATypeTag.NULL) {
- return BuiltinType.ANULL;
- }
- if (TypeHelper.canBeNull(t0)) {
- return AUnionType.createNullableType(BuiltinType.ABOOLEAN, "OptionalBoolean");
- }
- return BuiltinType.ABOOLEAN;
- }
-
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryMinusTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryMinusTypeComputer.java
new file mode 100644
index 0000000..31e559e
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryMinusTypeComputer.java
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.om.typecomputer.impl;
+
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.IAType;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
+
+public class UnaryMinusTypeComputer extends AbstractResultTypeComputer {
+
+ public static final UnaryMinusTypeComputer INSTANCE = new UnaryMinusTypeComputer();
+
+ private UnaryMinusTypeComputer() {
+ }
+
+ @Override
+ public void checkArgType(int argIndex, IAType type) throws AlgebricksException {
+ ATypeTag tag = type.getTypeTag();
+ switch (tag) {
+ case INT8:
+ case INT16:
+ case INT32:
+ case INT64:
+ case FLOAT:
+ case DOUBLE:
+ break;
+ default:
+ throw new NotImplementedException(
+ "Negative operations are not implemented for " + type.getDisplayName());
+ }
+ }
+
+ @Override
+ public IAType getResultType(IAType... knownTypes) {
+ ATypeTag tag = knownTypes[0].getTypeTag();
+ switch (tag) {
+ case INT8:
+ case INT16:
+ case INT32:
+ case INT64:
+ case FLOAT:
+ case DOUBLE:
+ return knownTypes[0];
+ default:
+ return null;
+ }
+ }
+}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryStringInt64OrNullTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryStringInt64OrNullTypeComputer.java
deleted file mode 100644
index f41a719..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryStringInt64OrNullTypeComputer.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-/**
- * @author Xiaoyu Ma
- */
-public class UnaryStringInt64OrNullTypeComputer implements IResultTypeComputer {
-
- public static final UnaryStringInt64OrNullTypeComputer INSTANCE = new UnaryStringInt64OrNullTypeComputer();
-
- private UnaryStringInt64OrNullTypeComputer() {
- }
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
- if (fce.getArguments().isEmpty()) {
- throw new AlgebricksException("Wrong Argument Number.");
- }
- ILogicalExpression arg0 = fce.getArguments().get(0).getValue();
- IAType t0;
- try {
- t0 = (IAType) env.getType(arg0);
- } catch (AlgebricksException e) {
- throw new AlgebricksException(e);
- }
- if (t0.getTypeTag() == ATypeTag.ANY) {
- return BuiltinType.ANY;
- }
-
- if (t0.getTypeTag() != ATypeTag.NULL && t0.getTypeTag() != ATypeTag.STRING && (t0.getTypeTag() == ATypeTag.UNION
- && !((AUnionType) t0).getUnionList().contains(BuiltinType.ASTRING))) {
- throw new NotImplementedException("Expects String Type.");
- }
-
- List<IAType> unionList = new ArrayList<IAType>();
- unionList.add(BuiltinType.ANULL);
- if (t0.getTypeTag() == ATypeTag.NULL) {
- return BuiltinType.ANULL;
- }
-
- if (t0.getTypeTag() == ATypeTag.STRING || t0.getTypeTag().equals(ATypeTag.UNION)) {
- return AUnionType.createNullableType(BuiltinType.AINT64, "String-length-Result");
- }
-
- throw new AlgebricksException("Cannot compute type");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryStringInt64TypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryStringInt64TypeComputer.java
new file mode 100644
index 0000000..7208243
--- /dev/null
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryStringInt64TypeComputer.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.om.typecomputer.impl;
+
+import org.apache.asterix.om.typecomputer.base.AbstractResultTypeComputer;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.BuiltinType;
+import org.apache.asterix.om.types.IAType;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+
+public class UnaryStringInt64TypeComputer extends AbstractResultTypeComputer {
+
+ public static final UnaryStringInt64TypeComputer INSTANCE = new UnaryStringInt64TypeComputer();
+
+ private UnaryStringInt64TypeComputer() {
+ }
+
+ @Override
+ public void checkArgType(int argIndex, IAType type) throws AlgebricksException {
+ ATypeTag tag = type.getTypeTag();
+ if (argIndex == 0) {
+ if (tag != ATypeTag.STRING) {
+ throw new AlgebricksException("Second argument should be string Type.");
+ }
+ } else {
+ throw new AlgebricksException("Wrong Argument Number.");
+ }
+ }
+
+ @Override
+ public IAType getResultType(IAType... types) {
+ return BuiltinType.AINT64;
+ }
+}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryStringOrNullTypeComputer.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryStringOrNullTypeComputer.java
deleted file mode 100644
index 4c11c8e..0000000
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnaryStringOrNullTypeComputer.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.om.typecomputer.impl;
-
-import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.types.TypeHelper;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
-import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
-import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
-
-/**
- * @author Xiaoyu Ma
- */
-public class UnaryStringOrNullTypeComputer implements IResultTypeComputer {
-
- public static final UnaryStringOrNullTypeComputer INSTANCE = new UnaryStringOrNullTypeComputer();
-
- private UnaryStringOrNullTypeComputer() {
- }
-
- @Override
- public IAType computeType(ILogicalExpression expression, IVariableTypeEnvironment env,
- IMetadataProvider<?, ?> metadataProvider) throws AlgebricksException {
- AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expression;
- if (fce.getArguments().isEmpty())
- throw new AlgebricksException("Wrong Argument Number.");
- ILogicalExpression arg0 = fce.getArguments().get(0).getValue();
- IAType t0;
- try {
- t0 = (IAType) env.getType(arg0);
- } catch (AlgebricksException e) {
- throw new AlgebricksException(e);
- }
-
- if (TypeHelper.canBeNull(t0)) {
- return AUnionType.createNullableType(BuiltinType.ASTRING);
- }
-
- if (t0.getTypeTag() == ATypeTag.NULL)
- return BuiltinType.ANULL;
-
- if (t0.getTypeTag() == ATypeTag.STRING)
- return BuiltinType.ASTRING;
-
- throw new AlgebricksException("Expects String Type.");
- }
-}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnorderedListConstructorResultType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnorderedListConstructorResultType.java
index 67b3c69..1e1d753 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnorderedListConstructorResultType.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/typecomputer/impl/UnorderedListConstructorResultType.java
@@ -19,15 +19,13 @@
package org.apache.asterix.om.typecomputer.impl;
-import java.util.ArrayList;
-
import org.apache.asterix.om.typecomputer.base.IResultTypeComputer;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
+import org.apache.asterix.om.typecomputer.base.TypeCastUtils;
+import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.AUnionType;
import org.apache.asterix.om.types.AUnorderedListType;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
-import org.apache.asterix.om.util.NonTaggedFormatUtil;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
import org.apache.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression;
@@ -46,24 +44,28 @@
/**
* if type has been top-down propagated, use the enforced type
*/
- AUnorderedListType reqType = (AUnorderedListType) TypeComputerUtilities.getRequiredType(f);
- if (reqType != null)
+ AUnorderedListType reqType = (AUnorderedListType) TypeCastUtils.getRequiredType(f);
+ if (reqType != null) {
return reqType;
+ }
- ArrayList<IAType> types = new ArrayList<IAType>();
+ IAType currentType = null;
+ boolean any = false;
for (int k = 0; k < f.getArguments().size(); k++) {
IAType type = (IAType) env.getType(f.getArguments().get(k).getValue());
- if (NonTaggedFormatUtil.isOptional(type))
- type = ((AUnionType) type).getNullableType();
- if (types.indexOf(type) < 0) {
- types.add(type);
+ if (type.getTypeTag() == ATypeTag.UNION) {
+ type = ((AUnionType) type).getActualType();
}
+ if (currentType != null && !currentType.equals(type)) {
+ any = true;
+ break;
+ }
+ currentType = type;
}
- if (types.size() == 1) {
- return new AUnorderedListType(types.get(0), null);
- } else {
+ if (any || currentType == null) {
return new AUnorderedListType(BuiltinType.ANY, null);
+ } else {
+ return new AUnorderedListType(currentType, null);
}
-
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/ARecordType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/ARecordType.java
index 6147276..163421d 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/ARecordType.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/ARecordType.java
@@ -168,7 +168,7 @@
}
if (subRecordType.getTypeTag().equals(ATypeTag.UNION)) {
//enforced SubType
- subRecordType = ((AUnionType) subRecordType).getNullableType();
+ subRecordType = ((AUnionType) subRecordType).getActualType();
if (subRecordType.getTypeTag() != ATypeTag.RECORD) {
throw new AsterixException(
"Field accessor is not defined for values of type " + subRecordType.getTypeTag());
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/ATypeTag.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/ATypeTag.java
index 3dc2caa..4d6a96c 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/ATypeTag.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/ATypeTag.java
@@ -40,7 +40,7 @@
FLOAT(11),
DOUBLE(12),
STRING(13),
- NULL(14),
+ MISSING(14),
BOOLEAN(15),
DATETIME(16),
DATE(17),
@@ -65,12 +65,14 @@
YEARMONTHDURATION(36),
DAYTIMEDURATION(37),
UUID(38),
- SHORTWITHOUTTYPEINFO(40);
+ SHORTWITHOUTTYPEINFO(40),
+ NULL(41);
/*
* Serialized Tags begin
*/
public static final byte SERIALIZED_STRING_TYPE_TAG = STRING.serialize();
+ public static final byte SERIALIZED_MISSING_TYPE_TAG = MISSING.serialize();
public static final byte SERIALIZED_NULL_TYPE_TAG = NULL.serialize();
public static final byte SERIALIZED_DOUBLE_TYPE_TAG = DOUBLE.serialize();
public static final byte SERIALIZED_RECORD_TYPE_TAG = RECORD.serialize();
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/AUnionType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/AUnionType.java
index 65f0098..3c29e7f 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/AUnionType.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/AUnionType.java
@@ -32,7 +32,7 @@
public class AUnionType extends AbstractComplexType {
private static final long serialVersionUID = 1L;
- public static final int OPTIONAL_TYPE_INDEX_IN_UNION_LIST = 1;
+ private static final int OPTIONAL_TYPE_INDEX_IN_UNION_LIST = 0;
private final List<IAType> unionList;
public AUnionType(List<IAType> unionList, String typeName) {
@@ -44,18 +44,98 @@
return unionList;
}
- public void setTypeAtIndex(IAType type, int index) {
- unionList.set(index, type);
+ public boolean isMissableType() {
+ return containsType(BuiltinType.AMISSING);
}
public boolean isNullableType() {
- return unionList.size() == 2 && unionList.get(0).equals(BuiltinType.ANULL);
+ return containsType(BuiltinType.ANULL);
}
- public IAType getNullableType() {
+ public boolean isUnknownableType() {
+ return isMissableType() || isNullableType();
+ }
+
+ private boolean containsType(IAType t) {
+ for (int index = 0; index < unionList.size(); ++index) {
+ if (unionList.get(index) != null && unionList.get(index).equals(t)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public IAType getActualType() {
return unionList.get(AUnionType.OPTIONAL_TYPE_INDEX_IN_UNION_LIST);
}
+ public void setActualType(IAType type) {
+ if (AUnionType.OPTIONAL_TYPE_INDEX_IN_UNION_LIST < unionList.size()) {
+ unionList.set(AUnionType.OPTIONAL_TYPE_INDEX_IN_UNION_LIST, type);
+ } else {
+ unionList.add(type);
+ }
+ }
+
+ public static IAType createMissableType(IAType type, String typeName) {
+ if (type != null && type.getTypeTag() == ATypeTag.MISSING) {
+ return type;
+ }
+ List<IAType> unionList = new ArrayList<>();
+ if (type != null && type.getTypeTag() == ATypeTag.UNION) {
+ AUnionType unionType = (AUnionType) type;
+ unionList.addAll(unionType.getUnionList());
+ } else {
+ unionList.add(type);
+ }
+ unionList.add(BuiltinType.AMISSING);
+ return new AUnionType(unionList, typeName);
+ }
+
+ public static IAType createMissableType(IAType t) {
+ if (t != null && t.getTypeTag() == ATypeTag.MISSING) {
+ return t;
+ }
+ String s = t != null ? t.getTypeName() : null;
+ return createMissableType(t, s == null ? null : s + "?");
+ }
+
+ public static IAType createNullableType(IAType type, String typeName) {
+ if (type != null && type.getTypeTag() == ATypeTag.NULL) {
+ return type;
+ }
+ List<IAType> unionList = new ArrayList<>();
+ if (type != null && type.getTypeTag() == ATypeTag.UNION) {
+ AUnionType unionType = (AUnionType) type;
+ unionList.addAll(unionType.getUnionList());
+ } else {
+ unionList.add(type);
+ }
+ unionList.add(BuiltinType.ANULL);
+ return new AUnionType(unionList, typeName);
+ }
+
+ public static IAType createNullableType(IAType t) {
+ if (t != null && t.getTypeTag() == ATypeTag.NULL) {
+ return t;
+ }
+ String s = t != null ? t.getTypeName() : null;
+ return createNullableType(t, s == null ? null : s + "?");
+ }
+
+ public static IAType createUnknownableType(IAType type, String typeName) {
+ List<IAType> unionList = new ArrayList<>();
+ unionList.add(type);
+ unionList.add(BuiltinType.ANULL);
+ unionList.add(BuiltinType.AMISSING);
+ return new AUnionType(unionList, typeName);
+ }
+
+ public static IAType createUnknownableType(IAType t) {
+ String s = t != null ? t.getTypeName() : null;
+ return createUnknownableType(t, s == null ? null : s + "?");
+ }
+
@Override
public String getDisplayName() {
return "AUnion";
@@ -92,22 +172,10 @@
return BuiltinType.ASTERIX_TYPE;
}
- public static AUnionType createNullableType(IAType type, String typeName) {
- List<IAType> unionList = new ArrayList<IAType>();
- unionList.add(BuiltinType.ANULL);
- unionList.add(type);
- return new AUnionType(unionList, typeName);
- }
-
- public static AUnionType createNullableType(IAType t) {
- String s = t != null ? t.getTypeName() : null;
- return createNullableType(t, s == null ? null : s + "?");
- }
-
@Override
public void generateNestedDerivedTypeNames() {
- if (isNullableType()) {
- IAType nullableType = getNullableType();
+ if (isUnknownableType()) {
+ IAType nullableType = getActualType();
if (nullableType.getTypeTag().isDerivedType() && nullableType.getTypeName() == null) {
AbstractComplexType derivedType = (AbstractComplexType) nullableType;
derivedType.setTypeName(getTypeName());
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/BuiltinType.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/BuiltinType.java
index 620b9ae..f556de5 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/BuiltinType.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/BuiltinType.java
@@ -286,6 +286,33 @@
}
};
+ public final static BuiltinType AMISSING = new LowerCaseConstructorType() {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public String getDisplayName() {
+ return "Missing";
+ }
+
+ @Override
+ public ATypeTag getTypeTag() {
+ return ATypeTag.MISSING;
+ }
+
+ @Override
+ public String getTypeName() {
+ return "missing";
+ }
+
+ @Override
+ public JSONObject toJSON() throws JSONException {
+ JSONObject type = new JSONObject();
+ type.put("type", "AMISSING");
+ return type;
+ }
+ };
+
public final static BuiltinType ANULL = new LowerCaseConstructorType() {
private static final long serialVersionUID = 1L;
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/TypeHelper.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/TypeHelper.java
index 5c556d6..4839c41 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/TypeHelper.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/TypeHelper.java
@@ -18,69 +18,44 @@
*/
package org.apache.asterix.om.types;
-import java.util.ArrayList;
-import java.util.List;
-
public class TypeHelper {
- public static boolean canBeNull(IAType t) {
+ public static boolean canBeMissing(IAType t) {
switch (t.getTypeTag()) {
- case NULL: {
+ case MISSING:
return true;
- }
- case UNION: {
- AUnionType ut = (AUnionType) t;
- for (IAType t2 : ut.getUnionList()) {
- if (canBeNull(t2)) {
- return true;
- }
- }
- return false;
- }
+ case UNION:
+ return ((AUnionType) t).isMissableType();
default: {
return false;
}
}
}
- public static IAType getNonOptionalType(IAType t) {
- if (t.getTypeTag() != ATypeTag.UNION) {
- return t;
+ public static boolean canBeUnknown(IAType t) {
+ switch (t.getTypeTag()) {
+ case MISSING:
+ case NULL:
+ return true;
+ case UNION:
+ return ((AUnionType) t).isUnknownableType();
+ default:
+ return false;
}
- AUnionType ut = (AUnionType) t;
- List<IAType> x = new ArrayList<IAType>();
- for (IAType t1 : ut.getUnionList()) {
- IAType y = getNonOptionalType(t1);
- if (y != BuiltinType.ANULL) {
- x.add(y);
- }
- }
- if (x.isEmpty()) {
- return BuiltinType.ANULL;
- }
- if (x.size() == 1) {
- return x.get(0);
- }
- return new AUnionType(x, null);
}
public static boolean isClosed(IAType t) {
switch (t.getTypeTag()) {
- case ANY: {
+ case MISSING:
+ case ANY:
return false;
- }
- case UNION: {
- AUnionType ut = (AUnionType) t;
- for (IAType t1 : ut.getUnionList()) {
- if (!isClosed(t1)) {
- return false;
- }
+ case UNION:
+ if (!isClosed(((AUnionType) t).getActualType())) {
+ return false;
}
return true;
- }
- default: {
+ default:
return true;
- }
}
}
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/TypeTagUtil.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/TypeTagUtil.java
index a73ff73..2a50506 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/TypeTagUtil.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/types/TypeTagUtil.java
@@ -42,6 +42,8 @@
return BuiltinType.ADOUBLE;
case STRING:
return BuiltinType.ASTRING;
+ case MISSING:
+ return BuiltinType.AMISSING;
case NULL:
return BuiltinType.ANULL;
case BOOLEAN:
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/util/NonTaggedFormatUtil.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/util/NonTaggedFormatUtil.java
index c24ce45..1009fbb 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/util/NonTaggedFormatUtil.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/util/NonTaggedFormatUtil.java
@@ -18,8 +18,6 @@
*/
package org.apache.asterix.om.util;
-import java.util.List;
-
import org.apache.asterix.common.config.DatasetConfig.IndexType;
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
@@ -50,10 +48,11 @@
public static final boolean isFixedSizedCollection(IAType type) {
switch (type.getTypeTag()) {
case UNION:
- if (!((AUnionType) type).isNullableType())
+ if (!((AUnionType) type).isUnknownableType()) {
return false;
- else
- return isFixedSizedCollection(((AUnionType) type).getNullableType());
+ } else {
+ return isFixedSizedCollection(((AUnionType) type).getActualType());
+ }
default:
return isFixedSizedCollection(type.getTypeTag());
}
@@ -76,19 +75,20 @@
}
public static final boolean hasNullableField(ARecordType recType) {
- IAType type;
- List<IAType> unionList;
for (int i = 0; i < recType.getFieldTypes().length; i++) {
- type = recType.getFieldTypes()[i];
+ IAType type = recType.getFieldTypes()[i];
if (type != null) {
- if (type.getTypeTag() == ATypeTag.NULL)
+ ATypeTag tag = type.getTypeTag();
+ if (tag == ATypeTag.NULL) {
return true;
- if (type.getTypeTag() == ATypeTag.UNION) { // union
- unionList = ((AUnionType) type).getUnionList();
- for (int j = 0; j < unionList.size(); j++)
- if (unionList.get(j).getTypeTag() == ATypeTag.NULL)
- return true;
-
+ }
+ if (tag != ATypeTag.UNION) {
+ continue;
+ }
+ // union
+ AUnionType unionType = (AUnionType) type;
+ if (unionType.isUnknownableType()) {
+ return true;
}
}
}
@@ -102,7 +102,7 @@
* @return true if it is optional; false otherwise
*/
public static boolean isOptional(IAType type) {
- return type.getTypeTag() == ATypeTag.UNION && ((AUnionType) type).isNullableType();
+ return type.getTypeTag() == ATypeTag.UNION && ((AUnionType) type).isUnknownableType();
}
public static int getFieldValueLength(byte[] serNonTaggedAObject, int offset, ATypeTag typeTag, boolean tagged)
@@ -114,6 +114,7 @@
throw new AsterixException("Field value has type tag ANY, but it should have a concrete type.");
}
return getFieldValueLength(serNonTaggedAObject, offset, tag, true) + 1;
+ case MISSING:
case NULL:
return 0;
case BOOLEAN:
@@ -139,10 +140,11 @@
case UUID:
return 16;
case INTERVAL:
- if (tagged)
+ if (tagged) {
return AIntervalSerializerDeserializer.getIntervalLength(serNonTaggedAObject, offset + 1);
- else
+ } else {
return AIntervalSerializerDeserializer.getIntervalLength(serNonTaggedAObject, offset);
+ }
case POINT3D:
case CIRCLE:
return 24;
@@ -150,10 +152,11 @@
case RECTANGLE:
return 32;
case POLYGON:
- if (tagged)
+ if (tagged) {
return AInt16SerializerDeserializer.getShort(serNonTaggedAObject, offset + 1) * 16 + 2;
- else
+ } else {
return AInt16SerializerDeserializer.getShort(serNonTaggedAObject, offset) * 16 + 2;
+ }
case STRING:
if (tagged) {
int len = UTF8StringUtil.getUTFLength(serNonTaggedAObject, offset + 1);
@@ -171,21 +174,24 @@
return len + ByteArrayPointable.getNumberBytesToStoreMeta(len);
}
case RECORD:
- if (tagged)
+ if (tagged) {
return ARecordSerializerDeserializer.getRecordLength(serNonTaggedAObject, offset + 1) - 1;
- else
+ } else {
return ARecordSerializerDeserializer.getRecordLength(serNonTaggedAObject, offset) - 1;
+ }
case ORDEREDLIST:
- if (tagged)
+ if (tagged) {
return AOrderedListSerializerDeserializer.getOrderedListLength(serNonTaggedAObject, offset + 1) - 1;
- else
+ } else {
return AOrderedListSerializerDeserializer.getOrderedListLength(serNonTaggedAObject, offset) - 1;
+ }
case UNORDEREDLIST:
- if (tagged)
+ if (tagged) {
return AUnorderedListSerializerDeserializer.getUnorderedListLength(serNonTaggedAObject, offset + 1)
- 1;
- else
+ } else {
return AUnorderedListSerializerDeserializer.getUnorderedListLength(serNonTaggedAObject, offset) - 1;
+ }
default:
throw new NotImplementedException(
"No getLength implemented for a value of this type " + typeTag + " .");
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/visitors/IOMVisitor.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/visitors/IOMVisitor.java
index 2bc80af..6ef6a9d 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/visitors/IOMVisitor.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/visitors/IOMVisitor.java
@@ -35,6 +35,7 @@
import org.apache.asterix.om.base.AInt8;
import org.apache.asterix.om.base.AInterval;
import org.apache.asterix.om.base.ALine;
+import org.apache.asterix.om.base.AMissing;
import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.AOrderedList;
import org.apache.asterix.om.base.APoint;
@@ -91,6 +92,8 @@
public void visitARecord(ARecord obj) throws AsterixException;
+ public void visitAMissing(AMissing obj) throws AsterixException;
+
public void visitANull(ANull obj) throws AsterixException;
public void visitAPoint(APoint obj) throws AsterixException;
diff --git a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/visitors/OMPrintToStringVisitor.java b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/visitors/OMPrintToStringVisitor.java
index da0e270..0752a84 100644
--- a/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/visitors/OMPrintToStringVisitor.java
+++ b/asterixdb/asterix-om/src/main/java/org/apache/asterix/om/visitors/OMPrintToStringVisitor.java
@@ -36,6 +36,7 @@
import org.apache.asterix.om.base.AInt8;
import org.apache.asterix.om.base.AInterval;
import org.apache.asterix.om.base.ALine;
+import org.apache.asterix.om.base.AMissing;
import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.AOrderedList;
import org.apache.asterix.om.base.APoint;
@@ -150,6 +151,11 @@
}
@Override
+ public void visitAMissing(AMissing obj) throws AsterixException {
+ buffer.append("missing");
+ }
+
+ @Override
public void visitANull(ANull obj) throws AsterixException {
buffer.append("null");
}
@@ -252,8 +258,8 @@
}
default: {
// TODO Auto-generated method stub
- throw new NotImplementedException("Pretty-printing is not implemented for type " + obj.getTypeTag()
- + " .");
+ throw new NotImplementedException(
+ "Pretty-printing is not implemented for type " + obj.getTypeTag() + " .");
}
}
diff --git a/asterixdb/asterix-runtime/pom.xml b/asterixdb/asterix-runtime/pom.xml
index eabe06e..3bfe55a 100644
--- a/asterixdb/asterix-runtime/pom.xml
+++ b/asterixdb/asterix-runtime/pom.xml
@@ -79,5 +79,10 @@
<artifactId>asm-all</artifactId>
<version>5.1</version>
</dependency>
+ <dependency>
+ <groupId>com.e-movimento.tinytools</groupId>
+ <artifactId>privilegedaccessor</artifactId>
+ <version>1.2.2</version>
+ </dependency>
</dependencies>
</project>
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/AbstractSerializableAvgAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/AbstractSerializableAvgAggregateFunction.java
index c3b9b47..41a2d3f 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/AbstractSerializableAvgAggregateFunction.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/AbstractSerializableAvgAggregateFunction.java
@@ -46,9 +46,9 @@
import org.apache.asterix.runtime.evaluators.common.ClosedRecordConstructorEvalFactory.ClosedRecordConstructorEval;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
-import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.data.std.api.IPointable;
@@ -128,7 +128,7 @@
long count = BufferSerDeUtil.getLong(state, start + COUNT_OFFSET);
ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]);
ATypeTag aggType = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(state[start + AGG_TYPE_OFFSET]);
- if (typeTag == ATypeTag.NULL) {
+ if (typeTag == ATypeTag.MISSING || typeTag == ATypeTag.NULL) {
processNull(state, start);
return;
} else if (aggType == ATypeTag.SYSTEM_NULL) {
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/AbstractSerializableCountAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/AbstractSerializableCountAggregateFunction.java
index 6270e78..d11997c 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/AbstractSerializableCountAggregateFunction.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/AbstractSerializableCountAggregateFunction.java
@@ -29,9 +29,9 @@
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.data.std.api.IPointable;
@@ -77,7 +77,7 @@
eval.evaluate(tuple, inputVal);
ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER
.deserialize(inputVal.getByteArray()[inputVal.getStartOffset()]);
- if (typeTag == ATypeTag.NULL) {
+ if (typeTag == ATypeTag.MISSING || typeTag == ATypeTag.NULL) {
processNull(state, start);
} else {
cnt++;
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/AbstractSerializableSumAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/AbstractSerializableSumAggregateFunction.java
index 03eb2d3..d742d83 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/AbstractSerializableSumAggregateFunction.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/AbstractSerializableSumAggregateFunction.java
@@ -41,9 +41,9 @@
import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
-import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.algebricks.runtime.base.ISerializedAggregateEvaluator;
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.data.std.api.IPointable;
@@ -92,7 +92,7 @@
int offset = inputVal.getStartOffset();
ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]);
- if (typeTag == ATypeTag.NULL) {
+ if (typeTag == ATypeTag.MISSING || typeTag == ATypeTag.NULL) {
processNull(state, start);
return;
} else if (aggType == ATypeTag.SYSTEM_NULL) {
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableAvgAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableAvgAggregateFunction.java
index d8c7fe2..346fa76 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableAvgAggregateFunction.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableAvgAggregateFunction.java
@@ -57,7 +57,7 @@
@Override
protected boolean skipStep(byte[] state, int start) {
ATypeTag aggType = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(state[start + AGG_TYPE_OFFSET]);
- return (aggType == ATypeTag.NULL);
+ return aggType == ATypeTag.NULL;
}
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalAvgAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalAvgAggregateFunction.java
index 83a856c..3895911 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalAvgAggregateFunction.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableGlobalAvgAggregateFunction.java
@@ -58,7 +58,7 @@
@Override
protected boolean skipStep(byte[] state, int start) {
ATypeTag aggType = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(state[start + AGG_TYPE_OFFSET]);
- return (aggType == ATypeTag.NULL);
+ return aggType == ATypeTag.NULL;
}
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateAvgAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateAvgAggregateFunction.java
index 3ea3d76..af2f663 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateAvgAggregateFunction.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableIntermediateAvgAggregateFunction.java
@@ -58,7 +58,7 @@
@Override
protected boolean skipStep(byte[] state, int start) {
ATypeTag aggType = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(state[start + AGG_TYPE_OFFSET]);
- return (aggType == ATypeTag.NULL);
+ return aggType == ATypeTag.NULL;
}
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalAvgAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalAvgAggregateFunction.java
index c15a937..aa9b385 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalAvgAggregateFunction.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableLocalAvgAggregateFunction.java
@@ -58,7 +58,7 @@
@Override
protected boolean skipStep(byte[] state, int start) {
ATypeTag aggType = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(state[start + AGG_TYPE_OFFSET]);
- return (aggType == ATypeTag.NULL);
+ return aggType == ATypeTag.NULL;
}
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableSumAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableSumAggregateFunction.java
index e5190ae..db3de24 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableSumAggregateFunction.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/serializable/std/SerializableSumAggregateFunction.java
@@ -47,7 +47,7 @@
@Override
protected boolean skipStep(byte[] state, int start) {
ATypeTag aggType = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(state[start + AGG_TYPE_OFFSET]);
- return (aggType == ATypeTag.NULL);
+ return aggType == ATypeTag.NULL;
}
@Override
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/AbstractAvgAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/AbstractAvgAggregateFunction.java
index a57aacd..e403107 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/AbstractAvgAggregateFunction.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/AbstractAvgAggregateFunction.java
@@ -127,7 +127,7 @@
int offset = inputVal.getStartOffset();
ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(data[offset]);
- if (typeTag == ATypeTag.NULL) {
+ if (typeTag == ATypeTag.MISSING || typeTag == ATypeTag.NULL) {
processNull();
return;
} else if (aggType == ATypeTag.SYSTEM_NULL) {
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/AbstractCountAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/AbstractCountAggregateFunction.java
index f93617d..ca44fa3 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/AbstractCountAggregateFunction.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/AbstractCountAggregateFunction.java
@@ -67,7 +67,7 @@
ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER
.deserialize(inputVal.getByteArray()[inputVal.getStartOffset()]);
// Ignore SYSTEM_NULL.
- if (typeTag == ATypeTag.NULL) {
+ if (typeTag == ATypeTag.NULL || typeTag == ATypeTag.MISSING) {
processNull();
} else if (typeTag != ATypeTag.SYSTEM_NULL) {
cnt++;
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/AbstractMinMaxAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/AbstractMinMaxAggregateFunction.java
index c5a0104..5372cfb 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/AbstractMinMaxAggregateFunction.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/AbstractMinMaxAggregateFunction.java
@@ -64,15 +64,15 @@
@Override
public void step(IFrameTupleReference tuple) throws AlgebricksException {
+ if (skipStep()) {
+ return;
+ }
eval.evaluate(tuple, inputVal);
-
ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER
.deserialize(inputVal.getByteArray()[inputVal.getStartOffset()]);
- if (typeTag == ATypeTag.NULL) {
+ if (typeTag == ATypeTag.MISSING || typeTag == ATypeTag.NULL) {
processNull();
return;
- } else if (aggType == ATypeTag.NULL) {
- return;
} else if (aggType == ATypeTag.SYSTEM_NULL) {
if (typeTag == ATypeTag.SYSTEM_NULL) {
// Ignore.
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/AbstractSumAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/AbstractSumAggregateFunction.java
index 2948887..6938255 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/AbstractSumAggregateFunction.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/AbstractSumAggregateFunction.java
@@ -86,7 +86,7 @@
int offset = inputVal.getStartOffset();
ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(data[offset]);
- if (typeTag == ATypeTag.NULL) {
+ if (typeTag == ATypeTag.MISSING || typeTag == ATypeTag.NULL) {
processNull();
return;
} else if (aggType == ATypeTag.SYSTEM_NULL) {
@@ -131,9 +131,6 @@
sum += val;
break;
}
- case NULL: {
- break;
- }
case SYSTEM_NULL: {
processSystemNull();
break;
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/AvgAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/AvgAggregateFunction.java
index fd52df3..b5fd5ed 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/AvgAggregateFunction.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/AvgAggregateFunction.java
@@ -55,7 +55,7 @@
@Override
protected boolean skipStep() {
- return (aggType == ATypeTag.NULL);
+ return aggType == ATypeTag.NULL;
}
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/GlobalAvgAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/GlobalAvgAggregateFunction.java
index db01fde..3555863 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/GlobalAvgAggregateFunction.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/GlobalAvgAggregateFunction.java
@@ -55,7 +55,7 @@
@Override
protected boolean skipStep() {
- return (aggType == ATypeTag.NULL);
+ return aggType == ATypeTag.NULL;
}
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/IntermediateAvgAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/IntermediateAvgAggregateFunction.java
index 1543f95..667ceda 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/IntermediateAvgAggregateFunction.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/IntermediateAvgAggregateFunction.java
@@ -55,7 +55,7 @@
@Override
protected boolean skipStep() {
- return (aggType == ATypeTag.NULL);
+ return aggType == ATypeTag.NULL;
}
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/LocalAvgAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/LocalAvgAggregateFunction.java
index 0b19900..018a2ca 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/LocalAvgAggregateFunction.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/LocalAvgAggregateFunction.java
@@ -55,7 +55,7 @@
@Override
protected boolean skipStep() {
- return (aggType == ATypeTag.NULL);
+ return aggType == ATypeTag.NULL;
}
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/MinMaxAggregateFunction.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/MinMaxAggregateFunction.java
index 65ecc32..894f332 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/MinMaxAggregateFunction.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/aggregates/std/MinMaxAggregateFunction.java
@@ -41,7 +41,7 @@
@Override
protected boolean skipStep() {
- return (aggType == ATypeTag.NULL);
+ return aggType == ATypeTag.NULL;
}
@Override
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/CircleCenterAccessor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/CircleCenterAccessor.java
index d59380d..7e9b74c 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/CircleCenterAccessor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/CircleCenterAccessor.java
@@ -26,7 +26,6 @@
import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AMutablePoint;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.APoint;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
@@ -71,10 +70,6 @@
private final DataOutput out = resultStorage.getDataOutput();
private final IPointable argPtr = new VoidPointable();
private final IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
-
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final AMutablePoint aPoint = new AMutablePoint(0, 0);
@SuppressWarnings("unchecked")
private final ISerializerDeserializer<APoint> pointSerde = AqlSerializerDeserializerProvider.INSTANCE
@@ -97,8 +92,6 @@
+ ACircleSerializerDeserializer.getCenterPointCoordinateOffset(Coordinate.Y));
aPoint.setValue(cX, cY);
pointSerde.serialize(aPoint, out);
- } else if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException("get-center does not support the type: "
+ bytes[startOffset] + " It is only implemented for CIRCLE.");
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/CircleRadiusAccessor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/CircleRadiusAccessor.java
index 9771eaf..9ed2802 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/CircleRadiusAccessor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/CircleRadiusAccessor.java
@@ -26,7 +26,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ADouble;
import org.apache.asterix.om.base.AMutableDouble;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -69,10 +68,6 @@
private final DataOutput out = resultStorage.getDataOutput();
private final IPointable argPtr = new VoidPointable();
private final IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
-
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final AMutableDouble aDouble = new AMutableDouble(0);
@SuppressWarnings("unchecked")
private final ISerializerDeserializer<ADouble> doubleSerde = AqlSerializerDeserializerProvider.INSTANCE
@@ -92,8 +87,6 @@
startOffset + ACircleSerializerDeserializer.getRadiusOffset());
aDouble.setValue(radius);
doubleSerde.serialize(aDouble, out);
- } else if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException("get-radius does not support the type: "
+ bytes[startOffset] + " It is only implemented for CIRCLE.");
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/LineRectanglePolygonAccessor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/LineRectanglePolygonAccessor.java
index 2439082..e5f74c4 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/LineRectanglePolygonAccessor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/LineRectanglePolygonAccessor.java
@@ -30,7 +30,6 @@
import org.apache.asterix.dataflow.data.nontagged.serde.ARectangleSerializerDeserializer;
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AMutablePoint;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.APoint;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
@@ -80,10 +79,6 @@
private final OrderedListBuilder listBuilder = new OrderedListBuilder();
private final ArrayBackedValueStorage inputVal = new ArrayBackedValueStorage();
private final AOrderedListType pointListType = new AOrderedListType(BuiltinType.APOINT, null);
-
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final AMutablePoint aPoint = new AMutablePoint(0, 0);
@SuppressWarnings("unchecked")
private final ISerializerDeserializer<APoint> pointSerde = AqlSerializerDeserializerProvider.INSTANCE
@@ -157,8 +152,6 @@
listBuilder.addItem(inputVal);
}
listBuilder.write(out, true);
- } else if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException(
"get-points does not support the type: " + bytes[startOffset]
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/PointXCoordinateAccessor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/PointXCoordinateAccessor.java
index cf00b12..878747b 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/PointXCoordinateAccessor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/PointXCoordinateAccessor.java
@@ -27,7 +27,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ADouble;
import org.apache.asterix.om.base.AMutableDouble;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -70,10 +69,6 @@
private final DataOutput out = resultStorage.getDataOutput();
private final IPointable argPtr = new VoidPointable();
private final IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
-
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final AMutableDouble aDouble = new AMutableDouble(0);
@SuppressWarnings("unchecked")
private final ISerializerDeserializer<ADouble> doubleSerde = AqlSerializerDeserializerProvider.INSTANCE
@@ -93,8 +88,6 @@
startOffset + APointSerializerDeserializer.getCoordinateOffset(Coordinate.X));
aDouble.setValue(x);
doubleSerde.serialize(aDouble, out);
- } else if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException("get-x does not support the type: " + bytes[startOffset]
+ " It is only implemented for POINT.");
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/PointYCoordinateAccessor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/PointYCoordinateAccessor.java
index c36a869..99e396c 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/PointYCoordinateAccessor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/PointYCoordinateAccessor.java
@@ -27,7 +27,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ADouble;
import org.apache.asterix.om.base.AMutableDouble;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -73,10 +72,6 @@
private final DataOutput out = resultStorage.getDataOutput();
private final IPointable argPtr = new VoidPointable();
private final IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
-
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final AMutableDouble aDouble = new AMutableDouble(0);
@SuppressWarnings("unchecked")
private final ISerializerDeserializer<ADouble> doubleSerde = AqlSerializerDeserializerProvider.INSTANCE
@@ -96,8 +91,6 @@
startOffset + APointSerializerDeserializer.getCoordinateOffset(Coordinate.Y));
aDouble.setValue(y);
doubleSerde.serialize(aDouble, out);
- } else if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException("get-y does not support the type: " + bytes[startOffset]
+ " It is only implemented for POINT.");
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalDayAccessor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalDayAccessor.java
index 1dcb6c9..3732954 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalDayAccessor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalDayAccessor.java
@@ -28,7 +28,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AInt64;
import org.apache.asterix.om.base.AMutableInt64;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
@@ -84,9 +83,6 @@
private final ISerializerDeserializer<AInt64> intSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT64);
private final AMutableInt64 aMutableInt64 = new AMutableInt64(0);
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
@@ -117,10 +113,6 @@
* GregorianCalendarSystem.CHRONON_OF_DAY;
} else if (bytes[startOffset] == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
chrononTimeInMs = AInt64SerializerDeserializer.getLong(bytes, startOffset + 1);
- } else if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
} else {
throw new AlgebricksException("Inapplicable input type: " + bytes[startOffset]);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalHourAccessor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalHourAccessor.java
index 969dfe9..dc10d71 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalHourAccessor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalHourAccessor.java
@@ -28,7 +28,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AInt64;
import org.apache.asterix.om.base.AMutableInt64;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
@@ -85,9 +84,6 @@
private final ISerializerDeserializer<AInt64> intSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT64);
private final AMutableInt64 aMutableInt64 = new AMutableInt64(0);
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
@@ -117,10 +113,6 @@
chrononTimeInMs = AInt32SerializerDeserializer.getInt(bytes, startOffset + 1);
} else if (bytes[startOffset] == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
chrononTimeInMs = AInt64SerializerDeserializer.getLong(bytes, startOffset + 1);
- } else if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
} else {
throw new AlgebricksException("Inapplicable input type: " + bytes[startOffset]);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalEndAccessor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalEndAccessor.java
index d8525dd..54ad490 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalEndAccessor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalEndAccessor.java
@@ -28,7 +28,6 @@
import org.apache.asterix.om.base.AMutableDate;
import org.apache.asterix.om.base.AMutableDateTime;
import org.apache.asterix.om.base.AMutableTime;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.ATime;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
@@ -88,9 +87,6 @@
private final ISerializerDeserializer<ATime> timeSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ATIME);
private final AMutableTime aTime = new AMutableTime(0);
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
@@ -100,11 +96,7 @@
resultStorage.reset();
try {
- if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- } else if (bytes[startOffset] == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
+ if (bytes[startOffset] == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
byte timeType = AIntervalSerializerDeserializer.getIntervalTimeType(bytes,
startOffset + 1);
long endTime = AIntervalSerializerDeserializer.getIntervalEnd(bytes, startOffset + 1);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalEndDateAccessor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalEndDateAccessor.java
index 3a9aa5a..ae7b7f1 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalEndDateAccessor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalEndDateAccessor.java
@@ -25,7 +25,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ADate;
import org.apache.asterix.om.base.AMutableDate;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -76,10 +75,6 @@
.getSerializerDeserializer(BuiltinType.ADATE);
private final AMutableDate aDate = new AMutableDate(0);
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
-
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
eval.evaluate(tuple, argPtr);
@@ -88,11 +83,7 @@
resultStorage.reset();
try {
- if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- } else if (bytes[startOffset] == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
+ if (bytes[startOffset] == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
byte timeType = AIntervalSerializerDeserializer.getIntervalTimeType(bytes,
startOffset + 1);
long endTime = AIntervalSerializerDeserializer.getIntervalEnd(bytes, startOffset + 1);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalEndDatetimeAccessor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalEndDatetimeAccessor.java
index 925d88d..0c28a6d 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalEndDatetimeAccessor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalEndDatetimeAccessor.java
@@ -25,7 +25,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ADateTime;
import org.apache.asterix.om.base.AMutableDateTime;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -77,9 +76,6 @@
private final ISerializerDeserializer<ADateTime> datetimeSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADATETIME);
private final AMutableDateTime aDateTime = new AMutableDateTime(0);
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
@@ -89,11 +85,7 @@
resultStorage.reset();
try {
- if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- } else if (bytes[startOffset] == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
+ if (bytes[startOffset] == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
byte timeType = AIntervalSerializerDeserializer.getIntervalTimeType(bytes,
startOffset + 1);
long endTime = AIntervalSerializerDeserializer.getIntervalEnd(bytes, startOffset + 1);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalEndTimeAccessor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalEndTimeAccessor.java
index a393846..1008d9b 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalEndTimeAccessor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalEndTimeAccessor.java
@@ -24,7 +24,6 @@
import org.apache.asterix.dataflow.data.nontagged.serde.AIntervalSerializerDeserializer;
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AMutableTime;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.ATime;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
@@ -75,9 +74,6 @@
private final ISerializerDeserializer<ATime> timeSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ATIME);
private final AMutableTime aTime = new AMutableTime(0);
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
@@ -87,11 +83,7 @@
resultStorage.reset();
try {
- if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- } else if (bytes[startOffset] == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
+ if (bytes[startOffset] == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
byte timeType = AIntervalSerializerDeserializer.getIntervalTimeType(bytes,
startOffset + 1);
long endTime = AIntervalSerializerDeserializer.getIntervalEnd(bytes, startOffset + 1);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartAccessor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartAccessor.java
index ef391b2..7ab7f27 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartAccessor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartAccessor.java
@@ -28,7 +28,6 @@
import org.apache.asterix.om.base.AMutableDate;
import org.apache.asterix.om.base.AMutableDateTime;
import org.apache.asterix.om.base.AMutableTime;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.ATime;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
@@ -87,9 +86,6 @@
private final ISerializerDeserializer<ATime> timeSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ATIME);
private final AMutableTime aTime = new AMutableTime(0);
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
@@ -99,11 +95,7 @@
resultStorage.reset();
try {
- if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- } else if (bytes[startOffset] == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
+ if (bytes[startOffset] == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
byte timeType = AIntervalSerializerDeserializer.getIntervalTimeType(bytes,
startOffset + 1);
long startTime = AIntervalSerializerDeserializer.getIntervalStart(bytes,
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartDateAccessor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartDateAccessor.java
index e2d8883..35b17a2 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartDateAccessor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartDateAccessor.java
@@ -25,7 +25,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ADate;
import org.apache.asterix.om.base.AMutableDate;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -75,9 +74,6 @@
private final ISerializerDeserializer<ADate> dateSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADATE);
private final AMutableDate aDate = new AMutableDate(0);
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
@@ -87,11 +83,7 @@
resultStorage.reset();
try {
- if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- } else if (bytes[startOffset] == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
+ if (bytes[startOffset] == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
byte timeType = AIntervalSerializerDeserializer.getIntervalTimeType(bytes,
startOffset + 1);
long startTime = AIntervalSerializerDeserializer.getIntervalStart(bytes,
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartDatetimeAccessor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartDatetimeAccessor.java
index b3a89c1..7a1376b 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartDatetimeAccessor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartDatetimeAccessor.java
@@ -25,7 +25,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ADateTime;
import org.apache.asterix.om.base.AMutableDateTime;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -75,9 +74,6 @@
private final ISerializerDeserializer<ADateTime> datetimeSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADATETIME);
private final AMutableDateTime aDateTime = new AMutableDateTime(0);
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
@@ -87,11 +83,7 @@
resultStorage.reset();
try {
- if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- } else if (bytes[startOffset] == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
+ if (bytes[startOffset] == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
byte timeType = AIntervalSerializerDeserializer.getIntervalTimeType(bytes,
startOffset + 1);
long startTime = AIntervalSerializerDeserializer.getIntervalStart(bytes,
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartTimeAccessor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartTimeAccessor.java
index 12ee1f0..ae4fb4d 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartTimeAccessor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalIntervalStartTimeAccessor.java
@@ -24,7 +24,6 @@
import org.apache.asterix.dataflow.data.nontagged.serde.AIntervalSerializerDeserializer;
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AMutableTime;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.ATime;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
@@ -75,9 +74,6 @@
private final ISerializerDeserializer<ATime> timeSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ATIME);
private final AMutableTime aTime = new AMutableTime(0);
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
@@ -87,11 +83,7 @@
resultStorage.reset();
try {
- if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- } else if (bytes[startOffset] == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
+ if (bytes[startOffset] == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
byte timeType = AIntervalSerializerDeserializer.getIntervalTimeType(bytes,
startOffset + 1);
long startTime = AIntervalSerializerDeserializer.getIntervalStart(bytes,
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalMillisecondAccessor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalMillisecondAccessor.java
index a0bef32..453aae0 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalMillisecondAccessor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalMillisecondAccessor.java
@@ -28,7 +28,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AInt64;
import org.apache.asterix.om.base.AMutableInt64;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
@@ -84,9 +83,6 @@
private final ISerializerDeserializer<AInt64> intSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT64);
private final AMutableInt64 aMutableInt64 = new AMutableInt64(0);
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
@@ -116,10 +112,6 @@
chrononTimeInMs = AInt32SerializerDeserializer.getInt(bytes, startOffset + 1);
} else if (bytes[startOffset] == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
chrononTimeInMs = AInt64SerializerDeserializer.getLong(bytes, startOffset + 1);
- } else if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
} else {
throw new AlgebricksException("Inapplicable input type: " + bytes[startOffset]);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalMinuteAccessor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalMinuteAccessor.java
index cdd0f8a..6455c4f 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalMinuteAccessor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalMinuteAccessor.java
@@ -28,7 +28,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AInt64;
import org.apache.asterix.om.base.AMutableInt64;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
@@ -87,9 +86,6 @@
private final ISerializerDeserializer<AInt64> intSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT64);
private final AMutableInt64 aMutableInt64 = new AMutableInt64(0);
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
@@ -119,10 +115,6 @@
chrononTimeInMs = AInt32SerializerDeserializer.getInt(bytes, startOffset + 1);
} else if (bytes[startOffset] == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
chrononTimeInMs = AInt64SerializerDeserializer.getLong(bytes, startOffset + 1);
- } else if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
} else {
throw new AlgebricksException("Inapplicable input type: " + bytes[startOffset]);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalMonthAccessor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalMonthAccessor.java
index 4a27e82..e6fb01f 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalMonthAccessor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalMonthAccessor.java
@@ -28,7 +28,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AInt64;
import org.apache.asterix.om.base.AMutableInt64;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
@@ -84,9 +83,6 @@
private final ISerializerDeserializer<AInt64> intSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT64);
private final AMutableInt64 aMutableInt64 = new AMutableInt64(0);
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
@@ -117,10 +113,6 @@
* GregorianCalendarSystem.CHRONON_OF_DAY;
} else if (bytes[startOffset] == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
chrononTimeInMs = AInt64SerializerDeserializer.getLong(bytes, startOffset + 1);
- } else if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
} else {
throw new AlgebricksException("Inapplicable input type: " + bytes[startOffset]);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalSecondAccessor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalSecondAccessor.java
index 6abe7a39..e14d08d 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalSecondAccessor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalSecondAccessor.java
@@ -28,7 +28,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AInt64;
import org.apache.asterix.om.base.AMutableInt64;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
@@ -84,9 +83,6 @@
private final ISerializerDeserializer<AInt64> intSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT64);
private final AMutableInt64 aMutableInt64 = new AMutableInt64(0);
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
@@ -117,10 +113,6 @@
chrononTimeInMs = AInt32SerializerDeserializer.getInt(bytes, startOffset + 1);
} else if (bytes[startOffset] == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
chrononTimeInMs = AInt64SerializerDeserializer.getLong(bytes, startOffset + 1);
- } else if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
} else {
throw new AlgebricksException("Inapplicable input type: " + bytes[startOffset]);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalYearAccessor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalYearAccessor.java
index ccf54c6..41c123b 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalYearAccessor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/accessors/TemporalYearAccessor.java
@@ -28,7 +28,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AInt64;
import org.apache.asterix.om.base.AMutableInt64;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
@@ -85,9 +84,6 @@
private final ISerializerDeserializer<AInt64> intSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT64);
private final AMutableInt64 aMutableInt64 = new AMutableInt64(0);
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
@@ -119,10 +115,6 @@
* GregorianCalendarSystem.CHRONON_OF_DAY;
} else if (bytes[startOffset] == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
chrononTimeInMs = AInt64SerializerDeserializer.getLong(bytes, startOffset + 1);
- } else if (bytes[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
} else if (bytes[startOffset] == ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
int year;
strExprPtr.set(bytes, startOffset + 1, len - 1);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/AbstractTypeCheckEvaluator.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/AbstractTypeCheckEvaluator.java
new file mode 100644
index 0000000..800afd7
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/AbstractTypeCheckEvaluator.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.evaluators.common;
+
+import java.io.DataOutput;
+
+import org.apache.asterix.dataflow.data.nontagged.serde.AObjectSerializerDeserializer;
+import org.apache.asterix.om.base.ABoolean;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.data.std.api.IPointable;
+import org.apache.hyracks.data.std.primitive.VoidPointable;
+import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public abstract class AbstractTypeCheckEvaluator implements IScalarEvaluator {
+
+ private final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+ private final DataOutput out = resultStorage.getDataOutput();
+ private final IPointable argPtr = new VoidPointable();
+ private final IScalarEvaluator eval;
+ private static final AObjectSerializerDeserializer aObjSerDer = AObjectSerializerDeserializer.INSTANCE;
+
+ public AbstractTypeCheckEvaluator(IScalarEvaluator argEval) {
+ this.eval = argEval;
+ }
+
+ @Override
+ public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+ eval.evaluate(tuple, argPtr);
+ boolean match = isMatch(argPtr.getByteArray()[argPtr.getStartOffset()]);
+ ABoolean res = match ? ABoolean.TRUE : ABoolean.FALSE;
+ try {
+ resultStorage.reset();
+ aObjSerDer.serialize(res, out);
+ result.set(resultStorage);
+ } catch (HyracksDataException e) {
+ throw new AlgebricksException(e);
+ }
+ }
+
+ protected abstract boolean isMatch(byte typeTag);
+
+}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/ClosedRecordConstructorEvalFactory.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/ClosedRecordConstructorEvalFactory.java
index 6ebb684..5a95707 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/ClosedRecordConstructorEvalFactory.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/ClosedRecordConstructorEvalFactory.java
@@ -82,10 +82,13 @@
recBuilder.init();
for (int i = 0; i < evalFields.length; i++) {
evalFields[i].evaluate(tuple, fieldValuePointable);
- if (fieldValuePointable.getByteArray()[fieldValuePointable
- .getStartOffset()] != ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- recBuilder.addField(i, fieldValuePointable);
+ byte[] data = fieldValuePointable.getByteArray();
+ int offset = fieldValuePointable.getStartOffset();
+ if (data[offset] == ATypeTag.SERIALIZED_MISSING_TYPE_TAG) {
+ // Turns MISSING into NULL for a closed field.
+ data[offset] = ATypeTag.SERIALIZED_NULL_TYPE_TAG;
}
+ recBuilder.addField(i, fieldValuePointable);
}
recBuilder.write(out, true);
result.set(resultStorage);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/CreateMBREvalFactory.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/CreateMBREvalFactory.java
index c92daa2..0a4d258 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/CreateMBREvalFactory.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/CreateMBREvalFactory.java
@@ -76,43 +76,58 @@
eval0.evaluate(tuple, inputArg0);
eval1.evaluate(tuple, inputArg1);
eval2.evaluate(tuple, inputArg2);
+ byte[] data0 = inputArg0.getByteArray();
+ byte[] data1 = inputArg1.getByteArray();
+ byte[] data2 = inputArg2.getByteArray();
int startOffset0 = inputArg0.getStartOffset();
int startOffset1 = inputArg1.getStartOffset();
int startOffset2 = inputArg2.getStartOffset();
- resultStorage.reset();
- // type-check: (Point/Line/Polygon/Circle/Rectangle/Null, Int32, Int32)
- if (inputArg1.getByteArray()[startOffset1] != ATypeTag.SERIALIZED_INT32_TYPE_TAG
- || inputArg2.getByteArray()[startOffset2] != ATypeTag.SERIALIZED_INT32_TYPE_TAG) {
- throw new AlgebricksException(
- "Expects Types: (Point/Line/Polygon/Circle/Rectangle/Null, Int32, Int32).");
- }
-
try {
- int dimension = AInt32SerializerDeserializer.getInt(inputArg1.getByteArray(), startOffset1 + 1);
+ if (data0[startOffset0] == ATypeTag.SERIALIZED_MISSING_TYPE_TAG
+ || data1[startOffset1] == ATypeTag.SERIALIZED_MISSING_TYPE_TAG
+ || data2[startOffset2] == ATypeTag.SERIALIZED_MISSING_TYPE_TAG) {
+ out.writeByte(ATypeTag.SERIALIZED_MISSING_TYPE_TAG);
+ result.set(resultStorage);
+ return;
+ }
+ if (data0[startOffset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
+ || data1[startOffset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
+ || data2[startOffset2] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
+ out.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
+ result.set(resultStorage);
+ return;
+ }
+
+ resultStorage.reset();
+ // type-check: (Point/Line/Polygon/Circle/Rectangle/Null, Int32, Int32)
+ if (data1[startOffset1] != ATypeTag.SERIALIZED_INT32_TYPE_TAG
+ || data2[startOffset2] != ATypeTag.SERIALIZED_INT32_TYPE_TAG) {
+ throw new AlgebricksException(
+ "Expects Types: (Point/Line/Polygon/Circle/Rectangle/Null, Int32, Int32).");
+ }
+
+ int dimension = AInt32SerializerDeserializer.getInt(data1, startOffset1 + 1);
int coordinate = AInt32SerializerDeserializer.getInt(inputArg2.getByteArray(), startOffset2 + 1);
double value;
if (dimension == 2) {
- ATypeTag tag = EnumDeserializer.ATYPETAGDESERIALIZER
- .deserialize(inputArg0.getByteArray()[startOffset0]);
+ ATypeTag tag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(data0[startOffset0]);
switch (tag) {
case POINT:
switch (coordinate) {
case 0: // 0 is for min x, 1 is for min y, 2
- // for
+ // for
// max x, and 3 for max y
case 2: {
- double x = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
- startOffset0 + APointSerializerDeserializer
- .getCoordinateOffset(Coordinate.X));
+ double x = ADoubleSerializerDeserializer.getDouble(data0, startOffset0
+ + APointSerializerDeserializer.getCoordinateOffset(Coordinate.X));
value = x;
}
break;
case 1:
case 3: {
- double y = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
- startOffset0 + APointSerializerDeserializer
- .getCoordinateOffset(Coordinate.Y));
+ double y = ADoubleSerializerDeserializer.getDouble(data0, startOffset0
+ + APointSerializerDeserializer.getCoordinateOffset(Coordinate.Y));
value = y;
}
@@ -128,10 +143,10 @@
switch (coordinate) {
case 0: {
value = Double.MAX_VALUE;
- double startX = ADoubleSerializerDeserializer.getDouble(
- inputArg0.getByteArray(), startOffset0 + ALineSerializerDeserializer
+ double startX = ADoubleSerializerDeserializer.getDouble(data0,
+ startOffset0 + ALineSerializerDeserializer
.getStartPointCoordinateOffset(Coordinate.X));
- double endX = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ double endX = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ALineSerializerDeserializer
.getEndPointCoordinateOffset(Coordinate.X));
@@ -140,10 +155,10 @@
break;
case 1: {
value = Double.MAX_VALUE;
- double startY = ADoubleSerializerDeserializer.getDouble(
- inputArg0.getByteArray(), startOffset0 + ALineSerializerDeserializer
+ double startY = ADoubleSerializerDeserializer.getDouble(data0,
+ startOffset0 + ALineSerializerDeserializer
.getStartPointCoordinateOffset(Coordinate.Y));
- double endY = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ double endY = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ALineSerializerDeserializer
.getEndPointCoordinateOffset(Coordinate.Y));
@@ -152,10 +167,10 @@
break;
case 2: {
value = Double.MIN_VALUE;
- double startX = ADoubleSerializerDeserializer.getDouble(
- inputArg0.getByteArray(), startOffset0 + ALineSerializerDeserializer
+ double startX = ADoubleSerializerDeserializer.getDouble(data0,
+ startOffset0 + ALineSerializerDeserializer
.getStartPointCoordinateOffset(Coordinate.X));
- double endX = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ double endX = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ALineSerializerDeserializer
.getEndPointCoordinateOffset(Coordinate.X));
@@ -164,10 +179,10 @@
break;
case 3: {
value = Double.MIN_VALUE;
- double startY = ADoubleSerializerDeserializer.getDouble(
- inputArg0.getByteArray(), startOffset0 + ALineSerializerDeserializer
+ double startY = ADoubleSerializerDeserializer.getDouble(data0,
+ startOffset0 + ALineSerializerDeserializer
.getStartPointCoordinateOffset(Coordinate.Y));
- double endY = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ double endY = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ALineSerializerDeserializer
.getEndPointCoordinateOffset(Coordinate.Y));
@@ -181,13 +196,13 @@
}
break;
case POLYGON:
- int numOfPoints = AInt16SerializerDeserializer.getShort(inputArg0.getByteArray(),
+ int numOfPoints = AInt16SerializerDeserializer.getShort(data0,
startOffset0 + APolygonSerializerDeserializer.getNumberOfPointsOffset());
switch (coordinate) {
case 0: {
value = Double.MAX_VALUE;
for (int i = 0; i < numOfPoints; i++) {
- double x = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ double x = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + APolygonSerializerDeserializer.getCoordinateOffset(i,
Coordinate.X));
value = Math.min(x, value);
@@ -197,7 +212,7 @@
case 1: {
value = Double.MAX_VALUE;
for (int i = 0; i < numOfPoints; i++) {
- double y = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ double y = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + APolygonSerializerDeserializer.getCoordinateOffset(i,
Coordinate.Y));
value = Math.min(y, value);
@@ -207,7 +222,7 @@
case 2: {
value = Double.MIN_VALUE;
for (int i = 0; i < numOfPoints; i++) {
- double x = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ double x = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + APolygonSerializerDeserializer.getCoordinateOffset(i,
Coordinate.X));
value = Math.max(x, value);
@@ -217,7 +232,7 @@
case 3: {
value = Double.MIN_VALUE;
for (int i = 0; i < numOfPoints; i++) {
- double y = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ double y = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + APolygonSerializerDeserializer.getCoordinateOffset(i,
Coordinate.Y));
value = Math.max(y, value);
@@ -233,43 +248,39 @@
case CIRCLE:
switch (coordinate) {
case 0: {
- double x = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ double x = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ACircleSerializerDeserializer
.getCenterPointCoordinateOffset(Coordinate.X));
- double radius = ADoubleSerializerDeserializer.getDouble(
- inputArg0.getByteArray(),
+ double radius = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ACircleSerializerDeserializer.getRadiusOffset());
value = x - radius;
}
break;
case 1: {
- double y = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ double y = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ACircleSerializerDeserializer
.getCenterPointCoordinateOffset(Coordinate.Y));
- double radius = ADoubleSerializerDeserializer.getDouble(
- inputArg0.getByteArray(),
+ double radius = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ACircleSerializerDeserializer.getRadiusOffset());
value = y - radius;
}
break;
case 2: {
- double x = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ double x = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ACircleSerializerDeserializer
.getCenterPointCoordinateOffset(Coordinate.X));
- double radius = ADoubleSerializerDeserializer.getDouble(
- inputArg0.getByteArray(),
+ double radius = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ACircleSerializerDeserializer.getRadiusOffset());
value = x + radius;
}
break;
case 3: {
- double y = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ double y = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ACircleSerializerDeserializer
.getCenterPointCoordinateOffset(Coordinate.Y));
- double radius = ADoubleSerializerDeserializer.getDouble(
- inputArg0.getByteArray(),
+ double radius = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ACircleSerializerDeserializer.getRadiusOffset());
value = y + radius;
@@ -285,25 +296,25 @@
value = Double.MAX_VALUE;
switch (coordinate) {
case 0: {
- value = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ value = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ARectangleSerializerDeserializer
.getBottomLeftCoordinateOffset(Coordinate.X));
}
break;
case 1: {
- value = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ value = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ARectangleSerializerDeserializer
.getBottomLeftCoordinateOffset(Coordinate.Y));
}
break;
case 2: {
- value = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ value = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ARectangleSerializerDeserializer
.getUpperRightCoordinateOffset(Coordinate.X));
}
break;
case 3: {
- value = ADoubleSerializerDeserializer.getDouble(inputArg0.getByteArray(),
+ value = ADoubleSerializerDeserializer.getDouble(data0,
startOffset0 + ARectangleSerializerDeserializer
.getUpperRightCoordinateOffset(Coordinate.Y));
}
@@ -314,11 +325,6 @@
}
}
break;
- case NULL: {
- out.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
- result.set(resultStorage);
- return;
- }
default:
throw new NotImplementedException(
"create-mbr is only implemented for POINT, LINE, POLYGON, CIRCLE and RECTANGLE. Encountered type: "
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceCheckEvaluator.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceCheckEvaluator.java
index 915ff53..3dca584 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceCheckEvaluator.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceCheckEvaluator.java
@@ -27,6 +27,7 @@
import org.apache.asterix.om.types.AOrderedListType;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.BuiltinType;
+import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
@@ -59,14 +60,29 @@
}
@Override
- protected void runArgEvals(IFrameTupleReference tuple) throws AlgebricksException {
- super.runArgEvals(tuple);
+ public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+ resultStorage.reset();
+
+ firstStringEval.evaluate(tuple, argPtr1);
+ firstTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(argPtr1.getByteArray()[argPtr1.getStartOffset()]);
+ secondStringEval.evaluate(tuple, argPtr2);
+ secondTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(argPtr2.getByteArray()[argPtr2.getStartOffset()]);
edThreshEval.evaluate(tuple, argPtrThreshold);
+
+ if (!checkArgTypes(firstTypeTag, secondTypeTag)) {
+ result.set(resultStorage);
+ return;
+ }
try {
edThresh = ATypeHierarchy.getIntegerValue(argPtrThreshold.getByteArray(), argPtrThreshold.getStartOffset());
- } catch (HyracksDataException e) {
+ editDistance = computeResult(argPtr1, argPtr2, firstTypeTag);
+ writeResult(editDistance);
+ } catch (IOException e) {
throw new AlgebricksException(e);
}
+ result.set(resultStorage);
}
@Override
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceEvaluator.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceEvaluator.java
index f6345d6..d2adc1c 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceEvaluator.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/EditDistanceEvaluator.java
@@ -25,7 +25,6 @@
import org.apache.asterix.fuzzyjoin.similarity.SimilarityMetricEditDistance;
import org.apache.asterix.om.base.AInt64;
import org.apache.asterix.om.base.AMutableInt64;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
@@ -59,9 +58,6 @@
@SuppressWarnings("unchecked")
protected final ISerializerDeserializer<AInt64> int64Serde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT64);
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
protected ATypeTag itemTypeTag;
protected ATypeTag firstTypeTag;
@@ -76,7 +72,14 @@
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
resultStorage.reset();
- runArgEvals(tuple);
+
+ firstStringEval.evaluate(tuple, argPtr1);
+ firstTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(argPtr1.getByteArray()[argPtr1.getStartOffset()]);
+ secondStringEval.evaluate(tuple, argPtr2);
+ secondTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(argPtr2.getByteArray()[argPtr2.getStartOffset()]);
+
if (!checkArgTypes(firstTypeTag, secondTypeTag)) {
result.set(resultStorage);
return;
@@ -96,15 +99,6 @@
result.set(resultStorage);
}
- protected void runArgEvals(IFrameTupleReference tuple) throws AlgebricksException {
- firstStringEval.evaluate(tuple, argPtr1);
- firstTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
- .deserialize(argPtr1.getByteArray()[argPtr1.getStartOffset()]);
- secondStringEval.evaluate(tuple, argPtr2);
- secondTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
- .deserialize(argPtr2.getByteArray()[argPtr2.getStartOffset()]);
- }
-
protected int computeResult(IPointable left, IPointable right, ATypeTag argType)
throws AlgebricksException, HyracksDataException {
byte[] leftBytes = left.getByteArray();
@@ -136,16 +130,6 @@
}
protected boolean checkArgTypes(ATypeTag typeTag1, ATypeTag typeTag2) throws AlgebricksException {
- // edit distance between null and anything else is undefined
- if (typeTag1 == ATypeTag.NULL || typeTag2 == ATypeTag.NULL) {
- try {
- nullSerde.serialize(ANull.NULL, out);
- } catch (IOException e) {
- throw new AlgebricksException(e);
- }
- return false;
- }
-
if (typeTag1 != typeTag2) {
throw new AlgebricksException(
"Incompatible argument types given in edit distance: " + typeTag1 + " " + typeTag2);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardCheckEvaluator.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardCheckEvaluator.java
index b2eca6d..f31b289 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardCheckEvaluator.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardCheckEvaluator.java
@@ -26,6 +26,7 @@
import org.apache.asterix.om.base.ABoolean;
import org.apache.asterix.om.types.AOrderedListType;
import org.apache.asterix.om.types.BuiltinType;
+import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.asterix.runtime.evaluators.functions.BinaryHashMap.BinaryEntry;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
@@ -61,11 +62,41 @@
}
@Override
- protected void runArgEvals(IFrameTupleReference tuple) throws AlgebricksException {
- super.runArgEvals(tuple);
+ public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+ resultStorage.reset();
+
+ firstOrdListEval.evaluate(tuple, argPtr1);
+ secondOrdListEval.evaluate(tuple, argPtr2);
jaccThreshEval.evaluate(tuple, jaccThreshPointable);
- jaccThresh = (float) AFloatSerializerDeserializer.getFloat(jaccThreshPointable.getByteArray(),
+
+ firstTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(argPtr1.getByteArray()[argPtr1.getStartOffset()]);
+ secondTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(argPtr2.getByteArray()[argPtr2.getStartOffset()]);
+
+ firstItemTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(argPtr1.getByteArray()[argPtr1.getStartOffset() + 1]);
+ secondItemTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(argPtr2.getByteArray()[argPtr2.getStartOffset() + 1]);
+
+ jaccThresh = AFloatSerializerDeserializer.getFloat(jaccThreshPointable.getByteArray(),
jaccThreshPointable.getStartOffset() + TYPE_INDICATOR_SIZE);
+
+ if (!checkArgTypes(firstTypeTag, secondTypeTag)) {
+ result.set(resultStorage);
+ return;
+ }
+ if (prepareLists(argPtr1, argPtr2, firstTypeTag)) {
+ jaccSim = computeResult();
+ } else {
+ jaccSim = 0.0f;
+ }
+ try {
+ writeResult(jaccSim);
+ } catch (IOException e) {
+ throw new AlgebricksException(e);
+ }
+ result.set(resultStorage);
}
@Override
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardEvaluator.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardEvaluator.java
index 92946c6..01c4b6b 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardEvaluator.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/common/SimilarityJaccardEvaluator.java
@@ -100,7 +100,20 @@
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
resultStorage.reset();
- runArgEvals(tuple);
+
+ firstOrdListEval.evaluate(tuple, argPtr1);
+ secondOrdListEval.evaluate(tuple, argPtr2);
+
+ firstTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(argPtr1.getByteArray()[argPtr1.getStartOffset()]);
+ secondTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(argPtr2.getByteArray()[argPtr2.getStartOffset()]);
+
+ firstItemTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(argPtr1.getByteArray()[argPtr1.getStartOffset() + 1]);
+ secondItemTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(argPtr2.getByteArray()[argPtr2.getStartOffset() + 1]);
+
if (!checkArgTypes(firstTypeTag, secondTypeTag)) {
result.set(resultStorage);
return;
@@ -118,28 +131,6 @@
result.set(resultStorage);
}
- protected void runArgEvals(IFrameTupleReference tuple) throws AlgebricksException {
- firstOrdListEval.evaluate(tuple, argPtr1);
- secondOrdListEval.evaluate(tuple, argPtr2);
-
- firstTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
- .deserialize(argPtr1.getByteArray()[argPtr1.getStartOffset()]);
- secondTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
- .deserialize(argPtr2.getByteArray()[argPtr2.getStartOffset()]);
-
- if (firstTypeTag == ATypeTag.NULL) {
- return;
- }
- if (secondTypeTag == ATypeTag.NULL) {
- return;
- }
-
- firstItemTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
- .deserialize(argPtr1.getByteArray()[argPtr1.getStartOffset() + 1]);
- secondItemTypeTag = EnumDeserializer.ATYPETAGDESERIALIZER
- .deserialize(argPtr2.getByteArray()[argPtr2.getStartOffset() + 1]);
- }
-
protected boolean prepareLists(IPointable left, IPointable right, ATypeTag argType) throws AlgebricksException {
try {
firstListIter.reset(left.getByteArray(), left.getStartOffset());
@@ -249,15 +240,6 @@
}
protected boolean checkArgTypes(ATypeTag typeTag1, ATypeTag typeTag2) throws AlgebricksException {
- // Jaccard between null and anything else is 0
- if (typeTag1 == ATypeTag.NULL || typeTag2 == ATypeTag.NULL) {
- try {
- writeResult(0.0f);
- } catch (IOException e) {
- throw new AlgebricksException(e);
- }
- return false;
- }
switch (typeTag1) {
case ORDEREDLIST: {
firstListIter = fstOrdListIter;
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/AbstractComparisonEvaluator.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/AbstractComparisonEvaluator.java
index 30f6562..ebf255f 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/AbstractComparisonEvaluator.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/AbstractComparisonEvaluator.java
@@ -20,18 +20,16 @@
import java.io.DataOutput;
-import org.apache.asterix.dataflow.data.nontagged.comparators.ABinaryComparator;
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ABoolean;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
+import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.BinaryComparatorConstant.ComparableResultCode;
import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.api.IPointable;
@@ -42,13 +40,6 @@
public abstract class AbstractComparisonEvaluator implements IScalarEvaluator {
- protected enum ComparisonResult {
- LESS_THAN,
- EQUAL,
- GREATER_THAN,
- UNKNOWN
- }
-
protected ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
protected DataOutput out = resultStorage.getDataOutput();
protected TaggedValuePointable argLeft = (TaggedValuePointable) TaggedValuePointable.FACTORY.createPointable();
@@ -62,9 +53,6 @@
@SuppressWarnings("unchecked")
protected ISerializerDeserializer<ABoolean> serde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ABOOLEAN);
- @SuppressWarnings("unchecked")
- protected ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
public AbstractComparisonEvaluator(IScalarEvaluatorFactory evalLeftFactory,
IScalarEvaluatorFactory evalRightFactory, IHyracksTaskContext context) throws AlgebricksException {
@@ -75,7 +63,12 @@
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
resultStorage.reset();
- evalInputs(tuple);
+
+ // Evaluates input args.
+ evalLeft.evaluate(tuple, argLeft);
+ evalRight.evaluate(tuple, argRight);
+ argLeft.getValue(outLeft);
+ argRight.getValue(outRight);
// checks whether we can apply >, >=, <, and <= to the given type since
// these operations cannot be defined for certain types.
@@ -83,54 +76,27 @@
checkTotallyOrderable();
}
+ ABoolean b;
// Checks whether two types are comparable
- switch (comparabilityCheck()) {
- case UNKNOWN:
- // result:UNKNOWN - NULL value found
- try {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
- }
- case FALSE:
- // result:FALSE - two types cannot be compared. Thus we return FALSE since this is equality comparison
- ABoolean b = ABoolean.FALSE;
- try {
- serde.serialize(b, out);
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
- }
- break;
- case TRUE:
- // Two types can be compared
- ComparisonResult r = compareResults();
- ABoolean b1 = getComparisonResult(r) ? ABoolean.TRUE : ABoolean.FALSE;
- try {
- serde.serialize(b1, out);
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
- }
- break;
- default:
- throw new AlgebricksException(
- "Comparison cannot be processed. The return code from ComparabilityCheck is not correct.");
+ if (comparabilityCheck()) {
+ // Two types can be compared
+ int r = compareResults();
+ b = getComparisonResult(r) ? ABoolean.TRUE : ABoolean.FALSE;
+ } else {
+ // result:FALSE - two types cannot be compared. Thus we return FALSE since this is equality comparison
+ b = ABoolean.FALSE;
+ }
+ try {
+ serde.serialize(b, out);
+ } catch (HyracksDataException e) {
+ throw new AlgebricksException(e);
}
result.set(resultStorage);
}
protected abstract boolean isTotallyOrderable();
- protected abstract boolean getComparisonResult(ComparisonResult r);
-
- protected void evalInputs(IFrameTupleReference tuple) throws AlgebricksException {
- evalLeft.evaluate(tuple, argLeft);
- evalRight.evaluate(tuple, argRight);
-
- argLeft.getValue(outLeft);
- argRight.getValue(outRight);
- }
+ protected abstract boolean getComparisonResult(int r);
// checks whether we can apply >, >=, <, and <= operations to the given type since
// these operations can not be defined for certain types.
@@ -155,46 +121,19 @@
}
// checks whether two types are comparable
- protected ComparableResultCode comparabilityCheck() {
- // just check TypeTags
- return ABinaryComparator.isComparable(argLeft.getTag(), argRight.getTag());
+ protected boolean comparabilityCheck() {
+ // Checks whether two types are comparable or not
+ ATypeTag typeTag1 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argLeft.getTag());
+ ATypeTag typeTag2 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argRight.getTag());
+
+ // Are two types compatible, meaning that they can be compared? (e.g., compare between numeric types
+ return ATypeHierarchy.isCompatible(typeTag1, typeTag2);
}
- protected ComparisonResult compareResults() throws AlgebricksException {
- boolean isLeftNull = false;
- boolean isRightNull = false;
- ATypeTag typeTag1 = null;
- ATypeTag typeTag2 = null;
-
- if (outLeft.getLength() == 0) {
- isLeftNull = true;
- } else {
- typeTag1 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argLeft.getTag());
- if (typeTag1 == ATypeTag.NULL) {
- isLeftNull = true;
- }
- }
- if (outRight.getLength() == 0) {
- isRightNull = true;
- } else {
- typeTag2 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argRight.getTag());
- if (typeTag2 == ATypeTag.NULL) {
- isRightNull = true;
- }
- }
-
- if (isLeftNull || isRightNull) {
- return ComparisonResult.UNKNOWN;
- }
-
- int result = ch.compare(typeTag1, typeTag2, outLeft, outRight);
- if (result == 0) {
- return ComparisonResult.EQUAL;
- } else if (result < 0) {
- return ComparisonResult.LESS_THAN;
- } else {
- return ComparisonResult.GREATER_THAN;
- }
+ protected int compareResults() throws AlgebricksException {
+ int result = ch.compare(EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argLeft.getTag()),
+ EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argRight.getTag()), outLeft, outRight);
+ return result;
}
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/ComparisonEvalFactory.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/ComparisonEvalFactory.java
deleted file mode 100644
index 649f262..0000000
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/ComparisonEvalFactory.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.runtime.evaluators.comparisons;
-
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.functions.AlgebricksBuiltinFunctions.ComparisonKind;
-import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
-import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
-import org.apache.hyracks.api.context.IHyracksTaskContext;
-
-public class ComparisonEvalFactory implements IScalarEvaluatorFactory {
- private static final long serialVersionUID = 1L;
-
- private IScalarEvaluatorFactory evalLeftFactory;
- private IScalarEvaluatorFactory evalRightFactory;
- private ComparisonKind comparisonKind;
-
- public ComparisonEvalFactory(IScalarEvaluatorFactory evalLeftFactory, IScalarEvaluatorFactory evalRightFactory,
- ComparisonKind comparisonKind) {
- this.evalLeftFactory = evalLeftFactory;
- this.evalRightFactory = evalRightFactory;
- this.comparisonKind = comparisonKind;
- }
-
- @Override
- public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
- switch (comparisonKind) {
- // Should we do any normalization?
- case EQ: {
- return new EqualityComparisonEvaluator(evalLeftFactory, evalRightFactory, ctx);
- }
- case GE: {
- return new GreaterThanOrEqualComparisonEvaluator(evalLeftFactory, evalRightFactory, ctx);
- }
- case GT: {
- return new GreaterThanComparisonEvaluator(evalLeftFactory, evalRightFactory, ctx);
- }
- case LE: {
- return new LessThanOrEqualComparisonEvaluator(evalLeftFactory, evalRightFactory, ctx);
- }
- case LT: {
- return new LessThanComparisonEvaluator(evalLeftFactory, evalRightFactory, ctx);
- }
- case NEQ: {
- return new InequalityComparisonEvaluator(evalLeftFactory, evalRightFactory, ctx);
- }
- default: {
- throw new IllegalStateException();
- }
- }
- }
-
- static class EqualityComparisonEvaluator extends AbstractComparisonEvaluator {
- public EqualityComparisonEvaluator(IScalarEvaluatorFactory evalLeftFactory,
- IScalarEvaluatorFactory evalRightFactory, IHyracksTaskContext context) throws AlgebricksException {
- super(evalLeftFactory, evalRightFactory, context);
- }
-
- @Override
- protected boolean getComparisonResult(ComparisonResult r) {
- return (r == ComparisonResult.EQUAL);
- }
-
- @Override
- protected boolean isTotallyOrderable() {
- return false;
- }
- }
-
- static class InequalityComparisonEvaluator extends AbstractComparisonEvaluator {
- public InequalityComparisonEvaluator(IScalarEvaluatorFactory evalLeftFactory,
- IScalarEvaluatorFactory evalRightFactory, IHyracksTaskContext context) throws AlgebricksException {
- super(evalLeftFactory, evalRightFactory, context);
- }
-
- @Override
- protected boolean getComparisonResult(ComparisonResult r) {
- return (r != ComparisonResult.EQUAL);
- }
-
- @Override
- protected boolean isTotallyOrderable() {
- return false;
- }
- }
-
- static class GreaterThanOrEqualComparisonEvaluator extends AbstractComparisonEvaluator {
- public GreaterThanOrEqualComparisonEvaluator(IScalarEvaluatorFactory evalLeftFactory,
- IScalarEvaluatorFactory evalRightFactory, IHyracksTaskContext context) throws AlgebricksException {
- super(evalLeftFactory, evalRightFactory, context);
- }
-
- @Override
- protected boolean getComparisonResult(ComparisonResult r) {
- return (r == ComparisonResult.EQUAL || r == ComparisonResult.GREATER_THAN);
- }
-
- @Override
- protected boolean isTotallyOrderable() {
- return true;
- }
- }
-
- static class GreaterThanComparisonEvaluator extends AbstractComparisonEvaluator {
- public GreaterThanComparisonEvaluator(IScalarEvaluatorFactory evalLeftFactory,
- IScalarEvaluatorFactory evalRightFactory, IHyracksTaskContext context) throws AlgebricksException {
- super(evalLeftFactory, evalRightFactory, context);
- }
-
- @Override
- protected boolean getComparisonResult(ComparisonResult r) {
- return (r == ComparisonResult.GREATER_THAN);
- }
-
- @Override
- protected boolean isTotallyOrderable() {
- return true;
- }
- }
-
- static class LessThanOrEqualComparisonEvaluator extends AbstractComparisonEvaluator {
- public LessThanOrEqualComparisonEvaluator(IScalarEvaluatorFactory evalLeftFactory,
- IScalarEvaluatorFactory evalRightFactory, IHyracksTaskContext context) throws AlgebricksException {
- super(evalLeftFactory, evalRightFactory, context);
- }
-
- @Override
- protected boolean getComparisonResult(ComparisonResult r) {
- return (r == ComparisonResult.EQUAL || r == ComparisonResult.LESS_THAN);
- }
-
- @Override
- protected boolean isTotallyOrderable() {
- return true;
- }
- }
-
- static class LessThanComparisonEvaluator extends AbstractComparisonEvaluator {
- public LessThanComparisonEvaluator(IScalarEvaluatorFactory evalLeftFactory,
- IScalarEvaluatorFactory evalRightFactory, IHyracksTaskContext context) throws AlgebricksException {
- super(evalLeftFactory, evalRightFactory, context);
- }
-
- @Override
- protected boolean getComparisonResult(ComparisonResult r) {
- return (r == ComparisonResult.LESS_THAN);
- }
-
- @Override
- protected boolean isTotallyOrderable() {
- return true;
- }
- }
-
-}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/EqualsDescriptor.java
similarity index 69%
copy from asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java
copy to asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/EqualsDescriptor.java
index 0bfa5a8..122c1a2 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/EqualsDescriptor.java
@@ -16,62 +16,55 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.asterix.runtime.evaluators.functions;
+
+package org.apache.asterix.runtime.evaluators.comparisons;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
-import org.apache.asterix.om.types.IAType;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.data.std.api.IPointable;
-import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
-public class EmbedTypeDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
+public class EqualsDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private static final long serialVersionUID = 1L;
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
@Override
public IFunctionDescriptor createFunctionDescriptor() {
- return new EmbedTypeDescriptor();
+ return new EqualsDescriptor();
}
};
- @SuppressWarnings("unused")
- private IAType fieldType;
-
- public void reset(IAType fieldType) {
- this.fieldType = fieldType;
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return AsterixBuiltinFunctions.EQ;
}
@Override
- public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
+ public IScalarEvaluatorFactory createEvaluatorFactory(IScalarEvaluatorFactory[] args) throws AlgebricksException {
return new IScalarEvaluatorFactory() {
-
private static final long serialVersionUID = 1L;
@Override
public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
- // TODO Auto-generated method stub
- return new IScalarEvaluator() {
+ return new AbstractComparisonEvaluator(args[0], args[1], ctx) {
@Override
- public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
- // TODO Auto-generated method stub
+ protected boolean getComparisonResult(int r) {
+ return r == 0;
+ }
+ @Override
+ protected boolean isTotallyOrderable() {
+ return false;
}
};
}
- };
- }
- @Override
- public FunctionIdentifier getIdentifier() {
- return AsterixBuiltinFunctions.EMBED_TYPE;
+ };
}
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/GreaterThanDescriptor.java
similarity index 69%
copy from asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java
copy to asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/GreaterThanDescriptor.java
index 0bfa5a8..1bc731a 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/GreaterThanDescriptor.java
@@ -16,62 +16,55 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.asterix.runtime.evaluators.functions;
+
+package org.apache.asterix.runtime.evaluators.comparisons;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
-import org.apache.asterix.om.types.IAType;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.data.std.api.IPointable;
-import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
-public class EmbedTypeDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
+public class GreaterThanDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private static final long serialVersionUID = 1L;
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
@Override
public IFunctionDescriptor createFunctionDescriptor() {
- return new EmbedTypeDescriptor();
+ return new GreaterThanDescriptor();
}
};
- @SuppressWarnings("unused")
- private IAType fieldType;
-
- public void reset(IAType fieldType) {
- this.fieldType = fieldType;
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return AsterixBuiltinFunctions.GT;
}
@Override
- public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
+ public IScalarEvaluatorFactory createEvaluatorFactory(IScalarEvaluatorFactory[] args) throws AlgebricksException {
return new IScalarEvaluatorFactory() {
-
private static final long serialVersionUID = 1L;
@Override
public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
- // TODO Auto-generated method stub
- return new IScalarEvaluator() {
+ return new AbstractComparisonEvaluator(args[0], args[1], ctx) {
@Override
- public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
- // TODO Auto-generated method stub
+ protected boolean getComparisonResult(int r) {
+ return r > 0;
+ }
+ @Override
+ protected boolean isTotallyOrderable() {
+ return true;
}
};
}
- };
- }
- @Override
- public FunctionIdentifier getIdentifier() {
- return AsterixBuiltinFunctions.EMBED_TYPE;
+ };
}
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/GreaterThanOrEqualsDescriptor.java
similarity index 69%
copy from asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java
copy to asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/GreaterThanOrEqualsDescriptor.java
index 0bfa5a8..b6318ad 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/GreaterThanOrEqualsDescriptor.java
@@ -16,62 +16,55 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.asterix.runtime.evaluators.functions;
+
+package org.apache.asterix.runtime.evaluators.comparisons;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
-import org.apache.asterix.om.types.IAType;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.data.std.api.IPointable;
-import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
-public class EmbedTypeDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
+public class GreaterThanOrEqualsDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private static final long serialVersionUID = 1L;
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
@Override
public IFunctionDescriptor createFunctionDescriptor() {
- return new EmbedTypeDescriptor();
+ return new GreaterThanOrEqualsDescriptor();
}
};
- @SuppressWarnings("unused")
- private IAType fieldType;
-
- public void reset(IAType fieldType) {
- this.fieldType = fieldType;
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return AsterixBuiltinFunctions.GE;
}
@Override
- public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
+ public IScalarEvaluatorFactory createEvaluatorFactory(IScalarEvaluatorFactory[] args) throws AlgebricksException {
return new IScalarEvaluatorFactory() {
-
private static final long serialVersionUID = 1L;
@Override
public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
- // TODO Auto-generated method stub
- return new IScalarEvaluator() {
+ return new AbstractComparisonEvaluator(args[0], args[1], ctx) {
@Override
- public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
- // TODO Auto-generated method stub
+ protected boolean getComparisonResult(int r) {
+ return r >= 0;
+ }
+ @Override
+ protected boolean isTotallyOrderable() {
+ return true;
}
};
}
- };
- }
- @Override
- public FunctionIdentifier getIdentifier() {
- return AsterixBuiltinFunctions.EMBED_TYPE;
+ };
}
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/LessThanDescriptor.java
similarity index 69%
copy from asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java
copy to asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/LessThanDescriptor.java
index 0bfa5a8..d375a61 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/LessThanDescriptor.java
@@ -16,62 +16,53 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.asterix.runtime.evaluators.functions;
+
+package org.apache.asterix.runtime.evaluators.comparisons;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
-import org.apache.asterix.om.types.IAType;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.data.std.api.IPointable;
-import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
-public class EmbedTypeDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
+public class LessThanDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private static final long serialVersionUID = 1L;
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
@Override
public IFunctionDescriptor createFunctionDescriptor() {
- return new EmbedTypeDescriptor();
+ return new LessThanDescriptor();
}
};
- @SuppressWarnings("unused")
- private IAType fieldType;
-
- public void reset(IAType fieldType) {
- this.fieldType = fieldType;
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return AsterixBuiltinFunctions.LT;
}
@Override
- public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
+ public IScalarEvaluatorFactory createEvaluatorFactory(IScalarEvaluatorFactory[] args) throws AlgebricksException {
return new IScalarEvaluatorFactory() {
-
private static final long serialVersionUID = 1L;
@Override
public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
- // TODO Auto-generated method stub
- return new IScalarEvaluator() {
+ return new AbstractComparisonEvaluator(args[0], args[1], ctx) {
@Override
- public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
- // TODO Auto-generated method stub
+ protected boolean getComparisonResult(int r) {
+ return r < 0;
+ }
+ @Override
+ protected boolean isTotallyOrderable() {
+ return true;
}
};
}
};
}
-
- @Override
- public FunctionIdentifier getIdentifier() {
- return AsterixBuiltinFunctions.EMBED_TYPE;
- }
-
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/LessThanOrEqualsDescriptor.java
similarity index 69%
copy from asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java
copy to asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/LessThanOrEqualsDescriptor.java
index 0bfa5a8..4bcaa5b 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/LessThanOrEqualsDescriptor.java
@@ -16,62 +16,55 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.asterix.runtime.evaluators.functions;
+
+package org.apache.asterix.runtime.evaluators.comparisons;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
-import org.apache.asterix.om.types.IAType;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.data.std.api.IPointable;
-import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
-public class EmbedTypeDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
+public class LessThanOrEqualsDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private static final long serialVersionUID = 1L;
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
@Override
public IFunctionDescriptor createFunctionDescriptor() {
- return new EmbedTypeDescriptor();
+ return new LessThanOrEqualsDescriptor();
}
};
- @SuppressWarnings("unused")
- private IAType fieldType;
-
- public void reset(IAType fieldType) {
- this.fieldType = fieldType;
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return AsterixBuiltinFunctions.LE;
}
@Override
- public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
+ public IScalarEvaluatorFactory createEvaluatorFactory(IScalarEvaluatorFactory[] args) throws AlgebricksException {
return new IScalarEvaluatorFactory() {
-
private static final long serialVersionUID = 1L;
@Override
public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
- // TODO Auto-generated method stub
- return new IScalarEvaluator() {
+ return new AbstractComparisonEvaluator(args[0], args[1], ctx) {
@Override
- public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
- // TODO Auto-generated method stub
+ protected boolean getComparisonResult(int r) {
+ return r <= 0;
+ }
+ @Override
+ protected boolean isTotallyOrderable() {
+ return true;
}
};
}
- };
- }
- @Override
- public FunctionIdentifier getIdentifier() {
- return AsterixBuiltinFunctions.EMBED_TYPE;
+ };
}
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/NotEqualsDescriptor.java
similarity index 70%
copy from asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java
copy to asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/NotEqualsDescriptor.java
index 0bfa5a8..11ee60f 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/comparisons/NotEqualsDescriptor.java
@@ -16,62 +16,55 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.asterix.runtime.evaluators.functions;
+
+package org.apache.asterix.runtime.evaluators.comparisons;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
-import org.apache.asterix.om.types.IAType;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.data.std.api.IPointable;
-import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
-public class EmbedTypeDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
+public class NotEqualsDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private static final long serialVersionUID = 1L;
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
@Override
public IFunctionDescriptor createFunctionDescriptor() {
- return new EmbedTypeDescriptor();
+ return new NotEqualsDescriptor();
}
};
- @SuppressWarnings("unused")
- private IAType fieldType;
-
- public void reset(IAType fieldType) {
- this.fieldType = fieldType;
+ @Override
+ public FunctionIdentifier getIdentifier() {
+ return AsterixBuiltinFunctions.NEQ;
}
@Override
- public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
+ public IScalarEvaluatorFactory createEvaluatorFactory(IScalarEvaluatorFactory[] args) throws AlgebricksException {
return new IScalarEvaluatorFactory() {
-
private static final long serialVersionUID = 1L;
@Override
public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
- // TODO Auto-generated method stub
- return new IScalarEvaluator() {
+ return new AbstractComparisonEvaluator(args[0], args[1], ctx) {
@Override
- public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
- // TODO Auto-generated method stub
+ protected boolean getComparisonResult(int r) {
+ return r != 0;
+ }
+ @Override
+ protected boolean isTotallyOrderable() {
+ return false;
}
};
}
- };
- }
- @Override
- public FunctionIdentifier getIdentifier() {
- return AsterixBuiltinFunctions.EMBED_TYPE;
+ };
}
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ABinaryHexStringConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ABinaryHexStringConstructorDescriptor.java
index 422f325..74f4b65 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ABinaryHexStringConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ABinaryHexStringConstructorDescriptor.java
@@ -22,20 +22,16 @@
import java.io.DataOutput;
import java.io.IOException;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
@@ -80,10 +76,6 @@
private IValueParser byteArrayParser;
private UTF8StringPointable utf8Ptr = new UTF8StringPointable();
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
-
public ABinaryConstructorEvaluator(IScalarEvaluatorFactory copyEvaluatorFactory,
IValueParserFactory valueParserFactory, IHyracksTaskContext context) throws AlgebricksException {
eval = copyEvaluatorFactory.createScalarEvaluator(context);
@@ -99,11 +91,7 @@
int len = inputArg.getLength();
ATypeTag tt = ATypeTag.VALUE_TYPE_MAPPING[binary[startOffset]];
- if (tt == ATypeTag.NULL) {
- resultStorage.reset();
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- } else if (tt == ATypeTag.BINARY) {
+ if (tt == ATypeTag.BINARY) {
result.set(inputArg);
} else if (tt == ATypeTag.STRING) {
resultStorage.reset();
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ABooleanConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ABooleanConstructorDescriptor.java
index 0e41f4a..85ecb75 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ABooleanConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ABooleanConstructorDescriptor.java
@@ -24,7 +24,6 @@
import org.apache.asterix.formats.nontagged.AqlBinaryComparatorFactoryProvider;
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ABoolean;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -73,9 +72,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ABoolean> booleanSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ABOOLEAN);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
@@ -100,12 +96,9 @@
} else {
throw new AlgebricksException(errorMessage);
}
- } else if (serString[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException(errorMessage);
}
- result.set(resultStorage);
} catch (IOException e1) {
throw new AlgebricksException(errorMessage);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ACircleConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ACircleConstructorDescriptor.java
index 708b027..319ab0e 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ACircleConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ACircleConstructorDescriptor.java
@@ -25,7 +25,6 @@
import org.apache.asterix.om.base.ACircle;
import org.apache.asterix.om.base.AMutableCircle;
import org.apache.asterix.om.base.AMutablePoint;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -72,9 +71,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ACircle> circleSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ACIRCLE);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@@ -97,8 +93,6 @@
Double.parseDouble(s.substring(commaIndex + 1, spaceIndex)));
aCircle.setValue(aPoint, Double.parseDouble(s.substring(spaceIndex + 1, s.length())));
circleSerde.serialize(aCircle, out);
- } else if (serString[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException(errorMessage);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java
index d306159..06b9948 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADateConstructorDescriptor.java
@@ -24,7 +24,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ADate;
import org.apache.asterix.om.base.AMutableDate;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.ADateParserFactory;
import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
@@ -72,9 +71,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ADate> dateSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADATE);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@@ -109,24 +105,19 @@
long chrononTimeInMs = ADateParserFactory.parseDatePart(serString, startOffset,
endOffset - startOffset + 1);
-
short temp = 0;
if (chrononTimeInMs < 0
&& chrononTimeInMs % GregorianCalendarSystem.CHRONON_OF_DAY != 0) {
temp = 1;
}
-
aDate.setValue((int) (chrononTimeInMs / GregorianCalendarSystem.CHRONON_OF_DAY) - temp);
-
dateSerde.serialize(aDate, out);
- } else if (serString[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException(errorMessage);
}
result.set(resultStorage);
- } catch (IOException e1) {
- throw new AlgebricksException(errorMessage);
+ } catch (IOException e) {
+ throw new AlgebricksException(e);
}
}
};
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java
index a538b2b..63f3461 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADateTimeConstructorDescriptor.java
@@ -24,7 +24,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ADateTime;
import org.apache.asterix.om.base.AMutableDateTime;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.ADateParserFactory;
import org.apache.asterix.om.base.temporal.ATimeParserFactory;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
@@ -71,9 +70,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ADateTime> datetimeSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADATETIME);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@Override
@@ -115,8 +111,6 @@
aDateTime.setValue(chrononTimeInMs);
datetimeSerde.serialize(aDateTime, out);
- } else if (serString[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException(errorMessage);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADayTimeDurationConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADayTimeDurationConstructorDescriptor.java
index 31ceb9f..f95a441 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADayTimeDurationConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADayTimeDurationConstructorDescriptor.java
@@ -23,7 +23,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ADayTimeDuration;
import org.apache.asterix.om.base.AMutableDayTimeDuration;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.ADurationParserFactory;
import org.apache.asterix.om.base.temporal.ADurationParserFactory.ADurationParseOption;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
@@ -73,9 +72,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ADayTimeDuration> dayTimeDurationSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADAYTIMEDURATION);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@Override
@@ -96,8 +92,6 @@
aDayTimeDuration, ADurationParseOption.DAY_TIME);
dayTimeDurationSerde.serialize(aDayTimeDuration, out);
- } else if (serString[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException(errorMessage);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADoubleConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADoubleConstructorDescriptor.java
index adacd51..92d7c72 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADoubleConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADoubleConstructorDescriptor.java
@@ -25,7 +25,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ADouble;
import org.apache.asterix.om.base.AMutableDouble;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -77,9 +76,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ADouble> doubleSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADOUBLE);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@@ -107,8 +103,6 @@
aDouble.setValue(Double.parseDouble(utf8Ptr.toString()));
}
doubleSerde.serialize(aDouble, out);
- } else if (serString[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException(errorMessage);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADurationConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADurationConstructorDescriptor.java
index cd48249..18dc471 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADurationConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ADurationConstructorDescriptor.java
@@ -23,7 +23,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ADuration;
import org.apache.asterix.om.base.AMutableDuration;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.ADurationParserFactory;
import org.apache.asterix.om.base.temporal.ADurationParserFactory.ADurationParseOption;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
@@ -70,9 +69,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ADuration> durationSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADURATION);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@Override
@@ -90,8 +86,6 @@
ADurationParserFactory.parseDuration(serString, utf8Ptr.getCharStartOffset(),
stringLength, aDuration, ADurationParseOption.All);
durationSerde.serialize(aDuration, out);
- } else if (serString[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException(errorMessage);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AFloatConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AFloatConstructorDescriptor.java
index 842ebab..e293552 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AFloatConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AFloatConstructorDescriptor.java
@@ -25,7 +25,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AFloat;
import org.apache.asterix.om.base.AMutableFloat;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -86,9 +85,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<AFloat> floatSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AFLOAT);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@Override
@@ -115,8 +111,6 @@
aFloat.setValue(Float.parseFloat(utf8Ptr.toString()));
}
floatSerde.serialize(aFloat, out);
- } else if (serString[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException(errorMessage);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt16ConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt16ConstructorDescriptor.java
index 2a0d795..f413c82 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt16ConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt16ConstructorDescriptor.java
@@ -24,7 +24,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AInt16;
import org.apache.asterix.om.base.AMutableInt16;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -73,9 +72,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<AInt16> int16Serde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT16);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@Override
@@ -118,8 +114,6 @@
aInt16.setValue(value);
int16Serde.serialize(aInt16, out);
- } else if (serString[startOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException(errorMessage);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt32ConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt32ConstructorDescriptor.java
index 3d335f2..a727026 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt32ConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt32ConstructorDescriptor.java
@@ -24,7 +24,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AInt32;
import org.apache.asterix.om.base.AMutableInt32;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -72,9 +71,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<AInt32> int32Serde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT32);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@Override
@@ -117,8 +113,6 @@
aInt32.setValue(value);
int32Serde.serialize(aInt32, out);
- } else if (serString[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException(errorMessage);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt64ConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt64ConstructorDescriptor.java
index c658423..12775fb 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt64ConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt64ConstructorDescriptor.java
@@ -24,7 +24,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AInt64;
import org.apache.asterix.om.base.AMutableInt64;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -73,9 +72,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<AInt64> int64Serde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT64);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@Override
@@ -118,8 +114,6 @@
aInt64.setValue(value);
int64Serde.serialize(aInt64, out);
- } else if (serString[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException(errorMessage);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt8ConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt8ConstructorDescriptor.java
index c865820..90359de 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt8ConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AInt8ConstructorDescriptor.java
@@ -24,7 +24,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AInt8;
import org.apache.asterix.om.base.AMutableInt8;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -73,9 +72,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<AInt8> int8Serde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT8);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@Override
@@ -118,8 +114,6 @@
aInt8.setValue(value);
int8Serde.serialize(aInt8, out);
- } else if (serString[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException(errorMessage);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AIntervalConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AIntervalConstructorDescriptor.java
index 172ad4f..ccfdb43 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AIntervalConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AIntervalConstructorDescriptor.java
@@ -27,7 +27,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AInterval;
import org.apache.asterix.om.base.AMutableInterval;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -75,9 +74,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<AInterval> intervalSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINTERVAL);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
@@ -91,13 +87,6 @@
int offset1 = argPtr1.getStartOffset();
try {
- if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
-
if (bytes0[offset0] != bytes1[offset1]) {
throw new AlgebricksException(FID.getName()
+ ": expects both arguments to be of the same type. Either DATE/TIME/DATETIME, but got "
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AIntervalStartFromDateConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AIntervalStartFromDateConstructorDescriptor.java
index 55ff7d1..ca115fb 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AIntervalStartFromDateConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AIntervalStartFromDateConstructorDescriptor.java
@@ -29,7 +29,6 @@
import org.apache.asterix.om.base.AInterval;
import org.apache.asterix.om.base.AMutableDuration;
import org.apache.asterix.om.base.AMutableInterval;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.ADateParserFactory;
import org.apache.asterix.om.base.temporal.ADurationParserFactory;
import org.apache.asterix.om.base.temporal.ADurationParserFactory.ADurationParseOption;
@@ -87,9 +86,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<AInterval> intervalSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINTERVAL);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@Override
@@ -106,13 +102,6 @@
int len1 = argPtr1.getLength();
try {
- if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
-
long intervalStart = 0, intervalEnd = 0;
if (bytes0[offset0] == ATypeTag.SERIALIZED_DATE_TYPE_TAG) {
intervalStart = ADateSerializerDeserializer.getChronon(bytes0, offset0 + 1)
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AIntervalStartFromDateTimeConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AIntervalStartFromDateTimeConstructorDescriptor.java
index dab0714..b8c56fb 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AIntervalStartFromDateTimeConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AIntervalStartFromDateTimeConstructorDescriptor.java
@@ -29,7 +29,6 @@
import org.apache.asterix.om.base.AInterval;
import org.apache.asterix.om.base.AMutableDuration;
import org.apache.asterix.om.base.AMutableInterval;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.ADateParserFactory;
import org.apache.asterix.om.base.temporal.ADurationParserFactory;
import org.apache.asterix.om.base.temporal.ADurationParserFactory.ADurationParseOption;
@@ -85,9 +84,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<AInterval> intervalSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINTERVAL);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@Override
@@ -103,13 +99,6 @@
int len1 = argPtr1.getLength();
try {
- if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
-
long intervalStart = 0, intervalEnd = 0;
if (bytes0[offset0] == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
intervalStart = ADateTimeSerializerDeserializer.getChronon(bytes0, offset0 + 1);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AIntervalStartFromTimeConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AIntervalStartFromTimeConstructorDescriptor.java
index b3df622..49644f3 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AIntervalStartFromTimeConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AIntervalStartFromTimeConstructorDescriptor.java
@@ -28,7 +28,6 @@
import org.apache.asterix.om.base.AInterval;
import org.apache.asterix.om.base.AMutableDuration;
import org.apache.asterix.om.base.AMutableInterval;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.ADurationParserFactory;
import org.apache.asterix.om.base.temporal.ADurationParserFactory.ADurationParseOption;
import org.apache.asterix.om.base.temporal.ATimeParserFactory;
@@ -85,9 +84,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<AInterval> intervalSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINTERVAL);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@Override
@@ -104,13 +100,6 @@
int len1 = argPtr1.getLength();
try {
- if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
-
long intervalStart = 0, intervalEnd = 0;
if (bytes0[offset0] == ATypeTag.SERIALIZED_TIME_TYPE_TAG) {
intervalStart = ATimeSerializerDeserializer.getChronon(bytes0, offset0 + 1);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ALineConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ALineConstructorDescriptor.java
index 82e7150..b912a4e 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ALineConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ALineConstructorDescriptor.java
@@ -25,7 +25,6 @@
import org.apache.asterix.om.base.ALine;
import org.apache.asterix.om.base.AMutableLine;
import org.apache.asterix.om.base.AMutablePoint;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -73,9 +72,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ALine> lineSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ALINE);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@Override
@@ -99,8 +95,6 @@
Double.parseDouble(s.substring(commaIndex + 1, s.length())));
aLine.setValue(aPoint[0], aPoint[1]);
lineSerde.serialize(aLine, out);
- } else if (serString[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException(errorMessage);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ANullConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ANullConstructorDescriptor.java
index 623d546..71359a8 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ANullConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ANullConstructorDescriptor.java
@@ -23,7 +23,7 @@
import org.apache.asterix.formats.nontagged.AqlBinaryComparatorFactoryProvider;
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ANull;
+import org.apache.asterix.om.base.AMissing;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -70,8 +70,8 @@
IBinaryComparator utf8BinaryComparator = AqlBinaryComparatorFactoryProvider.UTF8STRING_POINTABLE_INSTANCE
.createBinaryComparator();
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
+ private ISerializerDeserializer<AMissing> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.AMISSING);
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
@@ -85,7 +85,7 @@
if (utf8BinaryComparator.compare(serString, offset + 1, len - 1, NULL, 0,
NULL.length) == 0) {
resultStorage.reset();
- nullSerde.serialize(ANull.NULL, out);
+ nullSerde.serialize(AMissing.MISSING, out);
result.set(resultStorage);
return;
} else {
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/APoint3DConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/APoint3DConstructorDescriptor.java
index f0cea4b..b7982da 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/APoint3DConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/APoint3DConstructorDescriptor.java
@@ -23,7 +23,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AMutablePoint3D;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.APoint3D;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
@@ -71,9 +70,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<APoint3D> point3DSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.APOINT3D);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@Override
@@ -94,8 +90,6 @@
Double.parseDouble(s.substring(firstCommaIndex + 1, secondCommaIndex)),
Double.parseDouble(s.substring(secondCommaIndex + 1, s.length())));
point3DSerde.serialize(aPoint3D, out);
- } else if (serString[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException(errorMessage);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/APointConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/APointConstructorDescriptor.java
index 32d1ae6..78ac2da 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/APointConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/APointConstructorDescriptor.java
@@ -23,7 +23,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AMutablePoint;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.APoint;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
@@ -70,9 +69,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<APoint> pointSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.APOINT);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@Override
@@ -91,8 +87,6 @@
aPoint.setValue(Double.parseDouble(s.substring(0, s.indexOf(','))),
Double.parseDouble(s.substring(s.indexOf(',') + 1, s.length())));
pointSerde.serialize(aPoint, out);
- } else if (serString[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException(errorMessage);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/APolygonConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/APolygonConstructorDescriptor.java
index fc163ad..0735e37 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/APolygonConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/APolygonConstructorDescriptor.java
@@ -22,20 +22,16 @@
import java.io.IOException;
import org.apache.asterix.dataflow.data.nontagged.serde.APointSerializerDeserializer;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
@@ -65,9 +61,6 @@
private IPointable inputArg = new VoidPointable();
private IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
private String errorMessage = "This can not be an instance of polygon";
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@Override
@@ -93,8 +86,6 @@
APointSerializerDeserializer.serialize(Double.parseDouble(points[i].split(",")[0]),
Double.parseDouble(points[i].split(",")[1]), out);
}
- } else if (serString[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException(errorMessage);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ARectangleConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ARectangleConstructorDescriptor.java
index b2dbe1e..e6eb5c1 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ARectangleConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ARectangleConstructorDescriptor.java
@@ -24,7 +24,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AMutablePoint;
import org.apache.asterix.om.base.AMutableRectangle;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.ARectangle;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
@@ -72,9 +71,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ARectangle> rectangle2DSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ARECTANGLE);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@Override
@@ -106,8 +102,6 @@
"Rectangle arugment must be either (bottom left point, top right point) or (top right point, bottom left point)");
}
rectangle2DSerde.serialize(aRectangle, out);
- } else if (serString[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException(errorMessage);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AStringConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AStringConstructorDescriptor.java
index 6399ace..930b584 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AStringConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AStringConstructorDescriptor.java
@@ -28,20 +28,16 @@
import org.apache.asterix.dataflow.data.nontagged.serde.AInt32SerializerDeserializer;
import org.apache.asterix.dataflow.data.nontagged.serde.AInt64SerializerDeserializer;
import org.apache.asterix.dataflow.data.nontagged.serde.AInt8SerializerDeserializer;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
@@ -72,9 +68,6 @@
private DataOutput out = resultStorage.getDataOutput();
private IPointable inputArg = new VoidPointable();
private IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private UTF8StringBuilder builder = new UTF8StringBuilder();
private GrowableArray baaos = new GrowableArray();
@@ -89,10 +82,7 @@
int len = inputArg.getLength();
ATypeTag tt = ATypeTag.VALUE_TYPE_MAPPING[serString[offset]];
- if (tt == ATypeTag.NULL) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- } else if (tt == ATypeTag.STRING) {
+ if (tt == ATypeTag.STRING) {
result.set(inputArg);
} else {
builder.reset(baaos, len);
@@ -134,7 +124,7 @@
break;
}
- // NotYetImplemented
+ // NotYetImplemented
case CIRCLE:
case DATE:
case DATETIME:
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ATimeConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ATimeConstructorDescriptor.java
index ed8051d..a296ae9 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ATimeConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/ATimeConstructorDescriptor.java
@@ -23,7 +23,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AMutableTime;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.ATime;
import org.apache.asterix.om.base.temporal.ATimeParserFactory;
import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
@@ -72,9 +71,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ATime> timeSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ATIME);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@Override
@@ -108,9 +104,6 @@
aTime.setValue(chrononTimeInMs);
timeSerde.serialize(aTime, out);
-
- } else if (serString[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException(errorMessage);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AUUIDFromStringConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AUUIDFromStringConstructorDescriptor.java
index e058813..44140fb 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AUUIDFromStringConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AUUIDFromStringConstructorDescriptor.java
@@ -23,7 +23,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AMutableUUID;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.AUUID;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
@@ -75,9 +74,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<AUUID> uuidSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AUUID);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@@ -96,8 +92,6 @@
int offset = utf8Ptr.getCharStartOffset();
uuid.parseUUIDHexBytes(serString, offset);
uuidSerde.serialize(uuid, out);
- } else if (serString[start] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException(errorMessage);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AYearMonthDurationConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AYearMonthDurationConstructorDescriptor.java
index eaf8257..160043f 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AYearMonthDurationConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/AYearMonthDurationConstructorDescriptor.java
@@ -22,7 +22,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AMutableYearMonthDuration;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.AYearMonthDuration;
import org.apache.asterix.om.base.temporal.ADurationParserFactory;
import org.apache.asterix.om.base.temporal.ADurationParserFactory.ADurationParseOption;
@@ -72,9 +71,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<AYearMonthDuration> yearMonthDurationSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AYEARMONTHDURATION);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@Override
@@ -92,8 +88,6 @@
ADurationParserFactory.parseDuration(serString, utf8Ptr.getCharStartOffset(),
stringLength, aYearMonthDuration, ADurationParseOption.YEAR_MONTH);
yearMonthDurationSerde.serialize(aYearMonthDuration, out);
- } else if (serString[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException(errorMessage);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/OpenRecordConstructorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/OpenRecordConstructorDescriptor.java
index af3ba54..f6ff2d9 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/OpenRecordConstructorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/constructors/OpenRecordConstructorDescriptor.java
@@ -97,14 +97,20 @@
recBuilder.init();
for (int i = 0; i < evalFields.length; i++) {
evalFields[i].evaluate(tuple, fieldValuePointable);
- if (openFields[i]) {
+ byte[] data = fieldValuePointable.getByteArray();
+ int offset = fieldValuePointable.getStartOffset();
+ boolean openField = openFields[i];
+ if (openField && data[offset] != ATypeTag.SERIALIZED_MISSING_TYPE_TAG) {
+ // MISSING for an open field means the field does not exist.
evalNames[i].evaluate(tuple, fieldNamePointable);
recBuilder.addField(fieldNamePointable, fieldValuePointable);
- } else {
- if (fieldValuePointable.getByteArray()[fieldValuePointable
- .getStartOffset()] != ATypeTag.NULL.serialize()) {
- recBuilder.addField(closedFieldId, fieldValuePointable);
- }
+ }
+ if (!openField && data[offset] == ATypeTag.SERIALIZED_MISSING_TYPE_TAG) {
+ // Turns MISSING into NULL for a closed field.
+ data[offset] = ATypeTag.SERIALIZED_NULL_TYPE_TAG;
+ }
+ if (!openField) {
+ recBuilder.addField(closedFieldId, fieldValuePointable);
closedFieldId++;
}
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractBinaryStringBoolEval.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractBinaryStringBoolEval.java
index 4a5c59a..fd89493 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractBinaryStringBoolEval.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractBinaryStringBoolEval.java
@@ -22,7 +22,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ABoolean;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
@@ -56,9 +55,6 @@
@SuppressWarnings({ "rawtypes" })
private ISerializerDeserializer boolSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ABOOLEAN);
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
public AbstractBinaryStringBoolEval(IHyracksTaskContext context, IScalarEvaluatorFactory evalLeftFactory,
IScalarEvaluatorFactory evalRightFactory, FunctionIdentifier funcID) throws AlgebricksException {
@@ -81,20 +77,11 @@
int len1 = ptr1.getLength();
resultStorage.reset();
- try {
- if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, dout);
- result.set(resultStorage);
- return;
- } else if (bytes0[offset0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
- || bytes1[offset1] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
- throw new AlgebricksException(funcID.getName() + ": expects input type STRING or NULL, but got "
- + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[offset0]) + " and "
- + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]) + ")!");
- }
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
+ if (bytes0[offset0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
+ || bytes1[offset1] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
+ throw new AlgebricksException(funcID.getName() + ": expects input type STRING or NULL, but got "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[offset0]) + " and "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]) + ")!");
}
leftPtr.set(bytes0, offset0 + 1, len0 - 1);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractNumericArithmeticEval.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractNumericArithmeticEval.java
index 0d262fb..56b473e 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractNumericArithmeticEval.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractNumericArithmeticEval.java
@@ -43,7 +43,6 @@
import org.apache.asterix.om.base.AMutableInt64;
import org.apache.asterix.om.base.AMutableInt8;
import org.apache.asterix.om.base.AMutableTime;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.BuiltinType;
@@ -136,21 +135,15 @@
@SuppressWarnings("unchecked")
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
-
try {
resultStorage.reset();
resultType = 0;
int currentType = 0;
- for (int i = 0; i < args.length; i++) {
- IPointable argPtr;
- if (i == 0) {
- evalLeft.evaluate(tuple, argPtr0);
- argPtr = argPtr0;
- } else {
- evalRight.evaluate(tuple, argPtr1);
- argPtr = argPtr1;
- }
+ evalLeft.evaluate(tuple, argPtr0);
+ evalRight.evaluate(tuple, argPtr1);
+ for (int i = 0; i < args.length; i++) {
+ IPointable argPtr = i == 0 ? argPtr0 : argPtr1;
byte[] bytes = argPtr.getByteArray();
int offset = argPtr.getStartOffset();
@@ -197,16 +190,9 @@
case DURATION:
case YEARMONTHDURATION:
case DAYTIMEDURATION:
- evaluateTemporalArthmeticOperation(typeTag, tuple);
+ evaluateTemporalArthmeticOperation(typeTag);
result.set(resultStorage);
return;
- case NULL: {
- serde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
- serde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
default: {
throw new NotImplementedException(getIdentifier().getName()
+ (i == 0 ? ": Left" : ": Right")
@@ -296,22 +282,14 @@
}
@SuppressWarnings("unchecked")
- private void evaluateTemporalArthmeticOperation(ATypeTag leftType, IFrameTupleReference tuple)
+ private void evaluateTemporalArthmeticOperation(ATypeTag leftType)
throws HyracksDataException, AlgebricksException {
- evalRight.evaluate(tuple, argPtr1);
byte[] bytes1 = argPtr1.getByteArray();
int offset1 = argPtr1.getStartOffset();
ATypeTag rightType = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]);
byte[] bytes0 = argPtr0.getByteArray();
int offset0 = argPtr0.getStartOffset();
- if (leftType == ATypeTag.NULL || rightType == ATypeTag.NULL) {
- serde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
- serde.serialize(ANull.NULL, out);
- return;
- }
-
if (rightType == leftType) {
serde = AqlSerializerDeserializerProvider.INSTANCE
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractQuadStringStringEval.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractQuadStringStringEval.java
index 0085461..daa9a54 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractQuadStringStringEval.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractQuadStringStringEval.java
@@ -26,7 +26,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AMutableString;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
@@ -60,9 +59,6 @@
private AMutableString resultBuffer = new AMutableString("");
@SuppressWarnings("rawtypes")
- private ISerializerDeserializer nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
- @SuppressWarnings("rawtypes")
private ISerializerDeserializer strSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ASTRING);
@@ -90,34 +86,20 @@
eval3.evaluate(tuple, array3);
resultStorage.reset();
- try {
- if (array0.getByteArray()[array0.getStartOffset()] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || array1.getByteArray()[array1.getStartOffset()] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || array2.getByteArray()[array2.getStartOffset()] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || array3.getByteArray()[array3.getStartOffset()] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, dout);
- result.set(resultStorage);
- return;
- } else if (array0.getByteArray()[array0.getStartOffset()] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
- || array1.getByteArray()[array1.getStartOffset()] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
- || array2.getByteArray()[array2.getStartOffset()] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
- || array3.getByteArray()[array3.getStartOffset()] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
- throw new AlgebricksException(funcID.getName()
- + ": expects input type (STRING/NULL, STRING/NULL, STRING/NULL, STRING/NULL), but got ("
- + EnumDeserializer.ATYPETAGDESERIALIZER
- .deserialize(array0.getByteArray()[array0.getStartOffset()])
- + ", "
- + EnumDeserializer.ATYPETAGDESERIALIZER
- .deserialize(array1.getByteArray()[array1.getStartOffset()])
- + ", "
- + EnumDeserializer.ATYPETAGDESERIALIZER
- .deserialize(array2.getByteArray()[array2.getStartOffset()])
- + ", " + EnumDeserializer.ATYPETAGDESERIALIZER
- .deserialize(array3.getByteArray()[array3.getStartOffset()])
- + ".");
- }
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
+ if (array0.getByteArray()[array0.getStartOffset()] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
+ || array1.getByteArray()[array1.getStartOffset()] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
+ || array2.getByteArray()[array2.getStartOffset()] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
+ || array3.getByteArray()[array3.getStartOffset()] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
+ throw new AlgebricksException(funcID.getName()
+ + ": expects input type (STRING/NULL, STRING/NULL, STRING/NULL, STRING/NULL), but got ("
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(array0.getByteArray()[array0.getStartOffset()])
+ + ", "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(array1.getByteArray()[array1.getStartOffset()])
+ + ", "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(array2.getByteArray()[array2.getStartOffset()])
+ + ", "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(array3.getByteArray()[array3.getStartOffset()])
+ + ".");
}
strPtr1st.set(array0.getByteArray(), array0.getStartOffset() + 1, array0.getLength());
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractTripleStringBoolEval.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractTripleStringBoolEval.java
index f1f07dd..6f1ce15 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractTripleStringBoolEval.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractTripleStringBoolEval.java
@@ -22,7 +22,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ABoolean;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
@@ -53,9 +52,6 @@
@SuppressWarnings("rawtypes")
private ISerializerDeserializer boolSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ABOOLEAN);
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final FunctionIdentifier funcID;
@@ -65,7 +61,7 @@
public AbstractTripleStringBoolEval(IHyracksTaskContext context, IScalarEvaluatorFactory eval0,
IScalarEvaluatorFactory eval1, IScalarEvaluatorFactory eval2, FunctionIdentifier funcID)
- throws AlgebricksException {
+ throws AlgebricksException {
this.eval0 = eval0.createScalarEvaluator(context);
this.eval1 = eval1.createScalarEvaluator(context);
this.eval2 = eval2.createScalarEvaluator(context);
@@ -80,32 +76,17 @@
eval2.evaluate(tuple, array2);
resultStorage.reset();
- try {
- if (array0.getByteArray()[array0.getStartOffset()] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || array1.getByteArray()[array1.getStartOffset()] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || array2.getByteArray()[array2.getStartOffset()] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, dout);
- result.set(resultStorage);
- return;
- }
-
- if (array0.getByteArray()[array0.getStartOffset()] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
- || array1.getByteArray()[array1.getStartOffset()] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
- || array2.getByteArray()[array2.getStartOffset()] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
- throw new AlgebricksException(
- funcID.getName() + ": expects iput type (STRING/NULL, STRING/NULL, STRING) but got ("
- + EnumDeserializer.ATYPETAGDESERIALIZER
- .deserialize(array0.getByteArray()[array0.getStartOffset()])
- + ", "
- + EnumDeserializer.ATYPETAGDESERIALIZER
- .deserialize(array1.getByteArray()[array1.getStartOffset()])
- + ", " + EnumDeserializer.ATYPETAGDESERIALIZER
- .deserialize(array2.getByteArray()[array2.getStartOffset()])
- + ")");
- }
-
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
+ if (array0.getByteArray()[array0.getStartOffset()] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
+ || array1.getByteArray()[array1.getStartOffset()] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
+ || array2.getByteArray()[array2.getStartOffset()] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
+ throw new AlgebricksException(funcID.getName()
+ + ": expects iput type (STRING/NULL, STRING/NULL, STRING/NULL) but got ("
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(array0.getByteArray()[array0.getStartOffset()])
+ + ", "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(array1.getByteArray()[array1.getStartOffset()])
+ + ", "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(array2.getByteArray()[array2.getStartOffset()])
+ + ")");
}
strPtr1st.set(array0.getByteArray(), array0.getStartOffset() + 1, array0.getLength());
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractTripleStringStringEval.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractTripleStringStringEval.java
index 7511b82..bcbee23 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractTripleStringStringEval.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AbstractTripleStringStringEval.java
@@ -22,7 +22,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AMutableString;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
@@ -52,9 +51,6 @@
private AMutableString resultBuffer = new AMutableString("");
@SuppressWarnings("rawtypes")
- private ISerializerDeserializer nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
- @SuppressWarnings("rawtypes")
private ISerializerDeserializer strSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ASTRING);
@@ -66,7 +62,7 @@
public AbstractTripleStringStringEval(IHyracksTaskContext context, IScalarEvaluatorFactory eval0,
IScalarEvaluatorFactory eval1, IScalarEvaluatorFactory eval2, FunctionIdentifier funcID)
- throws AlgebricksException {
+ throws AlgebricksException {
this.eval0 = eval0.createScalarEvaluator(context);
this.eval1 = eval1.createScalarEvaluator(context);
this.eval2 = eval2.createScalarEvaluator(context);
@@ -81,29 +77,17 @@
eval2.evaluate(tuple, array2);
resultStorage.reset();
- try {
- if (array0.getByteArray()[array0.getStartOffset()] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || array1.getByteArray()[array1.getStartOffset()] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || array2.getByteArray()[array2.getStartOffset()] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, dout);
- result.set(resultStorage);
- return;
- } else if (array0.getByteArray()[array0.getStartOffset()] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
- || array1.getByteArray()[array1.getStartOffset()] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
- || array2.getByteArray()[array2.getStartOffset()] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
- throw new AlgebricksException(
- funcID.getName() + ": expects input type (STRING/NULL, STRING/NULL, STRING/NULL), but got ("
- + EnumDeserializer.ATYPETAGDESERIALIZER
- .deserialize(array0.getByteArray()[array0.getStartOffset()])
- + ", "
- + EnumDeserializer.ATYPETAGDESERIALIZER
- .deserialize(array1.getByteArray()[array1.getStartOffset()])
- + ", " + EnumDeserializer.ATYPETAGDESERIALIZER
- .deserialize(array2.getByteArray()[array2.getStartOffset()])
- + ".");
- }
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
+ if (array0.getByteArray()[array0.getStartOffset()] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
+ || array1.getByteArray()[array1.getStartOffset()] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
+ || array2.getByteArray()[array2.getStartOffset()] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
+ throw new AlgebricksException(funcID.getName()
+ + ": expects input type (STRING/NULL, STRING/NULL, STRING/NULL), but got ("
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(array0.getByteArray()[array0.getStartOffset()])
+ + ", "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(array1.getByteArray()[array1.getStartOffset()])
+ + ", "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(array2.getByteArray()[array2.getStartOffset()])
+ + ".");
}
strPtr1st.set(array0.getByteArray(), array0.getStartOffset() + 1, array0.getLength());
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AndDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AndDescriptor.java
index 01abb1b..7150517 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AndDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AndDescriptor.java
@@ -23,6 +23,7 @@
import org.apache.asterix.dataflow.data.nontagged.serde.ABooleanSerializerDeserializer;
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ABoolean;
+import org.apache.asterix.om.base.AMissing;
import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
@@ -80,6 +81,9 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
+ @SuppressWarnings("unchecked")
+ private ISerializerDeserializer<AMissing> missingSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.AMISSING);
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
@@ -88,25 +92,40 @@
int n = args.length;
boolean res = true;
boolean metNull = false;
+ boolean metMissing = false;
for (int i = 0; i < n; i++) {
evals[i].evaluate(tuple, argPtr);
byte[] bytes = argPtr.getByteArray();
int offset = argPtr.getStartOffset();
-
+ boolean isNull = false;
+ boolean isMissing = false;
+ if (bytes[offset] == ATypeTag.SERIALIZED_MISSING_TYPE_TAG) {
+ isMissing = true;
+ metMissing = true;
+ }
if (bytes[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
+ isNull = true;
metNull = true;
+ }
+ if (isMissing || isNull) {
continue;
}
boolean argResult = ABooleanSerializerDeserializer.getBoolean(bytes, offset + 1);
- res = res && argResult;
- }
- if (metNull) {
- if (!res) {
- ABoolean aResult = ABoolean.FALSE;
- booleanSerde.serialize(aResult, out);
- } else {
- nullSerde.serialize(ANull.NULL, out);
+ if (argResult == false) {
+ // anything AND FALSE = FALSE
+ booleanSerde.serialize(ABoolean.FALSE, out);
+ result.set(resultStorage);
+ return;
}
+ res &= argResult;
+ }
+ if (metMissing) {
+ // MISSING AND NULL = MISSING
+ // MISSING AND TRUE = MISSING
+ missingSerde.serialize(AMissing.MISSING, out);
+ } else if (metNull) {
+ // NULL AND TRUE = NULL
+ nullSerde.serialize(ANull.NULL, out);
} else {
ABoolean aResult = res ? (ABoolean.TRUE) : (ABoolean.FALSE);
booleanSerde.serialize(aResult, out);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AnyCollectionMemberDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AnyCollectionMemberDescriptor.java
index 546eebd..16cec14 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AnyCollectionMemberDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/AnyCollectionMemberDescriptor.java
@@ -24,13 +24,10 @@
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.dataflow.data.nontagged.serde.AOrderedListSerializerDeserializer;
import org.apache.asterix.dataflow.data.nontagged.serde.AUnorderedListSerializerDeserializer;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.asterix.om.util.NonTaggedFormatUtil;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
@@ -39,7 +36,6 @@
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
@@ -86,9 +82,6 @@
private DataOutput out = resultStorage.getDataOutput();
private IPointable inputArgList = new VoidPointable();
private IScalarEvaluator evalList = listEvalFactory.createScalarEvaluator(ctx);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private int itemOffset;
private int itemLength;
@@ -101,12 +94,6 @@
byte[] serList = inputArgList.getByteArray();
int offset = inputArgList.getStartOffset();
- if (serList[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
-
if (serList[offset] != ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG
&& serList[offset] != ATypeTag.SERIALIZED_UNORDEREDLIST_TYPE_TAG) {
throw new AlgebricksException(AsterixBuiltinFunctions.ANY_COLLECTION_MEMBER.getName()
@@ -116,14 +103,14 @@
if (serList[offset] == ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG) {
if (AOrderedListSerializerDeserializer.getNumberOfItems(serList, offset) == 0) {
- out.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
+ out.writeByte(ATypeTag.SERIALIZED_MISSING_TYPE_TAG);
result.set(resultStorage);
return;
}
itemOffset = AOrderedListSerializerDeserializer.getItemOffset(serList, offset, 0);
} else {
if (AUnorderedListSerializerDeserializer.getNumberOfItems(serList, offset) == 0) {
- out.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
+ out.writeByte(ATypeTag.SERIALIZED_MISSING_TYPE_TAG);
result.set(resultStorage);
return;
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NotNullDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/CheckUnknownDescriptor.java
similarity index 91%
rename from asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NotNullDescriptor.java
rename to asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/CheckUnknownDescriptor.java
index 45fc04c..abd0d3a 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NotNullDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/CheckUnknownDescriptor.java
@@ -38,13 +38,13 @@
* If the input is not null, just return it directly;
* Otherwise, throw a runtime exception.
*/
-public class NotNullDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+public class CheckUnknownDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private static final long serialVersionUID = 1L;
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
@Override
public IFunctionDescriptor createFunctionDescriptor() {
- return new NotNullDescriptor();
+ return new CheckUnknownDescriptor();
}
};
@@ -58,7 +58,7 @@
return new IScalarEvaluator() {
private IPointable inputArg = new VoidPointable();
private IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
- private String errorMessage = AsterixBuiltinFunctions.NOT_NULL
+ private String errorMessage = AsterixBuiltinFunctions.CHECK_UNKNOWN
+ ": the input value cannot be NULL.";
@Override
@@ -67,7 +67,8 @@
byte[] data = inputArg.getByteArray();
int offset = inputArg.getStartOffset();
- if (data[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
+ if (data[offset] == ATypeTag.SERIALIZED_MISSING_TYPE_TAG
+ || data[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
throw new AlgebricksException(errorMessage);
}
result.set(inputArg);
@@ -79,7 +80,7 @@
@Override
public FunctionIdentifier getIdentifier() {
- return AsterixBuiltinFunctions.NOT_NULL;
+ return AsterixBuiltinFunctions.CHECK_UNKNOWN;
}
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/CreatePointDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/CreatePointDescriptor.java
index b65c5c0..6d37152 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/CreatePointDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/CreatePointDescriptor.java
@@ -22,10 +22,8 @@
import java.io.IOException;
import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
-import org.apache.asterix.dataflow.data.nontagged.serde.ANullSerializerDeserializer;
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AMutablePoint;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.APoint;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
@@ -86,10 +84,8 @@
int offset1 = inputArg1.getStartOffset();
// type-check: (double, double)
- if ((bytes0[offset0] != ATypeTag.SERIALIZED_DOUBLE_TYPE_TAG
- && bytes0[offset0] != ATypeTag.SERIALIZED_NULL_TYPE_TAG)
- || (bytes1[offset1] != ATypeTag.SERIALIZED_DOUBLE_TYPE_TAG
- && bytes1[offset1] != ATypeTag.SERIALIZED_NULL_TYPE_TAG)) {
+ if (bytes0[offset0] != ATypeTag.SERIALIZED_DOUBLE_TYPE_TAG
+ || bytes1[offset1] != ATypeTag.SERIALIZED_DOUBLE_TYPE_TAG) {
throw new AlgebricksException(AsterixBuiltinFunctions.CREATE_POINT.getName()
+ ": expects input type: (DOUBLE, DOUBLE) but got ("
+ EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[offset0]) + ", "
@@ -98,14 +94,9 @@
resultStorage.reset();
try {
- if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- ANullSerializerDeserializer.INSTANCE.serialize(ANull.NULL, out);
- } else {
- aPoint.setValue(ADoubleSerializerDeserializer.getDouble(bytes0, offset0 + 1),
- ADoubleSerializerDeserializer.getDouble(bytes1, offset1 + 1));
- pointSerde.serialize(aPoint, out);
- }
+ aPoint.setValue(ADoubleSerializerDeserializer.getDouble(bytes0, offset0 + 1),
+ ADoubleSerializerDeserializer.getDouble(bytes1, offset1 + 1));
+ pointSerde.serialize(aPoint, out);
} catch (IOException e1) {
throw new AlgebricksException(e1);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/DeepEqualityDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/DeepEqualityDescriptor.java
index 174deb1..dec8829 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/DeepEqualityDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/DeepEqualityDescriptor.java
@@ -76,9 +76,9 @@
final DataOutput out = resultStorage.getDataOutput();
final IScalarEvaluator evalLeft = evalFactoryLeft.createScalarEvaluator(ctx);
final IScalarEvaluator evalRight = evalFactoryRight.createScalarEvaluator(ctx);
- final DeepEqualAssessor deepEqualAssessor = new DeepEqualAssessor();
return new IScalarEvaluator() {
+ private final DeepEqualAssessor deepEqualAssessor = new DeepEqualAssessor();
private final PointableAllocator allocator = new PointableAllocator();
private final IVisitablePointable pointableLeft = allocator.allocateFieldValue(inputTypeLeft);
private final IVisitablePointable pointableRight = allocator.allocateFieldValue(inputTypeRight);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EditDistanceListIsFilterable.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EditDistanceListIsFilterableDescriptor.java
similarity index 80%
rename from asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EditDistanceListIsFilterable.java
rename to asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EditDistanceListIsFilterableDescriptor.java
index 01ddb55..a4c4311 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EditDistanceListIsFilterable.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EditDistanceListIsFilterableDescriptor.java
@@ -46,20 +46,21 @@
import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
/**
- * Checks whether a list with an edit distance threshold can be filtered with a lower bounding on the number of common list elements.
- * This function returns 'true' if the lower bound on the number of common elements is positive, 'false' otherwise.
- * For example, this function is used during an indexed nested-loop join based on edit distance. We partition the tuples of the probing
- * dataset into those that are filterable and those that are not. Those that are filterable are forwarded to the index. The others are
- * are fed into a (non indexed) nested-loop join.
+ * Checks whether a list with an edit distance threshold can be filtered with a lower bounding on the number
+ * of common list elements. This function returns 'true' if the lower bound on the number of common elements
+ * is positive, 'false' otherwise. For example, this function is used during an indexed nested-loop join based
+ * on edit distance. We partition the tuples of the probing dataset into those that are filterable and those
+ * that are not. Those that are filterable are forwarded to the index. The others are are fed into a (non
+ * indexed) nested-loop join.
*/
-public class EditDistanceListIsFilterable extends AbstractScalarFunctionDynamicDescriptor {
+public class EditDistanceListIsFilterableDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private static final long serialVersionUID = 1L;
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
@Override
public IFunctionDescriptor createFunctionDescriptor() {
- return new EditDistanceListIsFilterable();
+ return new EditDistanceListIsFilterableDescriptor();
}
};
@@ -83,7 +84,8 @@
private static class EditDistanceListIsFilterableEvaluator implements IScalarEvaluator {
- protected final IPointable argPtr = new VoidPointable();
+ protected final IPointable listPtr = new VoidPointable();
+ protected final IPointable edThreshPtr = new VoidPointable();
protected final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
protected final DataOutput output = resultStorage.getDataOutput();
@@ -103,36 +105,32 @@
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
resultStorage.reset();
- ATypeTag typeTag = null;
+
+ listEval.evaluate(tuple, listPtr);
+ edThreshEval.evaluate(tuple, edThreshPtr);
// Check type and compute string length.
- listEval.evaluate(tuple, argPtr);
- byte[] bytes = argPtr.getByteArray();
- int offset = argPtr.getStartOffset();
+ byte[] bytes = listPtr.getByteArray();
+ int offset = listPtr.getStartOffset();
- typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]);
- long listLen = 0;
+ ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]);
+ long listLen;
switch (typeTag) {
- case UNORDEREDLIST: {
+ case UNORDEREDLIST:
listLen = AUnorderedListSerializerDeserializer.getNumberOfItems(bytes, offset);
break;
- }
- case ORDEREDLIST: {
+ case ORDEREDLIST:
listLen = AOrderedListSerializerDeserializer.getNumberOfItems(bytes, offset);
break;
- }
- default: {
+ default:
throw new AlgebricksException(AsterixBuiltinFunctions.EDIT_DISTANCE_LIST_IS_FILTERABLE.getName()
+ ": expects input type ORDEREDLIST or UNORDEREDLIST as the first argument, but got "
+ typeTag + ".");
- }
}
// Check type and extract edit-distance threshold.
- edThreshEval.evaluate(tuple, argPtr);
- bytes = argPtr.getByteArray();
- offset = argPtr.getStartOffset();
- typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]);
+ bytes = edThreshPtr.getByteArray();
+ offset = edThreshPtr.getStartOffset();
long edThresh;
try {
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EditDistanceStringIsFilterable.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EditDistanceStringIsFilterable.java
deleted file mode 100644
index a707e46..0000000
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EditDistanceStringIsFilterable.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.runtime.evaluators.functions;
-
-import java.io.DataOutput;
-import java.io.IOException;
-
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ABoolean;
-import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
-import org.apache.asterix.om.functions.IFunctionDescriptor;
-import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.BuiltinType;
-import org.apache.asterix.om.types.EnumDeserializer;
-import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
-import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
-import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
-import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
-import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.data.std.api.IPointable;
-import org.apache.hyracks.data.std.primitive.BooleanPointable;
-import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
-import org.apache.hyracks.data.std.primitive.VoidPointable;
-import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
-import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
-
-/**
- * Checks whether a string with an edit distance threshold can be filtered with a lower bounding on number of common grams.
- * This function returns 'true' if the lower bound on the number of common grams is positive, 'false' otherwise.
- * For example, this function is used during an indexed nested-loop join based on edit distance. We partition the tuples of the probing
- * dataset into those that are filterable and those that are not. Those that are filterable are forwarded to the index. The others are
- * are fed into a (non indexed) nested-loop join.
- */
-public class EditDistanceStringIsFilterable extends AbstractScalarFunctionDynamicDescriptor {
-
- private static final long serialVersionUID = 1L;
- public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
- @Override
- public IFunctionDescriptor createFunctionDescriptor() {
- return new EditDistanceStringIsFilterable();
- }
- };
-
- @Override
- public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
- throws AlgebricksException {
- return new IScalarEvaluatorFactory() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
- return new EditDistanceStringIsFilterableEvaluator(args, ctx);
- }
- };
- }
-
- @Override
- public FunctionIdentifier getIdentifier() {
- return AsterixBuiltinFunctions.EDIT_DISTANCE_STRING_IS_FILTERABLE;
- }
-
- private static class EditDistanceStringIsFilterableEvaluator implements IScalarEvaluator {
-
- protected final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
- protected final DataOutput output = resultStorage.getDataOutput();
- protected final IPointable argPtr = new VoidPointable();
-
- protected final IScalarEvaluator stringEval;
- protected final IScalarEvaluator edThreshEval;
- protected final IScalarEvaluator gramLenEval;
- protected final IScalarEvaluator usePrePostEval;
-
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ABoolean> booleanSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ABOOLEAN);
-
- private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
-
- public EditDistanceStringIsFilterableEvaluator(IScalarEvaluatorFactory[] args, IHyracksTaskContext context)
- throws AlgebricksException {
- stringEval = args[0].createScalarEvaluator(context);
- edThreshEval = args[1].createScalarEvaluator(context);
- gramLenEval = args[2].createScalarEvaluator(context);
- usePrePostEval = args[3].createScalarEvaluator(context);
- }
-
- @Override
- public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
- resultStorage.reset();
- ATypeTag typeTag = null;
-
- // Check type and compute string length.
- stringEval.evaluate(tuple, argPtr);
- typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argPtr.getByteArray()[argPtr.getStartOffset()]);
- if (!typeTag.equals(ATypeTag.STRING)) {
- throw new AlgebricksException(AsterixBuiltinFunctions.EDIT_DISTANCE_STRING_IS_FILTERABLE.getName()
- + ": expects input type STRING as first argument, but got " + typeTag + ".");
- }
-
- utf8Ptr.set(argPtr.getByteArray(), argPtr.getStartOffset() + 1, argPtr.getLength());
- int strLen = utf8Ptr.getStringLength();
-
- // Check type and extract edit-distance threshold.
- edThreshEval.evaluate(tuple, argPtr);
- typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argPtr.getByteArray()[argPtr.getStartOffset()]);
-
- long edThresh = 0;
-
- try {
- edThresh = ATypeHierarchy.getIntegerValue(argPtr.getByteArray(), argPtr.getStartOffset());
- } catch (HyracksDataException e1) {
- throw new AlgebricksException(e1);
- }
-
- // Check type and extract gram length.
- gramLenEval.evaluate(tuple, argPtr);
- typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argPtr.getByteArray()[argPtr.getStartOffset()]);
-
- long gramLen = 0;
- try {
- gramLen = ATypeHierarchy.getIntegerValue(argPtr.getByteArray(), argPtr.getStartOffset());
- } catch (HyracksDataException e1) {
- throw new AlgebricksException(e1);
- }
-
- // Check type and extract usePrePost flag.
- usePrePostEval.evaluate(tuple, argPtr);
- typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(argPtr.getByteArray()[argPtr.getStartOffset()]);
- if (!typeTag.equals(ATypeTag.BOOLEAN)) {
- throw new AlgebricksException(AsterixBuiltinFunctions.EDIT_DISTANCE_STRING_IS_FILTERABLE.getName()
- + ": expects input type BOOLEAN as fourth argument, but got " + typeTag + ".");
- }
- boolean usePrePost = BooleanPointable.getBoolean(argPtr.getByteArray(), argPtr.getStartOffset() + 1);
-
- // Compute result.
- long numGrams = (usePrePost) ? strLen + gramLen - 1 : strLen - gramLen + 1;
- long lowerBound = numGrams - edThresh * gramLen;
- try {
- if (lowerBound <= 0 || strLen == 0) {
- booleanSerde.serialize(ABoolean.FALSE, output);
- } else {
- booleanSerde.serialize(ABoolean.TRUE, output);
- }
- } catch (IOException e) {
- throw new AlgebricksException(e);
- }
- result.set(resultStorage);
- }
- }
-}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EditDistanceStringIsFilterableDescriptor.java
similarity index 69%
copy from asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java
copy to asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EditDistanceStringIsFilterableDescriptor.java
index 0bfa5a8..8944453 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EditDistanceStringIsFilterableDescriptor.java
@@ -21,57 +21,46 @@
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
-import org.apache.asterix.om.types.IAType;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.data.std.api.IPointable;
-import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
-public class EmbedTypeDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+/**
+ * Checks whether a string with an edit distance threshold can be filtered with a lower bounding
+ * on number of common grams. This function returns 'true' if the lower bound on the number of
+ * common grams is positive, 'false' otherwise. For example, this function is used during an indexed
+ * nested-loop join based on edit distance. We partition the tuples of the probing dataset into those
+ * that are filterable and those that are not. Those that are filterable are forwarded to the index.
+ * The others are fed into a (non indexed) nested-loop join.
+ */
+public class EditDistanceStringIsFilterableDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private static final long serialVersionUID = 1L;
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
@Override
public IFunctionDescriptor createFunctionDescriptor() {
- return new EmbedTypeDescriptor();
+ return new EditDistanceStringIsFilterableDescriptor();
}
};
- @SuppressWarnings("unused")
- private IAType fieldType;
-
- public void reset(IAType fieldType) {
- this.fieldType = fieldType;
- }
-
@Override
- public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
+ public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
+ throws AlgebricksException {
return new IScalarEvaluatorFactory() {
-
private static final long serialVersionUID = 1L;
@Override
public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
- // TODO Auto-generated method stub
- return new IScalarEvaluator() {
-
- @Override
- public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
- // TODO Auto-generated method stub
-
- }
- };
+ return new EditDistanceStringIsFilterableEvaluator(args, ctx);
}
};
}
@Override
public FunctionIdentifier getIdentifier() {
- return AsterixBuiltinFunctions.EMBED_TYPE;
+ return AsterixBuiltinFunctions.EDIT_DISTANCE_STRING_IS_FILTERABLE;
}
-
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EditDistanceStringIsFilterableEvaluator.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EditDistanceStringIsFilterableEvaluator.java
new file mode 100644
index 0000000..595a85a
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EditDistanceStringIsFilterableEvaluator.java
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.evaluators.functions;
+
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import org.apache.asterix.om.base.ABoolean;
+import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.BuiltinType;
+import org.apache.asterix.om.types.EnumDeserializer;
+import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.data.std.api.IPointable;
+import org.apache.hyracks.data.std.primitive.BooleanPointable;
+import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
+import org.apache.hyracks.data.std.primitive.VoidPointable;
+import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public class EditDistanceStringIsFilterableEvaluator implements IScalarEvaluator {
+
+ protected final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
+ protected final DataOutput output = resultStorage.getDataOutput();
+ protected final IPointable stringPtr = new VoidPointable();
+ protected final IPointable edThreshPtr = new VoidPointable();
+ protected final IPointable gramLenPtr = new VoidPointable();
+ protected final IPointable usePrePostPtr = new VoidPointable();
+
+ protected final IScalarEvaluator stringEval;
+ protected final IScalarEvaluator edThreshEval;
+ protected final IScalarEvaluator gramLenEval;
+ protected final IScalarEvaluator usePrePostEval;
+
+ @SuppressWarnings("unchecked")
+ private final ISerializerDeserializer<ABoolean> booleanSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ABOOLEAN);
+
+ private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
+
+ public EditDistanceStringIsFilterableEvaluator(IScalarEvaluatorFactory[] args, IHyracksTaskContext context)
+ throws AlgebricksException {
+ stringEval = args[0].createScalarEvaluator(context);
+ edThreshEval = args[1].createScalarEvaluator(context);
+ gramLenEval = args[2].createScalarEvaluator(context);
+ usePrePostEval = args[3].createScalarEvaluator(context);
+ }
+
+ @Override
+ public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+ resultStorage.reset();
+
+ stringEval.evaluate(tuple, stringPtr);
+ edThreshEval.evaluate(tuple, edThreshPtr);
+ gramLenEval.evaluate(tuple, gramLenPtr);
+ usePrePostEval.evaluate(tuple, usePrePostPtr);
+
+ // Check type and compute string length.
+ ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(stringPtr.getByteArray()[stringPtr.getStartOffset()]);
+ if (!typeTag.equals(ATypeTag.STRING)) {
+ throw new AlgebricksException(AsterixBuiltinFunctions.EDIT_DISTANCE_STRING_IS_FILTERABLE.getName()
+ + ": expects input type STRING as first argument, but got " + typeTag + ".");
+ }
+ utf8Ptr.set(stringPtr.getByteArray(), stringPtr.getStartOffset() + 1, stringPtr.getLength());
+ int strLen = utf8Ptr.getStringLength();
+
+ // Check type and extract edit-distance threshold.
+ long edThresh = 0;
+ try {
+ edThresh = ATypeHierarchy.getIntegerValue(edThreshPtr.getByteArray(), edThreshPtr.getStartOffset());
+ } catch (HyracksDataException e1) {
+ throw new AlgebricksException(e1);
+ }
+
+ // Check type and extract gram length.
+ long gramLen = 0;
+ try {
+ gramLen = ATypeHierarchy.getIntegerValue(gramLenPtr.getByteArray(), gramLenPtr.getStartOffset());
+ } catch (HyracksDataException e1) {
+ throw new AlgebricksException(e1);
+ }
+
+ // Check type and extract usePrePost flag.
+ typeTag = EnumDeserializer.ATYPETAGDESERIALIZER
+ .deserialize(usePrePostPtr.getByteArray()[usePrePostPtr.getStartOffset()]);
+ if (!typeTag.equals(ATypeTag.BOOLEAN)) {
+ throw new AlgebricksException(AsterixBuiltinFunctions.EDIT_DISTANCE_STRING_IS_FILTERABLE.getName()
+ + ": expects input type BOOLEAN as fourth argument, but got " + typeTag + ".");
+ }
+ boolean usePrePost = BooleanPointable.getBoolean(usePrePostPtr.getByteArray(),
+ usePrePostPtr.getStartOffset() + 1);
+
+ // Compute result.
+ long numGrams = usePrePost ? strLen + gramLen - 1 : strLen - gramLen + 1;
+ long lowerBound = numGrams - edThresh * gramLen;
+ try {
+ if (lowerBound <= 0 || strLen == 0) {
+ booleanSerde.serialize(ABoolean.FALSE, output);
+ } else {
+ booleanSerde.serialize(ABoolean.TRUE, output);
+ }
+ } catch (IOException e) {
+ throw new AlgebricksException(e);
+ }
+ result.set(resultStorage);
+ }
+}
\ No newline at end of file
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/FlowRecordDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/FlowRecordDescriptor.java
deleted file mode 100644
index 5c9d8ef..0000000
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/FlowRecordDescriptor.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.asterix.runtime.evaluators.functions;
-
-import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
-import org.apache.asterix.om.functions.IFunctionDescriptor;
-import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
-import org.apache.asterix.om.pointables.PointableAllocator;
-import org.apache.asterix.om.pointables.base.IVisitablePointable;
-import org.apache.asterix.om.types.ARecordType;
-import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
-import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
-import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
-import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.data.std.api.IPointable;
-import org.apache.hyracks.data.std.primitive.VoidPointable;
-import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
-
-public class FlowRecordDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
- public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
- @Override
- public IFunctionDescriptor createFunctionDescriptor() {
- return new FlowRecordDescriptor();
- }
- };
-
- private static final long serialVersionUID = 1L;
- private ARecordType inputType;
-
- public void reset(ARecordType inputType) {
- this.inputType = inputType;
- }
-
- @Override
- public FunctionIdentifier getIdentifier() {
- return AsterixBuiltinFunctions.FLOW_RECORD;
- }
-
- @Override
- public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
- final IScalarEvaluatorFactory recordEvalFactory = args[0];
-
- return new IScalarEvaluatorFactory() {
- private static final long serialVersionUID = 1L;
-
- @Override
- public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
- final IPointable recordPtr = new VoidPointable();
- final IScalarEvaluator recEvaluator = recordEvalFactory.createScalarEvaluator(ctx);
-
- return new IScalarEvaluator() {
- // pointable allocator
- private PointableAllocator allocator = new PointableAllocator();
- final IVisitablePointable recAccessor = allocator.allocateRecordValue(inputType);
-
- @Override
- public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
- try {
- recEvaluator.evaluate(tuple, recordPtr);
- recAccessor.set(recordPtr);
- result.set(recAccessor);
- } catch (Exception ioe) {
- throw new AlgebricksException(ioe);
- }
- }
- };
- }
- };
- }
-
-}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/FuzzyEqDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/FuzzyEqDescriptor.java
deleted file mode 100644
index eaa6028..0000000
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/FuzzyEqDescriptor.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.runtime.evaluators.functions;
-
-import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
-import org.apache.asterix.om.functions.IFunctionDescriptor;
-import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
-import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.common.exceptions.NotImplementedException;
-import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
-import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
-
-public class FuzzyEqDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
- private static final long serialVersionUID = 1L;
- public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
- public IFunctionDescriptor createFunctionDescriptor() {
- return new FuzzyEqDescriptor();
- }
- };
-
- @Override
- public IScalarEvaluatorFactory createEvaluatorFactory(IScalarEvaluatorFactory[] args) throws AlgebricksException {
- throw new NotImplementedException();
- }
-
- @Override
- public FunctionIdentifier getIdentifier() {
- return AsterixBuiltinFunctions.FUZZY_EQ;
- }
-
-}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/GetItemDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/GetItemDescriptor.java
index 020336f..88b8a51 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/GetItemDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/GetItemDescriptor.java
@@ -85,7 +85,7 @@
private IPointable inputArgIdx = new VoidPointable();
private IScalarEvaluator evalList = listEvalFactory.createScalarEvaluator(ctx);
private IScalarEvaluator evalIdx = indexEvalFactory.createScalarEvaluator(ctx);
- private byte[] nullBytes = new byte[] { ATypeTag.SERIALIZED_NULL_TYPE_TAG };
+ private byte[] missingBytes = new byte[] { ATypeTag.SERIALIZED_MISSING_TYPE_TAG };
private int itemIndex;
private int itemOffset;
private int itemLength;
@@ -102,11 +102,6 @@
byte[] indexBytes = inputArgIdx.getByteArray();
int indexOffset = inputArgIdx.getStartOffset();
- if (serOrderedList[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- result.set(nullBytes, 0, 1);
- return;
- }
-
if (serOrderedList[offset] == ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG) {
itemIndex = ATypeHierarchy.getIntegerValue(indexBytes, indexOffset);
} else {
@@ -118,14 +113,12 @@
+ ").");
}
- if (itemIndex >= AOrderedListSerializerDeserializer.getNumberOfItems(serOrderedList, offset)) {
- result.set(nullBytes, 0, 1);
+ if (itemIndex < 0 || itemIndex >= AOrderedListSerializerDeserializer
+ .getNumberOfItems(serOrderedList, offset)) {
+ // Out-of-bound index access should return MISSING.
+ result.set(missingBytes, 0, 1);
return;
}
- if (itemIndex < 0) {
- throw new AlgebricksException(
- AsterixBuiltinFunctions.GET_ITEM.getName() + ": item index cannot be negative!");
- }
itemTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serOrderedList[offset + 1]);
if (itemTag == ATypeTag.ANY) {
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsMissingDescriptor.java
similarity index 70%
rename from asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java
rename to asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsMissingDescriptor.java
index 0bfa5a8..45c3f6d 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsMissingDescriptor.java
@@ -21,48 +21,38 @@
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
-import org.apache.asterix.om.types.IAType;
+import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import org.apache.asterix.runtime.evaluators.common.AbstractTypeCheckEvaluator;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.data.std.api.IPointable;
-import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
-public class EmbedTypeDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
+public class IsMissingDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private static final long serialVersionUID = 1L;
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
@Override
public IFunctionDescriptor createFunctionDescriptor() {
- return new EmbedTypeDescriptor();
+ return new IsMissingDescriptor();
}
};
- @SuppressWarnings("unused")
- private IAType fieldType;
-
- public void reset(IAType fieldType) {
- this.fieldType = fieldType;
- }
-
@Override
- public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
+ public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
+ throws AlgebricksException {
return new IScalarEvaluatorFactory() {
-
private static final long serialVersionUID = 1L;
@Override
- public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
- // TODO Auto-generated method stub
- return new IScalarEvaluator() {
+ public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
+ final IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
+ return new AbstractTypeCheckEvaluator(eval) {
@Override
- public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
- // TODO Auto-generated method stub
-
+ protected boolean isMatch(byte typeTag) {
+ return typeTag == ATypeTag.SERIALIZED_MISSING_TYPE_TAG;
}
};
}
@@ -71,7 +61,7 @@
@Override
public FunctionIdentifier getIdentifier() {
- return AsterixBuiltinFunctions.EMBED_TYPE;
+ return AsterixBuiltinFunctions.IS_MISSING;
}
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsNullDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsNullDescriptor.java
index a528dae..3ae3bd9 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsNullDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsNullDescriptor.java
@@ -18,25 +18,17 @@
*/
package org.apache.asterix.runtime.evaluators.functions;
-import java.io.DataOutput;
-
-import org.apache.asterix.dataflow.data.nontagged.serde.AObjectSerializerDeserializer;
-import org.apache.asterix.om.base.ABoolean;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import org.apache.asterix.runtime.evaluators.common.AbstractTypeCheckEvaluator;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.data.std.api.IPointable;
-import org.apache.hyracks.data.std.primitive.VoidPointable;
-import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
-import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
public class IsNullDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private static final long serialVersionUID = 1L;
@@ -51,32 +43,16 @@
public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
throws AlgebricksException {
return new IScalarEvaluatorFactory() {
-
private static final long serialVersionUID = 1L;
@Override
public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
- return new IScalarEvaluator() {
-
- private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
- private DataOutput out = resultStorage.getDataOutput();
- private IPointable argPtr = new VoidPointable();
- private IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
- private final AObjectSerializerDeserializer aObjSerDer = AObjectSerializerDeserializer.INSTANCE;
+ final IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
+ return new AbstractTypeCheckEvaluator(eval) {
@Override
- public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
- eval.evaluate(tuple, argPtr);
- boolean isNull = argPtr.getByteArray()[argPtr
- .getStartOffset()] == ATypeTag.SERIALIZED_NULL_TYPE_TAG;
- ABoolean res = isNull ? ABoolean.TRUE : ABoolean.FALSE;
- try {
- resultStorage.reset();
- aObjSerDer.serialize(res, out);
- result.set(resultStorage);
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
- }
+ protected boolean isMatch(byte typeTag) {
+ return typeTag == ATypeTag.SERIALIZED_NULL_TYPE_TAG;
}
};
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsUnknownDescriptor.java
similarity index 70%
copy from asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java
copy to asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsUnknownDescriptor.java
index 0bfa5a8..be04c86 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/EmbedTypeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/IsUnknownDescriptor.java
@@ -21,48 +21,39 @@
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
-import org.apache.asterix.om.types.IAType;
+import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
+import org.apache.asterix.runtime.evaluators.common.AbstractTypeCheckEvaluator;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.data.std.api.IPointable;
-import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
-public class EmbedTypeDescriptor extends AbstractScalarFunctionDynamicDescriptor {
-
+public class IsUnknownDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private static final long serialVersionUID = 1L;
public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
@Override
public IFunctionDescriptor createFunctionDescriptor() {
- return new EmbedTypeDescriptor();
+ return new IsUnknownDescriptor();
}
};
- @SuppressWarnings("unused")
- private IAType fieldType;
-
- public void reset(IAType fieldType) {
- this.fieldType = fieldType;
- }
-
@Override
- public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args) {
+ public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
+ throws AlgebricksException {
return new IScalarEvaluatorFactory() {
-
private static final long serialVersionUID = 1L;
@Override
- public IScalarEvaluator createScalarEvaluator(IHyracksTaskContext ctx) throws AlgebricksException {
- // TODO Auto-generated method stub
- return new IScalarEvaluator() {
+ public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
+ final IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
+ return new AbstractTypeCheckEvaluator(eval) {
@Override
- public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
- // TODO Auto-generated method stub
-
+ protected boolean isMatch(byte typeTag) {
+ return typeTag == ATypeTag.SERIALIZED_NULL_TYPE_TAG
+ || typeTag == ATypeTag.SERIALIZED_MISSING_TYPE_TAG;
}
};
}
@@ -71,7 +62,7 @@
@Override
public FunctionIdentifier getIdentifier() {
- return AsterixBuiltinFunctions.EMBED_TYPE;
+ return AsterixBuiltinFunctions.IS_UNKOWN;
}
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/LenDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/LenDescriptor.java
index d42d96f..c681d78 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/LenDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/LenDescriptor.java
@@ -26,7 +26,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AInt64;
import org.apache.asterix.om.base.AMutableInt64;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -40,7 +39,6 @@
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
@@ -77,9 +75,6 @@
@SuppressWarnings("unchecked")
private final ISerializerDeserializer<AInt64> int64Serde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT64);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
@@ -88,16 +83,6 @@
byte[] serList = inputVal.getByteArray();
int offset = inputVal.getStartOffset();
- if (serList[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- try {
- nullSerde.serialize(ANull.NULL, out);
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
- }
- result.set(resultStorage);
- return;
- }
-
if (serList[offset] != ATypeTag.SERIALIZED_ORDEREDLIST_TYPE_TAG
&& serList[offset] != ATypeTag.SERIALIZED_UNORDEREDLIST_TYPE_TAG) {
throw new AlgebricksException(AsterixBuiltinFunctions.LEN.getName()
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NotDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NotDescriptor.java
index f05c2ed..fb209a9 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NotDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NotDescriptor.java
@@ -23,7 +23,6 @@
import org.apache.asterix.dataflow.data.nontagged.serde.ABooleanSerializerDeserializer;
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ABoolean;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -77,9 +76,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ABoolean> booleanSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ABOOLEAN);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
@@ -94,8 +90,6 @@
boolean argRes = ABooleanSerializerDeserializer.getBoolean(bytes, offset + 1);
ABoolean aResult = argRes ? (ABoolean.FALSE) : (ABoolean.TRUE);
booleanSerde.serialize(aResult, out);
- } else if (bytes[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException(errorMessage);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericAbsDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericAbsDescriptor.java
index 47c78d6..373547e 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericAbsDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericAbsDescriptor.java
@@ -38,7 +38,6 @@
import org.apache.asterix.om.base.AMutableInt32;
import org.apache.asterix.om.base.AMutableInt64;
import org.apache.asterix.om.base.AMutableInt8;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -105,11 +104,7 @@
int offset = argPtr.getStartOffset();
try {
- if (data[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- serde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
- serde.serialize(ANull.NULL, out);
- } else if (data[offset] == ATypeTag.SERIALIZED_INT8_TYPE_TAG) {
+ if (data[offset] == ATypeTag.SERIALIZED_INT8_TYPE_TAG) {
serde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT8);
byte val = AInt8SerializerDeserializer.getByte(data, offset + 1);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericFloorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericFloorDescriptor.java
index 0c6aae9..336bf15 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericFloorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericFloorDescriptor.java
@@ -38,7 +38,6 @@
import org.apache.asterix.om.base.AMutableInt32;
import org.apache.asterix.om.base.AMutableInt64;
import org.apache.asterix.om.base.AMutableInt8;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -105,11 +104,7 @@
int offset = argPtr.getStartOffset();
try {
- if (data[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- serde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
- serde.serialize(ANull.NULL, out);
- } else if (data[offset] == ATypeTag.SERIALIZED_INT8_TYPE_TAG) {
+ if (data[offset] == ATypeTag.SERIALIZED_INT8_TYPE_TAG) {
serde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT8);
byte val = AInt8SerializerDeserializer.getByte(data, offset + 1);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericModuloDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericModuloDescriptor.java
index 1bc936c..d40cb70 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericModuloDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericModuloDescriptor.java
@@ -33,7 +33,6 @@
import org.apache.asterix.om.base.AMutableInt32;
import org.apache.asterix.om.base.AMutableInt64;
import org.apache.asterix.om.base.AMutableInt8;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -84,8 +83,8 @@
return new IScalarEvaluator() {
private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
private DataOutput out = resultStorage.getDataOutput();
- // one temp. buffer re-used by both children
- private IPointable argPtr = new VoidPointable();
+ private IPointable leftPtr = new VoidPointable();
+ private IPointable rightPtr = new VoidPointable();
private IScalarEvaluator evalLeft = args[0].createScalarEvaluator(ctx);
private IScalarEvaluator evalRight = args[1].createScalarEvaluator(ctx);
private double[] operands = new double[args.length];
@@ -107,12 +106,10 @@
try {
resultStorage.reset();
+ evalLeft.evaluate(tuple, leftPtr);
+ evalRight.evaluate(tuple, rightPtr);
for (int i = 0; i < args.length; i++) {
- if (i == 0) {
- evalLeft.evaluate(tuple, argPtr);
- } else {
- evalRight.evaluate(tuple, argPtr);
- }
+ IPointable argPtr = i == 0 ? leftPtr : rightPtr;
byte[] data = argPtr.getByteArray();
int offset = argPtr.getStartOffset();
typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(data[offset]);
@@ -147,13 +144,6 @@
operands[i] = ADoubleSerializerDeserializer.getDouble(data, offset + 1);
break;
}
- case NULL: {
- serde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
- serde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
default: {
throw new NotImplementedException(AsterixBuiltinFunctions.NUMERIC_MOD.getName()
+ (i == 0 ? ": left" : ": right") + " operand can not be "
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericRoundDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericRoundDescriptor.java
index b05ff65..773ba27 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericRoundDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericRoundDescriptor.java
@@ -38,7 +38,6 @@
import org.apache.asterix.om.base.AMutableInt32;
import org.apache.asterix.om.base.AMutableInt64;
import org.apache.asterix.om.base.AMutableInt8;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -105,11 +104,7 @@
int offset = argPtr.getStartOffset();
try {
- if (data[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- serde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
- serde.serialize(ANull.NULL, out);
- } else if (data[offset] == ATypeTag.SERIALIZED_INT8_TYPE_TAG) {
+ if (data[offset] == ATypeTag.SERIALIZED_INT8_TYPE_TAG) {
serde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT8);
byte val = AInt8SerializerDeserializer.getByte(data, offset + 1);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericRoundHalfToEven2Descriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericRoundHalfToEven2Descriptor.java
index a1acb14..d39478d 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericRoundHalfToEven2Descriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericRoundHalfToEven2Descriptor.java
@@ -39,7 +39,6 @@
import org.apache.asterix.om.base.AMutableInt32;
import org.apache.asterix.om.base.AMutableInt64;
import org.apache.asterix.om.base.AMutableInt8;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -87,7 +86,8 @@
private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
private DataOutput out = resultStorage.getDataOutput();
- private IPointable argPtr = new VoidPointable();
+ private IPointable argValue = new VoidPointable();
+ private IPointable argPrecision = new VoidPointable();
private IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
private IScalarEvaluator precision = args[1].createScalarEvaluator(ctx);
private AMutableDouble aDouble = new AMutableDouble(0);
@@ -99,11 +99,9 @@
@SuppressWarnings("rawtypes")
private ISerializerDeserializer serde;
- private int getPrecision(IFrameTupleReference tuple) throws AlgebricksException {
- resultStorage.reset();
- precision.evaluate(tuple, argPtr);
- byte[] bytes = argPtr.getByteArray();
- int offset = argPtr.getStartOffset();
+ private int getPrecision() throws AlgebricksException {
+ byte[] bytes = argPrecision.getByteArray();
+ int offset = argPrecision.getStartOffset();
if (bytes[offset] == ATypeTag.SERIALIZED_INT8_TYPE_TAG) {
return AInt8SerializerDeserializer.getByte(bytes, offset + 1);
@@ -123,16 +121,13 @@
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
resultStorage.reset();
- eval.evaluate(tuple, argPtr);
- byte[] data = argPtr.getByteArray();
- int offset = argPtr.getStartOffset();
+ eval.evaluate(tuple, argValue);
+ precision.evaluate(tuple, argPrecision);
+ byte[] data = argValue.getByteArray();
+ int offset = argValue.getStartOffset();
try {
- if (data[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- serde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
- serde.serialize(ANull.NULL, out);
- } else if (data[offset] == ATypeTag.SERIALIZED_INT8_TYPE_TAG) {
+ if (data[offset] == ATypeTag.SERIALIZED_INT8_TYPE_TAG) {
serde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT8);
byte val = AInt8SerializerDeserializer.getByte(data, offset + 1);
@@ -166,7 +161,7 @@
} else {
BigDecimal r = new BigDecimal(Float.toString(val));
aFloat.setValue(
- r.setScale(getPrecision(tuple), BigDecimal.ROUND_HALF_EVEN).floatValue());
+ r.setScale(getPrecision(), BigDecimal.ROUND_HALF_EVEN).floatValue());
serde.serialize(aFloat, out);
}
} else if (data[offset] == ATypeTag.SERIALIZED_DOUBLE_TYPE_TAG) {
@@ -179,7 +174,7 @@
} else {
BigDecimal r = new BigDecimal(Double.toString(val));
aDouble.setValue(
- r.setScale(getPrecision(tuple), BigDecimal.ROUND_HALF_EVEN).doubleValue());
+ r.setScale(getPrecision(), BigDecimal.ROUND_HALF_EVEN).doubleValue());
serde.serialize(aDouble, out);
}
} else {
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericRoundHalfToEvenDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericRoundHalfToEvenDescriptor.java
index 0d18b24..575035e 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericRoundHalfToEvenDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericRoundHalfToEvenDescriptor.java
@@ -38,7 +38,6 @@
import org.apache.asterix.om.base.AMutableInt32;
import org.apache.asterix.om.base.AMutableInt64;
import org.apache.asterix.om.base.AMutableInt8;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -105,13 +104,7 @@
int offset = argPtr.getStartOffset();
try {
- if (data[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- serde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
- serde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- } else if (data[offset] == ATypeTag.SERIALIZED_INT8_TYPE_TAG) {
+ if (data[offset] == ATypeTag.SERIALIZED_INT8_TYPE_TAG) {
serde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT8);
byte val = AInt8SerializerDeserializer.getByte(data, offset + 1);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericSubtractDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericSubtractDescriptor.java
index b850f91..4355be0 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericSubtractDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericSubtractDescriptor.java
@@ -33,7 +33,6 @@
import org.apache.asterix.om.base.AMutableInt32;
import org.apache.asterix.om.base.AMutableInt64;
import org.apache.asterix.om.base.AMutableInt8;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -143,13 +142,6 @@
operands[i] = ADoubleSerializerDeserializer.getDouble(data, offset + 1);
break;
}
- case NULL: {
- serde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
- serde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
default: {
throw new NotImplementedException(AsterixBuiltinFunctions.NUMERIC_SUBTRACT
.getName() + (i == 0 ? ": left" : ": right") + " operand can not be "
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericUnaryMinusDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericUnaryMinusDescriptor.java
index 50e657d..422ab49 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericUnaryMinusDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/NumericUnaryMinusDescriptor.java
@@ -33,7 +33,6 @@
import org.apache.asterix.om.base.AMutableInt32;
import org.apache.asterix.om.base.AMutableInt64;
import org.apache.asterix.om.base.AMutableInt8;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -96,11 +95,7 @@
int offset = argPtr.getStartOffset();
try {
- if (data[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- serde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
- serde.serialize(ANull.NULL, out);
- } else if (data[offset] == ATypeTag.SERIALIZED_INT8_TYPE_TAG) {
+ if (data[offset] == ATypeTag.SERIALIZED_INT8_TYPE_TAG) {
serde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT8);
aInt8.setValue((byte) -AInt8SerializerDeserializer.getByte(data, offset + 1));
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/OrDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/OrDescriptor.java
index cbf4dcc..a98f4bb 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/OrDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/OrDescriptor.java
@@ -23,6 +23,7 @@
import org.apache.asterix.dataflow.data.nontagged.serde.ABooleanSerializerDeserializer;
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ABoolean;
+import org.apache.asterix.om.base.AMissing;
import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
@@ -80,6 +81,9 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
+ @SuppressWarnings("unchecked")
+ private ISerializerDeserializer<AMissing> missingSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.AMISSING);
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
@@ -88,29 +92,37 @@
int n = args.length;
boolean res = false;
boolean metNull = false;
+ boolean metMissing = false;
for (int i = 0; i < n; i++) {
evals[i].evaluate(tuple, argPtr);
byte[] data = argPtr.getByteArray();
int offset = argPtr.getStartOffset();
+ if (data[offset] == ATypeTag.SERIALIZED_MISSING_TYPE_TAG) {
+ metMissing = true;
+ continue;
+ }
if (data[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
metNull = true;
continue;
}
boolean argResult = ABooleanSerializerDeserializer.getBoolean(data, offset + 1);
if (argResult == true) {
- res = true;
- break;
+ // anything OR TRUE = TRUE
+ booleanSerde.serialize(ABoolean.TRUE, output);
+ result.set(resultStorage);
+ return;
}
+ res |= argResult;
}
if (metNull) {
- if (!res) {
- ABoolean aResult = ABoolean.FALSE;
- booleanSerde.serialize(aResult, output);
- } else {
- nullSerde.serialize(ANull.NULL, output);
- }
+ // NULL OR FALSE = NULL
+ // NULL OR MISSING = NULL
+ nullSerde.serialize(ANull.NULL, output);
+ } else if (metMissing) {
+ // MISSING OR FALSE = MISSING
+ missingSerde.serialize(AMissing.MISSING, output);
} else {
- ABoolean aResult = res ? (ABoolean.TRUE) : (ABoolean.FALSE);
+ ABoolean aResult = res ? ABoolean.TRUE : ABoolean.FALSE;
booleanSerde.serialize(aResult, output);
}
result.set(resultStorage);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/PrefixLenJaccardDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/PrefixLenJaccardDescriptor.java
index 9a7017a..c9e5807 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/PrefixLenJaccardDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/PrefixLenJaccardDescriptor.java
@@ -70,7 +70,8 @@
private final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
private final DataOutput out = resultStorage.getDataOutput();
- private final IPointable inputVal = new VoidPointable();
+ private final IPointable lenPtr = new VoidPointable();
+ private final IPointable thresholdPtr = new VoidPointable();
private final IScalarEvaluator evalLen = args[0].createScalarEvaluator(ctx);
private final IScalarEvaluator evalThreshold = args[1].createScalarEvaluator(ctx);
@@ -86,19 +87,20 @@
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
resultStorage.reset();
+ evalLen.evaluate(tuple, lenPtr);
+ evalThreshold.evaluate(tuple, thresholdPtr);
+
// length
- evalLen.evaluate(tuple, inputVal);
int length = 0;
try {
- length = ATypeHierarchy.getIntegerValue(inputVal.getByteArray(), inputVal.getStartOffset());
+ length = ATypeHierarchy.getIntegerValue(lenPtr.getByteArray(), lenPtr.getStartOffset());
} catch (HyracksDataException e1) {
throw new AlgebricksException(e1);
}
// similarity threshold
- evalThreshold.evaluate(tuple, inputVal);
- byte[] data = inputVal.getByteArray();
- int offset = inputVal.getStartOffset();
+ byte[] data = thresholdPtr.getByteArray();
+ int offset = thresholdPtr.getStartOffset();
if (data[offset] != ATypeTag.SERIALIZED_FLOAT_TYPE_TAG) {
throw new AlgebricksException(AsterixBuiltinFunctions.PREFIX_LEN_JACCARD.getName()
+ ": expects type FLOAT the first argument but got "
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/RegExpDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/RegExpDescriptor.java
index a0829fd..7b9ca73 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/RegExpDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/RegExpDescriptor.java
@@ -27,7 +27,6 @@
import org.apache.asterix.formats.nontagged.AqlBinaryComparatorFactoryProvider;
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ABoolean;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.AString;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
@@ -100,9 +99,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ABoolean> booleanSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ABOOLEAN);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private Matcher matcher;
private Pattern pattern;
@@ -112,15 +108,11 @@
// evaluate the pattern first
try {
evalPattern.evaluate(tuple, array0);
+ evalString.evaluate(tuple, array0);
+
byte[] patternBytes = array0.getByteArray();
int patternOffset = array0.getStartOffset();
int patternLen = array0.getLength();
-
- if (patternBytes[patternOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, dout);
- result.set(resultStorage);
- return;
- }
if (patternBytes[patternOffset] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
throw new AlgebricksException(AsterixBuiltinFunctions.REG_EXP.getName()
+ ": expects type STRING/NULL for the first input argument but got "
@@ -148,15 +140,9 @@
pattern = Pattern.compile(strPattern.getStringValue());
}
- evalString.evaluate(tuple, array0);
byte[] data = array0.getByteArray();
int offset = array0.getStartOffset();
int len = array0.getLength();
- if (data[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, dout);
- result.set(resultStorage);
- return;
- }
if (data[offset] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
throw new AlgebricksException(AsterixBuiltinFunctions.REG_EXP.getName()
+ ": expects type STRING/NULL for the second input argument but got "
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SpatialAreaDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SpatialAreaDescriptor.java
index 5d8f514..e31ad90 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SpatialAreaDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SpatialAreaDescriptor.java
@@ -26,13 +26,10 @@
import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import org.apache.asterix.dataflow.data.nontagged.serde.AInt16SerializerDeserializer;
import org.apache.asterix.dataflow.data.nontagged.serde.ARectangleSerializerDeserializer;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.asterix.runtime.evaluators.common.SpatialUtils;
@@ -42,7 +39,6 @@
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
@@ -74,10 +70,6 @@
private final IPointable argPtr = new VoidPointable();
private final IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
-
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
resultStorage.reset();
@@ -126,9 +118,6 @@
out.writeByte(ATypeTag.SERIALIZED_DOUBLE_TYPE_TAG);
out.writeDouble(area);
break;
- case NULL:
- nullSerde.serialize(ANull.NULL, out);
- break;
default:
throw new NotImplementedException(AsterixBuiltinFunctions.SPATIAL_AREA.getName()
+ ": does not support the type: " + tag
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SpatialCellDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SpatialCellDescriptor.java
index cb6d194..2208d6f 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SpatialCellDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SpatialCellDescriptor.java
@@ -27,7 +27,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AMutablePoint;
import org.apache.asterix.om.base.AMutableRectangle;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.ARectangle;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
@@ -81,9 +80,6 @@
private final AMutablePoint[] aPoint = { new AMutablePoint(0, 0), new AMutablePoint(0, 0) };
@SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
- @SuppressWarnings("unchecked")
private final ISerializerDeserializer<ARectangle> rectangleSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ARECTANGLE);
@@ -130,9 +126,6 @@
aPoint[1].setValue(x + xInc, y + yInc);
aRectangle.setValue(aPoint[0], aPoint[1]);
rectangleSerde.serialize(aRectangle, out);
- } else if (tag0 == ATypeTag.NULL || tag1 == ATypeTag.NULL || tag2 == ATypeTag.NULL
- || tag3 == ATypeTag.NULL) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new AlgebricksException(AsterixBuiltinFunctions.SPATIAL_CELL.getName()
+ ": expects input type: (POINT, POINT, DOUBLE, DOUBLE) but got ("
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SpatialDistanceDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SpatialDistanceDescriptor.java
index d7f260e..5c969b1 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SpatialDistanceDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SpatialDistanceDescriptor.java
@@ -24,13 +24,10 @@
import org.apache.asterix.dataflow.data.nontagged.Coordinate;
import org.apache.asterix.dataflow.data.nontagged.serde.ADoubleSerializerDeserializer;
import org.apache.asterix.dataflow.data.nontagged.serde.APointSerializerDeserializer;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -39,7 +36,6 @@
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
@@ -73,10 +69,6 @@
private final IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx);
private final IScalarEvaluator eval1 = args[1].createScalarEvaluator(ctx);
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
-
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
resultStorage.reset();
@@ -91,7 +83,7 @@
ATypeTag tag0 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[offset0]);
ATypeTag tag1 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]);
- double distance = 0.0;
+ double distance;
if (tag0 == ATypeTag.POINT) {
if (tag1 == ATypeTag.POINT) {
double x1 = ADoubleSerializerDeserializer.getDouble(bytes0,
@@ -108,8 +100,6 @@
+ ": does not support the type: " + tag1
+ "; it is only implemented for POINT.");
}
- } else if (tag0 == ATypeTag.NULL || tag1 == ATypeTag.NULL) {
- nullSerde.serialize(ANull.NULL, out);
} else {
throw new NotImplementedException(AsterixBuiltinFunctions.SPATIAL_DISTANCE.getName()
+ ": does not support the type: " + tag1
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SpatialIntersectDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SpatialIntersectDescriptor.java
index 626fe80..03ec9a6 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SpatialIntersectDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SpatialIntersectDescriptor.java
@@ -450,7 +450,7 @@
private boolean triangleTriangleIntersection(DoubleArray trianglesX0, DoubleArray trianglesY0,
int triangleId0, DoubleArray trianglesX1, DoubleArray trianglesY1, int triangleId1)
- throws HyracksDataException { // separating axis theorem
+ throws HyracksDataException { // separating axis theorem
for (int side = 0; side < 3; side++) {
spatialUtils.findNormals(trianglesX0, trianglesY0, triangleId0, side);
@@ -830,9 +830,6 @@
case RECTANGLE:
res = pointInRectangle(bytes0, offset0, bytes1, offset1);
break;
- case NULL:
- res = false;
- break;
default:
throw new NotImplementedException(AsterixBuiltinFunctions.SPATIAL_INTERSECT
.getName() + ": does not support the type: " + tag1
@@ -900,9 +897,6 @@
case RECTANGLE:
res = lineRectangleIntersection(bytes0, offset0, bytes1, offset1);
break;
- case NULL:
- res = false;
- break;
default:
throw new NotImplementedException(AsterixBuiltinFunctions.SPATIAL_INTERSECT
.getName() + ": does not support the type: " + tag1
@@ -993,9 +987,6 @@
case RECTANGLE:
res = rectanglePolygonIntersection(bytes1, offset1, bytes0, offset0);
break;
- case NULL:
- res = false;
- break;
default:
throw new NotImplementedException(AsterixBuiltinFunctions.SPATIAL_INTERSECT
.getName() + ": does not support the type: " + tag1
@@ -1019,9 +1010,6 @@
case RECTANGLE:
res = rectangleCircleIntersection(bytes1, offset1, bytes0, offset0);
break;
- case NULL:
- res = false;
- break;
default:
throw new NotImplementedException(AsterixBuiltinFunctions.SPATIAL_INTERSECT
.getName() + ": does not support the type: " + tag1
@@ -1069,18 +1057,12 @@
}
}
break;
- case NULL:
- res = false;
- break;
default:
throw new NotImplementedException(AsterixBuiltinFunctions.SPATIAL_INTERSECT
.getName() + ": does not support the type: " + tag1
+ "; it is only implemented for POINT, ALINE, POLYGON, and CIRCLE.");
}
break;
- case NULL:
- res = false;
- break;
default:
throw new NotImplementedException(AsterixBuiltinFunctions.SPATIAL_INTERSECT
.getName() + ": does not support the type: " + tag1
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/Substring2Descriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/Substring2Descriptor.java
index 8abda5f..f0c9fba 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/Substring2Descriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/Substring2Descriptor.java
@@ -63,7 +63,8 @@
private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
private DataOutput out = resultStorage.getDataOutput();
- private IPointable argPtr = new VoidPointable();
+ private IPointable argString = new VoidPointable();
+ private IPointable argStart = new VoidPointable();
private IScalarEvaluator evalString = args[0].createScalarEvaluator(ctx);
private IScalarEvaluator evalStart = args[1].createScalarEvaluator(ctx);
private final GrowableArray array = new GrowableArray();
@@ -73,22 +74,21 @@
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
resultStorage.reset();
- evalStart.evaluate(tuple, argPtr);
+ evalStart.evaluate(tuple, argStart);
+ evalString.evaluate(tuple, argString);
+
int start = 0;
-
- byte[] bytes = argPtr.getByteArray();
- int offset = argPtr.getStartOffset();
-
+ byte[] bytes = argStart.getByteArray();
+ int offset = argStart.getStartOffset();
try {
start = ATypeHierarchy.getIntegerValue(bytes, offset) - 1;
} catch (HyracksDataException e1) {
throw new AlgebricksException(e1);
}
- evalString.evaluate(tuple, argPtr);
- bytes = argPtr.getByteArray();
- offset = argPtr.getStartOffset();
- int len = argPtr.getLength();
+ bytes = argString.getByteArray();
+ offset = argString.getStartOffset();
+ int len = argString.getLength();
if (bytes[offset] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
throw new AlgebricksException(AsterixBuiltinFunctions.SUBSTRING2.getName()
+ ": expects type STRING for the first argument but got "
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringAfterDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringAfterDescriptor.java
index 32db2c2..23dbbec 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringAfterDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringAfterDescriptor.java
@@ -81,22 +81,14 @@
int patternOffset = array1.getStartOffset();
int patternLen = array1.getLength();
- if ((src[srcOffset] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
- && src[srcOffset] != ATypeTag.SERIALIZED_NULL_TYPE_TAG)
- || (pattern[patternOffset] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
- && pattern[patternOffset] != ATypeTag.SERIALIZED_NULL_TYPE_TAG)) {
+ if (src[srcOffset] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
+ || pattern[patternOffset] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
throw new AlgebricksException(AsterixBuiltinFunctions.SUBSTRING_AFTER.getName()
+ ": expects input type (STRING/NULL, STRING/NULL) but got ("
+ EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(src[srcOffset]) + ", "
+ EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(pattern[patternOffset]) + ").");
}
try {
- if (src[srcOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || pattern[patternOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- out.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
- result.set(resultStorage);
- return;
- }
stringPtr.set(src, srcOffset + 1, srcLen - 1);
patternPtr.set(pattern, patternOffset + 1, patternLen - 1);
array.reset();
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringBeforeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringBeforeDescriptor.java
index f418213..65aa34b 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringBeforeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringBeforeDescriptor.java
@@ -83,10 +83,8 @@
int patternOffset = array1.getStartOffset();
int patternLen = array1.getLength();
- if ((src[srcOffset] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
- && src[srcOffset] != ATypeTag.SERIALIZED_NULL_TYPE_TAG)
- || (pattern[patternOffset] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
- && pattern[patternOffset] != ATypeTag.SERIALIZED_NULL_TYPE_TAG)) {
+ if (src[srcOffset] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
+ || pattern[patternOffset] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
throw new AlgebricksException(AsterixBuiltinFunctions.SUBSTRING_BEFORE.getName()
+ ": expects input type (STRING/NULL, STRING/NULL) but got ("
+ EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(src[srcOffset]) + ", "
@@ -94,12 +92,6 @@
}
try {
- if (src[srcOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || pattern[patternOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- out.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
- result.set(resultStorage);
- return;
- }
stringPtr.set(src, srcOffset + 1, srcLen - 1);
patternPtr.set(pattern, patternOffset + 1, patternLen - 1);
array.reset();
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringDescriptor.java
index 660fbb8..e960b58 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/SubstringDescriptor.java
@@ -25,18 +25,15 @@
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.api.IPointable;
-import org.apache.hyracks.data.std.primitive.DoublePointable;
-import org.apache.hyracks.data.std.primitive.FloatPointable;
-import org.apache.hyracks.data.std.primitive.IntegerPointable;
-import org.apache.hyracks.data.std.primitive.LongPointable;
-import org.apache.hyracks.data.std.primitive.ShortPointable;
import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
@@ -67,7 +64,9 @@
private final ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
private final DataOutput out = resultStorage.getDataOutput();
- private final IPointable argPtr = new VoidPointable();
+ private IPointable argString = new VoidPointable();
+ private IPointable argStart = new VoidPointable();
+ private IPointable argLen = new VoidPointable();
private final IScalarEvaluator evalString = args[0].createScalarEvaluator(ctx);
private final IScalarEvaluator evalStart = args[1].createScalarEvaluator(ctx);
private final IScalarEvaluator evalLen = args[2].createScalarEvaluator(ctx);
@@ -79,81 +78,31 @@
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
resultStorage.reset();
- evalStart.evaluate(tuple, argPtr);
- byte[] bytes = argPtr.getByteArray();
- int offset = argPtr.getStartOffset();
+ evalString.evaluate(tuple, argString);
+ evalStart.evaluate(tuple, argStart);
+ evalLen.evaluate(tuple, argLen);
+
int start = 0;
-
- ATypeTag argPtrTypeTag = ATypeTag.VALUE_TYPE_MAPPING[bytes[offset]];
-
- switch (argPtrTypeTag) {
- case INT64:
- start = (int) LongPointable.getLong(bytes, offset + 1) - 1;
- break;
- case INT32:
- start = IntegerPointable.getInteger(bytes, offset + 1) - 1;
- break;
- case INT8:
- start = bytes[offset + 1] - 1;
- break;
- case INT16:
- start = ShortPointable.getShort(bytes, offset + 1) - 1;
- break;
- case FLOAT:
- start = (int) FloatPointable.getFloat(bytes, offset + 1) - 1;
- break;
- case DOUBLE:
- start = (int) DoublePointable.getDouble(bytes, offset + 1) - 1;
- break;
- default:
- throw new AlgebricksException(AsterixBuiltinFunctions.SUBSTRING.getName()
- + ": expects type INT8/16/32/64/FLOAT/DOUBLE for the second argument but got "
- + argPtrTypeTag);
+ byte[] bytes = argStart.getByteArray();
+ int offset = argStart.getStartOffset();
+ try {
+ start = ATypeHierarchy.getIntegerValue(bytes, offset) - 1;
+ } catch (HyracksDataException e1) {
+ throw new AlgebricksException(e1);
}
- evalLen.evaluate(tuple, argPtr);
- bytes = argPtr.getByteArray();
- offset = argPtr.getStartOffset();
int len = 0;
-
- argPtrTypeTag = ATypeTag.VALUE_TYPE_MAPPING[bytes[offset]];
-
- switch (argPtrTypeTag) {
- case INT64:
- len = (int) LongPointable.getLong(bytes, offset + 1);
- break;
- case INT32:
- len = IntegerPointable.getInteger(bytes, offset + 1);
- break;
- case INT8:
- len = bytes[offset + 1];
- break;
- case INT16:
- len = ShortPointable.getShort(bytes, offset + 1);
- break;
- case FLOAT:
- len = (int) FloatPointable.getFloat(bytes, offset + 1);
- break;
- case DOUBLE:
- len = (int) DoublePointable.getDouble(bytes, offset + 1);
- break;
- default:
- throw new AlgebricksException(AsterixBuiltinFunctions.SUBSTRING.getName()
- + ": expects type INT8/16/32/64/FLOAT/DOUBLE for the third argument but got "
- + argPtrTypeTag);
+ bytes = argLen.getByteArray();
+ offset = argLen.getStartOffset();
+ try {
+ len = ATypeHierarchy.getIntegerValue(bytes, offset);
+ } catch (HyracksDataException e1) {
+ throw new AlgebricksException(e1);
}
- evalString.evaluate(tuple, argPtr);
- bytes = argPtr.getByteArray();
- offset = argPtr.getStartOffset();
- int length = argPtr.getLength();
- argPtrTypeTag = ATypeTag.VALUE_TYPE_MAPPING[bytes[offset]];
-
- if (argPtrTypeTag != ATypeTag.STRING) {
- throw new AlgebricksException(AsterixBuiltinFunctions.SUBSTRING.getName()
- + ": expects type STRING for the first argument but got " + argPtrTypeTag);
- }
-
+ bytes = argString.getByteArray();
+ offset = argString.getStartOffset();
+ int length = argString.getLength();
string.set(bytes, offset + 1, length - 1);
array.reset();
try {
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractBinaryScalarEvaluator.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractBinaryScalarEvaluator.java
index e87c4eb..c12df6f 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractBinaryScalarEvaluator.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractBinaryScalarEvaluator.java
@@ -21,34 +21,25 @@
import java.io.DataOutput;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
-import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
public abstract class AbstractBinaryScalarEvaluator implements IScalarEvaluator {
- @SuppressWarnings("unchecked")
- protected ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
protected ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
protected DataOutput dataOutput = resultStorage.getDataOutput();
protected IPointable[] pointables;
protected IScalarEvaluator[] evaluators;
- public AbstractBinaryScalarEvaluator(final IHyracksTaskContext context, final IScalarEvaluatorFactory[] evaluatorFactories)
- throws AlgebricksException {
+ public AbstractBinaryScalarEvaluator(final IHyracksTaskContext context,
+ final IScalarEvaluatorFactory[] evaluatorFactories) throws AlgebricksException {
pointables = new IPointable[evaluatorFactories.length];
evaluators = new IScalarEvaluator[evaluatorFactories.length];
for (int i = 0; i < evaluators.length; ++i) {
@@ -57,27 +48,12 @@
}
}
- public ATypeTag evaluateTuple(IFrameTupleReference tuple, int id) throws AlgebricksException {
- evaluators[id].evaluate(tuple, pointables[id]);
- return ATypeTag.VALUE_TYPE_MAPPING[pointables[id].getByteArray()[pointables[id].getStartOffset()]];
- }
-
- public boolean serializeNullIfAnyNull(ATypeTag... tags) throws HyracksDataException {
- for (ATypeTag typeTag : tags) {
- if (typeTag == ATypeTag.NULL) {
- nullSerde.serialize(ANull.NULL, dataOutput);
- return true;
- }
- }
- return false;
- }
-
private static final String FIRST = "1st";
private static final String SECOND = "2nd";
private static final String THIRD = "3rd";
private static final String TH = "th";
- public static String rankToString(int i) {
+ protected String rankToString(int i) {
String prefix = "";
if (i >= 10) {
prefix = String.valueOf(i / 10);
@@ -94,7 +70,7 @@
}
}
- public static void checkTypeMachingThrowsIfNot(String title, ATypeTag[] expected, ATypeTag... actual)
+ protected void checkTypeMachingThrowsIfNot(String title, ATypeTag[] expected, ATypeTag... actual)
throws AlgebricksException {
for (int i = 0; i < expected.length; i++) {
if (expected[i] != actual[i]) {
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractFindBinaryEvaluator.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractFindBinaryEvaluator.java
new file mode 100644
index 0000000..b9acc4d
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractFindBinaryEvaluator.java
@@ -0,0 +1,122 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.evaluators.functions.binary;
+
+import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import org.apache.asterix.om.base.AInt64;
+import org.apache.asterix.om.base.AMutableInt64;
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.BuiltinType;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
+import org.apache.hyracks.api.exceptions.HyracksDataException;
+import org.apache.hyracks.data.std.api.IPointable;
+import org.apache.hyracks.data.std.primitive.ByteArrayPointable;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+
+public abstract class AbstractFindBinaryEvaluator extends AbstractBinaryScalarEvaluator {
+
+ private static final ATypeTag[] EXPECTED_INPUT_TAG = { ATypeTag.BINARY, ATypeTag.BINARY };
+ protected String functionName;
+ protected AMutableInt64 result = new AMutableInt64(-1);
+ protected final ByteArrayPointable textPtr = new ByteArrayPointable();
+ protected final ByteArrayPointable wordPtr = new ByteArrayPointable();
+
+ @SuppressWarnings("unchecked")
+ protected ISerializerDeserializer<AInt64> intSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.AINT64);
+
+ public AbstractFindBinaryEvaluator(IHyracksTaskContext context, IScalarEvaluatorFactory[] copyEvaluatorFactories,
+ String functionName) throws AlgebricksException {
+ super(context, copyEvaluatorFactories);
+ this.functionName = functionName;
+ }
+
+ @Override
+ public void evaluate(IFrameTupleReference tuple, IPointable resultPointable) throws AlgebricksException {
+ resultStorage.reset();
+ for (int i = 0; i < pointables.length; ++i) {
+ evaluators[i].evaluate(tuple, pointables[i]);
+ }
+
+ int fromOffset = getFromOffset(tuple);
+ try {
+ ATypeTag textTag = ATypeTag.VALUE_TYPE_MAPPING[pointables[0].getByteArray()[pointables[0]
+ .getStartOffset()]];
+ ATypeTag wordTag = ATypeTag.VALUE_TYPE_MAPPING[pointables[1].getByteArray()[pointables[1]
+ .getStartOffset()]];
+
+ checkTypeMachingThrowsIfNot(functionName, EXPECTED_INPUT_TAG, textTag, wordTag);
+ textPtr.set(pointables[0].getByteArray(), pointables[0].getStartOffset() + 1,
+ pointables[0].getLength() - 1);
+ wordPtr.set(pointables[1].getByteArray(), pointables[0].getStartOffset() + 1,
+ pointables[1].getLength() - 1);
+ result.setValue(1L + indexOf(textPtr.getByteArray(), textPtr.getContentStartOffset(),
+ textPtr.getContentLength(), wordPtr.getByteArray(), wordPtr.getContentStartOffset(),
+ wordPtr.getContentLength(), fromOffset));
+ intSerde.serialize(result, dataOutput);
+ } catch (HyracksDataException e) {
+ throw new AlgebricksException(e);
+ }
+ resultPointable.set(resultStorage);
+ }
+
+ protected abstract int getFromOffset(IFrameTupleReference tuple) throws AlgebricksException;
+
+ // copy from String.indexOf(String)
+ private int indexOf(byte[] source, int sourceOffset, int sourceCount, byte[] target, int targetOffset,
+ int targetCount, int fromIndex) {
+ if (fromIndex >= sourceCount) {
+ return targetCount == 0 ? sourceCount : -1;
+ }
+ int from = fromIndex;
+ if (from < 0) {
+ from = 0;
+ }
+ if (targetCount == 0) {
+ return from;
+ }
+
+ byte first = target[targetOffset];
+ int max = sourceOffset + (sourceCount - targetCount);
+
+ for (int i = sourceOffset + fromIndex; i <= max; i++) {
+ /* Look for first character. */
+ if (source[i] != first) {
+ continue;
+ }
+
+ /* Found first character, now look at the rest of v2 */
+ int j = i + 1;
+ int end = j + targetCount - 1;
+ for (int k = targetOffset + 1; j < end && source[j] == target[k]; j++, k++) {
+ ;
+ }
+ if (j == end) {
+ /* Found whole string. */
+ return i - sourceOffset;
+ }
+ }
+ return -1;
+ }
+
+}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractSubBinaryEvaluator.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractSubBinaryEvaluator.java
new file mode 100644
index 0000000..8b5c512
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/AbstractSubBinaryEvaluator.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.evaluators.functions.binary;
+
+import java.io.IOException;
+
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
+import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
+import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
+import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.data.std.api.IPointable;
+import org.apache.hyracks.data.std.primitive.ByteArrayPointable;
+import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
+import org.apache.hyracks.util.encoding.VarLenIntEncoderDecoder;
+
+public abstract class AbstractSubBinaryEvaluator extends AbstractBinaryScalarEvaluator {
+
+ private ByteArrayPointable byteArrayPointable = new ByteArrayPointable();
+ private byte[] metaBuffer = new byte[5];
+ protected final String functionName;
+
+ private static final ATypeTag[] EXPECTED_INPUT_TAGS = { ATypeTag.BINARY, ATypeTag.INT32 };
+
+ public AbstractSubBinaryEvaluator(IHyracksTaskContext context, IScalarEvaluatorFactory[] copyEvaluatorFactories,
+ String functionName) throws AlgebricksException {
+ super(context, copyEvaluatorFactories);
+ this.functionName = functionName;
+ }
+
+ @Override
+ public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
+ resultStorage.reset();
+ for (int i = 0; i < pointables.length; ++i) {
+ evaluators[i].evaluate(tuple, pointables[i]);
+ }
+
+ try {
+ ATypeTag argTag0 = ATypeTag.VALUE_TYPE_MAPPING[pointables[0].getByteArray()[pointables[0]
+ .getStartOffset()]];
+ ATypeTag argTag1 = ATypeTag.VALUE_TYPE_MAPPING[pointables[1].getByteArray()[pointables[1]
+ .getStartOffset()]];
+ checkTypeMachingThrowsIfNot(functionName, EXPECTED_INPUT_TAGS, argTag0, argTag1);
+
+ byteArrayPointable.set(pointables[0].getByteArray(), pointables[0].getStartOffset() + 1,
+ pointables[0].getLength() - 1);
+ byte[] startBytes = pointables[1].getByteArray();
+ int offset = pointables[1].getStartOffset();
+
+ int subStart;
+
+ // strange SQL index convention
+ subStart = ATypeHierarchy.getIntegerValue(startBytes, offset) - 1;
+
+ int totalLength = byteArrayPointable.getContentLength();
+ int subLength = getSubLength(tuple);
+
+ if (subStart < 0) {
+ subStart = 0;
+ }
+
+ if (subStart >= totalLength || subLength < 0) {
+ subLength = 0;
+ } else if (subLength > totalLength // for the IntMax case
+ || subStart + subLength > totalLength) {
+ subLength = totalLength - subStart;
+ }
+
+ dataOutput.write(ATypeTag.BINARY.serialize());
+ int metaLength = VarLenIntEncoderDecoder.encode(subLength, metaBuffer, 0);
+ dataOutput.write(metaBuffer, 0, metaLength);
+ dataOutput.write(byteArrayPointable.getByteArray(), byteArrayPointable.getContentStartOffset() + subStart,
+ subLength);
+ } catch (IOException e) {
+ throw new AlgebricksException(e);
+ }
+ result.set(resultStorage);
+ }
+
+ protected abstract int getSubLength(IFrameTupleReference tuple) throws AlgebricksException;
+}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/BinaryConcatDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/BinaryConcatDescriptor.java
index 2747260..b06203b 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/BinaryConcatDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/BinaryConcatDescriptor.java
@@ -22,10 +22,13 @@
import java.io.IOException;
import org.apache.asterix.common.exceptions.AsterixException;
+import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.om.types.ATypeTag;
+import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.asterix.runtime.evaluators.common.AsterixListAccessor;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -33,6 +36,7 @@
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
+import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.ByteArrayPointable;
@@ -66,11 +70,16 @@
private final AsterixListAccessor listAccessor = new AsterixListAccessor();
private final byte[] metaBuffer = new byte[5];
+ @SuppressWarnings("unchecked")
+ private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.ANULL);
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
resultStorage.reset();
- ATypeTag typeTag = evaluateTuple(tuple, 0);
+ evaluators[0].evaluate(tuple, pointables[0]);
+ ATypeTag typeTag = ATypeTag.VALUE_TYPE_MAPPING[pointables[0].getByteArray()[pointables[0]
+ .getStartOffset()]];
if (typeTag != ATypeTag.UNORDEREDLIST && typeTag != ATypeTag.ORDEREDLIST) {
throw new AlgebricksException(getIdentifier().getName()
+ ": expects input type ORDEREDLIST/UNORDEREDLIST, but got " + typeTag);
@@ -113,8 +122,17 @@
}
result.set(resultStorage);
}
- };
+ private boolean serializeNullIfAnyNull(ATypeTag... tags) throws HyracksDataException {
+ for (ATypeTag typeTag : tags) {
+ if (typeTag == ATypeTag.NULL) {
+ nullSerde.serialize(ANull.NULL, dataOutput);
+ return true;
+ }
+ }
+ return false;
+ }
+ };
}
};
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/BinaryLengthDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/BinaryLengthDescriptor.java
index 9e9aab4..0a50c24 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/BinaryLengthDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/BinaryLengthDescriptor.java
@@ -69,12 +69,10 @@
public void evaluate(IFrameTupleReference tuple, IPointable resultPointable)
throws AlgebricksException {
resultStorage.reset();
- ATypeTag tag = evaluateTuple(tuple, 0);
+ evaluators[0].evaluate(tuple, pointables[0]);
+ ATypeTag tag = ATypeTag.VALUE_TYPE_MAPPING[pointables[0].getByteArray()[pointables[0]
+ .getStartOffset()]];
try {
- if (serializeNullIfAnyNull(tag)) {
- resultPointable.set(resultStorage);
- return;
- }
checkTypeMachingThrowsIfNot(getIdentifier().getName(), EXPECTED_TAGS, tag);
int len = ByteArrayPointable.getContentLength(pointables[0].getByteArray(),
pointables[0].getStartOffset() + 1);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryDescriptor.java
index c7b4843..94ec311 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryDescriptor.java
@@ -19,24 +19,15 @@
package org.apache.asterix.runtime.evaluators.functions.binary;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.AInt64;
-import org.apache.asterix.om.base.AMutableInt64;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.data.std.api.IPointable;
-import org.apache.hyracks.data.std.primitive.ByteArrayPointable;
import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
public class FindBinaryDescriptor extends AbstractScalarFunctionDynamicDescriptor {
@@ -53,8 +44,6 @@
return AsterixBuiltinFunctions.FIND_BINARY;
}
- private static final ATypeTag[] EXPECTED_INPUT_TAG = { ATypeTag.BINARY, ATypeTag.BINARY };
-
@Override
public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
throws AlgebricksException {
@@ -63,7 +52,7 @@
@Override
public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
- return new AbstractFindBinaryCopyEvaluator(ctx, args, getIdentifier().getName()) {
+ return new AbstractFindBinaryEvaluator(ctx, args, getIdentifier().getName()) {
@Override
protected int getFromOffset(IFrameTupleReference tuple) throws AlgebricksException {
return 0;
@@ -73,93 +62,4 @@
};
}
- static abstract class AbstractFindBinaryCopyEvaluator extends AbstractBinaryScalarEvaluator {
-
- public AbstractFindBinaryCopyEvaluator(IHyracksTaskContext context,
- IScalarEvaluatorFactory[] copyEvaluatorFactories, String functionName) throws AlgebricksException {
- super(context, copyEvaluatorFactories);
- this.functionName = functionName;
- }
-
- protected String functionName;
- protected AMutableInt64 result = new AMutableInt64(-1);
- protected final ByteArrayPointable textPtr = new ByteArrayPointable();
- protected final ByteArrayPointable wordPtr = new ByteArrayPointable();
-
- @SuppressWarnings("unchecked")
- protected ISerializerDeserializer<AInt64> intSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.AINT64);
-
- @Override
- public void evaluate(IFrameTupleReference tuple, IPointable resultPointable) throws AlgebricksException {
- resultStorage.reset();
- ATypeTag textTag = evaluateTuple(tuple, 0);
- ATypeTag wordTag = evaluateTuple(tuple, 1);
- int fromOffset = getFromOffset(tuple);
-
- try {
- if (serializeNullIfAnyNull(textTag, wordTag)) {
- resultPointable.set(resultStorage);
- return;
- }
- checkTypeMachingThrowsIfNot(functionName, EXPECTED_INPUT_TAG, textTag, wordTag);
-
- textPtr.set(pointables[0].getByteArray(), pointables[0].getStartOffset() + 1,
- pointables[0].getLength() - 1);
- wordPtr.set(pointables[1].getByteArray(), pointables[0].getStartOffset() + 1,
- pointables[1].getLength() - 1);
- result.setValue(1 + indexOf(textPtr.getByteArray(), textPtr.getContentStartOffset(),
- textPtr.getContentLength(), wordPtr.getByteArray(), wordPtr.getContentStartOffset(),
- wordPtr.getContentLength(), fromOffset));
- intSerde.serialize(result, dataOutput);
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
- }
- resultPointable.set(resultStorage);
- }
-
- protected abstract int getFromOffset(IFrameTupleReference tuple) throws AlgebricksException;
- }
-
- // copy from String.indexOf(String)
- static int indexOf(byte[] source, int sourceOffset, int sourceCount, byte[] target, int targetOffset,
- int targetCount, int fromIndex) {
- if (fromIndex >= sourceCount) {
- return (targetCount == 0 ? sourceCount : -1);
- }
- if (fromIndex < 0) {
- fromIndex = 0;
- }
- if (targetCount == 0) {
- return fromIndex;
- }
-
- byte first = target[targetOffset];
- int max = sourceOffset + (sourceCount - targetCount);
-
- for (int i = sourceOffset + fromIndex; i <= max; i++) {
- /* Look for first character. */
- if (source[i] != first) {
- while (++i <= max && source[i] != first) {
- ;
- }
- }
-
- /* Found first character, now look at the rest of v2 */
- if (i <= max) {
- int j = i + 1;
- int end = j + targetCount - 1;
- for (int k = targetOffset + 1; j < end && source[j] == target[k]; j++, k++) {
- ;
- }
-
- if (j == end) {
- /* Found whole string. */
- return i - sourceOffset;
- }
- }
- }
- return -1;
- }
-
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryFromDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryFromDescriptor.java
index 6b8ee38..5ed3773 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryFromDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/FindBinaryFromDescriptor.java
@@ -55,11 +55,9 @@
@Override
public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
- return new FindBinaryDescriptor.AbstractFindBinaryCopyEvaluator(ctx, args,
- getIdentifier().getName()) {
+ return new AbstractFindBinaryEvaluator(ctx, args, getIdentifier().getName()) {
@Override
protected int getFromOffset(IFrameTupleReference tuple) throws AlgebricksException {
- evaluateTuple(tuple, 2);
int getFrom = 0;
try {
getFrom = ATypeHierarchy.getIntegerValue(pointables[2].getByteArray(),
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/ParseBinaryDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/ParseBinaryDescriptor.java
index a067557..2488710 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/ParseBinaryDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/ParseBinaryDescriptor.java
@@ -43,8 +43,8 @@
public class ParseBinaryDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private static final long serialVersionUID = 1L;
- static final UTF8StringPointable HEX_FORMAT = UTF8StringPointable.generateUTF8Pointable("hex");
- static final UTF8StringPointable BASE64_FORMAT = UTF8StringPointable.generateUTF8Pointable("base64");
+ private static final UTF8StringPointable HEX_FORMAT = UTF8StringPointable.generateUTF8Pointable("hex");
+ private static final UTF8StringPointable BASE64_FORMAT = UTF8StringPointable.generateUTF8Pointable("base64");
public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
@Override
@@ -84,14 +84,15 @@
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
resultStorage.reset();
- ATypeTag binaryTag = evaluateTuple(tuple, 0);
- ATypeTag formatTag = evaluateTuple(tuple, 1);
+ evaluators[0].evaluate(tuple, pointables[0]);
+ evaluators[1].evaluate(tuple, pointables[1]);
try {
- if (serializeNullIfAnyNull(binaryTag, formatTag)) {
- result.set(resultStorage);
- return;
- }
+ ATypeTag binaryTag = ATypeTag.VALUE_TYPE_MAPPING[pointables[0].getByteArray()[pointables[0]
+ .getStartOffset()]];
+
+ ATypeTag formatTag = ATypeTag.VALUE_TYPE_MAPPING[pointables[1].getByteArray()[pointables[1]
+ .getStartOffset()]];
checkTypeMachingThrowsIfNot(getIdentifier().getName(), EXPECTED_INPUT_TAGS, binaryTag,
formatTag);
stringPointable.set(pointables[0].getByteArray(), pointables[0].getStartOffset() + 1,
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/PrintBinaryDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/PrintBinaryDescriptor.java
index 92b9ec1..2dc1e34 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/PrintBinaryDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/PrintBinaryDescriptor.java
@@ -19,9 +19,6 @@
package org.apache.asterix.runtime.evaluators.functions.binary;
-import static org.apache.asterix.runtime.evaluators.functions.binary.ParseBinaryDescriptor.BASE64_FORMAT;
-import static org.apache.asterix.runtime.evaluators.functions.binary.ParseBinaryDescriptor.HEX_FORMAT;
-
import java.io.IOException;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
@@ -45,6 +42,8 @@
public class PrintBinaryDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private static final long serialVersionUID = 1L;
+ private static final UTF8StringPointable HEX_FORMAT = UTF8StringPointable.generateUTF8Pointable("hex");
+ private static final UTF8StringPointable BASE64_FORMAT = UTF8StringPointable.generateUTF8Pointable("base64");
@Override
public FunctionIdentifier getIdentifier() {
@@ -78,14 +77,14 @@
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
resultStorage.reset();
- ATypeTag arg0Tag = evaluateTuple(tuple, 0);
- ATypeTag arg1Tag = evaluateTuple(tuple, 1);
+ evaluators[0].evaluate(tuple, pointables[0]);
+ evaluators[1].evaluate(tuple, pointables[1]);
try {
- if (serializeNullIfAnyNull(arg0Tag, arg1Tag)) {
- result.set(resultStorage);
- return;
- }
+ ATypeTag arg0Tag = ATypeTag.VALUE_TYPE_MAPPING[pointables[0].getByteArray()[pointables[0]
+ .getStartOffset()]];
+ ATypeTag arg1Tag = ATypeTag.VALUE_TYPE_MAPPING[pointables[1].getByteArray()[pointables[1]
+ .getStartOffset()]];
checkTypeMachingThrowsIfNot(getIdentifier().getName(), EXPECTED_INPUT_TAGS, arg0Tag,
arg1Tag);
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromDescriptor.java
index 4d435ab..129cd54 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromDescriptor.java
@@ -52,8 +52,7 @@
@Override
public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
- return new SubBinaryFromToDescriptor.AbstractSubBinaryCopyEvaluator(ctx, args,
- getIdentifier().getName()) {
+ return new AbstractSubBinaryEvaluator(ctx, args, getIdentifier().getName()) {
@Override
protected int getSubLength(IFrameTupleReference tuple) throws AlgebricksException {
return Integer.MAX_VALUE;
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromToDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromToDescriptor.java
index 20fdeed..bb23877 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromToDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromToDescriptor.java
@@ -19,12 +19,9 @@
package org.apache.asterix.runtime.evaluators.functions.binary;
-import java.io.IOException;
-
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
-import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -33,10 +30,7 @@
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.exceptions.HyracksDataException;
-import org.apache.hyracks.data.std.api.IPointable;
-import org.apache.hyracks.data.std.primitive.ByteArrayPointable;
import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
-import org.apache.hyracks.util.encoding.VarLenIntEncoderDecoder;
public class SubBinaryFromToDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private static final long serialVersionUID = 1L;
@@ -60,10 +54,10 @@
@Override
public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
- return new AbstractSubBinaryCopyEvaluator(ctx, args, getIdentifier().getName()) {
+
+ return new AbstractSubBinaryEvaluator(ctx, args, getIdentifier().getName()) {
@Override
protected int getSubLength(IFrameTupleReference tuple) throws AlgebricksException {
- evaluateTuple(tuple, 2);
int subLength = 0;
try {
subLength = ATypeHierarchy.getIntegerValue(pointables[2].getByteArray(),
@@ -78,70 +72,4 @@
}
};
}
-
- static abstract class AbstractSubBinaryCopyEvaluator extends AbstractBinaryScalarEvaluator {
- public AbstractSubBinaryCopyEvaluator(IHyracksTaskContext context,
- IScalarEvaluatorFactory[] copyEvaluatorFactories, String functionName) throws AlgebricksException {
- super(context, copyEvaluatorFactories);
- this.functionName = functionName;
- }
-
- private ByteArrayPointable byteArrayPointable = new ByteArrayPointable();
- private byte[] metaBuffer = new byte[5];
- protected final String functionName;
-
- static final ATypeTag[] EXPECTED_INPUT_TAGS = { ATypeTag.BINARY, ATypeTag.INT32 };
-
- @Override
- public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
- resultStorage.reset();
- ATypeTag argTag0 = evaluateTuple(tuple, 0);
- ATypeTag argTag1 = evaluateTuple(tuple, 1);
-
- try {
- if (serializeNullIfAnyNull(argTag0, argTag1)) {
- result.set(resultStorage);
- return;
- }
- checkTypeMachingThrowsIfNot(functionName, EXPECTED_INPUT_TAGS, argTag0, argTag1);
-
- byteArrayPointable.set(pointables[0].getByteArray(), pointables[0].getStartOffset() + 1,
- pointables[0].getLength() - 1);
- byte[] startBytes = pointables[1].getByteArray();
- int offset = pointables[1].getStartOffset();
-
- int subStart = 0;
-
- // strange SQL index convention
- subStart = ATypeHierarchy.getIntegerValue(startBytes, offset) - 1;
-
- int totalLength = byteArrayPointable.getContentLength();
- int subLength = getSubLength(tuple);
-
- if (subStart < 0) {
- subStart = 0;
- }
-
- if (subStart >= totalLength || subLength < 0) {
- subLength = 0;
- } else if (subLength > totalLength // for the IntMax case
- || subStart + subLength > totalLength) {
- subLength = totalLength - subStart;
- }
-
- dataOutput.write(ATypeTag.BINARY.serialize());
- int metaLength = VarLenIntEncoderDecoder.encode(subLength, metaBuffer, 0);
- dataOutput.write(metaBuffer, 0, metaLength);
- dataOutput.write(byteArrayPointable.getByteArray(),
- byteArrayPointable.getContentStartOffset() + subStart, subLength);
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
- } catch (IOException e) {
- throw new AlgebricksException(e);
- }
- result.set(resultStorage);
- }
-
- protected abstract int getSubLength(IFrameTupleReference tuple) throws AlgebricksException;
- }
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByIndexEvalFactory.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByIndexEvalFactory.java
index dd70d1e..f3257ca 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByIndexEvalFactory.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByIndexEvalFactory.java
@@ -23,12 +23,9 @@
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.dataflow.data.nontagged.serde.ARecordSerializerDeserializer;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.types.ARecordType;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.AUnionType;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.om.util.NonTaggedFormatUtil;
@@ -37,7 +34,6 @@
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.IntegerPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
@@ -71,14 +67,11 @@
private IPointable inputArg1 = new VoidPointable();
private IScalarEvaluator eval0 = recordEvalFactory.createScalarEvaluator(ctx);
private IScalarEvaluator eval1 = fieldIndexEvalFactory.createScalarEvaluator(ctx);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private int fieldIndex;
private int fieldValueOffset;
private int fieldValueLength;
private IAType fieldValueType;
- private ATypeTag fieldValueTypeTag = ATypeTag.NULL;
+ private ATypeTag fieldValueTypeTag;
/*
* inputArg0: the record
@@ -94,12 +87,6 @@
byte[] serRecord = inputArg0.getByteArray();
int offset = inputArg0.getStartOffset();
- if (serRecord[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
-
if (serRecord[offset] != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
throw new AlgebricksException("Field accessor is not defined for values of type "
+ EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serRecord[offset]));
@@ -119,7 +106,7 @@
if (fieldValueType.getTypeTag().equals(ATypeTag.UNION)) {
if (((AUnionType) fieldValueType).isNullableType()) {
- fieldValueTypeTag = ((AUnionType) fieldValueType).getNullableType().getTypeTag();
+ fieldValueTypeTag = ((AUnionType) fieldValueType).getActualType().getTypeTag();
fieldValueLength = NonTaggedFormatUtil.getFieldValueLength(serRecord, fieldValueOffset,
fieldValueTypeTag, false);
out.writeByte(fieldValueTypeTag.serialize());
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByNameEvalFactory.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByNameEvalFactory.java
index d11c91e..62779f3 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByNameEvalFactory.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessByNameEvalFactory.java
@@ -23,18 +23,14 @@
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.dataflow.data.nontagged.serde.ARecordSerializerDeserializer;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.asterix.om.util.NonTaggedFormatUtil;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
@@ -64,12 +60,9 @@
private IPointable inputArg1 = new VoidPointable();
private IScalarEvaluator eval0 = recordEvalFactory.createScalarEvaluator(ctx);
private IScalarEvaluator eval1 = fldNameEvalFactory.createScalarEvaluator(ctx);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private int fieldValueOffset;
private int fieldValueLength;
- private ATypeTag fieldValueTypeTag = ATypeTag.NULL;
+ private ATypeTag fieldValueTypeTag;
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
@@ -81,12 +74,6 @@
int serRecordOffset = inputArg0.getStartOffset();
int serRecordLen = inputArg0.getLength();
- if (serRecord[serRecordOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
-
if (serRecord[serRecordOffset] != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
throw new AlgebricksException(AsterixBuiltinFunctions.FIELD_ACCESS_BY_NAME.getName()
+ ": expects input type NULL or RECORD, but got "
@@ -98,7 +85,7 @@
fieldValueOffset = ARecordSerializerDeserializer.getFieldOffsetByName(serRecord, serRecordOffset,
serRecordLen, serFldName, serFldNameOffset);
if (fieldValueOffset < 0) {
- out.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
+ out.writeByte(ATypeTag.SERIALIZED_MISSING_TYPE_TAG);
result.set(resultStorage);
return;
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessNestedEvalFactory.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessNestedEvalFactory.java
index 7d307439d..92e40cc 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessNestedEvalFactory.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/FieldAccessNestedEvalFactory.java
@@ -25,6 +25,7 @@
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.dataflow.data.nontagged.serde.ARecordSerializerDeserializer;
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
+import org.apache.asterix.om.base.AMissing;
import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.AString;
import org.apache.asterix.om.types.ARecordType;
@@ -35,7 +36,6 @@
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.om.types.runtime.RuntimeRecordTypeInfo;
import org.apache.asterix.om.util.NonTaggedFormatUtil;
-import org.apache.commons.lang.NotImplementedException;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
@@ -79,6 +79,9 @@
@SuppressWarnings("unchecked")
private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ANULL);
+ @SuppressWarnings("unchecked")
+ private final ISerializerDeserializer<AMissing> missingSerde = AqlSerializerDeserializerProvider.INSTANCE
+ .getSerializerDeserializer(BuiltinType.AMISSING);
{
generateFieldsPointables();
@@ -115,11 +118,6 @@
int start = offset;
int len = inputArg0.getLength();
- if (serRecord[start] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
if (serRecord[start] != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
throw new AlgebricksException("Field accessor is not defined for values of type "
+ EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serRecord[start]));
@@ -133,7 +131,7 @@
IAType subType = recordType;
recTypeInfos[0].reset(recordType);
- ATypeTag subTypeTag = ATypeTag.NULL;
+ ATypeTag subTypeTag = ATypeTag.MISSING;
boolean openField = false;
int pathIndex = 0;
@@ -141,7 +139,7 @@
for (; pathIndex < fieldPointables.length; pathIndex++) {
if (subType.getTypeTag().equals(ATypeTag.UNION)) {
//enforced SubType
- subType = ((AUnionType) subType).getNullableType();
+ subType = ((AUnionType) subType).getActualType();
if (subType.getTypeTag().serialize() != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
throw new AlgebricksException(
"Field accessor is not defined for values of type " + subTypeTag);
@@ -161,7 +159,8 @@
subFieldIndex, nullBitmapSize, ((ARecordType) subType).isOpen());
if (subFieldOffset == 0) {
// the field is null, we checked the null bit map
- out.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
+ // any path after null will return null.
+ nullSerde.serialize(ANull.NULL, out);
result.set(resultStorage);
return;
}
@@ -171,14 +170,9 @@
recTypeInfos[pathIndex + 1].reset((ARecordType) subType);
}
if (subType.getTypeTag().equals(ATypeTag.UNION)) {
- if (((AUnionType) subType).isNullableType()) {
- subTypeTag = ((AUnionType) subType).getNullableType().getTypeTag();
- subFieldLength = NonTaggedFormatUtil.getFieldValueLength(serRecord, subFieldOffset,
- subTypeTag, false);
- } else {
- // union .. the general case
- throw new NotImplementedException();
- }
+ subTypeTag = ((AUnionType) subType).getActualType().getTypeTag();
+ subFieldLength = NonTaggedFormatUtil.getFieldValueLength(serRecord, subFieldOffset,
+ subTypeTag, false);
} else {
subTypeTag = subType.getTypeTag();
subFieldLength = NonTaggedFormatUtil.getFieldValueLength(serRecord, subFieldOffset,
@@ -192,17 +186,12 @@
subRecordTmpStream.write(serRecord, subFieldOffset, subFieldLength);
serRecord = subRecordTmpStream.getByteArray();
start = 0;
-
- // type check
- if (serRecord[start] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
- if (serRecord[start] != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
- throw new AlgebricksException("Field accessor is not defined for values of type "
- + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serRecord[start]));
- }
+ }
+ // type check
+ if (pathIndex < fieldPointables.length - 1
+ && serRecord[start] != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
+ throw new AlgebricksException("Field accessor is not defined for values of type "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serRecord[start]));
}
}
@@ -212,7 +201,7 @@
subFieldOffset = ARecordSerializerDeserializer.getFieldOffsetByName(serRecord, start, len,
fieldPointables[pathIndex].getByteArray(), fieldPointables[pathIndex].getStartOffset());
if (subFieldOffset < 0) {
- out.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
+ out.writeByte(ATypeTag.SERIALIZED_MISSING_TYPE_TAG);
result.set(resultStorage);
return;
}
@@ -221,21 +210,22 @@
subFieldLength = NonTaggedFormatUtil.getFieldValueLength(serRecord, subFieldOffset, subTypeTag,
true) + 1;
- if (pathIndex < fieldPointables.length - 1) {
- //setup next iteration
- start = subFieldOffset;
- len = subFieldLength;
+ if (pathIndex >= fieldPointables.length - 1) {
+ continue;
+ }
+ //setup next iteration
+ start = subFieldOffset;
+ len = subFieldLength;
- // type check
- if (serRecord[start] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
- if (serRecord[start] != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
- throw new AlgebricksException("Field accessor is not defined for values of type "
- + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serRecord[start]));
- }
+ // type check
+ if (serRecord[start] == ATypeTag.SERIALIZED_MISSING_TYPE_TAG) {
+ missingSerde.serialize(AMissing.MISSING, out);
+ result.set(resultStorage);
+ return;
+ }
+ if (serRecord[start] != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
+ throw new AlgebricksException("Field accessor is not defined for values of type "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serRecord[start]));
}
}
// emit the final result.
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/GetRecordFieldValueEvalFactory.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/GetRecordFieldValueEvalFactory.java
index 71ce3a9..80e5fa5 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/GetRecordFieldValueEvalFactory.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/GetRecordFieldValueEvalFactory.java
@@ -23,11 +23,8 @@
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.dataflow.data.nontagged.serde.ARecordSerializerDeserializer;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.types.ARecordType;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.asterix.om.types.runtime.RuntimeRecordTypeInfo;
import org.apache.asterix.om.util.NonTaggedFormatUtil;
@@ -35,7 +32,6 @@
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
@@ -67,10 +63,6 @@
private final IPointable inputArg1 = new VoidPointable();
private final IScalarEvaluator recordEval = recordEvalFactory.createScalarEvaluator(ctx);
private final IScalarEvaluator fieldNameEval = fldNameEvalFactory.createScalarEvaluator(ctx);
-
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private final RuntimeRecordTypeInfo recTypeInfo = new RuntimeRecordTypeInfo();
{
@@ -85,21 +77,12 @@
byte[] serFldName = inputArg1.getByteArray();
int serFldNameOffset = inputArg1.getStartOffset();
int serFldNameLen = inputArg1.getLength();
- if (serFldName[serFldNameOffset] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
recordEval.evaluate(tuple, inputArg0);
byte[] serRecord = inputArg0.getByteArray();
int serRecordOffset = inputArg0.getStartOffset();
int serRecordLen = inputArg0.getLength();
- if (serRecord[serRecordOffset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
+
if (serRecord[serRecordOffset] != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
throw new AlgebricksException("Field accessor is not defined for values of type "
+ EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(serRecord[serRecordOffset]));
@@ -134,7 +117,7 @@
subFieldOffset = ARecordSerializerDeserializer.getFieldOffsetByName(serRecord, serRecordOffset,
serRecordLen, serFldName, serFldNameOffset);
if (subFieldOffset < 0) {
- out.writeByte(ATypeTag.SERIALIZED_NULL_TYPE_TAG);
+ out.writeByte(ATypeTag.SERIALIZED_MISSING_TYPE_TAG);
result.set(resultStorage);
return;
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/GetRecordFieldsEvalFactory.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/GetRecordFieldsEvalFactory.java
index a24906d..0471b74 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/GetRecordFieldsEvalFactory.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/GetRecordFieldsEvalFactory.java
@@ -22,19 +22,14 @@
import java.io.IOException;
import org.apache.asterix.common.exceptions.AsterixException;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.pointables.nonvisitor.ARecordPointable;
import org.apache.asterix.om.types.ARecordType;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
@@ -56,10 +51,6 @@
public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
return new IScalarEvaluator() {
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
-
private final ARecordPointable recordPointable = (ARecordPointable) ARecordPointable.FACTORY
.createPointable();
private IPointable inputArg0 = new VoidPointable();
@@ -76,16 +67,6 @@
int offset = inputArg0.getStartOffset();
int len = inputArg0.getLength();
- if (data[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- try {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
- }
- }
-
if (data[offset] != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
throw new AlgebricksException("Field accessor is not defined for values of type "
+ EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(data[offset]));
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordAddFieldsDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordAddFieldsDescriptor.java
index eee240b..6565935 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordAddFieldsDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordAddFieldsDescriptor.java
@@ -26,8 +26,6 @@
import org.apache.asterix.common.exceptions.AsterixException;
import org.apache.asterix.dataflow.data.nontagged.comparators.ListItemBinaryComparatorFactory;
import org.apache.asterix.dataflow.data.nontagged.hash.ListItemBinaryHashFunctionFactory;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -36,11 +34,10 @@
import org.apache.asterix.om.pointables.PointableAllocator;
import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
import org.apache.asterix.om.pointables.base.IVisitablePointable;
-import org.apache.asterix.om.typecomputer.impl.TypeComputerUtils;
+import org.apache.asterix.om.typecomputer.impl.TypeComputeUtils;
import org.apache.asterix.om.types.AOrderedListType;
import org.apache.asterix.om.types.ARecordType;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.om.types.runtime.RuntimeRecordTypeInfo;
@@ -54,7 +51,6 @@
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.dataflow.value.IBinaryComparator;
import org.apache.hyracks.api.dataflow.value.IBinaryHashFunction;
-import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
@@ -76,9 +72,9 @@
private IAType inputFieldListItemType;
public void reset(IAType outType, IAType inType0, IAType inType1) {
- outRecType = TypeComputerUtils.extractRecordType(outType);
- inRecType = TypeComputerUtils.extractRecordType(inType0);
- inListType = TypeComputerUtils.extractOrderedListType(inType1);
+ outRecType = TypeComputeUtils.extractRecordType(outType);
+ inRecType = TypeComputeUtils.extractRecordType(inType0);
+ inListType = TypeComputeUtils.extractOrderedListType(inType1);
inputFieldListItemType = inListType.getItemType();
if (inputFieldListItemType == null || inputFieldListItemType.getTypeTag() == ATypeTag.ANY) {
inputFieldListItemType = DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE;
@@ -91,9 +87,6 @@
return new IScalarEvaluatorFactory() {
private static final long serialVersionUID = 1L;
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerDe = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@Override
public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
@@ -134,7 +127,6 @@
.createBinaryComparator();
private BinaryHashMap hashMap = new BinaryHashMap(TABLE_SIZE, TABLE_FRAME_SIZE, putHashFunc,
getHashFunc, cmp);
-
private ArrayBackedValueStorage resultStorage = new ArrayBackedValueStorage();
private DataOutput out = resultStorage.getDataOutput();
@@ -146,18 +138,6 @@
eval0.evaluate(tuple, argPtr0);
eval1.evaluate(tuple, argPtr1);
- if (argPtr0.getByteArray()[argPtr0.getStartOffset()] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || argPtr1.getByteArray()[argPtr1
- .getStartOffset()] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- try {
- nullSerDe.serialize(ANull.NULL, out);
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
- }
- result.set(resultStorage);
- return;
- }
-
// Make sure we get a valid record
if (argPtr0.getByteArray()[argPtr0.getStartOffset()] != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
throw new AlgebricksException("Expected an ordederlist of type " + inRecType + " but "
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeDescriptor.java
index 0f11a48..2f54c9e 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordMergeDescriptor.java
@@ -25,8 +25,6 @@
import org.apache.asterix.builders.RecordBuilder;
import org.apache.asterix.common.exceptions.AsterixException;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -34,10 +32,9 @@
import org.apache.asterix.om.pointables.PointableAllocator;
import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
import org.apache.asterix.om.pointables.base.IVisitablePointable;
-import org.apache.asterix.om.typecomputer.impl.TypeComputerUtils;
+import org.apache.asterix.om.typecomputer.impl.TypeComputeUtils;
import org.apache.asterix.om.types.ARecordType;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.IAType;
import org.apache.asterix.om.types.runtime.RuntimeRecordTypeInfo;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
@@ -48,8 +45,6 @@
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
@@ -78,9 +73,9 @@
private ARecordType inRecType1;
public void reset(IAType outType, IAType inType0, IAType inType1) {
- outRecType = TypeComputerUtils.extractRecordType(outType);
- inRecType0 = TypeComputerUtils.extractRecordType(inType0);
- inRecType1 = TypeComputerUtils.extractRecordType(inType1);
+ outRecType = TypeComputeUtils.extractRecordType(outType);
+ inRecType0 = TypeComputeUtils.extractRecordType(inType0);
+ inRecType1 = TypeComputeUtils.extractRecordType(inType1);
}
@Override
@@ -90,10 +85,6 @@
private static final long serialVersionUID = 1L;
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerDe = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
-
@Override
public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws AlgebricksException {
final PointableAllocator pa = new PointableAllocator();
@@ -123,17 +114,6 @@
eval0.evaluate(tuple, argPtr0);
eval1.evaluate(tuple, argPtr1);
- if (argPtr0.getByteArray()[argPtr0.getStartOffset()] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || argPtr1.getByteArray()[argPtr1.getStartOffset()] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- try {
- nullSerDe.serialize(ANull.NULL, out);
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
- }
- result.set(resultStorage);
- return;
- }
-
vp0.set(argPtr0);
vp1.set(argPtr1);
@@ -151,7 +131,7 @@
private void mergeFields(ARecordType combinedType, ARecordVisitablePointable leftRecord,
ARecordVisitablePointable rightRecord, boolean openFromParent, int nestedLevel)
- throws IOException, AsterixException, AlgebricksException {
+ throws IOException, AsterixException, AlgebricksException {
if (rbStack.size() < (nestedLevel + 1)) {
rbStack.add(new RecordBuilder());
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordRemoveFieldsEvalFactory.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordRemoveFieldsEvalFactory.java
index 57c6d01..68865c3 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordRemoveFieldsEvalFactory.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/records/RecordRemoveFieldsEvalFactory.java
@@ -28,8 +28,6 @@
import org.apache.asterix.builders.RecordBuilder;
import org.apache.asterix.common.exceptions.AsterixException;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.pointables.AListVisitablePointable;
import org.apache.asterix.om.pointables.ARecordVisitablePointable;
@@ -39,7 +37,6 @@
import org.apache.asterix.om.types.AOrderedListType;
import org.apache.asterix.om.types.ARecordType;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.asterix.om.types.runtime.RuntimeRecordTypeInfo;
import org.apache.asterix.runtime.evaluators.functions.PointableHelper;
@@ -47,7 +44,6 @@
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
@@ -56,9 +52,6 @@
class RecordRemoveFieldsEvalFactory implements IScalarEvaluatorFactory {
private static final long serialVersionUID = 1L;
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerDe = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private IScalarEvaluatorFactory inputRecordEvalFactory;
private IScalarEvaluatorFactory removeFieldPathsFactory;
private ARecordType requiredRecType;
@@ -103,16 +96,6 @@
eval0.evaluate(tuple, inputArg0);
eval1.evaluate(tuple, inputArg1);
- if (inputArg0.getByteArray()[inputArg0.getStartOffset()] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- try {
- nullSerDe.serialize(ANull.NULL, out);
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
- }
- result.set(resultStorage);
- return;
- }
-
if (inputArg0.getByteArray()[inputArg0.getStartOffset()] != ATypeTag.SERIALIZED_RECORD_TYPE_TAG) {
throw new AlgebricksException(
AsterixBuiltinFunctions.REMOVE_FIELDS.getName() + ": expects input type " + inputRecType
@@ -146,7 +129,7 @@
private void processRecord(ARecordType requiredType, ARecordVisitablePointable srp,
AListVisitablePointable inputList, int nestedLevel)
- throws IOException, AsterixException, AlgebricksException {
+ throws IOException, AsterixException, AlgebricksException {
if (rbStack.size() < (nestedLevel + 1)) {
rbStack.add(new RecordBuilder());
}
@@ -177,7 +160,7 @@
private void addKeptFieldToSubRecord(ARecordType requiredType, IVisitablePointable fieldNamePointable,
IVisitablePointable fieldValuePointable, IVisitablePointable fieldTypePointable,
AListVisitablePointable inputList, int nestedLevel)
- throws IOException, AsterixException, AlgebricksException {
+ throws IOException, AsterixException, AlgebricksException {
runtimeRecordTypeInfo.reset(requiredType);
int pos = runtimeRecordTypeInfo.getFieldIndex(fieldNamePointable.getByteArray(),
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AbstractIntervalLogicFuncDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AbstractIntervalLogicFuncDescriptor.java
index 1cd3919..413459b 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AbstractIntervalLogicFuncDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AbstractIntervalLogicFuncDescriptor.java
@@ -22,7 +22,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ABoolean;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.pointables.nonvisitor.AIntervalPointable;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.BuiltinType;
@@ -42,9 +41,6 @@
public abstract class AbstractIntervalLogicFuncDescriptor extends AbstractScalarFunctionDynamicDescriptor {
private final static long serialVersionUID = 1L;
- /* (non-Javadoc)
- * @see org.apache.asterix.runtime.base.IScalarFunctionDynamicDescriptor#createEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.ICopyEvaluatorFactory[])
- */
@Override
public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
throws AlgebricksException {
@@ -73,9 +69,6 @@
// possible output types
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
- @SuppressWarnings("unchecked")
private ISerializerDeserializer<ABoolean> booleanSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ABOOLEAN);
@@ -86,13 +79,6 @@
eval1.evaluate(tuple, argPtr1);
try {
- if (argPtr0.getTag() == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || argPtr1.getTag() == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
-
if (argPtr0.getTag() != ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG
|| argPtr1.getTag() != ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
throw new AlgebricksException(getIdentifier().getName()
@@ -109,7 +95,7 @@
+ ": failed to compare intervals with different internal time type.");
}
- ABoolean res = (compareIntervals(il, interval0, interval1)) ? ABoolean.TRUE : ABoolean.FALSE;
+ ABoolean res = compareIntervals(il, interval0, interval1) ? ABoolean.TRUE : ABoolean.FALSE;
booleanSerde.serialize(res, out);
} catch (HyracksDataException hex) {
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java
index 6c445e2..1ce0c9c 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustDateTimeForTimeZoneDescriptor.java
@@ -21,8 +21,6 @@
import java.io.DataOutput;
import org.apache.asterix.dataflow.data.nontagged.serde.ADateTimeSerializerDeserializer;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.ATimeParserFactory;
import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
import org.apache.asterix.om.base.temporal.GregorianCalendarSystem.Fields;
@@ -30,7 +28,6 @@
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -38,7 +35,6 @@
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
@@ -80,10 +76,6 @@
private IScalarEvaluator eval1 = args[1].createScalarEvaluator(ctx);
// possible output types
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
-
private GregorianCalendarSystem calInstance = GregorianCalendarSystem.getInstance();
private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@@ -102,13 +94,6 @@
int len1 = argPtr1.getLength();
try {
- if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
-
if (bytes0[offset0] != ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
throw new AlgebricksException(
FID.getName() + ": expects type DATETIME/NULL for parameter 0 but got "
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java
index 72e4200..bab00bd 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/AdjustTimeForTimeZoneDescriptor.java
@@ -21,8 +21,6 @@
import java.io.DataOutput;
import org.apache.asterix.dataflow.data.nontagged.serde.ATimeSerializerDeserializer;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.ATimeParserFactory;
import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
import org.apache.asterix.om.base.temporal.GregorianCalendarSystem.Fields;
@@ -30,7 +28,6 @@
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -38,7 +35,6 @@
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
@@ -78,11 +74,6 @@
private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx);
private IScalarEvaluator eval1 = args[1].createScalarEvaluator(ctx);
- // possible output types
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
-
private GregorianCalendarSystem calInstance = GregorianCalendarSystem.getInstance();
private final UTF8StringWriter writer = new UTF8StringWriter();
private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@@ -100,13 +91,6 @@
int len1 = argPtr1.getLength();
try {
- if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
-
if (bytes0[offset0] != ATypeTag.SERIALIZED_TIME_TYPE_TAG) {
throw new AlgebricksException(
FID.getName() + ": expects type TIME/NULL for parameter 0 but got "
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDuartionFromDateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDuartionFromDateDescriptor.java
index 418ad68..e38da7e 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDuartionFromDateDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDuartionFromDateDescriptor.java
@@ -25,7 +25,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ADuration;
import org.apache.asterix.om.base.AMutableDuration;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.DurationArithmeticOperations;
import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
@@ -80,10 +79,6 @@
private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx);
private IScalarEvaluator eval1 = args[1].createScalarEvaluator(ctx);
- // possible output types
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ADuration> durationSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADURATION);
@@ -104,13 +99,6 @@
int offset1 = argPtr1.getStartOffset();
try {
- if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
-
if (bytes0[offset0] != ATypeTag.SERIALIZED_DATE_TYPE_TAG) {
throw new AlgebricksException(
FID.getName() + ": expects type DATE/NULL for parameter 0 but got "
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDurationFromDateTimeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDurationFromDateTimeDescriptor.java
index dcef6ab..c42865c 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDurationFromDateTimeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/CalendarDurationFromDateTimeDescriptor.java
@@ -25,7 +25,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ADuration;
import org.apache.asterix.om.base.AMutableDuration;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.DurationArithmeticOperations;
import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
@@ -95,10 +94,6 @@
private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx);
private IScalarEvaluator eval1 = args[1].createScalarEvaluator(ctx);
- // possible output types
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ADuration> durationSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADURATION);
@@ -119,13 +114,6 @@
int offset1 = argPtr1.getStartOffset();
try {
- if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
-
if (bytes0[offset0] != ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
throw new AlgebricksException(
FID.getName() + ": expects type DATETIME/NULL for parameter 0 but got "
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromDatetimeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromDatetimeDescriptor.java
index bcdb20f..d4fa0e6 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromDatetimeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromDatetimeDescriptor.java
@@ -24,7 +24,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ADate;
import org.apache.asterix.om.base.AMutableDate;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
@@ -79,10 +78,6 @@
.getSerializerDeserializer(BuiltinType.ADATE);
private AMutableDate aDate = new AMutableDate(0);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
-
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
resultStorage.reset();
@@ -91,24 +86,19 @@
int offset = argPtr.getStartOffset();
try {
- if (bytes[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- } else {
- if (bytes[offset] != ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
- throw new AlgebricksException(
- FID.getName() + ": expects input type DATETIME/NULL but got "
- + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]));
- }
- long datetimeChronon = ADateTimeSerializerDeserializer.getChronon(bytes, offset + 1);
- int dateChrononInDays = (int) (datetimeChronon
- / GregorianCalendarSystem.CHRONON_OF_DAY);
- if (dateChrononInDays < 0
- && datetimeChronon % GregorianCalendarSystem.CHRONON_OF_DAY != 0) {
- dateChrononInDays -= 1;
- }
- aDate.setValue(dateChrononInDays);
- dateSerde.serialize(aDate, out);
+ if (bytes[offset] != ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
+ throw new AlgebricksException(
+ FID.getName() + ": expects input type DATETIME/NULL but got "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]));
}
+ long datetimeChronon = ADateTimeSerializerDeserializer.getChronon(bytes, offset + 1);
+ int dateChrononInDays = (int) (datetimeChronon / GregorianCalendarSystem.CHRONON_OF_DAY);
+ if (dateChrononInDays < 0
+ && datetimeChronon % GregorianCalendarSystem.CHRONON_OF_DAY != 0) {
+ dateChrononInDays -= 1;
+ }
+ aDate.setValue(dateChrononInDays);
+ dateSerde.serialize(aDate, out);
} catch (HyracksDataException hex) {
throw new AlgebricksException(hex);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromUnixTimeInDaysDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromUnixTimeInDaysDescriptor.java
index b6f7a2e..5fa57f6 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromUnixTimeInDaysDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DateFromUnixTimeInDaysDescriptor.java
@@ -23,11 +23,9 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ADate;
import org.apache.asterix.om.base.AMutableDate;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
-import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
@@ -77,22 +75,15 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ADate> dateSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADATE);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
resultStorage.reset();
eval.evaluate(tuple, argPtr);
try {
- if (argPtr.getByteArray()[argPtr.getStartOffset()] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- } else {
- aDate.setValue(
- ATypeHierarchy.getIntegerValue(argPtr.getByteArray(), argPtr.getStartOffset()));
- dateSerde.serialize(aDate, out);
- }
+ aDate.setValue(
+ ATypeHierarchy.getIntegerValue(argPtr.getByteArray(), argPtr.getStartOffset()));
+ dateSerde.serialize(aDate, out);
} catch (HyracksDataException hex) {
throw new AlgebricksException(hex);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromDateAndTimeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromDateAndTimeDescriptor.java
index ab88265..98f84aa 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromDateAndTimeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromDateAndTimeDescriptor.java
@@ -25,7 +25,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ADateTime;
import org.apache.asterix.om.base.AMutableDateTime;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
@@ -85,10 +84,6 @@
.getSerializerDeserializer(BuiltinType.ADATETIME);
private AMutableDateTime aDateTime = new AMutableDateTime(0);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
-
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
resultStorage.reset();
@@ -101,27 +96,21 @@
int offset1 = argPtr1.getStartOffset();
try {
- if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- } else {
- if (bytes0[offset0] != ATypeTag.SERIALIZED_DATE_TYPE_TAG
- && bytes1[offset1] != ATypeTag.SERIALIZED_TIME_TYPE_TAG) {
- throw new AlgebricksException(FID.getName()
- + ": expects input type (DATE/NULL, TIME/NULL) but got ("
- + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[offset0]) + ", "
- + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1])
- + ").");
+ if (bytes0[offset0] != ATypeTag.SERIALIZED_DATE_TYPE_TAG
+ && bytes1[offset1] != ATypeTag.SERIALIZED_TIME_TYPE_TAG) {
+ throw new AlgebricksException(FID.getName()
+ + ": expects input type (DATE/NULL, TIME/NULL) but got ("
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[offset0]) + ", "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]) + ").");
- }
-
- long datetimeChronon = ADateSerializerDeserializer.getChronon(bytes0, offset0 + 1)
- * GregorianCalendarSystem.CHRONON_OF_DAY
- + ATimeSerializerDeserializer.getChronon(bytes1, offset1 + 1);
-
- aDateTime.setValue(datetimeChronon);
- datetimeSerde.serialize(aDateTime, out);
}
+
+ long datetimeChronon = ADateSerializerDeserializer.getChronon(bytes0, offset0 + 1)
+ * GregorianCalendarSystem.CHRONON_OF_DAY
+ + ATimeSerializerDeserializer.getChronon(bytes1, offset1 + 1);
+
+ aDateTime.setValue(datetimeChronon);
+ datetimeSerde.serialize(aDateTime, out);
} catch (HyracksDataException hex) {
throw new AlgebricksException(hex);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromUnixTimeInMsDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromUnixTimeInMsDescriptor.java
index fae8566..d9c0156 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromUnixTimeInMsDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromUnixTimeInMsDescriptor.java
@@ -27,7 +27,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ADateTime;
import org.apache.asterix.om.base.AMutableDateTime;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -82,9 +81,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ADateTime> datetimeSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADATETIME);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private AMutableDateTime aDatetime = new AMutableDateTime(0);
@@ -96,29 +92,24 @@
int offset = argPtr.getStartOffset();
try {
ATypeTag argPtrTypeTag = ATypeTag.VALUE_TYPE_MAPPING[bytes[offset]];
- if (argPtrTypeTag == ATypeTag.NULL) {
- nullSerde.serialize(ANull.NULL, out);
- } else {
- switch (argPtrTypeTag) {
- case INT8:
- aDatetime.setValue(AInt8SerializerDeserializer.getByte(bytes, offset + 1));
- break;
- case INT16:
- aDatetime.setValue(AInt16SerializerDeserializer.getShort(bytes, offset + 1));
- break;
- case INT32:
- aDatetime.setValue(AInt32SerializerDeserializer.getInt(bytes, offset + 1));
- break;
- case INT64:
- aDatetime.setValue(AInt64SerializerDeserializer.getLong(bytes, offset + 1));
- break;
- default:
- throw new AlgebricksException(
- FID.getName() + ": expects type INT8/INT16/INT32/INT64/NULL but got "
- + argPtrTypeTag);
- }
- datetimeSerde.serialize(aDatetime, out);
+ switch (argPtrTypeTag) {
+ case INT8:
+ aDatetime.setValue(AInt8SerializerDeserializer.getByte(bytes, offset + 1));
+ break;
+ case INT16:
+ aDatetime.setValue(AInt16SerializerDeserializer.getShort(bytes, offset + 1));
+ break;
+ case INT32:
+ aDatetime.setValue(AInt32SerializerDeserializer.getInt(bytes, offset + 1));
+ break;
+ case INT64:
+ aDatetime.setValue(AInt64SerializerDeserializer.getLong(bytes, offset + 1));
+ break;
+ default:
+ throw new AlgebricksException(FID.getName()
+ + ": expects type INT8/INT16/INT32/INT64/NULL but got " + argPtrTypeTag);
}
+ datetimeSerde.serialize(aDatetime, out);
} catch (HyracksDataException hex) {
throw new AlgebricksException(hex);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromUnixTimeInSecsDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromUnixTimeInSecsDescriptor.java
index 1450ce6..a0258b6 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromUnixTimeInSecsDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DatetimeFromUnixTimeInSecsDescriptor.java
@@ -27,7 +27,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ADateTime;
import org.apache.asterix.om.base.AMutableDateTime;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -82,9 +81,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ADateTime> datetimeSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADATETIME);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private AMutableDateTime aDatetime = new AMutableDateTime(0);
@@ -100,33 +96,25 @@
ATypeTag argPtrTypeTag = ATypeTag.VALUE_TYPE_MAPPING[bytes[offset]];
- if (argPtrTypeTag == ATypeTag.NULL) {
- nullSerde.serialize(ANull.NULL, out);
- } else {
- switch (argPtrTypeTag) {
- case INT8:
- aDatetime.setValue(
- (AInt8SerializerDeserializer.getByte(bytes, offset + 1) * 1000l));
- break;
- case INT16:
- aDatetime.setValue(
- (AInt16SerializerDeserializer.getShort(bytes, offset + 1) * 1000l));
- break;
- case INT32:
- aDatetime.setValue(
- (AInt32SerializerDeserializer.getInt(bytes, offset + 1) * 1000l));
- break;
- case INT64:
- aDatetime.setValue(
- (AInt64SerializerDeserializer.getLong(bytes, offset + 1) * 1000l));
- break;
- default:
- throw new AlgebricksException(
- FID.getName() + ": expects type INT8/INT16/INT32/INT64/NULL but got "
- + argPtrTypeTag);
- }
- datetimeSerde.serialize(aDatetime, out);
+ switch (argPtrTypeTag) {
+ case INT8:
+ aDatetime.setValue(AInt8SerializerDeserializer.getByte(bytes, offset + 1) * 1000l);
+ break;
+ case INT16:
+ aDatetime
+ .setValue(AInt16SerializerDeserializer.getShort(bytes, offset + 1) * 1000l);
+ break;
+ case INT32:
+ aDatetime.setValue(AInt32SerializerDeserializer.getInt(bytes, offset + 1) * 1000l);
+ break;
+ case INT64:
+ aDatetime.setValue(AInt64SerializerDeserializer.getLong(bytes, offset + 1) * 1000l);
+ break;
+ default:
+ throw new AlgebricksException(FID.getName()
+ + ": expects type INT8/INT16/INT32/INT64/NULL but got " + argPtrTypeTag);
}
+ datetimeSerde.serialize(aDatetime, out);
} catch (HyracksDataException hex) {
throw new AlgebricksException(hex);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayOfWeekDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayOfWeekDescriptor.java
index d7b5044..e1fe88b 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayOfWeekDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayOfWeekDescriptor.java
@@ -25,7 +25,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AInt64;
import org.apache.asterix.om.base.AMutableInt64;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
@@ -83,10 +82,6 @@
.getSerializerDeserializer(BuiltinType.AINT64);
private AMutableInt64 aInt64 = new AMutableInt64(0);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
-
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
resultStorage.reset();
@@ -96,46 +91,42 @@
int offset = argPtr.getStartOffset();
try {
- if (bytes[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
+ int daysSinceAnchor;
+ int reminder = 0;
+ if (bytes[offset] == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
+ daysSinceAnchor = (int) (ADateTimeSerializerDeserializer.getChronon(bytes, offset + 1)
+ / GregorianCalendarSystem.CHRONON_OF_DAY);
+ reminder = (int) (ADateTimeSerializerDeserializer.getChronon(bytes, offset + 1)
+ % GregorianCalendarSystem.CHRONON_OF_DAY);
+ } else if (bytes[offset] == ATypeTag.SERIALIZED_DATE_TYPE_TAG) {
+ daysSinceAnchor = ADateSerializerDeserializer.getChronon(bytes, offset + 1);
} else {
- int daysSinceAnchor;
- int reminder = 0;
- if (bytes[offset] == ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
- daysSinceAnchor = (int) (ADateTimeSerializerDeserializer.getChronon(bytes,
- offset + 1) / GregorianCalendarSystem.CHRONON_OF_DAY);
- reminder = (int) (ADateTimeSerializerDeserializer.getChronon(bytes, offset + 1)
- % GregorianCalendarSystem.CHRONON_OF_DAY);
- } else if (bytes[offset] == ATypeTag.SERIALIZED_DATE_TYPE_TAG) {
- daysSinceAnchor = ADateSerializerDeserializer.getChronon(bytes, offset + 1);
- } else {
- throw new AlgebricksException(
- FID.getName() + ": expects input type DATETIME/DATE/NULL but got "
- + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]));
- }
-
- // adjust the day before 1970-01-01
- if (daysSinceAnchor < 0 && reminder != 0) {
- daysSinceAnchor -= 1;
- }
-
- // compute the weekday (0-based, and 0 = Sunday). Adjustment is needed as the anchor day is Thursday
- int weekday = (daysSinceAnchor + ANCHOR_WEEKDAY) % 7;
-
- // handle the negative weekday
- if (weekday < 0) {
- weekday += 7;
- }
-
- // convert from 0-based to 1-based (so 7 = Sunday)
- if (weekday == 0) {
- weekday = 7;
- }
-
- aInt64.setValue(weekday);
-
- int64Serde.serialize(aInt64, out);
+ throw new AlgebricksException(
+ FID.getName() + ": expects input type DATETIME/DATE/NULL but got "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]));
}
+
+ // adjust the day before 1970-01-01
+ if (daysSinceAnchor < 0 && reminder != 0) {
+ daysSinceAnchor -= 1;
+ }
+
+ // compute the weekday (0-based, and 0 = Sunday). Adjustment is needed as
+ // the anchor day is Thursday.
+ int weekday = (daysSinceAnchor + ANCHOR_WEEKDAY) % 7;
+
+ // handle the negative weekday
+ if (weekday < 0) {
+ weekday += 7;
+ }
+
+ // convert from 0-based to 1-based (so 7 = Sunday)
+ if (weekday == 0) {
+ weekday = 7;
+ }
+
+ aInt64.setValue(weekday);
+ int64Serde.serialize(aInt64, out);
} catch (HyracksDataException hex) {
throw new AlgebricksException(hex);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationComparatorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationComparatorDescriptor.java
index b7d170b..2d29c81 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationComparatorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationComparatorDescriptor.java
@@ -23,10 +23,7 @@
import org.apache.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ABoolean;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
-import org.apache.asterix.om.functions.IFunctionDescriptor;
-import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
@@ -50,26 +47,10 @@
public final static FunctionIdentifier LESS_THAN_FID = AsterixBuiltinFunctions.DAY_TIME_DURATION_LESS_THAN;
private final boolean isGreaterThan;
- private DayTimeDurationComparatorDescriptor(boolean isGreaterThan) {
+ protected DayTimeDurationComparatorDescriptor(boolean isGreaterThan) {
this.isGreaterThan = isGreaterThan;
}
- public final static IFunctionDescriptorFactory GREATER_THAN_FACTORY = new IFunctionDescriptorFactory() {
-
- @Override
- public IFunctionDescriptor createFunctionDescriptor() {
- return new DayTimeDurationComparatorDescriptor(true);
- }
- };
-
- public final static IFunctionDescriptorFactory LESS_THAN_FACTORY = new IFunctionDescriptorFactory() {
-
- @Override
- public IFunctionDescriptor createFunctionDescriptor() {
- return new DayTimeDurationComparatorDescriptor(false);
- }
- };
-
@Override
public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
throws AlgebricksException {
@@ -88,10 +69,6 @@
private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx);
private IScalarEvaluator eval1 = args[1].createScalarEvaluator(ctx);
- // possible output types
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ABoolean> boolSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ABOOLEAN);
@@ -108,13 +85,6 @@
int offset1 = argPtr1.getStartOffset();
try {
- if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
-
if (bytes0[offset0] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG
|| bytes1[offset1] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
throw new AlgebricksException(getIdentifier().getName()
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationGreaterThanComparatorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationGreaterThanComparatorDescriptor.java
new file mode 100644
index 0000000..9480508
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationGreaterThanComparatorDescriptor.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.evaluators.functions.temporal;
+
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+
+public class DayTimeDurationGreaterThanComparatorDescriptor extends DayTimeDurationComparatorDescriptor {
+ private static final long serialVersionUID = 1L;
+
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new DayTimeDurationGreaterThanComparatorDescriptor();
+ }
+ };
+
+ protected DayTimeDurationGreaterThanComparatorDescriptor() {
+ super(true);
+ }
+}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationLessThanComparatorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationLessThanComparatorDescriptor.java
new file mode 100644
index 0000000..7304ae9
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DayTimeDurationLessThanComparatorDescriptor.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.evaluators.functions.temporal;
+
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+
+public class DayTimeDurationLessThanComparatorDescriptor extends DayTimeDurationComparatorDescriptor {
+ private static final long serialVersionUID = 1L;
+
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new DayTimeDurationLessThanComparatorDescriptor();
+ }
+ };
+
+ protected DayTimeDurationLessThanComparatorDescriptor() {
+ super(false);
+ }
+}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationEqualDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationEqualDescriptor.java
index bd18f0b..0a88684 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationEqualDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationEqualDescriptor.java
@@ -23,7 +23,6 @@
import org.apache.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ABoolean;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -72,10 +71,6 @@
private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx);
private IScalarEvaluator eval1 = args[1].createScalarEvaluator(ctx);
- // possible output types
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ABoolean> boolSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ABOOLEAN);
@@ -92,13 +87,6 @@
int offset1 = argPtr1.getStartOffset();
try {
- if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
-
if (bytes0[offset0] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG
|| bytes1[offset1] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
throw new AlgebricksException(FID.getName()
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromIntervalDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromIntervalDescriptor.java
index 28d2b85..0c4042f 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromIntervalDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromIntervalDescriptor.java
@@ -24,7 +24,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ADayTimeDuration;
import org.apache.asterix.om.base.AMutableDayTimeDuration;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
@@ -74,10 +73,6 @@
private IScalarEvaluator eval = args[0].createScalarEvaluator(ctx);
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
-
- @SuppressWarnings("unchecked")
private ISerializerDeserializer<ADayTimeDuration> dayTimeDurationSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADAYTIMEDURATION);
@@ -92,11 +87,7 @@
int offset = argPtr.getStartOffset();
try {
- if (bytes[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- } else if (bytes[offset] != ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
+ if (bytes[offset] != ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG) {
throw new AlgebricksException(
FID.getName() + ": expects INTERVAL/NULL as the input but got "
+ EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]));
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMillisecondsDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMillisecondsDescriptor.java
index b1860bb..480cf8f 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMillisecondsDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMillisecondsDescriptor.java
@@ -27,7 +27,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ADuration;
import org.apache.asterix.om.base.AMutableDuration;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -75,10 +74,6 @@
private IPointable argPtr0 = new VoidPointable();
private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx);
- // possible output types
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ADuration> durationSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADURATION);
@@ -94,29 +89,24 @@
try {
ATypeTag argPtrTypeTag = ATypeTag.VALUE_TYPE_MAPPING[bytes[offset]];
- if (argPtrTypeTag == ATypeTag.NULL) {
- nullSerde.serialize(ANull.NULL, out);
- } else {
- switch (argPtrTypeTag) {
- case INT8:
- aDuration.setValue(0, AInt8SerializerDeserializer.getByte(bytes, offset + 1));
- break;
- case INT16:
- aDuration.setValue(0, AInt16SerializerDeserializer.getShort(bytes, offset + 1));
- break;
- case INT32:
- aDuration.setValue(0, AInt32SerializerDeserializer.getInt(bytes, offset + 1));
- break;
- case INT64:
- aDuration.setValue(0, AInt64SerializerDeserializer.getLong(bytes, offset + 1));
- break;
- default:
- throw new AlgebricksException(
- FID.getName() + ": expects type INT8/INT16/INT32/INT64/NULL but got "
- + argPtrTypeTag);
- }
- durationSerde.serialize(aDuration, out);
+ switch (argPtrTypeTag) {
+ case INT8:
+ aDuration.setValue(0, AInt8SerializerDeserializer.getByte(bytes, offset + 1));
+ break;
+ case INT16:
+ aDuration.setValue(0, AInt16SerializerDeserializer.getShort(bytes, offset + 1));
+ break;
+ case INT32:
+ aDuration.setValue(0, AInt32SerializerDeserializer.getInt(bytes, offset + 1));
+ break;
+ case INT64:
+ aDuration.setValue(0, AInt64SerializerDeserializer.getLong(bytes, offset + 1));
+ break;
+ default:
+ throw new AlgebricksException(FID.getName()
+ + ": expects type INT8/INT16/INT32/INT64/NULL but got " + argPtrTypeTag);
}
+ durationSerde.serialize(aDuration, out);
} catch (HyracksDataException hex) {
throw new AlgebricksException(hex);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMonthsDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMonthsDescriptor.java
index 334607a..5db6294 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMonthsDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/DurationFromMonthsDescriptor.java
@@ -23,11 +23,9 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ADuration;
import org.apache.asterix.om.base.AMutableDuration;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
-import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
@@ -71,10 +69,6 @@
private IPointable argPtr0 = new VoidPointable();
private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx);
- // possible output types
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ADuration> durationSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADURATION);
@@ -90,11 +84,6 @@
int offset = argPtr0.getStartOffset();
try {
- if (bytes[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
aDuration.setValue(ATypeHierarchy.getIntegerValue(bytes, offset), 0);
durationSerde.serialize(aDuration, out);
} catch (HyracksDataException hex) {
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetDayTimeDurationDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetDayTimeDurationDescriptor.java
index b75a5b9..cb84fc8 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetDayTimeDurationDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetDayTimeDurationDescriptor.java
@@ -24,7 +24,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ADayTimeDuration;
import org.apache.asterix.om.base.AMutableDayTimeDuration;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -71,10 +70,6 @@
private IPointable argPtr0 = new VoidPointable();
private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx);
- // possible output types
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ADayTimeDuration> dayTimeDurationSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADAYTIMEDURATION);
@@ -90,12 +85,6 @@
int offset = argPtr0.getStartOffset();
try {
- if (bytes[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
-
if (bytes[offset] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
throw new AlgebricksException(FID.getName() + ": expects NULL/DURATION, but got "
+ EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]));
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetOverlappingIntervalDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetOverlappingIntervalDescriptor.java
index 9726058..1de1e48 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetOverlappingIntervalDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetOverlappingIntervalDescriptor.java
@@ -96,10 +96,7 @@
byte type1 = argPtr1.getTag();
try {
- if (type0 == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || type1 == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- } else if (type0 == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG && type0 == type1) {
+ if (type0 == ATypeTag.SERIALIZED_INTERVAL_TYPE_TAG && type0 == type1) {
argPtr0.getValue(interval0);
argPtr1.getValue(interval1);
byte intervalType0 = interval0.getType();
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetYearMonthDurationDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetYearMonthDurationDescriptor.java
index d3397c4..d2e4b6e 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetYearMonthDurationDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/GetYearMonthDurationDescriptor.java
@@ -23,7 +23,6 @@
import org.apache.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AMutableYearMonthDuration;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.AYearMonthDuration;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
@@ -71,10 +70,6 @@
private IPointable argPtr0 = new VoidPointable();
private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx);
- // possible output types
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@SuppressWarnings("unchecked")
private ISerializerDeserializer<AYearMonthDuration> yearMonthDurationSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AYEARMONTHDURATION);
@@ -90,12 +85,6 @@
int offset0 = argPtr0.getStartOffset();
try {
- if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
-
if (bytes0[offset0] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
throw new AlgebricksException(FID.getName() + ": expects NULL/DURATION, but got "
+ EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[offset0]));
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalBinDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalBinDescriptor.java
index 2160910..b584442 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalBinDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalBinDescriptor.java
@@ -28,7 +28,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AInterval;
import org.apache.asterix.om.base.AMutableInterval;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.DurationArithmeticOperations;
import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
@@ -86,9 +85,6 @@
private final AMutableInterval aInterval = new AMutableInterval(0, 0, (byte) -1);
@SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
- @SuppressWarnings("unchecked")
private final ISerializerDeserializer<AInterval> intervalSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINTERVAL);
@@ -98,9 +94,11 @@
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
resultStorage.reset();
eval0.evaluate(tuple, argPtr0);
+ eval1.evaluate(tuple, argPtr1);
+ eval2.evaluate(tuple, argPtr2);
+
byte[] bytes0 = argPtr0.getByteArray();
int offset0 = argPtr0.getStartOffset();
-
ATypeTag type0 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes0[offset0]);
long chrononToBin = 0;
@@ -115,30 +113,18 @@
case DATETIME:
chrononToBin = ADateTimeSerializerDeserializer.getChronon(bytes0, offset0 + 1);
break;
- case NULL:
- try {
- nullSerde.serialize(ANull.NULL, out);
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
- }
- result.set(resultStorage);
- return;
default:
throw new AlgebricksException(getIdentifier().getName()
+ ": the first argument should be DATE/TIME/DATETIME/NULL but got " + type0);
-
}
- eval1.evaluate(tuple, argPtr1);
byte[] bytes1 = argPtr1.getByteArray();
int offset1 = argPtr1.getStartOffset();
ATypeTag type1 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]);
if (type0 != type1) {
- if (type0 != ATypeTag.NULL && type1 != ATypeTag.NULL) {
- throw new AlgebricksException(getIdentifier().getName() + ": expecting " + type0
- + " for the second argument but got " + type1);
- }
+ throw new AlgebricksException(getIdentifier().getName() + ": expecting " + type0
+ + " for the second argument but got " + type1);
}
long chrononToStart = 0;
@@ -153,20 +139,11 @@
case DATETIME:
chrononToStart = ADateTimeSerializerDeserializer.getChronon(bytes1, offset1 + 1);
break;
- case NULL:
- try {
- nullSerde.serialize(ANull.NULL, out);
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
- }
- result.set(resultStorage);
- return;
default:
throw new AlgebricksException(getIdentifier().getName() + ": expecting " + type0
+ " for the second argument but got " + type1);
}
- eval2.evaluate(tuple, argPtr2);
byte[] bytes2 = argPtr2.getByteArray();
int offset2 = argPtr2.getStartOffset();
ATypeTag type2 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes2[offset2]);
@@ -205,16 +182,7 @@
binIndex = totalChronon / dayTime
+ ((totalChronon < 0 && totalChronon % dayTime != 0) ? -1 : 0);
-
break;
- case NULL:
- try {
- nullSerde.serialize(ANull.NULL, out);
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
- }
- result.set(resultStorage);
- return;
default:
throw new AlgebricksException(getIdentifier().getName()
+ ": expecting YEARMONTHDURATION/DAYTIMEDURATION for the thrid argument but got "
@@ -253,18 +221,9 @@
binEndChronon = DurationArithmeticOperations.addDuration(chrononToStart,
yearMonth * ((int) binIndex + 1), dayTime * (binIndex + 1), false);
break;
- case NULL:
- try {
- nullSerde.serialize(ANull.NULL, out);
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
- }
- result.set(resultStorage);
- return;
default:
throw new AlgebricksException(getIdentifier().getName()
+ ": the first argument should be DATE/TIME/DATETIME/NULL but got " + type0);
-
}
try {
aInterval.setValue(binStartChronon, binEndChronon, type0.serialize());
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalEndsDecriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalEndsDescriptor.java
similarity index 87%
rename from asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalEndsDecriptor.java
rename to asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalEndsDescriptor.java
index 459652e..9571787 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalEndsDecriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalEndsDescriptor.java
@@ -25,15 +25,14 @@
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
-public class IntervalEndsDecriptor extends AbstractIntervalLogicFuncDescriptor {
+public class IntervalEndsDescriptor extends AbstractIntervalLogicFuncDescriptor {
+ private static final long serialVersionUID = 1L;
- private final static long serialVersionUID = 1L;
-
- public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
@Override
public IFunctionDescriptor createFunctionDescriptor() {
- return new IntervalEndsDecriptor();
+ return new IntervalEndsDescriptor();
}
};
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MillisecondsFromDayTimeDurationDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MillisecondsFromDayTimeDurationDescriptor.java
index 4b1fedd..ffca20751 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MillisecondsFromDayTimeDurationDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MillisecondsFromDayTimeDurationDescriptor.java
@@ -24,7 +24,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AInt64;
import org.apache.asterix.om.base.AMutableInt64;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -71,10 +70,6 @@
private IPointable argPtr0 = new VoidPointable();
private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx);
- // possible output types
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@SuppressWarnings("unchecked")
private ISerializerDeserializer<AInt64> int64Serde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT64);
@@ -90,12 +85,6 @@
int offset = argPtr0.getStartOffset();
try {
- if (bytes[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
-
if (bytes[offset] != ATypeTag.SERIALIZED_DAY_TIME_DURATION_TYPE_TAG) {
throw new AlgebricksException(
FID.getName() + ": expects NULL/DAY-TIME-DURATION, but got "
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MonthsFromYearMonthDurationDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MonthsFromYearMonthDurationDescriptor.java
index d7198f1..0d2b934 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MonthsFromYearMonthDurationDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/MonthsFromYearMonthDurationDescriptor.java
@@ -24,7 +24,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AInt64;
import org.apache.asterix.om.base.AMutableInt64;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
@@ -71,10 +70,6 @@
private IPointable argPtr0 = new VoidPointable();
private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx);
- // possible output types
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@SuppressWarnings("unchecked")
private ISerializerDeserializer<AInt64> int64Serde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINT64);
@@ -90,12 +85,6 @@
int offset = argPtr0.getStartOffset();
try {
- if (bytes[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
-
if (bytes[offset] != ATypeTag.SERIALIZED_YEAR_MONTH_DURATION_TYPE_TAG) {
throw new AlgebricksException(
FID.getName() + ": expects NULL/YEAR-MONTH-DURATION, but got "
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/OverlapBinsDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/OverlapBinsDescriptor.java
index fcf22e4..836408d 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/OverlapBinsDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/OverlapBinsDescriptor.java
@@ -31,7 +31,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AInterval;
import org.apache.asterix.om.base.AMutableInterval;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.DurationArithmeticOperations;
import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
@@ -48,7 +47,6 @@
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
-import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
@@ -93,10 +91,6 @@
protected final AOrderedListType intListType = new AOrderedListType(BuiltinType.AINTERVAL, null);
private final AMutableInterval aInterval = new AMutableInterval(0, 0, (byte) -1);
-
- @SuppressWarnings("unchecked")
- private final ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@SuppressWarnings("unchecked")
private final ISerializerDeserializer<AInterval> intervalSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.AINTERVAL);
@@ -107,6 +101,9 @@
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
resultStorage.reset();
eval0.evaluate(tuple, argPtr0);
+ eval1.evaluate(tuple, argPtr1);
+ eval2.evaluate(tuple, argPtr2);
+
byte[] bytes0 = argPtr0.getByteArray();
int offset0 = argPtr0.getStartOffset();
@@ -119,32 +116,18 @@
intervalStart = AIntervalSerializerDeserializer.getIntervalStart(bytes0, offset0 + 1);
intervalEnd = AIntervalSerializerDeserializer.getIntervalEnd(bytes0, offset0 + 1);
intervalTypeTag = AIntervalSerializerDeserializer.getIntervalTimeType(bytes0, offset0 + 1);
- } else if (type0 == ATypeTag.NULL) {
- try {
- nullSerde.serialize(ANull.NULL, out);
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
- }
- result.set(resultStorage);
- return;
} else {
throw new AlgebricksException(getIdentifier().getName()
- + ": the first argument should be INTERVAL/NULL but got " + type0);
+ + ": the first argument should be INTERVAL/NULL/MISSING but got " + type0);
}
// get the anchor instance time
- eval1.evaluate(tuple, argPtr1);
byte[] bytes1 = argPtr1.getByteArray();
int offset1 = argPtr1.getStartOffset();
-
ATypeTag type1 = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes1[offset1]);
-
- if (intervalTypeTag != type1.serialize()) {
- if (intervalTypeTag != ATypeTag.SERIALIZED_NULL_TYPE_TAG && type1 != ATypeTag.NULL) {
- throw new AlgebricksException(
- getIdentifier().getName() + ": expecting compatible type to " + type0 + "("
- + intervalTypeTag + ") for the second argument but got " + type1);
- }
+ if (intervalTypeTag != bytes1[offset1]) {
+ throw new AlgebricksException(getIdentifier().getName() + ": expecting compatible type to "
+ + type0 + "(" + intervalTypeTag + ") for the second argument but got " + type1);
}
long anchorTime = 0;
@@ -159,21 +142,12 @@
case DATETIME:
anchorTime = ADateTimeSerializerDeserializer.getChronon(bytes1, offset1 + 1);
break;
- case NULL:
- try {
- nullSerde.serialize(ANull.NULL, out);
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
- }
- result.set(resultStorage);
- return;
default:
throw new AlgebricksException(
getIdentifier().getName() + ": expecting compatible type to " + type0 + "("
+ intervalTypeTag + ") for the second argument but got " + type1);
}
- eval2.evaluate(tuple, argPtr2);
byte[] bytes2 = argPtr2.getByteArray();
int offset2 = argPtr2.getStartOffset();
@@ -215,16 +189,6 @@
firstBinIndex = totalChronon / dayTime
+ ((totalChronon < 0 && totalChronon % dayTime != 0) ? -1 : 0);
break;
-
- case NULL:
- try {
- nullSerde.serialize(ANull.NULL, out);
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
- }
- result.set(resultStorage);
- return;
-
default:
throw new AlgebricksException(getIdentifier().getName()
+ ": expecting YEARMONTHDURATION/DAYTIMEDURATION for the thrid argument but got "
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateDescriptor.java
index 1243394..1810b48 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateDescriptor.java
@@ -23,7 +23,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ADate;
import org.apache.asterix.om.base.AMutableDate;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.AsterixTemporalTypeParseException;
import org.apache.asterix.om.base.temporal.DateTimeFormatUtils;
import org.apache.asterix.om.base.temporal.DateTimeFormatUtils.DateTimeParseMode;
@@ -83,9 +82,6 @@
private IScalarEvaluator eval1 = args[1].createScalarEvaluator(ctx);
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
- @SuppressWarnings("unchecked")
private ISerializerDeserializer<ADate> dateSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADATE);
@@ -106,13 +102,6 @@
int len1 = argPtr1.getLength();
try {
- if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
-
if (bytes0[offset0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
|| bytes1[offset1] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
throw new AlgebricksException(getIdentifier().getName()
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateTimeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateTimeDescriptor.java
index 7c8847a..9717f8e 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateTimeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseDateTimeDescriptor.java
@@ -23,7 +23,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ADateTime;
import org.apache.asterix.om.base.AMutableDateTime;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.AsterixTemporalTypeParseException;
import org.apache.asterix.om.base.temporal.DateTimeFormatUtils;
import org.apache.asterix.om.base.temporal.DateTimeFormatUtils.DateTimeParseMode;
@@ -78,9 +77,6 @@
private IScalarEvaluator eval1 = args[1].createScalarEvaluator(ctx);
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
- @SuppressWarnings("unchecked")
private ISerializerDeserializer<ADateTime> datetimeSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ADATETIME);
@@ -101,13 +97,6 @@
int len1 = argPtr1.getLength();
try {
- if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
-
if (bytes0[offset0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
|| bytes1[offset1] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
throw new AlgebricksException(getIdentifier().getName()
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseTimeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseTimeDescriptor.java
index 893c357..fb4bc55 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseTimeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/ParseTimeDescriptor.java
@@ -22,7 +22,6 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AMutableTime;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.ATime;
import org.apache.asterix.om.base.temporal.AsterixTemporalTypeParseException;
import org.apache.asterix.om.base.temporal.DateTimeFormatUtils;
@@ -79,9 +78,6 @@
private IScalarEvaluator eval1 = args[1].createScalarEvaluator(ctx);
@SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
- @SuppressWarnings("unchecked")
private ISerializerDeserializer<ATime> timeSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ATIME);
@@ -102,13 +98,6 @@
int len1 = argPtr1.getLength();
try {
- if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
-
if (bytes0[offset0] != ATypeTag.SERIALIZED_STRING_TYPE_TAG
|| bytes1[offset1] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
throw new AlgebricksException(getIdentifier().getName()
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintDateDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintDateDescriptor.java
index f48a5c4..b979786 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintDateDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintDateDescriptor.java
@@ -22,8 +22,6 @@
import java.io.IOException;
import org.apache.asterix.dataflow.data.nontagged.serde.ADateSerializerDeserializer;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.DateTimeFormatUtils;
import org.apache.asterix.om.base.temporal.DateTimeFormatUtils.DateTimeParseMode;
import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
@@ -31,7 +29,6 @@
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -39,7 +36,6 @@
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
@@ -78,10 +74,6 @@
private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx);
private IScalarEvaluator eval1 = args[1].createScalarEvaluator(ctx);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
-
private StringBuilder sbder = new StringBuilder();
private final UTF8StringWriter utf8Writer = new UTF8StringWriter();
@@ -97,13 +89,6 @@
int offset1 = argPtr1.getStartOffset();
try {
- if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
-
if (bytes0[offset0] != ATypeTag.SERIALIZED_DATE_TYPE_TAG
|| bytes1[offset1] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
throw new AlgebricksException(getIdentifier().getName()
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintDateTimeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintDateTimeDescriptor.java
index 75fcfe7..780d09a 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintDateTimeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintDateTimeDescriptor.java
@@ -22,15 +22,12 @@
import java.io.IOException;
import org.apache.asterix.dataflow.data.nontagged.serde.ADateTimeSerializerDeserializer;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.DateTimeFormatUtils;
import org.apache.asterix.om.base.temporal.DateTimeFormatUtils.DateTimeParseMode;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -38,7 +35,6 @@
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
@@ -76,11 +72,6 @@
private IPointable argPtr1 = new VoidPointable();
private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx);
private IScalarEvaluator eval1 = args[1].createScalarEvaluator(ctx);
-
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
-
private StringBuilder sbder = new StringBuilder();
private UTF8StringWriter utf8Writer = new UTF8StringWriter();
private UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@@ -98,13 +89,6 @@
int len1 = argPtr1.getLength();
try {
- if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
-
if (bytes0[offset0] != ATypeTag.SERIALIZED_DATETIME_TYPE_TAG
|| bytes1[offset1] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
throw new AlgebricksException(getIdentifier().getName()
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintTimeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintTimeDescriptor.java
index 2318412..576de35 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintTimeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/PrintTimeDescriptor.java
@@ -22,15 +22,12 @@
import java.io.IOException;
import org.apache.asterix.dataflow.data.nontagged.serde.ATimeSerializerDeserializer;
-import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.temporal.DateTimeFormatUtils;
import org.apache.asterix.om.base.temporal.DateTimeFormatUtils.DateTimeParseMode;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.om.types.ATypeTag;
-import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -38,7 +35,6 @@
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluator;
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.UTF8StringPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
@@ -77,10 +73,6 @@
private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx);
private IScalarEvaluator eval1 = args[1].createScalarEvaluator(ctx);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
-
private StringBuilder sbder = new StringBuilder();
private final UTF8StringWriter writer = new UTF8StringWriter();
private final UTF8StringPointable utf8Ptr = new UTF8StringPointable();
@@ -98,13 +90,6 @@
int len1 = argPtr1.getLength();
try {
- if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
-
if (bytes0[offset0] != ATypeTag.SERIALIZED_TIME_TYPE_TAG
|| bytes1[offset1] != ATypeTag.SERIALIZED_STRING_TYPE_TAG) {
throw new AlgebricksException(getIdentifier().getName()
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/TimeFromDatetimeDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/TimeFromDatetimeDescriptor.java
index a8c3fe6..6846ef8 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/TimeFromDatetimeDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/TimeFromDatetimeDescriptor.java
@@ -23,7 +23,6 @@
import org.apache.asterix.dataflow.data.nontagged.serde.ADateTimeSerializerDeserializer;
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AMutableTime;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.ATime;
import org.apache.asterix.om.base.temporal.GregorianCalendarSystem;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
@@ -83,10 +82,6 @@
.getSerializerDeserializer(BuiltinType.ATIME);
private AMutableTime aTime = new AMutableTime(0);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
-
@Override
public void evaluate(IFrameTupleReference tuple, IPointable result) throws AlgebricksException {
resultStorage.reset();
@@ -96,22 +91,18 @@
int offset = argPtr.getStartOffset();
try {
- if (bytes[offset] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- } else {
- if (bytes[offset] != ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
- throw new AlgebricksException(
- FID.getName() + ": expects input type DATETIME/NULL but got "
- + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]));
- }
- long datetimeChronon = ADateTimeSerializerDeserializer.getChronon(bytes, offset + 1);
- int timeChronon = (int) (datetimeChronon % GregorianCalendarSystem.CHRONON_OF_DAY);
- if (timeChronon < 0) {
- timeChronon += GregorianCalendarSystem.CHRONON_OF_DAY;
- }
- aTime.setValue(timeChronon);
- timeSerde.serialize(aTime, out);
+ if (bytes[offset] != ATypeTag.SERIALIZED_DATETIME_TYPE_TAG) {
+ throw new AlgebricksException(
+ FID.getName() + ": expects input type DATETIME/NULL but got "
+ + EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(bytes[offset]));
}
+ long datetimeChronon = ADateTimeSerializerDeserializer.getChronon(bytes, offset + 1);
+ int timeChronon = (int) (datetimeChronon % GregorianCalendarSystem.CHRONON_OF_DAY);
+ if (timeChronon < 0) {
+ timeChronon += GregorianCalendarSystem.CHRONON_OF_DAY;
+ }
+ aTime.setValue(timeChronon);
+ timeSerde.serialize(aTime, out);
} catch (HyracksDataException hex) {
throw new AlgebricksException(hex);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/TimeFromUnixTimeInMsDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/TimeFromUnixTimeInMsDescriptor.java
index 48be51d..e46241d 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/TimeFromUnixTimeInMsDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/TimeFromUnixTimeInMsDescriptor.java
@@ -22,12 +22,10 @@
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.AMutableTime;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.base.ATime;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
-import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.hierachy.ATypeHierarchy;
import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor;
@@ -77,9 +75,6 @@
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ATime> timeSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ATIME);
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
private AMutableTime aTime = new AMutableTime(0);
@@ -88,13 +83,9 @@
resultStorage.reset();
eval.evaluate(tuple, argPtr);
try {
- if (argPtr.getByteArray()[argPtr.getStartOffset()] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- } else {
- aTime.setValue(
- ATypeHierarchy.getIntegerValue(argPtr.getByteArray(), argPtr.getStartOffset()));
- timeSerde.serialize(aTime, out);
- }
+ aTime.setValue(
+ ATypeHierarchy.getIntegerValue(argPtr.getByteArray(), argPtr.getStartOffset()));
+ timeSerde.serialize(aTime, out);
} catch (HyracksDataException hex) {
throw new AlgebricksException(hex);
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/YearMonthDurationComparatorDecriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/YearMonthDurationComparatorDescriptor.java
similarity index 77%
rename from asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/YearMonthDurationComparatorDecriptor.java
rename to asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/YearMonthDurationComparatorDescriptor.java
index 52cbaf5..10b8116 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/YearMonthDurationComparatorDecriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/YearMonthDurationComparatorDescriptor.java
@@ -23,10 +23,7 @@
import org.apache.asterix.dataflow.data.nontagged.serde.ADurationSerializerDeserializer;
import org.apache.asterix.formats.nontagged.AqlSerializerDeserializerProvider;
import org.apache.asterix.om.base.ABoolean;
-import org.apache.asterix.om.base.ANull;
import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
-import org.apache.asterix.om.functions.IFunctionDescriptor;
-import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.om.types.ATypeTag;
import org.apache.asterix.om.types.BuiltinType;
import org.apache.asterix.om.types.EnumDeserializer;
@@ -43,32 +40,16 @@
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference;
-public class YearMonthDurationComparatorDecriptor extends AbstractScalarFunctionDynamicDescriptor {
- private final static long serialVersionUID = 1L;
- public final static FunctionIdentifier GREATER_THAN_FID = AsterixBuiltinFunctions.YEAR_MONTH_DURATION_GREATER_THAN;
- public final static FunctionIdentifier LESS_THAN_FID = AsterixBuiltinFunctions.YEAR_MONTH_DURATION_LESS_THAN;
+public class YearMonthDurationComparatorDescriptor extends AbstractScalarFunctionDynamicDescriptor {
+ private static final long serialVersionUID = 1L;
+ public static final FunctionIdentifier GREATER_THAN_FID = AsterixBuiltinFunctions.YEAR_MONTH_DURATION_GREATER_THAN;
+ public static final FunctionIdentifier LESS_THAN_FID = AsterixBuiltinFunctions.YEAR_MONTH_DURATION_LESS_THAN;
private final boolean isGreaterThan;
- private YearMonthDurationComparatorDecriptor(boolean isGreaterThan) {
+ protected YearMonthDurationComparatorDescriptor(boolean isGreaterThan) {
this.isGreaterThan = isGreaterThan;
}
- public final static IFunctionDescriptorFactory GREATER_THAN_FACTORY = new IFunctionDescriptorFactory() {
-
- @Override
- public IFunctionDescriptor createFunctionDescriptor() {
- return new YearMonthDurationComparatorDecriptor(true);
- }
- };
-
- public final static IFunctionDescriptorFactory LESS_THAN_FACTORY = new IFunctionDescriptorFactory() {
-
- @Override
- public IFunctionDescriptor createFunctionDescriptor() {
- return new YearMonthDurationComparatorDecriptor(false);
- }
- };
-
@Override
public IScalarEvaluatorFactory createEvaluatorFactory(final IScalarEvaluatorFactory[] args)
throws AlgebricksException {
@@ -87,10 +68,6 @@
private IScalarEvaluator eval0 = args[0].createScalarEvaluator(ctx);
private IScalarEvaluator eval1 = args[1].createScalarEvaluator(ctx);
- // possible output types
- @SuppressWarnings("unchecked")
- private ISerializerDeserializer<ANull> nullSerde = AqlSerializerDeserializerProvider.INSTANCE
- .getSerializerDeserializer(BuiltinType.ANULL);
@SuppressWarnings("unchecked")
private ISerializerDeserializer<ABoolean> boolSerde = AqlSerializerDeserializerProvider.INSTANCE
.getSerializerDeserializer(BuiltinType.ABOOLEAN);
@@ -107,13 +84,6 @@
int offset1 = argPtr1.getStartOffset();
try {
- if (bytes0[offset0] == ATypeTag.SERIALIZED_NULL_TYPE_TAG
- || bytes1[offset1] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- nullSerde.serialize(ANull.NULL, out);
- result.set(resultStorage);
- return;
- }
-
if (bytes0[offset0] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG
|| bytes1[offset1] != ATypeTag.SERIALIZED_DURATION_TYPE_TAG) {
throw new AlgebricksException(getIdentifier().getName()
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalEndsDecriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/YearMonthDurationGreaterThanComparatorDescriptor.java
similarity index 60%
copy from asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalEndsDecriptor.java
copy to asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/YearMonthDurationGreaterThanComparatorDescriptor.java
index 459652e..42458ad 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/IntervalEndsDecriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/YearMonthDurationGreaterThanComparatorDescriptor.java
@@ -16,36 +16,24 @@
* specific language governing permissions and limitations
* under the License.
*/
+
package org.apache.asterix.runtime.evaluators.functions.temporal;
-import org.apache.asterix.om.functions.AsterixBuiltinFunctions;
import org.apache.asterix.om.functions.IFunctionDescriptor;
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
-import org.apache.asterix.om.pointables.nonvisitor.AIntervalPointable;
-import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-import org.apache.hyracks.algebricks.core.algebra.functions.FunctionIdentifier;
-public class IntervalEndsDecriptor extends AbstractIntervalLogicFuncDescriptor {
+public class YearMonthDurationGreaterThanComparatorDescriptor extends YearMonthDurationComparatorDescriptor {
- private final static long serialVersionUID = 1L;
-
+ private static final long serialVersionUID = 1L;
public final static IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
@Override
public IFunctionDescriptor createFunctionDescriptor() {
- return new IntervalEndsDecriptor();
+ return new YearMonthDurationGreaterThanComparatorDescriptor();
}
};
- @Override
- public FunctionIdentifier getIdentifier() {
- return AsterixBuiltinFunctions.INTERVAL_ENDS;
+ protected YearMonthDurationGreaterThanComparatorDescriptor() {
+ super(true);
}
-
- @Override
- protected boolean compareIntervals(IntervalLogic il, AIntervalPointable ip1, AIntervalPointable ip2)
- throws AlgebricksException {
- return il.ends(ip1, ip2);
- }
-
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/YearMonthDurationLessThanComparatorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/YearMonthDurationLessThanComparatorDescriptor.java
new file mode 100644
index 0000000..da8867d
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/temporal/YearMonthDurationLessThanComparatorDescriptor.java
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.asterix.runtime.evaluators.functions.temporal;
+
+import org.apache.asterix.om.functions.IFunctionDescriptor;
+import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
+
+public class YearMonthDurationLessThanComparatorDescriptor extends YearMonthDurationComparatorDescriptor {
+
+ private static final long serialVersionUID = 1L;
+ public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() {
+
+ @Override
+ public IFunctionDescriptor createFunctionDescriptor() {
+ return new YearMonthDurationLessThanComparatorDescriptor();
+ }
+ };
+
+ protected YearMonthDurationLessThanComparatorDescriptor() {
+ super(false);
+ }
+}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/staticcodegen/CodeGenUtil.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/staticcodegen/CodeGenUtil.java
index 3de9fc4..1da88a1 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/staticcodegen/CodeGenUtil.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/staticcodegen/CodeGenUtil.java
@@ -22,6 +22,8 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -36,11 +38,16 @@
public final static String DEFAULT_SUFFIX_FOR_GENERATED_CLASS = "Gen";
private final static String OBJECT_CLASS_NAME = "java/lang/Object";
+ private final static String DESCRIPTOR_SUPER_CLASS_NAME = "org/apache/asterix/runtime/"
+ + "evaluators/base/AbstractScalarFunctionDynamicDescriptor";
private final static String EVALUATOR_FACTORY = "EvaluatorFactory";
private final static String EVALUATOR = "Evaluator";
private final static String INNER = "Inner";
private final static String DESCRIPTOR = "Descriptor";
+ private final static String ACCESSOR = "Accessor";
private final static String DOLLAR = "$";
+ private final static String PKG_SUFFIX = "/generated";
+ private final static String ASTERIXDB_PREFIX = "org/apache/asterix";
/**
* The callback interface for a caller to determine what it needs to do for
@@ -74,15 +81,26 @@
* @throws IOException
* @throws ClassNotFoundException
*/
- public static void generateScalarFunctionDescriptorBinary(String packagePrefix,
+ public static List<Pair<String, String>> generateScalarFunctionDescriptorBinary(String packagePrefix,
String originalFuncDescriptorClassName, String suffixForGeneratedClass, ClassLoader classLoader,
ClassByteCodeAction action) throws IOException, ClassNotFoundException {
originalFuncDescriptorClassName = toInternalClassName(originalFuncDescriptorClassName);
- String targetFuncDescriptorClassName = toInternalClassName(
- originalFuncDescriptorClassName + suffixForGeneratedClass);
+ if (originalFuncDescriptorClassName.equals(DESCRIPTOR_SUPER_CLASS_NAME)) {
+ return Collections.emptyList();
+ }
+
+ String targetFuncDescriptorClassName = getGeneratedFunctionDescriptorInternalClassName(
+ originalFuncDescriptorClassName, suffixForGeneratedClass);
// Adds the mapping of the old/new names of the function descriptor.
List<Pair<String, String>> nameMappings = new ArrayList<>();
+
+ // Generates code for super classes except java.lang.Object.
+ Class<?> evaluatorClass = CodeGenUtil.class.getClassLoader()
+ .loadClass(toJdkStandardName(originalFuncDescriptorClassName));
+ nameMappings.addAll(generateScalarFunctionDescriptorBinary(packagePrefix,
+ evaluatorClass.getSuperclass().getName(), suffixForGeneratedClass, classLoader, action));
+
nameMappings.add(Pair.of(originalFuncDescriptorClassName, targetFuncDescriptorClassName));
nameMappings.add(Pair.of(toJdkStandardName(originalFuncDescriptorClassName),
toJdkStandardName(targetFuncDescriptorClassName)));
@@ -102,7 +120,7 @@
int evalFactoryCounter = 0;
for (String evaluateFactoryClassName : evaluatorFactoryClassNames) {
generateEvaluatorFactoryClassBinary(packagePrefix, evaluateFactoryClassName, suffixForGeneratedClass,
- ++evalFactoryCounter, nameMappings, classLoader, action);
+ evalFactoryCounter++, nameMappings, classLoader, action);
}
// Transforms the function descriptor class and outputs the generated class binary.
@@ -110,6 +128,21 @@
RenameClassVisitor renamingVisitor = new RenameClassVisitor(writer, nameMappings);
reader.accept(renamingVisitor, 0);
action.runAction(targetFuncDescriptorClassName, writer.toByteArray());
+ return nameMappings;
+ }
+
+ public static String getGeneratedFunctionDescriptorClassName(String originalFuncDescriptorClassName,
+ String suffixForGeneratedClass) {
+ return toJdkStandardName(getGeneratedFunctionDescriptorInternalClassName(originalFuncDescriptorClassName,
+ suffixForGeneratedClass));
+ }
+
+ private static String getGeneratedFunctionDescriptorInternalClassName(String originalFuncDescriptorClassName,
+ String suffixForGeneratedClass) {
+ String originalFuncDescriptorClassInternalName = toInternalClassName(originalFuncDescriptorClassName);
+ String targetFuncDescriptorClassName = getGeneratedClassName(originalFuncDescriptorClassInternalName,
+ suffixForGeneratedClass, 0);
+ return targetFuncDescriptorClassName;
}
/**
@@ -184,7 +217,7 @@
// Generates code for all evaluators.
int evalCounter = 0;
for (String evaluateClassName : evaluatorClassNames) {
- generateEvaluatorClassBinary(evaluateClassName, suffixForGeneratedClass, ++evalCounter, nameMappings,
+ generateEvaluatorClassBinary(evaluateClassName, suffixForGeneratedClass, evalCounter++, nameMappings,
classLoader, action);
}
@@ -235,13 +268,31 @@
nameMappings.add(
Pair.of(toJdkStandardName(originalEvaluatorClassName), toJdkStandardName(targetEvaluatorClassName)));
+ ClassReader firstPassReader = new ClassReader(getResourceStream(originalEvaluatorClassName, classLoader));
+ // Generates inner classes other than the evaluator.
+ Set<String> excludedNames = new HashSet<>();
+ for (Pair<String, String> entry : nameMappings) {
+ excludedNames.add(entry.getKey());
+ }
+ generateNonEvalInnerClasses(firstPassReader, excludedNames, nameMappings, suffixForGeneratedClass, classLoader,
+ action);
+
+ // Injects missing-handling byte code.
+ ClassWriter firstPassWriter = new ClassWriter(firstPassReader, 0);
+ EvaluatorMissingCheckVisitor missingHandlingVisitor = new EvaluatorMissingCheckVisitor(firstPassWriter);
+ firstPassReader.accept(missingHandlingVisitor, 0);
+
+ ClassReader secondPassReader = new ClassReader(firstPassWriter.toByteArray());
// Injects null-handling byte code and output the class binary.
- ClassReader reader = new ClassReader(getResourceStream(originalEvaluatorClassName, classLoader));
- ClassWriter writer = new ClassWriter(reader, 0);
- RenameClassVisitor renamingVisitor = new RenameClassVisitor(writer, nameMappings);
- EvaluatorVisitor evaluateVisitor = new EvaluatorVisitor(renamingVisitor);
- reader.accept(evaluateVisitor, 0);
- action.runAction(targetEvaluatorClassName, writer.toByteArray());
+ // Since we're going to add jump instructions, we have to let the ClassWriter to
+ // automatically generate frames for JVM to verify the class.
+ ClassWriter secondPassWriter = new ClassWriter(secondPassReader,
+ ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
+ RenameClassVisitor renamingVisitor = new RenameClassVisitor(secondPassWriter, nameMappings);
+ EvaluatorNullCheckVisitor nullHandlingVisitor = new EvaluatorNullCheckVisitor(renamingVisitor,
+ missingHandlingVisitor.getLastAddedLabel());
+ secondPassReader.accept(nullHandlingVisitor, 0);
+ action.runAction(targetEvaluatorClassName, secondPassWriter.toByteArray());
}
/**
@@ -275,7 +326,7 @@
String suffix = INNER + suffixForGeneratedClass;
for (String innerClassName : innerClassNames) {
// adds name mapping.
- String targetInnerClassName = getGeneratedClassName(innerClassName, suffix, ++counter);
+ String targetInnerClassName = getGeneratedClassName(innerClassName, suffix, counter++);
nameMappings.add(Pair.of(innerClassName, targetInnerClassName));
nameMappings.add(Pair.of(toJdkStandardName(innerClassName), toJdkStandardName(targetInnerClassName)));
@@ -325,15 +376,25 @@
StringBuilder sb = new StringBuilder();
int end = originalClassName.indexOf(DESCRIPTOR);
if (end < 0) {
+ end = originalClassName.indexOf(ACCESSOR);
+ }
+ if (end < 0) {
end = originalClassName.indexOf(DOLLAR);
}
if (end < 0) {
- end = originalClassName.length() - 1;
+ end = originalClassName.length();
}
- sb.append(originalClassName.substring(0, end));
+ String name = originalClassName.substring(0, end);
+ String lastName = name.substring(ASTERIXDB_PREFIX.length());
+
+ sb.append(ASTERIXDB_PREFIX);
+ sb.append(PKG_SUFFIX);
+ sb.append(lastName);
sb.append(suffix);
- sb.append(counter);
+ if (counter > 0) {
+ sb.append(counter);
+ }
return sb.toString();
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/staticcodegen/EvaluatorMissingCheckVisitor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/staticcodegen/EvaluatorMissingCheckVisitor.java
new file mode 100644
index 0000000..adedee5
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/staticcodegen/EvaluatorMissingCheckVisitor.java
@@ -0,0 +1,228 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.runtime.evaluators.staticcodegen;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+import org.objectweb.asm.tree.AbstractInsnNode;
+import org.objectweb.asm.tree.FieldInsnNode;
+import org.objectweb.asm.tree.IincInsnNode;
+import org.objectweb.asm.tree.InsnNode;
+import org.objectweb.asm.tree.IntInsnNode;
+import org.objectweb.asm.tree.VarInsnNode;
+
+/**
+ * This visitor adds missing-handling byte code into an evaluator class.
+ */
+public class EvaluatorMissingCheckVisitor extends ClassVisitor {
+ private static final String EVALUATE_DESC = "(Lorg/apache/hyracks/dataflow/common/data/"
+ + "accessors/IFrameTupleReference;Lorg/apache/hyracks/data/std/api/IPointable;)V";
+ private static final String EVALUATE = "evaluate";
+ private static final MethodIdentifier METHOD_IDENTIFIER = new MethodIdentifier(EVALUATE, EVALUATE_DESC, null);
+ private static final String TYPE_CHECKER_CLASS = "org/apache/asterix/runtime/evaluators/staticcodegen/TypeChecker";
+ private static final String TYPE_CHECKER_DESC = "L" + TYPE_CHECKER_CLASS + ";";
+ private static final String TYPE_CHECKER_NAME = "typeChecker";
+ private static final String IS_MISSING = "isMissing";
+ private static final String TYPECHECK_METHOD_DESC = "(Lorg/apache/hyracks/data/std/api/IPointable;"
+ + "Lorg/apache/hyracks/data/std/api/IPointable;)Z";
+ private static final String CONSTRUCTOR = "<init>";
+ private String className = null;
+ private Label lastAddedLabel = null;
+
+ public EvaluatorMissingCheckVisitor(ClassVisitor downStreamVisitor) {
+ super(Opcodes.ASM5, downStreamVisitor);
+ }
+
+ @Override
+ public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
+ if (cv != null) {
+ cv.visit(version, access, name, signature, superName, interfaces);
+ }
+ this.className = name;
+ }
+
+ @Override
+ public void visitEnd() {
+ if (cv != null) {
+ cv.visitField(Opcodes.ACC_PRIVATE | Opcodes.ACC_FINAL, TYPE_CHECKER_NAME, TYPE_CHECKER_DESC, null, null);
+ cv.visitEnd();
+ }
+ }
+
+ @Override
+ public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
+ MethodVisitor mv = cv.visitMethod(access, name, desc, signature, exceptions);
+ if (!METHOD_IDENTIFIER.equals(new MethodIdentifier(name, desc, signature)) && !name.equals(CONSTRUCTOR)) {
+ return mv;
+ }
+ if (name.equals(CONSTRUCTOR) && mv != null) {
+ return new ConstructorVisitor(Opcodes.ASM5, mv);
+ }
+ if (mv != null) {
+ return new InjectMissingCheckVisitor(Opcodes.ASM5, mv);
+ }
+ return null;
+ }
+
+ // Obtains the last added label.
+ Label getLastAddedLabel() {
+ return lastAddedLabel;
+ }
+
+ class ConstructorVisitor extends MethodVisitor {
+
+ public ConstructorVisitor(int api, MethodVisitor mv) {
+ super(api, mv);
+ }
+
+ @Override
+ public void visitInsn(int opcode) {
+ if (opcode != Opcodes.RETURN) {
+ mv.visitInsn(opcode);
+ return;
+ }
+ // Loads "this".
+ mv.visitVarInsn(Opcodes.ALOAD, 0);
+ // New TypeChecker.
+ mv.visitTypeInsn(Opcodes.NEW, TYPE_CHECKER_CLASS);
+ // Duplicate the top operand.
+ mv.visitInsn(Opcodes.DUP);
+ // Invoke the constructor of TypeChecker.
+ mv.visitMethodInsn(Opcodes.INVOKESPECIAL, TYPE_CHECKER_CLASS, CONSTRUCTOR, "()V", true);
+ // Putfield for the field typeChecker.
+ mv.visitFieldInsn(Opcodes.PUTFIELD, className, TYPE_CHECKER_NAME, TYPE_CHECKER_DESC);
+ // RETURN.
+ mv.visitInsn(Opcodes.RETURN);
+ }
+ }
+
+ class InjectMissingCheckVisitor extends MethodVisitor {
+
+ private FieldInsnNode fieldAccessNode = null;
+ private List<AbstractInsnNode> instructionsAfterFieldAccess = new ArrayList<>();
+ private boolean updateToNextLabel = false;
+
+ public InjectMissingCheckVisitor(int opcode, MethodVisitor mv) {
+ super(opcode, mv);
+ }
+
+ @Override
+ public void visitFieldInsn(int opcode, String owner, String name, String desc) {
+ mv.visitFieldInsn(opcode, owner, name, desc);
+ fieldAccessNode = new FieldInsnNode(opcode, owner, name, desc);
+ instructionsAfterFieldAccess.clear();
+ }
+
+ @Override
+ public void visitIincInsn(int var, int increment) {
+ if (fieldAccessNode != null) {
+ instructionsAfterFieldAccess.add(new IincInsnNode(var, increment));
+ }
+ super.visitIincInsn(var, increment);
+ }
+
+ @Override
+ public void visitInsn(int opcode) {
+ if (fieldAccessNode != null) {
+ instructionsAfterFieldAccess.add(new InsnNode(opcode));
+ }
+ super.visitInsn(opcode);
+ }
+
+ @Override
+ public void visitIntInsn(int opcode, int operand) {
+ if (fieldAccessNode != null) {
+ instructionsAfterFieldAccess.add(new IntInsnNode(opcode, operand));
+ }
+ super.visitIntInsn(opcode, operand);
+ }
+
+ @Override
+ public void visitVarInsn(int opcode, int operand) {
+ if (fieldAccessNode != null) {
+ instructionsAfterFieldAccess.add(new VarInsnNode(opcode, operand));
+ }
+ super.visitVarInsn(opcode, operand);
+ }
+
+ @Override
+ public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
+ mv.visitMethodInsn(opcode, owner, name, desc, itf);
+ if (fieldAccessNode == null || !METHOD_IDENTIFIER.equals(new MethodIdentifier(name, desc, null))) {
+ return;
+ }
+
+ // Loads the callee.
+ mv.visitVarInsn(Opcodes.ALOAD, 0);
+ mv.visitFieldInsn(Opcodes.GETFIELD, className, TYPE_CHECKER_NAME, TYPE_CHECKER_DESC);
+
+ // Loads "this".
+ mv.visitVarInsn(Opcodes.ALOAD, 0);
+ // Replays the field access instruction.
+ fieldAccessNode.accept(mv);
+
+ // Replays other instruction between the field access and the evaluator call.
+ for (AbstractInsnNode instruction : instructionsAfterFieldAccess) {
+ instruction.accept(mv);
+ }
+
+ // Loads the result IPointable.
+ mv.visitVarInsn(Opcodes.ALOAD, 2);
+
+ // Invokes the missing check method.
+ mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, TYPE_CHECKER_CLASS, IS_MISSING, TYPECHECK_METHOD_DESC, false);
+ lastAddedLabel = new Label();
+ // Adds the if branch.
+ mv.visitJumpInsn(Opcodes.IFEQ, lastAddedLabel);
+ mv.visitInsn(Opcodes.RETURN);
+ mv.visitLabel(lastAddedLabel);
+ }
+
+ @Override
+ public void visitLabel(Label label) {
+ if (updateToNextLabel) {
+ lastAddedLabel = label;
+ updateToNextLabel = false;
+ }
+ super.visitLabel(label);
+ }
+
+ @Override
+ public void visitJumpInsn(int opcode, Label label) {
+ super.visitJumpInsn(opcode, label);
+ if (lastAddedLabel == null) {
+ return;
+ }
+ try {
+ if (label.getOffset() < lastAddedLabel.getOffset()) {
+ // Backward jump, i.e., loop.
+ updateToNextLabel = true;
+ }
+ } catch (IllegalStateException e) {
+ // Forward jump, the offset is not available.
+ }
+ }
+ }
+
+}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/staticcodegen/EvaluatorNullCheckVisitor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/staticcodegen/EvaluatorNullCheckVisitor.java
new file mode 100644
index 0000000..30f810b
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/staticcodegen/EvaluatorNullCheckVisitor.java
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.runtime.evaluators.staticcodegen;
+
+import org.objectweb.asm.ClassVisitor;
+import org.objectweb.asm.Label;
+import org.objectweb.asm.MethodVisitor;
+import org.objectweb.asm.Opcodes;
+
+/**
+ * This visitor adds null-handling byte code into an evaluator class.
+ */
+public class EvaluatorNullCheckVisitor extends ClassVisitor {
+ private final static String EVALUATE_DESC = "(Lorg/apache/hyracks/dataflow/common/data/accessors/"
+ + "IFrameTupleReference;Lorg/apache/hyracks/data/std/api/IPointable;)V";
+ private final static String EVALUATE = "evaluate";
+ private final static MethodIdentifier METHOD_IDENTIFIER = new MethodIdentifier(EVALUATE, EVALUATE_DESC, null);
+ private final static String TYPE_CHECKER_CLASS = "org/apache/asterix/runtime/evaluators/staticcodegen/"
+ + "TypeChecker";
+ private final static String TYPE_CHECKER_DESC = "L" + TYPE_CHECKER_CLASS + ";";
+ private final static String TYPE_CHECKER_NAME = "typeChecker";
+ private final static String IS_NULL = "isNull";
+ private final static String TYPECHECK_METHOD_DESC = "(Lorg/apache/hyracks/data/std/api/IPointable;)Z";
+ private String className = null;
+ private final Label lastAddedLabel;
+
+ public EvaluatorNullCheckVisitor(ClassVisitor downStreamVisitor, Label lastAddedLabel) {
+ super(Opcodes.ASM5, downStreamVisitor);
+ this.lastAddedLabel = lastAddedLabel;
+ }
+
+ @Override
+ public void visit(int version, int access, String name, String signature, String superName, String[] interfaces) {
+ if (cv != null) {
+ cv.visit(version, access, name, signature, superName, interfaces);
+ }
+ this.className = name;
+ }
+
+ @Override
+ public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
+ MethodVisitor mv = cv.visitMethod(access, name, desc, signature, exceptions);
+ if (!METHOD_IDENTIFIER.equals(new MethodIdentifier(name, desc, signature))) {
+ return mv;
+ }
+ if (mv != null) {
+ return new InjectNullCheckVisitor(Opcodes.ASM5, mv);
+ }
+ return null;
+ }
+
+ // Obtains the last added label.
+ Label getLastAddedLabel() {
+ return lastAddedLabel;
+ }
+
+ class InjectNullCheckVisitor extends MethodVisitor {
+
+ public InjectNullCheckVisitor(int api, MethodVisitor mv) {
+ super(api, mv);
+ }
+
+ @Override
+ public void visitLabel(Label label) {
+ // Emits the label.
+ mv.visitLabel(label);
+
+ // Injects null-handling after the last missing-handling byte code.
+ if (lastAddedLabel == null || lastAddedLabel.getOffset() != label.getOffset()) {
+ return;
+ }
+
+ // Loads the callee.
+ mv.visitVarInsn(Opcodes.ALOAD, 0);
+ mv.visitFieldInsn(Opcodes.GETFIELD, className, TYPE_CHECKER_NAME, TYPE_CHECKER_DESC);
+
+ // Loads the result IPointable.
+ mv.visitVarInsn(Opcodes.ALOAD, 2);
+
+ // Invokes the null check method.
+ mv.visitMethodInsn(Opcodes.INVOKEVIRTUAL, TYPE_CHECKER_CLASS, IS_NULL, TYPECHECK_METHOD_DESC, false);
+ Label notNull = new Label();
+ // Adds the if branch.
+ mv.visitJumpInsn(Opcodes.IFEQ, notNull);
+ mv.visitInsn(Opcodes.RETURN);
+ mv.visitLabel(notNull);
+ }
+ }
+}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/staticcodegen/EvaluatorVisitor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/staticcodegen/EvaluatorVisitor.java
deleted file mode 100644
index 6d554d7..0000000
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/staticcodegen/EvaluatorVisitor.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.runtime.evaluators.staticcodegen;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.objectweb.asm.ClassVisitor;
-import org.objectweb.asm.Label;
-import org.objectweb.asm.MethodVisitor;
-import org.objectweb.asm.Opcodes;
-import org.objectweb.asm.tree.AbstractInsnNode;
-import org.objectweb.asm.tree.FieldInsnNode;
-import org.objectweb.asm.tree.IincInsnNode;
-import org.objectweb.asm.tree.InsnNode;
-import org.objectweb.asm.tree.IntInsnNode;
-
-/**
- * This visitor adds null-handling byte code into an evaluator class.
- */
-public class EvaluatorVisitor extends ClassVisitor {
- private final static String EVALUATE_DESC = "(Lorg/apache/hyracks/dataflow/common/data/accessors/IFrameTupleReference;Lorg/apache/hyracks/data/std/api/IPointable;)V";
- private final static String EVALUATE = "evaluate";
- private final static MethodIdentifier METHOD_IDENTIFIER = new MethodIdentifier(EVALUATE, EVALUATE_DESC, null);
- private final static String TYPECHECK_CLASS = "org/apache/asterix/runtime/evaluators/staticcodegen/TypeCheckUtil";
- private final static String IS_NULL = "isNull";
- private final static String TYPECHECK_METHOD_DESC = "(Lorg/apache/hyracks/data/std/api/IPointable;Lorg/apache/hyracks/data/std/api/IPointable;)Z";
-
- public EvaluatorVisitor(ClassVisitor downStreamVisitor) {
- super(Opcodes.ASM5, downStreamVisitor);
- }
-
- @Override
- public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
- MethodVisitor mv = cv.visitMethod(access, name, desc, signature, exceptions);
- if (!METHOD_IDENTIFIER.equals(new MethodIdentifier(name, desc, signature))) {
- return mv;
- }
- if (mv != null) {
- return new MethodVisitor(Opcodes.ASM5, mv) {
- private FieldInsnNode fieldAccessNode = null;
- private List<AbstractInsnNode> instructionsAfterFieldAccess = new ArrayList<>();
-
- @Override
- public void visitFieldInsn(int opcode, String owner, String name, String desc) {
- mv.visitFieldInsn(opcode, owner, name, desc);
- fieldAccessNode = new FieldInsnNode(opcode, owner, name, desc);
- instructionsAfterFieldAccess.clear();
- }
-
- @Override
- public void visitIincInsn(int var, int increment) {
- if (fieldAccessNode != null) {
- instructionsAfterFieldAccess.add(new IincInsnNode(var, increment));
- }
- super.visitIincInsn(var, increment);
- }
-
- @Override
- public void visitInsn(int opcode) {
- if (fieldAccessNode != null) {
- instructionsAfterFieldAccess.add(new InsnNode(opcode));
- }
- super.visitInsn(opcode);
- }
-
- @Override
- public void visitIntInsn(int opcode, int operand) {
- if (fieldAccessNode != null) {
- instructionsAfterFieldAccess.add(new IntInsnNode(opcode, operand));
- }
- super.visitIntInsn(opcode, operand);
- }
-
- @Override
- public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf) {
- mv.visitMethodInsn(opcode, owner, name, desc, itf);
- if (fieldAccessNode == null
- || !METHOD_IDENTIFIER.equals(new MethodIdentifier(name, desc, signature))) {
- return;
- }
- // Loads "this".
- mv.visitVarInsn(Opcodes.ALOAD, 0);
- // Replays the field access instruction.
- fieldAccessNode.accept(mv);
-
- // Replays other instruction between the field access and the evaluator call.
- for (AbstractInsnNode instruction : instructionsAfterFieldAccess) {
- instruction.accept(mv);
- }
-
- // Loads the result IPointable.
- mv.visitVarInsn(Opcodes.ALOAD, 2);
-
- // Invokes the null check method.
- mv.visitMethodInsn(Opcodes.INVOKESTATIC, TYPECHECK_CLASS, IS_NULL, TYPECHECK_METHOD_DESC, false);
- Label notNull = new Label();
- // Adds the if branch.
- mv.visitJumpInsn(Opcodes.IFEQ, notNull);
- mv.visitInsn(Opcodes.RETURN);
- mv.visitLabel(notNull);
- mv.visitFrame(Opcodes.F_SAME, 0, null, 0, null);
- }
- };
- }
- return null;
- }
-
-}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/staticcodegen/GatherInnerClassVisitor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/staticcodegen/GatherInnerClassVisitor.java
index 2293734..031707b 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/staticcodegen/GatherInnerClassVisitor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/staticcodegen/GatherInnerClassVisitor.java
@@ -44,7 +44,8 @@
@Override
public void visitInnerClass(String name, String outerName, String innerName, int access) {
- if (className == null || !name.equals(className)) {
+ if ((className == null || !name.equals(className))
+ && ((access & Opcodes.ACC_PUBLIC) == 0 || (access & Opcodes.ACC_STATIC) == 0)) {
innerClassNames.add(name);
}
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/staticcodegen/RenameClassVisitor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/staticcodegen/RenameClassVisitor.java
index 1eb7357..4396fd6 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/staticcodegen/RenameClassVisitor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/staticcodegen/RenameClassVisitor.java
@@ -53,7 +53,9 @@
@Override
public void visitInnerClass(String name, String outerName, String innerName, int access) {
- // Skips inner class descriptions.
+ if ((access & Opcodes.ACC_PUBLIC) != 0 && (access & Opcodes.ACC_STATIC) != 0) {
+ super.visitInnerClass(name, outerName, innerName, access);
+ }
}
@Override
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/staticcodegen/TypeCheckUtil.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/staticcodegen/TypeCheckUtil.java
deleted file mode 100644
index 0b02f39..0000000
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/staticcodegen/TypeCheckUtil.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.asterix.runtime.evaluators.staticcodegen;
-
-import org.apache.asterix.om.types.ATypeTag;
-import org.apache.hyracks.data.std.api.IPointable;
-
-/**
- * The null-handling code to be injected into the evaluator(...) method of scalar evaluators.
- */
-public class TypeCheckUtil {
-
- public static byte[] NULL_BYTES = new byte[] { ATypeTag.SERIALIZED_NULL_TYPE_TAG };
-
- public static boolean isNull(IPointable arg, IPointable resultPointable) {
- byte[] data = arg.getByteArray();
- int start = arg.getStartOffset();
- if (data[start] == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- resultPointable.set(NULL_BYTES, 0, 1);
- return true;
- }
- return false;
- }
-
-}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/staticcodegen/TypeChecker.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/staticcodegen/TypeChecker.java
new file mode 100644
index 0000000..55c2c4b
--- /dev/null
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/staticcodegen/TypeChecker.java
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.asterix.runtime.evaluators.staticcodegen;
+
+import org.apache.asterix.om.types.ATypeTag;
+import org.apache.hyracks.data.std.api.IPointable;
+
+/**
+ * The missing/null-handling code to be injected into the evaluator(...) method of scalar evaluators.
+ */
+public class TypeChecker {
+
+ private byte[] MISSING_BYTES = new byte[] { ATypeTag.SERIALIZED_MISSING_TYPE_TAG };
+ private byte[] NULL_BYTES = new byte[] { ATypeTag.SERIALIZED_NULL_TYPE_TAG };
+ private boolean meetNull = false;
+
+ /**
+ * This method should be called for each argument of a function.
+ *
+ * @param arg,
+ * the argument pointable.
+ * @param resultPointable,
+ * the returned result for the function.
+ * @return true if arg is MISSING; false otherwise.
+ */
+ public boolean isMissing(IPointable arg, IPointable resultPointable) {
+ byte[] data = arg.getByteArray();
+ int start = arg.getStartOffset();
+ byte serializedTypeTag = data[start];
+ if (serializedTypeTag == ATypeTag.SERIALIZED_MISSING_TYPE_TAG) {
+ resultPointable.set(MISSING_BYTES, 0, 1);
+ // resets meetNull for the next evaluate(...) call.
+ meetNull = false;
+ return true;
+ }
+ if (serializedTypeTag == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
+ meetNull |= true;
+ }
+ return false;
+ }
+
+ /**
+ * This method should be called after all arguments for a function are evaluated.
+ *
+ * @param resultPointable,
+ * the returned result for the function.
+ * @return true if any argument is NULL; false otherwise.
+ */
+ public boolean isNull(IPointable resultPointable) {
+ if (meetNull) {
+ resultPointable.set(NULL_BYTES, 0, 1);
+ // resets meetNull.
+ meetNull = false;
+ return true;
+ }
+ // resets meetNull for the next evaluate(...) call.
+ meetNull = false;
+ return false;
+ }
+
+}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/formats/NonTaggedDataFormat.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/formats/NonTaggedDataFormat.java
index c151dbd..5811cd6 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/formats/NonTaggedDataFormat.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/formats/NonTaggedDataFormat.java
@@ -26,7 +26,7 @@
import java.util.Map;
import org.apache.asterix.common.config.GlobalConfig;
-import org.apache.asterix.dataflow.data.nontagged.AqlNullWriterFactory;
+import org.apache.asterix.dataflow.data.nontagged.AqlMissingWriterFactory;
import org.apache.asterix.formats.base.IDataFormat;
import org.apache.asterix.formats.nontagged.AqlADMPrinterFactoryProvider;
import org.apache.asterix.formats.nontagged.AqlBinaryBooleanInspectorImpl;
@@ -43,7 +43,7 @@
import org.apache.asterix.formats.nontagged.AqlTypeTraitProvider;
import org.apache.asterix.om.base.ABoolean;
import org.apache.asterix.om.base.AInt32;
-import org.apache.asterix.om.base.ANull;
+import org.apache.asterix.om.base.AMissing;
import org.apache.asterix.om.base.AOrderedList;
import org.apache.asterix.om.base.AString;
import org.apache.asterix.om.base.IAObject;
@@ -54,7 +54,7 @@
import org.apache.asterix.om.functions.IFunctionDescriptorFactory;
import org.apache.asterix.om.functions.IFunctionManager;
import org.apache.asterix.om.pointables.base.DefaultOpenFieldType;
-import org.apache.asterix.om.typecomputer.base.TypeComputerUtilities;
+import org.apache.asterix.om.typecomputer.base.TypeCastUtils;
import org.apache.asterix.om.types.AOrderedListType;
import org.apache.asterix.om.types.ARecordType;
import org.apache.asterix.om.types.ATypeTag;
@@ -70,20 +70,11 @@
import org.apache.asterix.runtime.evaluators.constructors.OpenRecordConstructorDescriptor;
import org.apache.asterix.runtime.evaluators.functions.CastListDescriptor;
import org.apache.asterix.runtime.evaluators.functions.CastRecordDescriptor;
-import org.apache.asterix.runtime.evaluators.functions.DeepEqualityDescriptor;
-import org.apache.asterix.runtime.evaluators.functions.FlowRecordDescriptor;
import org.apache.asterix.runtime.evaluators.functions.OrderedListConstructorDescriptor;
import org.apache.asterix.runtime.evaluators.functions.UnorderedListConstructorDescriptor;
-import org.apache.asterix.runtime.evaluators.functions.records.FieldAccessByIndexDescriptor;
import org.apache.asterix.runtime.evaluators.functions.records.FieldAccessByIndexEvalFactory;
import org.apache.asterix.runtime.evaluators.functions.records.FieldAccessByNameDescriptor;
-import org.apache.asterix.runtime.evaluators.functions.records.FieldAccessNestedDescriptor;
import org.apache.asterix.runtime.evaluators.functions.records.FieldAccessNestedEvalFactory;
-import org.apache.asterix.runtime.evaluators.functions.records.GetRecordFieldValueDescriptor;
-import org.apache.asterix.runtime.evaluators.functions.records.GetRecordFieldsDescriptor;
-import org.apache.asterix.runtime.evaluators.functions.records.RecordAddFieldsDescriptor;
-import org.apache.asterix.runtime.evaluators.functions.records.RecordMergeDescriptor;
-import org.apache.asterix.runtime.evaluators.functions.records.RecordRemoveFieldsDescriptor;
import org.apache.commons.lang3.mutable.Mutable;
import org.apache.commons.lang3.mutable.MutableObject;
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
@@ -114,7 +105,7 @@
import org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory;
import org.apache.hyracks.algebricks.runtime.evaluators.ColumnAccessEvalFactory;
import org.apache.hyracks.algebricks.runtime.evaluators.ConstantEvalFactory;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.IPredicateEvaluatorFactoryProvider;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.util.ArrayBackedValueStorage;
@@ -125,6 +116,8 @@
import org.apache.hyracks.dataflow.common.data.parsers.LongParserFactory;
import org.apache.hyracks.dataflow.common.data.parsers.UTF8StringParserFactory;
+import junit.extensions.PA;
+
public class NonTaggedDataFormat implements IDataFormat {
private static boolean registered = false;
@@ -389,8 +382,8 @@
} else {
IAType itemType = (IAType) context.getType(f.getArguments().get(0).getValue());
if (itemType instanceof AUnionType) {
- if (((AUnionType) itemType).isNullableType()) {
- itemType = ((AUnionType) itemType).getNullableType();
+ if (((AUnionType) itemType).isUnknownableType()) {
+ itemType = ((AUnionType) itemType).getActualType();
} else {
// Convert UNION types into ANY.
itemType = BuiltinType.ANY;
@@ -408,7 +401,8 @@
IAType outType = (IAType) context.getType(expr);
IAType type0 = (IAType) context.getType(f.getArguments().get(0).getValue());
IAType type1 = (IAType) context.getType(f.getArguments().get(1).getValue());
- ((RecordMergeDescriptor) fd).reset(outType, type0, type1);
+ PA.invokeMethod(fd, "reset(org.apache.asterix.om.types.IAType, org.apache.asterix.om.types.IAType, "
+ + " org.apache.asterix.om.types.IAType)", outType, type0, type1);
}
});
@@ -420,7 +414,8 @@
AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expr;
IAType type0 = (IAType) context.getType(f.getArguments().get(0).getValue());
IAType type1 = (IAType) context.getType(f.getArguments().get(1).getValue());
- ((DeepEqualityDescriptor) fd).reset(type0, type1);
+ PA.invokeMethod(fd, "reset(org.apache.asterix.om.types.IAType, org.apache.asterix.om.types.IAType)",
+ type0, type1);
}
});
@@ -440,7 +435,8 @@
if (type1.getTypeTag().equals(ATypeTag.ANY)) {
type1 = DefaultOpenFieldType.NESTED_OPEN_AORDERED_LIST_TYPE;
}
- ((RecordAddFieldsDescriptor) fd).reset(outType, type0, type1);
+ PA.invokeMethod(fd, "reset(org.apache.asterix.om.types.IAType, org.apache.asterix.om.types.IAType,"
+ + " org.apache.asterix.om.types.IAType)", outType, type0, type1);
}
});
@@ -460,7 +456,8 @@
if (type1.getTypeTag().equals(ATypeTag.ANY)) {
type1 = DefaultOpenFieldType.NESTED_OPEN_AORDERED_LIST_TYPE;
}
- ((RecordRemoveFieldsDescriptor) fd).reset(outType, type0, type1);
+ PA.invokeMethod(fd, "reset(org.apache.asterix.om.types.IAType, org.apache.asterix.om.types.IAType,"
+ + " org.apache.asterix.om.types.IAType)", outType, type0, type1);
}
});
@@ -469,7 +466,7 @@
public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context)
throws AlgebricksException {
AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expr;
- ARecordType rt = (ARecordType) TypeComputerUtilities.getRequiredType(funcExpr);
+ ARecordType rt = (ARecordType) TypeCastUtils.getRequiredType(funcExpr);
IAType it = (IAType) context.getType(funcExpr.getArguments().get(0).getValue());
if (it.getTypeTag().equals(ATypeTag.ANY)) {
it = DefaultOpenFieldType.NESTED_OPEN_RECORD_TYPE;
@@ -482,7 +479,7 @@
public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context)
throws AlgebricksException {
AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expr;
- AbstractCollectionType rt = (AbstractCollectionType) TypeComputerUtilities.getRequiredType(funcExpr);
+ AbstractCollectionType rt = (AbstractCollectionType) TypeCastUtils.getRequiredType(funcExpr);
IAType it = (IAType) context.getType(funcExpr.getArguments().get(0).getValue());
if (it.getTypeTag().equals(ATypeTag.ANY)) {
it = DefaultOpenFieldType.NESTED_OPEN_AORDERED_LIST_TYPE;
@@ -490,15 +487,6 @@
((CastListDescriptor) fd).reset(rt, (AbstractCollectionType) it);
}
});
- functionTypeInferers.put(AsterixBuiltinFunctions.FLOW_RECORD, new FunctionTypeInferer() {
- @Override
- public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context)
- throws AlgebricksException {
- ARecordType it = (ARecordType) TypeComputerUtilities
- .getInputType((AbstractFunctionCallExpression) expr);
- ((FlowRecordDescriptor) fd).reset(it);
- }
- });
functionTypeInferers.put(AsterixBuiltinFunctions.OPEN_RECORD_CONSTRUCTOR, new FunctionTypeInferer() {
@Override
public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context)
@@ -561,16 +549,16 @@
switch (t.getTypeTag()) {
case RECORD: {
ARecordType recType = (ARecordType) t;
- ((FieldAccessByIndexDescriptor) fd).reset(recType);
+ PA.invokeMethod(fd, "reset(org.apache.asterix.om.types.ARecordType)", recType);
break;
}
case UNION: {
AUnionType unionT = (AUnionType) t;
- if (unionT.isNullableType()) {
- IAType t2 = unionT.getNullableType();
+ if (unionT.isUnknownableType()) {
+ IAType t2 = unionT.getActualType();
if (t2.getTypeTag() == ATypeTag.RECORD) {
ARecordType recType = (ARecordType) t2;
- ((FieldAccessByIndexDescriptor) fd).reset(recType);
+ PA.invokeMethod(fd, "reset(org.apache.asterix.om.types.ARecordType)", recType);
break;
}
}
@@ -598,7 +586,8 @@
switch (t.getTypeTag()) {
case RECORD: {
ARecordType recType = (ARecordType) t;
- ((FieldAccessNestedDescriptor) fd).reset(recType, listFieldPath);
+ PA.invokeMethod(fd, "reset(org.apache.asterix.om.types.ARecordType, java.util.List)", recType,
+ listFieldPath);
break;
}
default: {
@@ -615,7 +604,7 @@
IAType t = (IAType) context.getType(fce.getArguments().get(0).getValue());
if (t.getTypeTag().equals(ATypeTag.RECORD)) {
ARecordType recType = (ARecordType) t;
- ((GetRecordFieldsDescriptor) fd).reset(recType);
+ PA.invokeMethod(fd, "reset(org.apache.asterix.om.types.ARecordType)", recType);
} else {
throw new NotImplementedException("get-record-fields for data of type " + t);
}
@@ -629,7 +618,7 @@
IAType t = (IAType) context.getType(fce.getArguments().get(0).getValue());
if (t.getTypeTag().equals(ATypeTag.RECORD)) {
ARecordType recType = (ARecordType) t;
- ((GetRecordFieldValueDescriptor) fd).reset(recType);
+ PA.invokeMethod(fd, "reset(org.apache.asterix.om.types.ARecordType)", recType);
} else {
throw new NotImplementedException("get-record-field-value for data of type " + t);
}
@@ -662,8 +651,8 @@
@Override
public IScalarEvaluatorFactory getConstantEvalFactory(IAlgebricksConstantValue value) throws AlgebricksException {
IAObject obj = null;
- if (value.isNull()) {
- obj = ANull.NULL;
+ if (value.isMissing()) {
+ obj = AMissing.MISSING;
} else if (value.isTrue()) {
obj = ABoolean.TRUE;
} else if (value.isFalse()) {
@@ -688,8 +677,8 @@
}
@Override
- public INullWriterFactory getNullWriterFactory() {
- return AqlNullWriterFactory.INSTANCE;
+ public IMissingWriterFactory getMissingWriterFactory() {
+ return AqlMissingWriterFactory.INSTANCE;
}
@Override
@@ -701,7 +690,7 @@
switch (expr.getExpressionTag()) {
case CONSTANT: {
ConstantExpression c = (ConstantExpression) expr;
- if (c == ConstantExpression.NULL) {
+ if (c == ConstantExpression.MISSING) {
return 1;
} else if (c == ConstantExpression.FALSE || c == ConstantExpression.TRUE) {
return 2;
@@ -709,25 +698,26 @@
AsterixConstantValue acv = (AsterixConstantValue) c.getValue();
IAObject o = acv.getObject();
switch (o.getType().getTypeTag()) {
- case DOUBLE: {
+ case DOUBLE:
return 9;
- }
- case BOOLEAN: {
- return 2;
- }
- case NULL: {
- return 1;
- }
- case INT32: {
+ case FLOAT:
return 5;
- }
- case INT64: {
+ case BOOLEAN:
+ return 2;
+ case MISSING:
+ return 1;
+ case NULL:
+ return 1;
+ case INT8:
+ return 2;
+ case INT16:
+ return 3;
+ case INT32:
+ return 5;
+ case INT64:
return 9;
- }
- default: {
- // TODO
+ default:
return -1;
- }
}
}
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/operators/AsterixLSMPrimaryUpsertOperatorNodePushable.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/operators/AsterixLSMPrimaryUpsertOperatorNodePushable.java
index 7785978..24988d4 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/operators/AsterixLSMPrimaryUpsertOperatorNodePushable.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/operators/AsterixLSMPrimaryUpsertOperatorNodePushable.java
@@ -30,7 +30,7 @@
import org.apache.asterix.om.types.ATypeTag;
import org.apache.hyracks.api.comm.VSizeFrame;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.INullWriter;
+import org.apache.hyracks.api.dataflow.value.IMissingWriter;
import org.apache.hyracks.api.dataflow.value.IRecordDescriptorProvider;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
import org.apache.hyracks.api.exceptions.HyracksDataException;
@@ -59,8 +59,8 @@
private final PermutingFrameTupleReference key;
private MultiComparator keySearchCmp;
- private ArrayTupleBuilder nullTupleBuilder;
- private final INullWriter nullWriter;
+ private ArrayTupleBuilder missingTupleBuilder;
+ private final IMissingWriter missingWriter;
private ArrayTupleBuilder tb;
private DataOutput dos;
private RangePredicate searchPred;
@@ -79,8 +79,8 @@
int partition, int[] fieldPermutation, IRecordDescriptorProvider recordDescProvider, int numOfPrimaryKeys,
ARecordType recordType, int filterFieldIndex) {
super(opDesc, ctx, partition, fieldPermutation, recordDescProvider, IndexOperation.UPSERT);
- // initialize nullWriter
- this.nullWriter = opDesc.getNullWriterFactory().createNullWriter();
+ // initialize missingWriter
+ this.missingWriter = opDesc.getMissingWriterFactory().createMissingWriter();
// The search key should only have the primary index and not use the permutations.
this.key = new PermutingFrameTupleReference();
int[] searchKeyPermutations = new int[numOfPrimaryKeys];
@@ -114,14 +114,14 @@
index = indexHelper.getIndexInstance();
try {
- nullTupleBuilder = new ArrayTupleBuilder(1);
- DataOutput out = nullTupleBuilder.getDataOutput();
+ missingTupleBuilder = new ArrayTupleBuilder(1);
+ DataOutput out = missingTupleBuilder.getDataOutput();
try {
- nullWriter.writeNull(out);
+ missingWriter.writeMissing(out);
} catch (IOException e) {
throw new HyracksDataException(e);
}
- nullTupleBuilder.addFieldEndOffset();
+ missingTupleBuilder.addFieldEndOffset();
searchPred = createSearchPredicate();
tb = new ArrayTupleBuilder(recordDesc.getFieldCount());
dos = tb.getDataOutput();
@@ -180,11 +180,11 @@
}
public static boolean isNull(ITupleReference t1, int field) {
- return t1.getFieldData(field)[t1.getFieldStart(field)] == ATypeTag.SERIALIZED_NULL_TYPE_TAG;
+ return t1.getFieldData(field)[t1.getFieldStart(field)] == ATypeTag.SERIALIZED_MISSING_TYPE_TAG;
}
private void addNullField() throws IOException {
- dos.write(nullTupleBuilder.getByteArray());
+ dos.write(missingTupleBuilder.getByteArray());
tb.addFieldEndOffset();
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/operators/AsterixLSMTreeUpsertOperatorDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/operators/AsterixLSMTreeUpsertOperatorDescriptor.java
index 803e15d..0c1177f 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/operators/AsterixLSMTreeUpsertOperatorDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/operators/AsterixLSMTreeUpsertOperatorDescriptor.java
@@ -23,7 +23,7 @@
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.dataflow.IOperatorNodePushable;
import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.IRecordDescriptorProvider;
import org.apache.hyracks.api.dataflow.value.ITypeTraits;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
@@ -50,12 +50,12 @@
IFileSplitProvider fileSplitProvider, ITypeTraits[] typeTraits,
IBinaryComparatorFactory[] comparatorFactories, int[] bloomFilterKeyFields, int[] fieldPermutation,
IIndexDataflowHelperFactory dataflowHelperFactory, ITupleFilterFactory tupleFilterFactory,
- boolean isPrimary, String indexName, INullWriterFactory nullWriterFactory,
+ boolean isPrimary, String indexName, IMissingWriterFactory missingWriterFactory,
IModificationOperationCallbackFactory modificationOpCallbackProvider,
ISearchOperationCallbackFactory searchOpCallbackProvider, int[] prevValuePermutation) {
super(spec, recDesc, storageManager, lifecycleManagerProvider, fileSplitProvider, typeTraits,
comparatorFactories, bloomFilterKeyFields, fieldPermutation, IndexOperation.UPSERT,
- dataflowHelperFactory, tupleFilterFactory, isPrimary, indexName, nullWriterFactory,
+ dataflowHelperFactory, tupleFilterFactory, isPrimary, indexName, missingWriterFactory,
modificationOpCallbackProvider, searchOpCallbackProvider);
this.prevValuePermutation = prevValuePermutation;
}
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/unnestingfunctions/std/ScanCollectionDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/unnestingfunctions/std/ScanCollectionDescriptor.java
index 495e7b6..0883520 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/unnestingfunctions/std/ScanCollectionDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/unnestingfunctions/std/ScanCollectionDescriptor.java
@@ -80,7 +80,7 @@
private final IPointable inputVal = new VoidPointable();
private final IScalarEvaluator argEval = listEvalFactory.createScalarEvaluator(ctx);
private int itemIndex;
- private boolean metNull = false;
+ private boolean metUnknown = false;
@Override
public void init(IFrameTupleReference tuple) throws AlgebricksException {
@@ -88,8 +88,8 @@
argEval.evaluate(tuple, inputVal);
ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER
.deserialize(inputVal.getByteArray()[inputVal.getStartOffset()]);
- if (typeTag == ATypeTag.NULL) {
- metNull = true;
+ if (typeTag == ATypeTag.MISSING || typeTag == ATypeTag.NULL) {
+ metUnknown = true;
return;
}
listAccessor.reset(inputVal.getByteArray(), inputVal.getStartOffset());
@@ -102,7 +102,7 @@
@Override
public boolean step(IPointable result) throws AlgebricksException {
try {
- if (!metNull) {
+ if (!metUnknown) {
if (itemIndex < listAccessor.size()) {
resultStorage.reset();
listAccessor.writeItem(itemIndex, resultStorage.getDataOutput());
diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/unnestingfunctions/std/SubsetCollectionDescriptor.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/unnestingfunctions/std/SubsetCollectionDescriptor.java
index 4ad01d8..b6f8b0b 100644
--- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/unnestingfunctions/std/SubsetCollectionDescriptor.java
+++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/unnestingfunctions/std/SubsetCollectionDescriptor.java
@@ -73,7 +73,7 @@
private int posCrt;
private ATypeTag itemTag;
private boolean selfDescList = false;
- private boolean metNull = false;
+ private boolean metUnknown = false;
@Override
public void init(IFrameTupleReference tuple) throws AlgebricksException {
@@ -89,11 +89,12 @@
evalList.evaluate(tuple, inputVal);
byte[] serList = inputVal.getByteArray();
int offset = inputVal.getStartOffset();
- metNull = false;
+ metUnknown = false;
byte typeTag = serList[offset];
- if (typeTag == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
- metNull = true;
+ if (typeTag == ATypeTag.SERIALIZED_MISSING_TYPE_TAG
+ || typeTag == ATypeTag.SERIALIZED_NULL_TYPE_TAG) {
+ metUnknown = true;
return;
}
@@ -121,7 +122,7 @@
@Override
public boolean step(IPointable result) throws AlgebricksException {
- if (!metNull && posCrt < posStart + numItems && posCrt < numItemsMax) {
+ if (!metUnknown && posCrt < posStart + numItems && posCrt < numItemsMax) {
resultStorage.reset();
byte[] serList = inputVal.getByteArray();
int offset = inputVal.getStartOffset();
diff --git a/asterixdb/asterix-server/src/main/licenses/NOTICE b/asterixdb/asterix-server/src/main/licenses/NOTICE
index d9240eb..4686009 100644
--- a/asterixdb/asterix-server/src/main/licenses/NOTICE
+++ b/asterixdb/asterix-server/src/main/licenses/NOTICE
@@ -684,3 +684,51 @@
* license/LICENSE.jzlib.txt (BSD Style License)
* HOMEPAGE:
* http://www.jcraft.com/jzlib/
+
+ - repo/asm-all-5.1.jar
+
+ Copyright (c) 2000-2011 INRIA, France Telecom
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+
+ 3. Neither the name of the copyright holders nor the names of its
+ contributors may be used to endorse or promote products derived from
+ this software without specific prior written permission.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ THE POSSIBILITY OF SUCH DAMAGE.
+
+ - repo/privilegedaccessor-1.2.2.jar
+
+ Copyright 2004-2012 Sebastian Dietrich (Sebastian.Dietrich@e-movimento.com)
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
diff --git a/asterixdb/asterix-tools/src/main/java/org/apache/asterix/tools/datagen/AdmDataGen.java b/asterixdb/asterix-tools/src/main/java/org/apache/asterix/tools/datagen/AdmDataGen.java
index 30fb4e9..2918575 100644
--- a/asterixdb/asterix-tools/src/main/java/org/apache/asterix/tools/datagen/AdmDataGen.java
+++ b/asterixdb/asterix-tools/src/main/java/org/apache/asterix/tools/datagen/AdmDataGen.java
@@ -673,7 +673,7 @@
for (int i = 0; i < m; i++) {
IAType ti = recType.getFieldTypes()[i];
if (NonTaggedFormatUtil.isOptional(ti)) {
- ti = ((AUnionType) ti).getNullableType();
+ ti = ((AUnionType) ti).getActualType();
nullable[i] = true;
}
IRecordFieldDataGen rfdg = annot.getDeclaredFieldsDatagen()[i];
diff --git a/hyracks-fullstack/algebricks/algebricks-compiler/src/main/java/org/apache/hyracks/algebricks/compiler/api/AbstractCompilerFactoryBuilder.java b/hyracks-fullstack/algebricks/algebricks-compiler/src/main/java/org/apache/hyracks/algebricks/compiler/api/AbstractCompilerFactoryBuilder.java
index 1bafe5c..6f28df3 100644
--- a/hyracks-fullstack/algebricks/algebricks-compiler/src/main/java/org/apache/hyracks/algebricks/compiler/api/AbstractCompilerFactoryBuilder.java
+++ b/hyracks-fullstack/algebricks/algebricks-compiler/src/main/java/org/apache/hyracks/algebricks/compiler/api/AbstractCompilerFactoryBuilder.java
@@ -27,7 +27,7 @@
import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionRuntimeProvider;
import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionTypeComputer;
import org.apache.hyracks.algebricks.core.algebra.expressions.IMergeAggregationExpressionFactory;
-import org.apache.hyracks.algebricks.core.algebra.expressions.INullableTypeComputer;
+import org.apache.hyracks.algebricks.core.algebra.expressions.IMissableTypeComputer;
import org.apache.hyracks.algebricks.core.algebra.expressions.IPartialAggregationTypeComputer;
import org.apache.hyracks.algebricks.core.rewriter.base.AbstractRuleController;
import org.apache.hyracks.algebricks.core.rewriter.base.IAlgebraicRewriteRule;
@@ -41,7 +41,7 @@
import org.apache.hyracks.algebricks.data.IPrinterFactoryProvider;
import org.apache.hyracks.algebricks.data.ISerializerDeserializerProvider;
import org.apache.hyracks.algebricks.data.ITypeTraitProvider;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.IPredicateEvaluatorFactoryProvider;
public abstract class AbstractCompilerFactoryBuilder {
@@ -59,9 +59,9 @@
protected IPredicateEvaluatorFactoryProvider predEvaluatorFactoryProvider;
protected IExpressionRuntimeProvider expressionRuntimeProvider;
protected IExpressionTypeComputer expressionTypeComputer;
- protected INullableTypeComputer nullableTypeComputer;
+ protected IMissableTypeComputer missableTypeComputer;
protected IExpressionEvalSizeComputer expressionEvalSizeComputer;
- protected INullWriterFactory nullWriterFactory;
+ protected IMissingWriterFactory missingWriterFactory;
protected INormalizedKeyComputerFactoryProvider normalizedKeyComputerFactoryProvider;
protected IPartialAggregationTypeComputer partialAggregationTypeComputer;
protected IMergeAggregationExpressionFactory mergeAggregationExpressionFactory;
@@ -174,12 +174,12 @@
return clusterLocations;
}
- public void setNullWriterFactory(INullWriterFactory nullWriterFactory) {
- this.nullWriterFactory = nullWriterFactory;
+ public void setMissingWriterFactory(IMissingWriterFactory missingWriterFactory) {
+ this.missingWriterFactory = missingWriterFactory;
}
- public INullWriterFactory getNullWriterFactory() {
- return nullWriterFactory;
+ public IMissingWriterFactory getMissingWriterFactory() {
+ return missingWriterFactory;
}
public void setExpressionEvalSizeComputer(IExpressionEvalSizeComputer expressionEvalSizeComputer) {
@@ -224,12 +224,12 @@
this.physicalOptimizationConfig = physicalOptimizationConfig;
}
- public void setNullableTypeComputer(INullableTypeComputer nullableTypeComputer) {
- this.nullableTypeComputer = nullableTypeComputer;
+ public void setMissableTypeComputer(IMissableTypeComputer missableTypeComputer) {
+ this.missableTypeComputer = missableTypeComputer;
}
- public INullableTypeComputer getNullableTypeComputer() {
- return nullableTypeComputer;
+ public IMissableTypeComputer getMissableTypeComputer() {
+ return missableTypeComputer;
}
}
diff --git a/hyracks-fullstack/algebricks/algebricks-compiler/src/main/java/org/apache/hyracks/algebricks/compiler/api/HeuristicCompilerFactoryBuilder.java b/hyracks-fullstack/algebricks/algebricks-compiler/src/main/java/org/apache/hyracks/algebricks/compiler/api/HeuristicCompilerFactoryBuilder.java
index 1d3a55c..09982a0 100644
--- a/hyracks-fullstack/algebricks/algebricks-compiler/src/main/java/org/apache/hyracks/algebricks/compiler/api/HeuristicCompilerFactoryBuilder.java
+++ b/hyracks-fullstack/algebricks/algebricks-compiler/src/main/java/org/apache/hyracks/algebricks/compiler/api/HeuristicCompilerFactoryBuilder.java
@@ -25,7 +25,7 @@
import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionEvalSizeComputer;
import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionTypeComputer;
import org.apache.hyracks.algebricks.core.algebra.expressions.IMergeAggregationExpressionFactory;
-import org.apache.hyracks.algebricks.core.algebra.expressions.INullableTypeComputer;
+import org.apache.hyracks.algebricks.core.algebra.expressions.IMissableTypeComputer;
import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
import org.apache.hyracks.algebricks.core.algebra.prettyprint.LogicalOperatorPrettyPrintVisitor;
import org.apache.hyracks.algebricks.core.config.AlgebricksConfig;
@@ -51,11 +51,11 @@
public IOptimizationContext createOptimizationContext(int varCounter,
IExpressionEvalSizeComputer expressionEvalSizeComputer,
IMergeAggregationExpressionFactory mergeAggregationExpressionFactory,
- IExpressionTypeComputer expressionTypeComputer, INullableTypeComputer nullableTypeComputer,
+ IExpressionTypeComputer expressionTypeComputer, IMissableTypeComputer missableTypeComputer,
PhysicalOptimizationConfig physicalOptimizationConfig, AlgebricksPartitionConstraint clusterLocations) {
LogicalOperatorPrettyPrintVisitor prettyPrintVisitor = new LogicalOperatorPrettyPrintVisitor();
return new AlgebricksOptimizationContext(varCounter, expressionEvalSizeComputer,
- mergeAggregationExpressionFactory, expressionTypeComputer, nullableTypeComputer,
+ mergeAggregationExpressionFactory, expressionTypeComputer, missableTypeComputer,
physicalOptimizationConfig, clusterLocations, prettyPrintVisitor);
}
}
@@ -78,7 +78,7 @@
int varCounter) {
final IOptimizationContext oc = optCtxFactory.createOptimizationContext(varCounter,
expressionEvalSizeComputer, mergeAggregationExpressionFactory, expressionTypeComputer,
- nullableTypeComputer, physicalOptimizationConfig, clusterLocations);
+ missableTypeComputer, physicalOptimizationConfig, clusterLocations);
oc.setMetadataDeclarations(metadata);
final HeuristicOptimizer opt = new HeuristicOptimizer(plan, logicalRewrites, physicalRewrites, oc);
return new ICompiler() {
@@ -95,9 +95,9 @@
JobGenContext context = new JobGenContext(null, metadata, appContext,
serializerDeserializerProvider, hashFunctionFactoryProvider, hashFunctionFamilyProvider,
comparatorFactoryProvider, typeTraitProvider, binaryBooleanInspectorFactory,
- binaryIntegerInspectorFactory, printerProvider, nullWriterFactory,
+ binaryIntegerInspectorFactory, printerProvider, missingWriterFactory,
normalizedKeyComputerFactoryProvider, expressionRuntimeProvider, expressionTypeComputer,
- nullableTypeComputer, oc, expressionEvalSizeComputer, partialAggregationTypeComputer,
+ oc, expressionEvalSizeComputer, partialAggregationTypeComputer,
predEvaluatorFactoryProvider, physicalOptimizationConfig.getFrameSize(),
clusterLocations);
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/expressions/ConstantExpression.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/expressions/ConstantExpression.java
index 449688b..33da4f9 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/expressions/ConstantExpression.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/expressions/ConstantExpression.java
@@ -24,7 +24,6 @@
import java.util.Map;
import org.apache.commons.lang3.mutable.Mutable;
-
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
import org.apache.hyracks.algebricks.core.algebra.base.LogicalExpressionTag;
@@ -42,6 +41,11 @@
}
@Override
+ public boolean isMissing() {
+ return false;
+ }
+
+ @Override
public boolean isNull() {
return false;
}
@@ -64,6 +68,11 @@
}
@Override
+ public boolean isMissing() {
+ return false;
+ }
+
+ @Override
public boolean isNull() {
return false;
}
@@ -78,7 +87,7 @@
return "FALSE";
}
});
- public final static ConstantExpression NULL = new ConstantExpression(new IAlgebricksConstantValue() {
+ public final static ConstantExpression MISSING = new ConstantExpression(new IAlgebricksConstantValue() {
@Override
public boolean isTrue() {
@@ -86,18 +95,23 @@
}
@Override
- public boolean isNull() {
+ public boolean isMissing() {
return true;
}
@Override
+ public boolean isNull() {
+ return false;
+ }
+
+ @Override
public boolean isFalse() {
return false;
}
@Override
public String toString() {
- return "NULL";
+ return "MISSING";
}
});
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/expressions/IAlgebricksConstantValue.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/expressions/IAlgebricksConstantValue.java
index f80f82b..e6e2834 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/expressions/IAlgebricksConstantValue.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/expressions/IAlgebricksConstantValue.java
@@ -19,6 +19,8 @@
package org.apache.hyracks.algebricks.core.algebra.expressions;
public interface IAlgebricksConstantValue {
+ public boolean isMissing();
+
public boolean isNull();
public boolean isTrue();
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/expressions/INullableTypeComputer.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/expressions/IMissableTypeComputer.java
similarity index 87%
rename from hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/expressions/INullableTypeComputer.java
rename to hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/expressions/IMissableTypeComputer.java
index 2aea6b0..029f41a 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/expressions/INullableTypeComputer.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/expressions/IMissableTypeComputer.java
@@ -20,10 +20,10 @@
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
-public interface INullableTypeComputer {
- public Object makeNullableType(Object type) throws AlgebricksException;
+public interface IMissableTypeComputer {
+ public Object makeMissableType(Object type) throws AlgebricksException;
- public boolean canBeNull(Object type);
+ public boolean canBeMissing(Object type);
public Object getNonOptionalType(Object type);
}
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/functions/AlgebricksBuiltinFunctions.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/functions/AlgebricksBuiltinFunctions.java
index 874b751..07e4f98 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/functions/AlgebricksBuiltinFunctions.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/functions/AlgebricksBuiltinFunctions.java
@@ -50,6 +50,9 @@
// numerics
public final static FunctionIdentifier NUMERIC_ADD = new FunctionIdentifier(ALGEBRICKS_NS, "numeric-add", 2);
+ // missings
+ public final static FunctionIdentifier IS_MISSING = new FunctionIdentifier(ALGEBRICKS_NS, "is-missing", 1);
+
// nulls
public final static FunctionIdentifier IS_NULL = new FunctionIdentifier(ALGEBRICKS_NS, "is-null", 1);
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractLogicalOperator.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractLogicalOperator.java
index 61a2353..1a7e224 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractLogicalOperator.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/AbstractLogicalOperator.java
@@ -190,7 +190,7 @@
for (int i = 0; i < n; i++) {
envPointers[i] = new OpRefTypeEnvPointer(inputs.get(i), ctx);
}
- return new PropagatingTypeEnvironment(ctx.getExpressionTypeComputer(), ctx.getNullableTypeComputer(),
+ return new PropagatingTypeEnvironment(ctx.getExpressionTypeComputer(), ctx.getMissableTypeComputer(),
ctx.getMetadataProvider(), TypePropagationPolicy.ALL, envPointers);
}
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/GroupByOperator.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/GroupByOperator.java
index 1d26148..5b0fd14 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/GroupByOperator.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/GroupByOperator.java
@@ -256,7 +256,7 @@
}
}
IVariableTypeEnvironment env = new PropagatingTypeEnvironment(ctx.getExpressionTypeComputer(),
- ctx.getNullableTypeComputer(), ctx.getMetadataProvider(), TypePropagationPolicy.ALL, envPointers);
+ ctx.getMissableTypeComputer(), ctx.getMetadataProvider(), TypePropagationPolicy.ALL, envPointers);
ILogicalOperator child = inputs.get(0).getValue();
IVariableTypeEnvironment env2 = ctx.getOutputTypeEnvironment(child);
for (Pair<LogicalVariable, Mutable<ILogicalExpression>> p : getGroupByList()) {
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/LeftOuterJoinOperator.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/LeftOuterJoinOperator.java
index b5e4330..9470ab8 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/LeftOuterJoinOperator.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/LeftOuterJoinOperator.java
@@ -22,7 +22,6 @@
import java.util.List;
import org.apache.commons.lang3.mutable.Mutable;
-
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
import org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator;
@@ -66,7 +65,8 @@
envPointers[i] = new OpRefTypeEnvPointer(inputs.get(i), ctx);
}
PropagatingTypeEnvironment env = new PropagatingTypeEnvironment(ctx.getExpressionTypeComputer(),
- ctx.getNullableTypeComputer(), ctx.getMetadataProvider(), TypePropagationPolicy.LEFT_OUTER, envPointers);
+ ctx.getMissableTypeComputer(), ctx.getMetadataProvider(), TypePropagationPolicy.LEFT_OUTER,
+ envPointers);
List<LogicalVariable> liveVars = new ArrayList<LogicalVariable>();
VariableUtilities.getLiveVariables(inputs.get(1).getValue(), liveVars); // live variables from outer branch can be null together
env.getCorrelatedNullableVariableLists().add(liveVars);
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/LeftOuterUnnestMapOperator.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/LeftOuterUnnestMapOperator.java
index 56e2dfb..fbd8619 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/LeftOuterUnnestMapOperator.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/LeftOuterUnnestMapOperator.java
@@ -65,7 +65,7 @@
// For the variables from the inner branch, the output type is the union
// of (original type + null).
for (int i = 0; i < variables.size(); i++) {
- env.setVarType(variables.get(i), ctx.getNullableTypeComputer().makeNullableType(variableTypes.get(i)));
+ env.setVarType(variables.get(i), ctx.getMissableTypeComputer().makeMissableType(variableTypes.get(i)));
}
return env;
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/NestedTupleSourceOperator.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/NestedTupleSourceOperator.java
index 2b66e8f..35da55b 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/NestedTupleSourceOperator.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/NestedTupleSourceOperator.java
@@ -103,7 +103,7 @@
return ctx.getOutputTypeEnvironment(op);
}
};
- return new PropagatingTypeEnvironment(ctx.getExpressionTypeComputer(), ctx.getNullableTypeComputer(),
+ return new PropagatingTypeEnvironment(ctx.getExpressionTypeComputer(), ctx.getMissableTypeComputer(),
ctx.getMetadataProvider(), TypePropagationPolicy.ALL, p);
}
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/SelectOperator.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/SelectOperator.java
index 8a8d1f2..e8a9670 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/SelectOperator.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/SelectOperator.java
@@ -21,7 +21,6 @@
import java.util.ArrayList;
import org.apache.commons.lang3.mutable.Mutable;
-
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.base.ILogicalExpression;
import org.apache.hyracks.algebricks.core.algebra.base.LogicalExpressionTag;
@@ -45,7 +44,8 @@
private final boolean retainNull;
private final LogicalVariable nullPlaceholderVar;
- public SelectOperator(Mutable<ILogicalExpression> condition, boolean retainNull, LogicalVariable nullPlaceholderVar) {
+ public SelectOperator(Mutable<ILogicalExpression> condition, boolean retainNull,
+ LogicalVariable nullPlaceholderVar) {
this.condition = condition;
this.retainNull = retainNull;
this.nullPlaceholderVar = nullPlaceholderVar;
@@ -98,20 +98,22 @@
ITypeEnvPointer[] envPointers = new ITypeEnvPointer[1];
envPointers[0] = new OpRefTypeEnvPointer(inputs.get(0), ctx);
PropagatingTypeEnvironment env = new PropagatingTypeEnvironment(ctx.getExpressionTypeComputer(),
- ctx.getNullableTypeComputer(), ctx.getMetadataProvider(), TypePropagationPolicy.ALL, envPointers);
- if (condition.getValue().getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
- AbstractFunctionCallExpression f1 = (AbstractFunctionCallExpression) condition.getValue();
- if (f1.getFunctionIdentifier().equals(AlgebricksBuiltinFunctions.NOT)) {
- ILogicalExpression a1 = f1.getArguments().get(0).getValue();
- if (a1.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
- AbstractFunctionCallExpression f2 = (AbstractFunctionCallExpression) a1;
- if (f2.getFunctionIdentifier().equals(AlgebricksBuiltinFunctions.IS_NULL)) {
- ILogicalExpression a2 = f2.getArguments().get(0).getValue();
- if (a2.getExpressionTag() == LogicalExpressionTag.VARIABLE) {
- LogicalVariable var = ((VariableReferenceExpression) a2).getVariableReference();
- env.getNonNullVariables().add(var);
- }
- }
+ ctx.getMissableTypeComputer(), ctx.getMetadataProvider(), TypePropagationPolicy.ALL, envPointers);
+ if (condition.getValue().getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
+ return env;
+ }
+ AbstractFunctionCallExpression f1 = (AbstractFunctionCallExpression) condition.getValue();
+ if (!f1.getFunctionIdentifier().equals(AlgebricksBuiltinFunctions.NOT)) {
+ return env;
+ }
+ ILogicalExpression a1 = f1.getArguments().get(0).getValue();
+ if (a1.getExpressionTag() == LogicalExpressionTag.FUNCTION_CALL) {
+ AbstractFunctionCallExpression f2 = (AbstractFunctionCallExpression) a1;
+ if (f2.getFunctionIdentifier().equals(AlgebricksBuiltinFunctions.IS_MISSING)) {
+ ILogicalExpression a2 = f2.getArguments().get(0).getValue();
+ if (a2.getExpressionTag() == LogicalExpressionTag.VARIABLE) {
+ LogicalVariable var = ((VariableReferenceExpression) a2).getVariableReference();
+ env.getNonNullVariables().add(var);
}
}
}
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/SinkOperator.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/SinkOperator.java
index af85fdd7..5205959 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/SinkOperator.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/SinkOperator.java
@@ -75,7 +75,7 @@
envPointers[i] = new OpRefTypeEnvPointer(inputs.get(i), ctx);
}
PropagatingTypeEnvironment env = new PropagatingTypeEnvironment(ctx.getExpressionTypeComputer(),
- ctx.getNullableTypeComputer(), ctx.getMetadataProvider(), TypePropagationPolicy.ALL, envPointers);
+ ctx.getMissableTypeComputer(), ctx.getMetadataProvider(), TypePropagationPolicy.ALL, envPointers);
return env;
}
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/SubplanOperator.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/SubplanOperator.java
index cf11b3e..9dcc402 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/SubplanOperator.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/logical/SubplanOperator.java
@@ -108,7 +108,7 @@
i++;
}
}
- return new PropagatingTypeEnvironment(ctx.getExpressionTypeComputer(), ctx.getNullableTypeComputer(),
+ return new PropagatingTypeEnvironment(ctx.getExpressionTypeComputer(), ctx.getMissableTypeComputer(),
ctx.getMetadataProvider(), TypePropagationPolicy.LEFT_OUTER, envPointers);
}
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/HybridHashJoinPOperator.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/HybridHashJoinPOperator.java
index a24b87b..359cdb3 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/HybridHashJoinPOperator.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/HybridHashJoinPOperator.java
@@ -48,7 +48,7 @@
import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
import org.apache.hyracks.api.dataflow.value.IBinaryHashFunctionFactory;
import org.apache.hyracks.api.dataflow.value.IBinaryHashFunctionFamily;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.IPredicateEvaluatorFactory;
import org.apache.hyracks.api.dataflow.value.IPredicateEvaluatorFactoryProvider;
import org.apache.hyracks.api.dataflow.value.ITuplePairComparator;
@@ -110,7 +110,7 @@
@Override
public void contributeRuntimeOperator(IHyracksJobBuilder builder, JobGenContext context, ILogicalOperator op,
IOperatorSchema propagatedSchema, IOperatorSchema[] inputSchemas, IOperatorSchema outerPlanSchema)
- throws AlgebricksException {
+ throws AlgebricksException {
int[] keysLeft = JobGenHelper.variablesToFieldIndexes(keysLeftBranch, inputSchemas[0]);
int[] keysRight = JobGenHelper.variablesToFieldIndexes(keysRightBranch, inputSchemas[1]);
IVariableTypeEnvironment env = context.getTypeEnvironment(op);
@@ -128,14 +128,13 @@
IPredicateEvaluatorFactoryProvider predEvaluatorFactoryProvider = context
.getPredicateEvaluatorFactoryProvider();
- IPredicateEvaluatorFactory predEvaluatorFactory = (predEvaluatorFactoryProvider == null ? null
- : predEvaluatorFactoryProvider.getPredicateEvaluatorFactory(keysLeft, keysRight));
+ IPredicateEvaluatorFactory predEvaluatorFactory = predEvaluatorFactoryProvider == null ? null
+ : predEvaluatorFactoryProvider.getPredicateEvaluatorFactory(keysLeft, keysRight);
RecordDescriptor recDescriptor = JobGenHelper.mkRecordDescriptor(context.getTypeEnvironment(op),
propagatedSchema, context);
IOperatorDescriptorRegistry spec = builder.getJobSpec();
- IOperatorDescriptor opDesc = null;
-
+ IOperatorDescriptor opDesc;
boolean optimizedHashJoin = true;
for (IBinaryHashFunctionFamily family : hashFunFamilies) {
if (family == null) {
@@ -144,65 +143,12 @@
}
}
- if (!optimizedHashJoin) {
- 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: {
- INullWriterFactory[] nullWriterFactories = new INullWriterFactory[inputSchemas[1].getSize()];
- for (int j = 0; j < nullWriterFactories.length; j++) {
- nullWriterFactories[j] = context.getNullWriterFactory();
- }
- opDesc = new HybridHashJoinOperatorDescriptor(spec, getMemSizeInFrames(),
- maxInputBuildSizeInFrames, aveRecordsPerFrame, getFudgeFactor(), keysLeft, keysRight,
- hashFunFactories, comparatorFactories, recDescriptor, predEvaluatorFactory, true,
- nullWriterFactories);
- break;
- }
- default: {
- throw new NotImplementedException();
- }
- }
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
- }
+ if (optimizedHashJoin) {
+ opDesc = generateOptimizedHashJoinRuntime(context, inputSchemas, keysLeft, keysRight, hashFunFamilies,
+ comparatorFactories, predEvaluatorFactory, recDescriptor, spec);
} else {
- try {
- switch (kind) {
- case INNER: {
- opDesc = new OptimizedHybridHashJoinOperatorDescriptor(spec, getMemSizeInFrames(),
- maxInputBuildSizeInFrames, getFudgeFactor(), keysLeft, keysRight, hashFunFamilies,
- comparatorFactories, recDescriptor,
- new JoinMultiComparatorFactory(comparatorFactories, keysLeft, keysRight),
- new JoinMultiComparatorFactory(comparatorFactories, keysRight, keysLeft),
- predEvaluatorFactory);
- break;
- }
- case LEFT_OUTER: {
- INullWriterFactory[] nullWriterFactories = new INullWriterFactory[inputSchemas[1].getSize()];
- for (int j = 0; j < nullWriterFactories.length; j++) {
- nullWriterFactories[j] = context.getNullWriterFactory();
- }
- opDesc = new OptimizedHybridHashJoinOperatorDescriptor(spec, getMemSizeInFrames(),
- maxInputBuildSizeInFrames, getFudgeFactor(), keysLeft, keysRight, hashFunFamilies,
- comparatorFactories, recDescriptor,
- new JoinMultiComparatorFactory(comparatorFactories, keysLeft, keysRight),
- new JoinMultiComparatorFactory(comparatorFactories, keysRight, keysLeft),
- predEvaluatorFactory, true, nullWriterFactories);
- break;
- }
- default: {
- throw new NotImplementedException();
- }
- }
- } catch (HyracksDataException e) {
- throw new AlgebricksException(e);
- }
+ opDesc = generateHashJoinRuntime(context, inputSchemas, keysLeft, keysRight, hashFunFactories,
+ comparatorFactories, predEvaluatorFactory, recDescriptor, spec);
}
contributeOpDesc(builder, (AbstractLogicalOperator) op, opDesc);
@@ -212,30 +158,101 @@
builder.contributeGraphEdge(src2, 0, op, 1);
}
+ 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.getNullWriterFactory();
+ }
+ 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;
+ }
+
+ private IOperatorDescriptor generateOptimizedHashJoinRuntime(JobGenContext context, IOperatorSchema[] inputSchemas,
+ int[] keysLeft, int[] keysRight, IBinaryHashFunctionFamily[] hashFunFamilies,
+ IBinaryComparatorFactory[] comparatorFactories, IPredicateEvaluatorFactory predEvaluatorFactory,
+ RecordDescriptor recDescriptor, IOperatorDescriptorRegistry spec) throws AlgebricksException {
+ IOperatorDescriptor opDesc;
+ try {
+ switch (kind) {
+ case INNER:
+ opDesc = new OptimizedHybridHashJoinOperatorDescriptor(spec, getMemSizeInFrames(),
+ maxInputBuildSizeInFrames, getFudgeFactor(), keysLeft, keysRight, hashFunFamilies,
+ comparatorFactories, recDescriptor,
+ new JoinMultiComparatorFactory(comparatorFactories, keysLeft, keysRight),
+ new JoinMultiComparatorFactory(comparatorFactories, keysRight, keysLeft),
+ predEvaluatorFactory);
+ break;
+ case LEFT_OUTER:
+ IMissingWriterFactory[] nonMatchWriterFactories = new IMissingWriterFactory[inputSchemas[1]
+ .getSize()];
+ for (int j = 0; j < nonMatchWriterFactories.length; j++) {
+ nonMatchWriterFactories[j] = context.getNullWriterFactory();
+ }
+ opDesc = new OptimizedHybridHashJoinOperatorDescriptor(spec, getMemSizeInFrames(),
+ maxInputBuildSizeInFrames, getFudgeFactor(), keysLeft, keysRight, hashFunFamilies,
+ comparatorFactories, recDescriptor,
+ new JoinMultiComparatorFactory(comparatorFactories, keysLeft, keysRight),
+ new JoinMultiComparatorFactory(comparatorFactories, keysRight, keysLeft),
+ predEvaluatorFactory, true, nonMatchWriterFactories);
+ break;
+ default:
+ throw new NotImplementedException();
+ }
+ } catch (HyracksDataException e) {
+ throw new AlgebricksException(e);
+ }
+ return opDesc;
+ }
+
@Override
protected List<ILocalStructuralProperty> deliveredLocalProperties(ILogicalOperator op, IOptimizationContext context)
throws AlgebricksException {
- List<ILocalStructuralProperty> deliveredLocalProperties = new ArrayList<ILocalStructuralProperty>();
+ List<ILocalStructuralProperty> deliveredLocalProperties = new ArrayList<>();
// Inner join can kick off the "role reversal" optimization, which can kill data properties for the probe side.
- if (kind == JoinKind.LEFT_OUTER) {
- AbstractLogicalOperator probeOp = (AbstractLogicalOperator) op.getInputs().get(0).getValue();
- IPhysicalPropertiesVector probeSideProperties = probeOp.getPhysicalOperator().getDeliveredProperties();
- List<ILocalStructuralProperty> probeSideLocalProperties = probeSideProperties.getLocalProperties();
- if (probeSideLocalProperties != null) {
- // The local grouping property in the probe side will be maintained
- // and the local ordering property in the probe side will be turned into a local grouping property
- // if the grouping variables (or sort columns) in the local property contain all the join key variables
- // for the left branch:
- // 1. in case spilling is not kicked off, the ordering property is maintained and hence local grouping property is maintained.
- // 2. if spilling is kicked off, the grouping property is still maintained though the ordering property is destroyed.
- for (ILocalStructuralProperty property : probeSideLocalProperties) {
- Set<LogicalVariable> groupingVars = new ListSet<LogicalVariable>();
- Set<LogicalVariable> leftBranchVars = new ListSet<LogicalVariable>();
- property.getVariables(groupingVars);
- leftBranchVars.addAll(getKeysLeftBranch());
- if (groupingVars.containsAll(leftBranchVars)) {
- deliveredLocalProperties.add(new LocalGroupingProperty(groupingVars));
- }
+ if (kind != JoinKind.LEFT_OUTER) {
+ return deliveredLocalProperties;
+ }
+ AbstractLogicalOperator probeOp = (AbstractLogicalOperator) op.getInputs().get(0).getValue();
+ IPhysicalPropertiesVector probeSideProperties = probeOp.getPhysicalOperator().getDeliveredProperties();
+ List<ILocalStructuralProperty> probeSideLocalProperties = probeSideProperties.getLocalProperties();
+ if (probeSideLocalProperties != null) {
+ // The local grouping property in the probe side will be maintained
+ // and the local ordering property in the probe side will be turned into a local grouping property
+ // if the grouping variables (or sort columns) in the local property contain all the join key variables
+ // for the left branch:
+ // 1. in case spilling is not kicked off, the ordering property is maintained and hence local grouping
+ // property is maintained.
+ // 2. if spilling is kicked off, the grouping property is still maintained though the ordering property
+ // is destroyed.
+ for (ILocalStructuralProperty property : probeSideLocalProperties) {
+ Set<LogicalVariable> groupingVars = new ListSet<>();
+ Set<LogicalVariable> leftBranchVars = new ListSet<>();
+ property.getVariables(groupingVars);
+ leftBranchVars.addAll(getKeysLeftBranch());
+ if (groupingVars.containsAll(leftBranchVars)) {
+ deliveredLocalProperties.add(new LocalGroupingProperty(groupingVars));
}
}
}
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/InMemoryHashJoinPOperator.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/InMemoryHashJoinPOperator.java
index a92bd70..49a087f 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/InMemoryHashJoinPOperator.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/InMemoryHashJoinPOperator.java
@@ -40,7 +40,7 @@
import org.apache.hyracks.api.dataflow.IOperatorDescriptor;
import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
import org.apache.hyracks.api.dataflow.value.IBinaryHashFunctionFactory;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.IPredicateEvaluatorFactory;
import org.apache.hyracks.api.dataflow.value.IPredicateEvaluatorFactoryProvider;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
@@ -108,7 +108,7 @@
break;
}
case LEFT_OUTER: {
- INullWriterFactory[] nullWriterFactories = new INullWriterFactory[inputSchemas[1].getSize()];
+ IMissingWriterFactory[] nullWriterFactories = new IMissingWriterFactory[inputSchemas[1].getSize()];
for (int j = 0; j < nullWriterFactories.length; j++) {
nullWriterFactories[j] = context.getNullWriterFactory();
}
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/NLJoinPOperator.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/NLJoinPOperator.java
index 99acddb..c2b78a0 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/NLJoinPOperator.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/NLJoinPOperator.java
@@ -44,7 +44,7 @@
import org.apache.hyracks.api.comm.IFrameTupleAccessor;
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.dataflow.IOperatorDescriptor;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.ITuplePairComparator;
import org.apache.hyracks.api.dataflow.value.ITuplePairComparatorFactory;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
@@ -145,7 +145,7 @@
break;
}
case LEFT_OUTER: {
- INullWriterFactory[] nullWriterFactories = new INullWriterFactory[inputSchemas[1].getSize()];
+ IMissingWriterFactory[] nullWriterFactories = new IMissingWriterFactory[inputSchemas[1].getSize()];
for (int j = 0; j < nullWriterFactories.length; j++) {
nullWriterFactories[j] = context.getNullWriterFactory();
}
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/SubplanPOperator.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/SubplanPOperator.java
index 9fc0dd4..a67efd6 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/SubplanPOperator.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/operators/physical/SubplanPOperator.java
@@ -40,7 +40,7 @@
import org.apache.hyracks.algebricks.core.jobgen.impl.JobGenHelper;
import org.apache.hyracks.algebricks.runtime.base.AlgebricksPipeline;
import org.apache.hyracks.algebricks.runtime.operators.meta.SubplanRuntimeFactory;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
public class SubplanPOperator extends AbstractPhysicalOperator {
@@ -94,7 +94,7 @@
AlgebricksPipeline np = subplans[0];
RecordDescriptor inputRecordDesc = JobGenHelper.mkRecordDescriptor(
context.getTypeEnvironment(op.getInputs().get(0).getValue()), inputSchemas[0], context);
- INullWriterFactory[] nullWriterFactories = new INullWriterFactory[np.getOutputWidth()];
+ IMissingWriterFactory[] nullWriterFactories = new IMissingWriterFactory[np.getOutputWidth()];
for (int i = 0; i < nullWriterFactories.length; i++) {
nullWriterFactories[i] = context.getNullWriterFactory();
}
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/properties/TypePropagationPolicy.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/properties/TypePropagationPolicy.java
index e011a7f..061b272 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/properties/TypePropagationPolicy.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/properties/TypePropagationPolicy.java
@@ -22,7 +22,7 @@
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable;
-import org.apache.hyracks.algebricks.core.algebra.expressions.INullableTypeComputer;
+import org.apache.hyracks.algebricks.core.algebra.expressions.IMissableTypeComputer;
import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
import org.apache.hyracks.algebricks.core.algebra.typing.ITypeEnvPointer;
@@ -30,7 +30,7 @@
public static final TypePropagationPolicy ALL = new TypePropagationPolicy() {
@Override
- public Object getVarType(LogicalVariable var, INullableTypeComputer ntc,
+ public Object getVarType(LogicalVariable var, IMissableTypeComputer ntc,
List<LogicalVariable> nonNullVariableList, List<List<LogicalVariable>> correlatedNullableVariableLists,
ITypeEnvPointer... typeEnvs) throws AlgebricksException {
for (ITypeEnvPointer p : typeEnvs) {
@@ -41,7 +41,7 @@
}
Object t = env.getVarType(var, nonNullVariableList, correlatedNullableVariableLists);
if (t != null) {
- if (ntc != null && ntc.canBeNull(t)) {
+ if (ntc != null && ntc.canBeMissing(t)) {
for (List<LogicalVariable> list : correlatedNullableVariableLists) {
if (list.contains(var)) {
for (LogicalVariable v : list) {
@@ -62,41 +62,46 @@
public static final TypePropagationPolicy LEFT_OUTER = new TypePropagationPolicy() {
@Override
- public Object getVarType(LogicalVariable var, INullableTypeComputer ntc,
+ public Object getVarType(LogicalVariable var, IMissableTypeComputer ntc,
List<LogicalVariable> nonNullVariableList, List<List<LogicalVariable>> correlatedNullableVariableLists,
ITypeEnvPointer... typeEnvs) throws AlgebricksException {
int n = typeEnvs.length;
for (int i = 0; i < n; i++) {
Object t = typeEnvs[i].getTypeEnv().getVarType(var, nonNullVariableList,
correlatedNullableVariableLists);
- if (t != null) {
- if (i == 0) { // outer branch
- return t;
- } else { // inner branch
- boolean nonNullVarIsProduced = false;
- for (LogicalVariable v : nonNullVariableList) {
- if (v == var) {
- nonNullVarIsProduced = true;
- break;
- }
- if (typeEnvs[i].getTypeEnv().getVarType(v) != null) {
- nonNullVarIsProduced = true;
- break;
- }
- }
- if (nonNullVarIsProduced) {
- return t;
- } else {
- return ntc.makeNullableType(t);
- }
+ if (t == null) {
+ continue;
+ }
+ if (i == 0) { // outer branch
+ return t;
+ }
+
+ // inner branch
+ boolean nonMissingVarIsProduced = false;
+ for (LogicalVariable v : nonNullVariableList) {
+ boolean toBreak = false;
+ if (v == var) {
+ nonMissingVarIsProduced = true;
+ toBreak = true;
+ } else if (typeEnvs[i].getTypeEnv().getVarType(v) != null) {
+ nonMissingVarIsProduced = true;
+ toBreak = true;
}
+ if (toBreak) {
+ break;
+ }
+ }
+ if (nonMissingVarIsProduced) {
+ return t;
+ } else {
+ return ntc.makeMissableType(t);
}
}
return null;
}
};
- public abstract Object getVarType(LogicalVariable var, INullableTypeComputer ntc,
+ public abstract Object getVarType(LogicalVariable var, IMissableTypeComputer ntc,
List<LogicalVariable> nonNullVariableList, List<List<LogicalVariable>> correlatedNullableVariableLists,
ITypeEnvPointer... typeEnvs) throws AlgebricksException;
}
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/typing/ITypingContext.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/typing/ITypingContext.java
index 4d85111..7b77083 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/typing/ITypingContext.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/typing/ITypingContext.java
@@ -21,7 +21,7 @@
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator;
import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionTypeComputer;
-import org.apache.hyracks.algebricks.core.algebra.expressions.INullableTypeComputer;
+import org.apache.hyracks.algebricks.core.algebra.expressions.IMissableTypeComputer;
import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
@@ -32,7 +32,7 @@
public IExpressionTypeComputer getExpressionTypeComputer();
- public INullableTypeComputer getNullableTypeComputer();
+ public IMissableTypeComputer getMissableTypeComputer();
public IMetadataProvider<?, ?> getMetadataProvider();
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/typing/PropagatingTypeEnvironment.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/typing/PropagatingTypeEnvironment.java
index 076992f..a1be35d 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/typing/PropagatingTypeEnvironment.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/typing/PropagatingTypeEnvironment.java
@@ -24,7 +24,7 @@
import org.apache.hyracks.algebricks.common.exceptions.AlgebricksException;
import org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable;
import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionTypeComputer;
-import org.apache.hyracks.algebricks.core.algebra.expressions.INullableTypeComputer;
+import org.apache.hyracks.algebricks.core.algebra.expressions.IMissableTypeComputer;
import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
import org.apache.hyracks.algebricks.core.algebra.properties.TypePropagationPolicy;
@@ -32,7 +32,7 @@
private final TypePropagationPolicy policy;
- private final INullableTypeComputer nullableTypeComputer;
+ private final IMissableTypeComputer nullableTypeComputer;
private final ITypeEnvPointer[] envPointers;
@@ -41,7 +41,7 @@
private final List<List<LogicalVariable>> correlatedNullableVariableLists = new ArrayList<List<LogicalVariable>>();
public PropagatingTypeEnvironment(IExpressionTypeComputer expressionTypeComputer,
- INullableTypeComputer nullableTypeComputer, IMetadataProvider<?, ?> metadataProvider,
+ IMissableTypeComputer nullableTypeComputer, IMetadataProvider<?, ?> metadataProvider,
TypePropagationPolicy policy, ITypeEnvPointer[] envPointers) {
super(expressionTypeComputer, metadataProvider);
this.nullableTypeComputer = nullableTypeComputer;
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/util/OperatorPropertiesUtil.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/util/OperatorPropertiesUtil.java
index e78db9b..353a782 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/util/OperatorPropertiesUtil.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/algebra/util/OperatorPropertiesUtil.java
@@ -210,7 +210,7 @@
}
}
- public static boolean isNullTest(AbstractLogicalOperator op) {
+ public static boolean isMissingTest(AbstractLogicalOperator op) {
if (op.getOperatorTag() != LogicalOperatorTag.SELECT) {
return false;
}
@@ -231,7 +231,7 @@
return false;
}
AbstractFunctionCallExpression f2 = (AbstractFunctionCallExpression) a1;
- if (!f2.getFunctionIdentifier().equals(AlgebricksBuiltinFunctions.IS_NULL)) {
+ if (!f2.getFunctionIdentifier().equals(AlgebricksBuiltinFunctions.IS_MISSING)) {
return false;
}
return true;
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/jobgen/impl/JobGenContext.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/jobgen/impl/JobGenContext.java
index 4b94dcf..caa46c8 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/jobgen/impl/JobGenContext.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/jobgen/impl/JobGenContext.java
@@ -29,7 +29,6 @@
import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionEvalSizeComputer;
import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionRuntimeProvider;
import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionTypeComputer;
-import org.apache.hyracks.algebricks.core.algebra.expressions.INullableTypeComputer;
import org.apache.hyracks.algebricks.core.algebra.expressions.IPartialAggregationTypeComputer;
import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
@@ -44,7 +43,7 @@
import org.apache.hyracks.algebricks.data.IPrinterFactoryProvider;
import org.apache.hyracks.algebricks.data.ISerializerDeserializerProvider;
import org.apache.hyracks.algebricks.data.ITypeTraitProvider;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.IPredicateEvaluatorFactoryProvider;
public class JobGenContext {
@@ -57,7 +56,7 @@
private final IPrinterFactoryProvider printerFactoryProvider;
private final ITypeTraitProvider typeTraitProvider;
private final IMetadataProvider<?, ?> metadataProvider;
- private final INullWriterFactory nullWriterFactory;
+ private final IMissingWriterFactory nonMatchWriterFactory;
private final INormalizedKeyComputerFactoryProvider normalizedKeyComputerFactoryProvider;
private final Object appContext;
private final IBinaryBooleanInspectorFactory booleanInspectorFactory;
@@ -79,11 +78,10 @@
IBinaryComparatorFactoryProvider comparatorFactoryProvider, ITypeTraitProvider typeTraitProvider,
IBinaryBooleanInspectorFactory booleanInspectorFactory,
IBinaryIntegerInspectorFactory integerInspectorFactory, IPrinterFactoryProvider printerFactoryProvider,
- INullWriterFactory nullWriterFactory,
+ IMissingWriterFactory nullWriterFactory,
INormalizedKeyComputerFactoryProvider normalizedKeyComputerFactoryProvider,
IExpressionRuntimeProvider expressionRuntimeProvider, IExpressionTypeComputer expressionTypeComputer,
- INullableTypeComputer nullableTypeComputer, ITypingContext typingContext,
- IExpressionEvalSizeComputer expressionEvalSizeComputer,
+ ITypingContext typingContext, IExpressionEvalSizeComputer expressionEvalSizeComputer,
IPartialAggregationTypeComputer partialAggregationTypeComputer,
IPredicateEvaluatorFactoryProvider predEvaluatorFactoryProvider, int frameSize,
AlgebricksAbsolutePartitionConstraint clusterLocations) {
@@ -100,7 +98,7 @@
this.printerFactoryProvider = printerFactoryProvider;
this.clusterLocations = clusterLocations;
this.normalizedKeyComputerFactoryProvider = normalizedKeyComputerFactoryProvider;
- this.nullWriterFactory = nullWriterFactory;
+ this.nonMatchWriterFactory = nullWriterFactory;
this.expressionRuntimeProvider = expressionRuntimeProvider;
this.expressionTypeComputer = expressionTypeComputer;
this.typingContext = typingContext;
@@ -185,8 +183,8 @@
return expressionTypeComputer.getType(expr, typingContext.getMetadataProvider(), env);
}
- public INullWriterFactory getNullWriterFactory() {
- return nullWriterFactory;
+ public IMissingWriterFactory getNullWriterFactory() {
+ return nonMatchWriterFactory;
}
public INormalizedKeyComputerFactoryProvider getNormalizedKeyComputerFactoryProvider() {
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/rewriter/base/AlgebricksOptimizationContext.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/rewriter/base/AlgebricksOptimizationContext.java
index 154f4a1..86f61ad 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/rewriter/base/AlgebricksOptimizationContext.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/rewriter/base/AlgebricksOptimizationContext.java
@@ -33,7 +33,7 @@
import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionEvalSizeComputer;
import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionTypeComputer;
import org.apache.hyracks.algebricks.core.algebra.expressions.IMergeAggregationExpressionFactory;
-import org.apache.hyracks.algebricks.core.algebra.expressions.INullableTypeComputer;
+import org.apache.hyracks.algebricks.core.algebra.expressions.IMissableTypeComputer;
import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableEvalSizeEnvironment;
import org.apache.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment;
import org.apache.hyracks.algebricks.core.algebra.metadata.IMetadataProvider;
@@ -79,13 +79,13 @@
protected final Map<ILogicalOperator, ILogicalPropertiesVector> logicalProps = new HashMap<ILogicalOperator, ILogicalPropertiesVector>();
private final IExpressionTypeComputer expressionTypeComputer;
- private final INullableTypeComputer nullableTypeComputer;
+ private final IMissableTypeComputer nullableTypeComputer;
private final INodeDomain defaultNodeDomain;
private final LogicalOperatorPrettyPrintVisitor prettyPrintVisitor;
public AlgebricksOptimizationContext(int varCounter, IExpressionEvalSizeComputer expressionEvalSizeComputer,
IMergeAggregationExpressionFactory mergeAggregationExpressionFactory,
- IExpressionTypeComputer expressionTypeComputer, INullableTypeComputer nullableTypeComputer,
+ IExpressionTypeComputer expressionTypeComputer, IMissableTypeComputer nullableTypeComputer,
PhysicalOptimizationConfig physicalOptimizationConfig, AlgebricksPartitionConstraint clusterLocations) {
this(varCounter, expressionEvalSizeComputer, mergeAggregationExpressionFactory, expressionTypeComputer,
nullableTypeComputer, physicalOptimizationConfig, clusterLocations,
@@ -94,7 +94,7 @@
public AlgebricksOptimizationContext(int varCounter, IExpressionEvalSizeComputer expressionEvalSizeComputer,
IMergeAggregationExpressionFactory mergeAggregationExpressionFactory,
- IExpressionTypeComputer expressionTypeComputer, INullableTypeComputer nullableTypeComputer,
+ IExpressionTypeComputer expressionTypeComputer, IMissableTypeComputer nullableTypeComputer,
PhysicalOptimizationConfig physicalOptimizationConfig, AlgebricksPartitionConstraint clusterLocations,
LogicalOperatorPrettyPrintVisitor prettyPrintVisitor) {
this.varCounter = varCounter;
@@ -281,7 +281,7 @@
}
@Override
- public INullableTypeComputer getNullableTypeComputer() {
+ public IMissableTypeComputer getMissableTypeComputer() {
return nullableTypeComputer;
}
diff --git a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/rewriter/base/IOptimizationContextFactory.java b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/rewriter/base/IOptimizationContextFactory.java
index ce77942..0e5cf9c 100644
--- a/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/rewriter/base/IOptimizationContextFactory.java
+++ b/hyracks-fullstack/algebricks/algebricks-core/src/main/java/org/apache/hyracks/algebricks/core/rewriter/base/IOptimizationContextFactory.java
@@ -23,12 +23,12 @@
import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionEvalSizeComputer;
import org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionTypeComputer;
import org.apache.hyracks.algebricks.core.algebra.expressions.IMergeAggregationExpressionFactory;
-import org.apache.hyracks.algebricks.core.algebra.expressions.INullableTypeComputer;
+import org.apache.hyracks.algebricks.core.algebra.expressions.IMissableTypeComputer;
public interface IOptimizationContextFactory {
public IOptimizationContext createOptimizationContext(int varCounter,
IExpressionEvalSizeComputer expressionEvalSizeComputer,
IMergeAggregationExpressionFactory mergeAggregationExpressionFactory,
- IExpressionTypeComputer expressionTypeComputer, INullableTypeComputer nullableTypeComputer,
+ IExpressionTypeComputer expressionTypeComputer, IMissableTypeComputer missableTypeComputer,
PhysicalOptimizationConfig physicalOptimizationConfig, AlgebricksPartitionConstraint clusterLocations);
}
diff --git a/hyracks-fullstack/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/impl/NoopNullWriterFactory.java b/hyracks-fullstack/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/impl/NoopMissingWriterFactory.java
similarity index 63%
rename from hyracks-fullstack/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/impl/NoopNullWriterFactory.java
rename to hyracks-fullstack/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/impl/NoopMissingWriterFactory.java
index 841891a..5ca8d3b 100644
--- a/hyracks-fullstack/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/impl/NoopNullWriterFactory.java
+++ b/hyracks-fullstack/algebricks/algebricks-data/src/main/java/org/apache/hyracks/algebricks/data/impl/NoopMissingWriterFactory.java
@@ -18,30 +18,25 @@
*/
package org.apache.hyracks.algebricks.data.impl;
-import java.io.DataOutput;
-
-import org.apache.hyracks.api.dataflow.value.INullWriter;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriter;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.exceptions.HyracksDataException;
-public class NoopNullWriterFactory implements INullWriterFactory {
+public class NoopMissingWriterFactory implements IMissingWriterFactory {
private static final long serialVersionUID = 1L;
- public static final NoopNullWriterFactory INSTANCE = new NoopNullWriterFactory();
+ public static final NoopMissingWriterFactory INSTANCE = new NoopMissingWriterFactory();
- private NoopNullWriterFactory() {
+ private NoopMissingWriterFactory() {
}
@Override
- public INullWriter createNullWriter() {
+ public IMissingWriter createMissingWriter() {
+ return out -> writeMissing();
+ }
- return new INullWriter() {
-
- @Override
- public void writeNull(DataOutput out) throws HyracksDataException {
- // do nothing
- }
- };
+ private static void writeMissing() throws HyracksDataException {
+ // do nothing
}
}
diff --git a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/compiler/ConstantValue.java b/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/compiler/ConstantValue.java
index 278a585..90d5b83 100644
--- a/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/compiler/ConstantValue.java
+++ b/hyracks-fullstack/algebricks/algebricks-examples/piglet-example/src/main/java/org/apache/hyracks/algebricks/examples/piglet/compiler/ConstantValue.java
@@ -45,6 +45,11 @@
}
@Override
+ public boolean isMissing() {
+ return false;
+ }
+
+ @Override
public boolean isNull() {
return false;
}
diff --git a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/PushSelectIntoJoinRule.java b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/PushSelectIntoJoinRule.java
index 3ebbea1..44c76e0 100644
--- a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/PushSelectIntoJoinRule.java
+++ b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/PushSelectIntoJoinRule.java
@@ -169,23 +169,23 @@
for (int j = 0; j < intersectsBranch.length; j++) {
Mutable<ILogicalOperator> branch = branchIter.next();
boolean inter = intersectsBranch[j];
- if (inter) {
- if (j > 0 && isLoj) {
- // if a left outer join, if the select condition is not-null filtering,
- // we rewrite left outer join
- // to inner join for this case.
- if (containsNotNullFiltering(selectCondition)) {
- lojToInner = true;
- }
- }
- if ((j > 0 && isLoj) && containsNullFiltering(selectCondition)) {
- // Select is-null($$var) cannot be pushed in the right branch of a LOJ;
- notPushedStack.addFirst(select);
- } else {
- // Conditions for the left branch can always be pushed.
- // Other conditions can be pushed to the right branch of a LOJ.
- copySelectToBranch(select, branch, context);
- }
+ if (!inter) {
+ continue;
+ }
+
+ // if a left outer join, if the select condition is not-missing filtering,
+ // we rewrite left outer join
+ // to inner join for this case.
+ if (j > 0 && isLoj && containsNotMissingFiltering(selectCondition)) {
+ lojToInner = true;
+ }
+ if ((j > 0 && isLoj) && containsMissingFiltering(selectCondition)) {
+ // Select "is-not-missing($$var)" cannot be pushed in the right branch of a LOJ;
+ notPushedStack.addFirst(select);
+ } else {
+ // Conditions for the left branch can always be pushed.
+ // Other conditions can be pushed to the right branch of a LOJ.
+ copySelectToBranch(select, branch, context);
}
}
if (lojToInner) {
@@ -262,19 +262,19 @@
}
/**
- * Whether the expression contains a not-null filtering
+ * Whether the expression contains a not-missing filtering
*
* @param expr
- * @return true if the expression contains a not-null filtering function call; false otherwise.
+ * @return true if the expression contains a not-missing filtering function call; false otherwise.
*/
- private boolean containsNotNullFiltering(ILogicalExpression expr) {
+ private boolean containsNotMissingFiltering(ILogicalExpression expr) {
if (expr.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
return false;
}
ScalarFunctionCallExpression func = (ScalarFunctionCallExpression) expr;
if (func.getFunctionIdentifier() == AlgebricksBuiltinFunctions.AND) {
for (Mutable<ILogicalExpression> argumentRef : func.getArguments()) {
- if (containsNotNullFiltering(argumentRef.getValue())) {
+ if (containsNotMissingFiltering(argumentRef.getValue())) {
return true;
}
}
@@ -288,32 +288,32 @@
return false;
}
ScalarFunctionCallExpression func2 = (ScalarFunctionCallExpression) arg;
- if (func2.getFunctionIdentifier() != AlgebricksBuiltinFunctions.IS_NULL) {
+ if (func2.getFunctionIdentifier() != AlgebricksBuiltinFunctions.IS_MISSING) {
return false;
}
return true;
}
/**
- * Whether the expression contains a null filtering
+ * Whether the expression contains a missing filtering
*
* @param expr
- * @return true if the expression contains a null filtering function call; false otherwise.
+ * @return true if the expression contains a missing filtering function call; false otherwise.
*/
- private boolean containsNullFiltering(ILogicalExpression expr) {
+ private boolean containsMissingFiltering(ILogicalExpression expr) {
if (expr.getExpressionTag() != LogicalExpressionTag.FUNCTION_CALL) {
return false;
}
ScalarFunctionCallExpression func = (ScalarFunctionCallExpression) expr;
if (func.getFunctionIdentifier() == AlgebricksBuiltinFunctions.AND) {
for (Mutable<ILogicalExpression> argumentRef : func.getArguments()) {
- if (containsNullFiltering(argumentRef.getValue())) {
+ if (containsMissingFiltering(argumentRef.getValue())) {
return true;
}
}
return false;
}
- if (func.getFunctionIdentifier() != AlgebricksBuiltinFunctions.IS_NULL) {
+ if (func.getFunctionIdentifier() != AlgebricksBuiltinFunctions.IS_MISSING) {
return false;
}
return true;
diff --git a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/subplan/IntroduceGroupByForSubplanRule.java b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/subplan/IntroduceGroupByForSubplanRule.java
index 3e65d91..836f266 100644
--- a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/subplan/IntroduceGroupByForSubplanRule.java
+++ b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/subplan/IntroduceGroupByForSubplanRule.java
@@ -243,7 +243,7 @@
context.computeAndSetTypeEnvironmentForOperator(tmpAsgn);
}
- IFunctionInfo finfoEq = context.getMetadataProvider().lookupFunction(AlgebricksBuiltinFunctions.IS_NULL);
+ IFunctionInfo finfoEq = context.getMetadataProvider().lookupFunction(AlgebricksBuiltinFunctions.IS_MISSING);
ILogicalExpression isNullTest = new ScalarFunctionCallExpression(finfoEq,
new MutableObject<ILogicalExpression>(new VariableReferenceExpression(testForNull)));
IFunctionInfo finfoNot = context.getMetadataProvider().lookupFunction(AlgebricksBuiltinFunctions.NOT);
diff --git a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/subplan/IntroduceLeftOuterJoinForSubplanRule.java b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/subplan/IntroduceLeftOuterJoinForSubplanRule.java
index 93af981..f809e96 100644
--- a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/subplan/IntroduceLeftOuterJoinForSubplanRule.java
+++ b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/subplan/IntroduceLeftOuterJoinForSubplanRule.java
@@ -65,7 +65,7 @@
AbstractLogicalOperator op1 = (AbstractLogicalOperator) subplanRoot.getValue();
Mutable<ILogicalOperator> opUnder = subplan.getInputs().get(0);
- if (OperatorPropertiesUtil.isNullTest((AbstractLogicalOperator) opUnder.getValue())) {
+ if (OperatorPropertiesUtil.isMissingTest((AbstractLogicalOperator) opUnder.getValue())) {
return false;
}
diff --git a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/subplan/SubplanOutOfGroupRule.java b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/subplan/SubplanOutOfGroupRule.java
index 0aba194..049e853 100644
--- a/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/subplan/SubplanOutOfGroupRule.java
+++ b/hyracks-fullstack/algebricks/algebricks-rewriter/src/main/java/org/apache/hyracks/algebricks/rewriter/rules/subplan/SubplanOutOfGroupRule.java
@@ -82,7 +82,7 @@
if (op1.getOperatorTag() == LogicalOperatorTag.SUBPLAN) {
SubplanOperator subplan = (SubplanOperator) op1;
AbstractLogicalOperator op2 = (AbstractLogicalOperator) subplan.getInputs().get(0).getValue();
- if (OperatorPropertiesUtil.isNullTest(op2)) {
+ if (OperatorPropertiesUtil.isMissingTest(op2)) {
if (subplan.getNestedPlans().size() == 1) {
ILogicalPlan p1 = subplan.getNestedPlans().get(0);
if (p1.getRoots().size() == 1) {
diff --git a/hyracks-fullstack/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/meta/SubplanRuntimeFactory.java b/hyracks-fullstack/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/meta/SubplanRuntimeFactory.java
index ac9bae2..9a9fb72 100644
--- a/hyracks-fullstack/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/meta/SubplanRuntimeFactory.java
+++ b/hyracks-fullstack/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/meta/SubplanRuntimeFactory.java
@@ -31,8 +31,8 @@
import org.apache.hyracks.algebricks.runtime.operators.std.NestedTupleSourceRuntimeFactory.NestedTupleSourceRuntime;
import org.apache.hyracks.api.comm.IFrameWriter;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.INullWriter;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriter;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.dataflow.common.comm.io.ArrayTupleBuilder;
@@ -44,13 +44,13 @@
private final AlgebricksPipeline pipeline;
private final RecordDescriptor inputRecordDesc;
- private final INullWriterFactory[] nullWriterFactories;
+ private final IMissingWriterFactory[] missingWriterFactories;
- public SubplanRuntimeFactory(AlgebricksPipeline pipeline, INullWriterFactory[] nullWriterFactories,
+ public SubplanRuntimeFactory(AlgebricksPipeline pipeline, IMissingWriterFactory[] missingWriterFactories,
RecordDescriptor inputRecordDesc, int[] projectionList) {
super(projectionList);
this.pipeline = pipeline;
- this.nullWriterFactories = nullWriterFactories;
+ this.missingWriterFactories = missingWriterFactories;
this.inputRecordDesc = inputRecordDesc;
if (projectionList != null) {
throw new NotImplementedException();
@@ -76,9 +76,9 @@
final PipelineAssembler pa = new PipelineAssembler(pipeline, 1, 1, inputRecordDesc,
pipelineOutputRecordDescriptor);
- final INullWriter[] nullWriters = new INullWriter[nullWriterFactories.length];
- for (int i = 0; i < nullWriterFactories.length; i++) {
- nullWriters[i] = nullWriterFactories[i].createNullWriter();
+ final IMissingWriter[] nullWriters = new IMissingWriter[missingWriterFactories.length];
+ for (int i = 0; i < missingWriterFactories.length; i++) {
+ nullWriters[i] = missingWriterFactories[i].createMissingWriter();
}
return new AbstractOneInputOneOutputOneFramePushRuntime() {
@@ -132,7 +132,7 @@
}
DataOutput dos = tb.getDataOutput();
for (int i = 0; i < nullWriters.length; i++) {
- nullWriters[i].writeNull(dos);
+ nullWriters[i].writeMissing(dos);
tb.addFieldEndOffset();
}
}
diff --git a/hyracks-fullstack/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/StreamSelectRuntimeFactory.java b/hyracks-fullstack/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/StreamSelectRuntimeFactory.java
index 5eb4604..1bc5d51 100644
--- a/hyracks-fullstack/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/StreamSelectRuntimeFactory.java
+++ b/hyracks-fullstack/algebricks/algebricks-runtime/src/main/java/org/apache/hyracks/algebricks/runtime/operators/std/StreamSelectRuntimeFactory.java
@@ -30,8 +30,8 @@
import org.apache.hyracks.algebricks.runtime.operators.base.AbstractOneInputOneOutputOneFramePushRuntime;
import org.apache.hyracks.algebricks.runtime.operators.base.AbstractOneInputOneOutputRuntimeFactory;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.INullWriter;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriter;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.exceptions.HyracksDataException;
import org.apache.hyracks.data.std.api.IPointable;
import org.apache.hyracks.data.std.primitive.VoidPointable;
@@ -45,30 +45,30 @@
private final IBinaryBooleanInspectorFactory binaryBooleanInspectorFactory;
- private final boolean retainNull;
+ private final boolean retainMissing;
- private final int nullPlaceholderVariableIndex;
+ private final int missingPlaceholderVariableIndex;
- private final INullWriterFactory nullWriterFactory;
+ private final IMissingWriterFactory missingWriterFactory;
/**
* @param cond
* @param projectionList
* if projectionList is null, then no projection is performed
- * @param retainNull
- * @param nullPlaceholderVariableIndex
- * @param nullWriterFactory
+ * @param retainMissing
+ * @param missingPlaceholderVariableIndex
+ * @param missingWriterFactory
* @throws HyracksDataException
*/
public StreamSelectRuntimeFactory(IScalarEvaluatorFactory cond, int[] projectionList,
- IBinaryBooleanInspectorFactory binaryBooleanInspectorFactory, boolean retainNull,
- int nullPlaceholderVariableIndex, INullWriterFactory nullWriterFactory) {
+ IBinaryBooleanInspectorFactory binaryBooleanInspectorFactory, boolean retainMissing,
+ int missingPlaceholderVariableIndex, IMissingWriterFactory missingWriterFactory) {
super(projectionList);
this.cond = cond;
this.binaryBooleanInspectorFactory = binaryBooleanInspectorFactory;
- this.retainNull = retainNull;
- this.nullPlaceholderVariableIndex = nullPlaceholderVariableIndex;
- this.nullWriterFactory = nullWriterFactory;
+ this.retainMissing = retainMissing;
+ this.missingPlaceholderVariableIndex = missingPlaceholderVariableIndex;
+ this.missingWriterFactory = missingWriterFactory;
}
@Override
@@ -82,8 +82,8 @@
return new AbstractOneInputOneOutputOneFieldFramePushRuntime() {
private IPointable p = VoidPointable.FACTORY.createPointable();
private IScalarEvaluator eval;
- private INullWriter nullWriter = null;
- private ArrayTupleBuilder nullTupleBuilder = null;
+ private IMissingWriter missingWriter = null;
+ private ArrayTupleBuilder missingTupleBuilder = null;
private boolean isOpen = false;
@Override
@@ -100,12 +100,12 @@
writer.open();
//prepare nullTupleBuilder
- if (retainNull && nullWriter == null) {
- nullWriter = nullWriterFactory.createNullWriter();
- nullTupleBuilder = new ArrayTupleBuilder(1);
- DataOutput out = nullTupleBuilder.getDataOutput();
- nullWriter.writeNull(out);
- nullTupleBuilder.addFieldEndOffset();
+ if (retainMissing && missingWriter == null) {
+ missingWriter = missingWriterFactory.createMissingWriter();
+ missingTupleBuilder = new ArrayTupleBuilder(1);
+ DataOutput out = missingTupleBuilder.getDataOutput();
+ missingWriter.writeMissing(out);
+ missingTupleBuilder.addFieldEndOffset();
}
}
@@ -145,10 +145,10 @@
appendTupleToFrame(t);
}
} else {
- if (retainNull) {
+ if (retainMissing) {
for (int i = 0; i < tRef.getFieldCount(); i++) {
- if (i == nullPlaceholderVariableIndex) {
- appendField(nullTupleBuilder.getByteArray(), 0, nullTupleBuilder.getSize());
+ if (i == missingPlaceholderVariableIndex) {
+ appendField(missingTupleBuilder.getByteArray(), 0, missingTupleBuilder.getSize());
} else {
appendField(tAccess, t, i);
}
diff --git a/hyracks-fullstack/algebricks/algebricks-tests/src/test/java/org/apache/hyracks/algebricks/tests/pushruntime/PushRuntimeTest.java b/hyracks-fullstack/algebricks/algebricks-tests/src/test/java/org/apache/hyracks/algebricks/tests/pushruntime/PushRuntimeTest.java
index 0dc1961..4dafd0e 100644
--- a/hyracks-fullstack/algebricks/algebricks-tests/src/test/java/org/apache/hyracks/algebricks/tests/pushruntime/PushRuntimeTest.java
+++ b/hyracks-fullstack/algebricks/algebricks-tests/src/test/java/org/apache/hyracks/algebricks/tests/pushruntime/PushRuntimeTest.java
@@ -33,7 +33,7 @@
import org.apache.hyracks.algebricks.data.impl.BinaryBooleanInspectorImpl;
import org.apache.hyracks.algebricks.data.impl.BinaryIntegerInspectorImpl;
import org.apache.hyracks.algebricks.data.impl.IntegerPrinterFactory;
-import org.apache.hyracks.algebricks.data.impl.NoopNullWriterFactory;
+import org.apache.hyracks.algebricks.data.impl.NoopMissingWriterFactory;
import org.apache.hyracks.algebricks.data.impl.UTF8StringPrinterFactory;
import org.apache.hyracks.algebricks.runtime.aggregators.TupleCountAggregateFunctionFactory;
import org.apache.hyracks.algebricks.runtime.aggregators.TupleCountRunningAggregateFunctionFactory;
@@ -66,7 +66,7 @@
import org.apache.hyracks.api.constraints.PartitionConstraintHelper;
import org.apache.hyracks.api.dataflow.IOperatorDescriptor;
import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
import org.apache.hyracks.api.io.FileReference;
@@ -701,7 +701,7 @@
new RecordDescriptor[] { assign1Desc, assign2Desc, project1Desc });
SubplanRuntimeFactory subplan = new SubplanRuntimeFactory(pipeline,
- new INullWriterFactory[] { NoopNullWriterFactory.INSTANCE }, assign1Desc, null);
+ new IMissingWriterFactory[] { NoopMissingWriterFactory.INSTANCE }, assign1Desc, null);
RecordDescriptor subplanDesc = new RecordDescriptor(new ISerializerDeserializer[] {
IntegerSerializerDeserializer.INSTANCE, IntegerSerializerDeserializer.INSTANCE });
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/BinaryComparatorConstant.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/BinaryComparatorConstant.java
deleted file mode 100644
index de0e3ee..0000000
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/BinaryComparatorConstant.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.hyracks.api.dataflow.value;
-
-public final class BinaryComparatorConstant {
-
- // Result code for isComparable()
- // TRUE: can be comparable
- // FALSE: can not be comparable
- // UNKNOWN: can not be decided whether two arguments are comparable or not - usually NULL
-
- public static enum ComparableResultCode {
- TRUE,
- FALSE,
- UNKNOWN
- }
-
-}
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/INullWriter.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/IMissingWriter.java
similarity index 87%
rename from hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/INullWriter.java
rename to hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/IMissingWriter.java
index 9105146..1309233 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/INullWriter.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/IMissingWriter.java
@@ -22,6 +22,7 @@
import org.apache.hyracks.api.exceptions.HyracksDataException;
-public interface INullWriter {
- public void writeNull(DataOutput out) throws HyracksDataException;
+@FunctionalInterface
+public interface IMissingWriter {
+ public void writeMissing(DataOutput out) throws HyracksDataException;
}
diff --git a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/INullWriterFactory.java b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/IMissingWriterFactory.java
similarity index 87%
rename from hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/INullWriterFactory.java
rename to hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/IMissingWriterFactory.java
index 9cd46e5..bf15489 100644
--- a/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/INullWriterFactory.java
+++ b/hyracks-fullstack/hyracks/hyracks-api/src/main/java/org/apache/hyracks/api/dataflow/value/IMissingWriterFactory.java
@@ -20,6 +20,7 @@
import java.io.Serializable;
-public interface INullWriterFactory extends Serializable {
- public INullWriter createNullWriter();
+@FunctionalInterface
+public interface IMissingWriterFactory extends Serializable {
+ public IMissingWriter createMissingWriter();
}
diff --git a/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/GraceHashJoinOperatorDescriptor.java b/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/GraceHashJoinOperatorDescriptor.java
index 4e4256e..2f7b1c2 100644
--- a/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/GraceHashJoinOperatorDescriptor.java
+++ b/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/GraceHashJoinOperatorDescriptor.java
@@ -25,7 +25,7 @@
import org.apache.hyracks.api.dataflow.TaskId;
import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
import org.apache.hyracks.api.dataflow.value.IBinaryHashFunctionFactory;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.IPredicateEvaluator;
import org.apache.hyracks.api.dataflow.value.IPredicateEvaluatorFactory;
import org.apache.hyracks.api.dataflow.value.IRecordDescriptorProvider;
@@ -50,7 +50,7 @@
private final IBinaryComparatorFactory[] comparatorFactories;
private final IPredicateEvaluatorFactory predEvaluatorFactory;
private final boolean isLeftOuter;
- private final INullWriterFactory[] nullWriterFactories1;
+ private final IMissingWriterFactory[] nullWriterFactories1;
public GraceHashJoinOperatorDescriptor(IOperatorDescriptorRegistry spec, int memsize, int inputsize0,
int recordsPerFrame, double factor, int[] keys0, int[] keys1,
@@ -74,7 +74,8 @@
public GraceHashJoinOperatorDescriptor(IOperatorDescriptorRegistry spec, int memsize, int inputsize0,
int recordsPerFrame, double factor, int[] keys0, int[] keys1,
IBinaryHashFunctionFactory[] hashFunctionFactories, IBinaryComparatorFactory[] comparatorFactories,
- RecordDescriptor recordDescriptor, boolean isLeftOuter, INullWriterFactory[] nullWriterFactories1, IPredicateEvaluatorFactory predEvalFactory) {
+ RecordDescriptor recordDescriptor, boolean isLeftOuter, IMissingWriterFactory[] nullWriterFactories1,
+ IPredicateEvaluatorFactory predEvalFactory) {
super(spec, 2, 1);
this.memsize = memsize;
this.inputsize0 = inputsize0;
@@ -117,9 +118,9 @@
private class HashPartitionActivityNode extends AbstractActivityNode {
private static final long serialVersionUID = 1L;
- private int keys[];
+ private int[] keys;
- public HashPartitionActivityNode(ActivityId id, int keys[]) {
+ public HashPartitionActivityNode(ActivityId id, int[] keys) {
super(id);
this.keys = keys;
}
@@ -128,8 +129,9 @@
public IOperatorNodePushable createPushRuntime(IHyracksTaskContext ctx,
IRecordDescriptorProvider recordDescProvider, int partition, int nPartitions) {
return new GraceHashJoinPartitionBuildOperatorNodePushable(ctx, new TaskId(getActivityId(), partition),
- keys, hashFunctionFactories, comparatorFactories, (int) Math.ceil(Math.sqrt(inputsize0 * factor
- / nPartitions)), recordDescProvider.getInputRecordDescriptor(getActivityId(), 0));
+ keys, hashFunctionFactories, comparatorFactories,
+ (int) Math.ceil(Math.sqrt(inputsize0 * factor / nPartitions)),
+ recordDescProvider.getInputRecordDescriptor(getActivityId(), 0));
}
}
@@ -152,13 +154,14 @@
final RecordDescriptor rd0 = recordDescProvider.getInputRecordDescriptor(rpartAid, 0);
final RecordDescriptor rd1 = recordDescProvider.getInputRecordDescriptor(spartAid, 0);
int numPartitions = (int) Math.ceil(Math.sqrt(inputsize0 * factor / nPartitions));
- final IPredicateEvaluator predEvaluator = ( predEvaluatorFactory == null ? null : predEvaluatorFactory.createPredicateEvaluator() );
+ final IPredicateEvaluator predEvaluator = predEvaluatorFactory == null ? null
+ : predEvaluatorFactory.createPredicateEvaluator();
- return new GraceHashJoinOperatorNodePushable(ctx, new TaskId(new ActivityId(getOperatorId(),
- RPARTITION_ACTIVITY_ID), partition), new TaskId(new ActivityId(getOperatorId(),
- SPARTITION_ACTIVITY_ID), partition), recordsPerFrame, factor, keys0, keys1, hashFunctionFactories,
- comparatorFactories, nullWriterFactories1, rd1, rd0, recordDescriptors[0], numPartitions,
- predEvaluator, isLeftOuter);
+ return new GraceHashJoinOperatorNodePushable(ctx,
+ new TaskId(new ActivityId(getOperatorId(), RPARTITION_ACTIVITY_ID), partition),
+ new TaskId(new ActivityId(getOperatorId(), SPARTITION_ACTIVITY_ID), partition), recordsPerFrame,
+ factor, keys0, keys1, hashFunctionFactories, comparatorFactories, nullWriterFactories1, rd1, rd0,
+ recordDescriptors[0], numPartitions, predEvaluator, isLeftOuter);
}
}
}
diff --git a/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/GraceHashJoinOperatorNodePushable.java b/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/GraceHashJoinOperatorNodePushable.java
index 69e9e6a..2de8e6c 100644
--- a/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/GraceHashJoinOperatorNodePushable.java
+++ b/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/GraceHashJoinOperatorNodePushable.java
@@ -26,8 +26,8 @@
import org.apache.hyracks.api.dataflow.value.IBinaryComparator;
import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
import org.apache.hyracks.api.dataflow.value.IBinaryHashFunctionFactory;
-import org.apache.hyracks.api.dataflow.value.INullWriter;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriter;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.IPredicateEvaluator;
import org.apache.hyracks.api.dataflow.value.ITuplePartitionComputer;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
@@ -51,7 +51,7 @@
private final int[] keys1;
private final IBinaryHashFunctionFactory[] hashFunctionFactories;
private final IBinaryComparatorFactory[] comparatorFactories;
- private final INullWriterFactory[] nullWriterFactories;
+ private final IMissingWriterFactory[] nonMatchWriterFactories;
private final RecordDescriptor rd0;
private final RecordDescriptor rd1;
private final int recordsPerFrame;
@@ -62,7 +62,7 @@
GraceHashJoinOperatorNodePushable(IHyracksTaskContext ctx, Object state0Id, Object state1Id, int recordsPerFrame,
double factor, int[] keys0, int[] keys1, IBinaryHashFunctionFactory[] hashFunctionFactories,
- IBinaryComparatorFactory[] comparatorFactories, INullWriterFactory[] nullWriterFactories,
+ IBinaryComparatorFactory[] comparatorFactories, IMissingWriterFactory[] nullWriterFactories,
RecordDescriptor rd1, RecordDescriptor rd0, RecordDescriptor outRecordDescriptor, int numPartitions,
IPredicateEvaluator predEval, boolean isLeftOuter) {
this.ctx = ctx;
@@ -72,7 +72,7 @@
this.keys1 = keys1;
this.hashFunctionFactories = hashFunctionFactories;
this.comparatorFactories = comparatorFactories;
- this.nullWriterFactories = nullWriterFactories;
+ this.nonMatchWriterFactories = nullWriterFactories;
this.rd0 = rd0;
this.rd1 = rd1;
this.numPartitions = numPartitions;
@@ -98,10 +98,10 @@
ITuplePartitionComputer hpcRep1 = new RepartitionComputerFactory(numPartitions,
new FieldHashPartitionComputerFactory(keys1, hashFunctionFactories)).createPartitioner();
- final INullWriter[] nullWriters1 = isLeftOuter ? new INullWriter[nullWriterFactories.length] : null;
+ final IMissingWriter[] nullWriters1 = isLeftOuter ? new IMissingWriter[nonMatchWriterFactories.length] : null;
if (isLeftOuter) {
- for (int i = 0; i < nullWriterFactories.length; i++) {
- nullWriters1[i] = nullWriterFactories[i].createNullWriter();
+ for (int i = 0; i < nonMatchWriterFactories.length; i++) {
+ nullWriters1[i] = nonMatchWriterFactories[i].createMissingWriter();
}
}
try {
diff --git a/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/HybridHashJoinOperatorDescriptor.java b/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/HybridHashJoinOperatorDescriptor.java
index d0a81ee..4354367 100644
--- a/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/HybridHashJoinOperatorDescriptor.java
+++ b/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/HybridHashJoinOperatorDescriptor.java
@@ -33,8 +33,8 @@
import org.apache.hyracks.api.dataflow.value.IBinaryComparator;
import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
import org.apache.hyracks.api.dataflow.value.IBinaryHashFunctionFactory;
-import org.apache.hyracks.api.dataflow.value.INullWriter;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriter;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.IPredicateEvaluator;
import org.apache.hyracks.api.dataflow.value.IPredicateEvaluatorFactory;
import org.apache.hyracks.api.dataflow.value.IRecordDescriptorProvider;
@@ -47,7 +47,6 @@
import org.apache.hyracks.api.job.JobId;
import org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor;
import org.apache.hyracks.dataflow.common.comm.io.FrameTupleAppender;
-import org.apache.hyracks.dataflow.std.util.FrameTuplePairComparator;
import org.apache.hyracks.dataflow.common.comm.util.FrameUtils;
import org.apache.hyracks.dataflow.common.data.partition.FieldHashPartitionComputerFactory;
import org.apache.hyracks.dataflow.common.data.partition.RepartitionComputerFactory;
@@ -60,6 +59,7 @@
import org.apache.hyracks.dataflow.std.base.AbstractUnaryInputUnaryOutputOperatorNodePushable;
import org.apache.hyracks.dataflow.std.structures.ISerializableTable;
import org.apache.hyracks.dataflow.std.structures.SerializableHashTable;
+import org.apache.hyracks.dataflow.std.util.FrameTuplePairComparator;
public class HybridHashJoinOperatorDescriptor extends AbstractOperatorDescriptor {
private static final int BUILD_AND_PARTITION_ACTIVITY_ID = 0;
@@ -76,7 +76,7 @@
private final IBinaryComparatorFactory[] comparatorFactories;
private final IPredicateEvaluatorFactory predEvaluatorFactory;
private final boolean isLeftOuter;
- private final INullWriterFactory[] nullWriterFactories1;
+ private final IMissingWriterFactory[] nonMatchWriterFactories1;
/**
* @param spec
@@ -97,7 +97,7 @@
int recordsPerFrame, double factor, int[] keys0, int[] keys1,
IBinaryHashFunctionFactory[] hashFunctionFactories, IBinaryComparatorFactory[] comparatorFactories,
RecordDescriptor recordDescriptor, IPredicateEvaluatorFactory predEvalFactory, boolean isLeftOuter,
- INullWriterFactory[] nullWriterFactories1) throws HyracksDataException {
+ IMissingWriterFactory[] nullWriterFactories1) throws HyracksDataException {
super(spec, 2, 1);
this.memsize = memsize;
this.inputsize0 = inputsize0;
@@ -109,7 +109,7 @@
this.comparatorFactories = comparatorFactories;
this.predEvaluatorFactory = predEvalFactory;
this.isLeftOuter = isLeftOuter;
- this.nullWriterFactories1 = nullWriterFactories1;
+ this.nonMatchWriterFactories1 = nullWriterFactories1;
recordDescriptors[0] = recordDescriptor;
}
@@ -169,17 +169,18 @@
@Override
public IOperatorNodePushable createPushRuntime(final IHyracksTaskContext ctx,
IRecordDescriptorProvider recordDescProvider, final int partition, final int nPartitions)
- throws HyracksDataException {
+ throws HyracksDataException {
final RecordDescriptor rd0 = recordDescProvider.getInputRecordDescriptor(joinAid, 0);
final RecordDescriptor rd1 = recordDescProvider.getInputRecordDescriptor(getActivityId(), 0);
final IBinaryComparator[] comparators = new IBinaryComparator[comparatorFactories.length];
for (int i = 0; i < comparatorFactories.length; ++i) {
comparators[i] = comparatorFactories[i].createBinaryComparator();
}
- final INullWriter[] nullWriters1 = isLeftOuter ? new INullWriter[nullWriterFactories1.length] : null;
+ final IMissingWriter[] nullWriters1 = isLeftOuter ? new IMissingWriter[nonMatchWriterFactories1.length]
+ : null;
if (isLeftOuter) {
- for (int i = 0; i < nullWriterFactories1.length; i++) {
- nullWriters1[i] = nullWriterFactories1[i].createNullWriter();
+ for (int i = 0; i < nonMatchWriterFactories1.length; i++) {
+ nullWriters1[i] = nonMatchWriterFactories1[i].createMissingWriter();
}
}
final IPredicateEvaluator predEvaluator = (predEvaluatorFactory == null ? null
@@ -198,8 +199,9 @@
@Override
public void close() throws HyracksDataException {
- if (state.memoryForHashtable != 0)
+ if (state.memoryForHashtable != 0) {
build(inBuffer.getBuffer());
+ }
for (int i = 0; i < state.nPartitions; i++) {
ByteBuffer buf = bufferForPartitions[i].getBuffer();
@@ -359,17 +361,18 @@
@Override
public IOperatorNodePushable createPushRuntime(final IHyracksTaskContext ctx,
IRecordDescriptorProvider recordDescProvider, final int partition, final int nPartitions)
- throws HyracksDataException {
+ throws HyracksDataException {
final RecordDescriptor rd0 = recordDescProvider.getInputRecordDescriptor(getActivityId(), 0);
final RecordDescriptor rd1 = recordDescProvider.getInputRecordDescriptor(buildAid, 0);
final IBinaryComparator[] comparators = new IBinaryComparator[comparatorFactories.length];
for (int i = 0; i < comparatorFactories.length; ++i) {
comparators[i] = comparatorFactories[i].createBinaryComparator();
}
- final INullWriter[] nullWriters1 = isLeftOuter ? new INullWriter[nullWriterFactories1.length] : null;
+ final IMissingWriter[] nullWriters1 = isLeftOuter ? new IMissingWriter[nonMatchWriterFactories1.length]
+ : null;
if (isLeftOuter) {
- for (int i = 0; i < nullWriterFactories1.length; i++) {
- nullWriters1[i] = nullWriterFactories1[i].createNullWriter();
+ for (int i = 0; i < nonMatchWriterFactories1.length; i++) {
+ nullWriters1[i] = nonMatchWriterFactories1[i].createMissingWriter();
}
}
final IPredicateEvaluator predEvaluator = (predEvaluatorFactory == null ? null
@@ -436,8 +439,9 @@
if (!ftap.append(accessorProbe, i)) {
state.joiner.join(inBuffer.getBuffer(), writer);
ftap.reset(inBuffer, true);
- } else
+ } else {
break;
+ }
}
} else {
diff --git a/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/InMemoryHashJoin.java b/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/InMemoryHashJoin.java
index fee7dd8..486821b 100644
--- a/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/InMemoryHashJoin.java
+++ b/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/InMemoryHashJoin.java
@@ -28,7 +28,7 @@
import org.apache.hyracks.api.comm.IFrameWriter;
import org.apache.hyracks.api.comm.VSizeFrame;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.INullWriter;
+import org.apache.hyracks.api.dataflow.value.IMissingWriter;
import org.apache.hyracks.api.dataflow.value.IPredicateEvaluator;
import org.apache.hyracks.api.dataflow.value.ITuplePartitionComputer;
import org.apache.hyracks.api.exceptions.HyracksDataException;
@@ -51,7 +51,7 @@
private final FrameTupleAppender appender;
private final FrameTuplePairComparator tpComparator;
private final boolean isLeftOuter;
- private final ArrayTupleBuilder nullTupleBuild;
+ private final ArrayTupleBuilder missingTupleBuild;
private final ISerializableTable table;
private final int tableSize;
private final TuplePointer storedTuplePointer;
@@ -62,16 +62,16 @@
public InMemoryHashJoin(IHyracksTaskContext ctx, int tableSize, FrameTupleAccessor accessorProbe,
ITuplePartitionComputer tpcProbe, FrameTupleAccessor accessorBuild, ITuplePartitionComputer tpcBuild,
- FrameTuplePairComparator comparator, boolean isLeftOuter, INullWriter[] nullWritersBuild,
+ FrameTuplePairComparator comparator, boolean isLeftOuter, IMissingWriter[] missingWritersBuild,
ISerializableTable table, IPredicateEvaluator predEval) throws HyracksDataException {
this(ctx, tableSize, accessorProbe, tpcProbe, accessorBuild, tpcBuild, comparator, isLeftOuter,
- nullWritersBuild, table, predEval,
+ missingWritersBuild, table, predEval,
false);
}
public InMemoryHashJoin(IHyracksTaskContext ctx, int tableSize, FrameTupleAccessor accessorProbe,
ITuplePartitionComputer tpcProbe, FrameTupleAccessor accessorBuild, ITuplePartitionComputer tpcBuild,
- FrameTuplePairComparator comparator, boolean isLeftOuter, INullWriter[] nullWritersBuild,
+ FrameTuplePairComparator comparator, boolean isLeftOuter, IMissingWriter[] missingWritersBuild,
ISerializableTable table, IPredicateEvaluator predEval, boolean reverse) throws HyracksDataException {
this.ctx = ctx;
this.tableSize = tableSize;
@@ -88,14 +88,14 @@
this.isLeftOuter = isLeftOuter;
if (isLeftOuter) {
int fieldCountOuter = accessorBuild.getFieldCount();
- nullTupleBuild = new ArrayTupleBuilder(fieldCountOuter);
- DataOutput out = nullTupleBuild.getDataOutput();
+ missingTupleBuild = new ArrayTupleBuilder(fieldCountOuter);
+ DataOutput out = missingTupleBuild.getDataOutput();
for (int i = 0; i < fieldCountOuter; i++) {
- nullWritersBuild[i].writeNull(out);
- nullTupleBuild.addFieldEndOffset();
+ missingWritersBuild[i].writeMissing(out);
+ missingTupleBuild.addFieldEndOffset();
}
} else {
- nullTupleBuild = null;
+ missingTupleBuild = null;
}
reverseOutputOrder = reverse;
LOGGER.fine("InMemoryHashJoin has been created for a table size of " + tableSize + " for Thread ID "
@@ -140,8 +140,8 @@
}
if (!matchFound && isLeftOuter) {
FrameUtils.appendConcatToWriter(writer, appender, accessorProbe, tid,
- nullTupleBuild.getFieldEndOffsets(), nullTupleBuild.getByteArray(), 0,
- nullTupleBuild.getSize());
+ missingTupleBuild.getFieldEndOffsets(), missingTupleBuild.getByteArray(), 0,
+ missingTupleBuild.getSize());
}
}
diff --git a/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/InMemoryHashJoinOperatorDescriptor.java b/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/InMemoryHashJoinOperatorDescriptor.java
index be8d319f..0d6d163 100644
--- a/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/InMemoryHashJoinOperatorDescriptor.java
+++ b/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/InMemoryHashJoinOperatorDescriptor.java
@@ -31,8 +31,8 @@
import org.apache.hyracks.api.dataflow.value.IBinaryComparator;
import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
import org.apache.hyracks.api.dataflow.value.IBinaryHashFunctionFactory;
-import org.apache.hyracks.api.dataflow.value.INullWriter;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriter;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.IPredicateEvaluator;
import org.apache.hyracks.api.dataflow.value.IPredicateEvaluatorFactory;
import org.apache.hyracks.api.dataflow.value.IRecordDescriptorProvider;
@@ -42,7 +42,6 @@
import org.apache.hyracks.api.job.IOperatorDescriptorRegistry;
import org.apache.hyracks.api.job.JobId;
import org.apache.hyracks.dataflow.common.comm.io.FrameTupleAccessor;
-import org.apache.hyracks.dataflow.std.util.FrameTuplePairComparator;
import org.apache.hyracks.dataflow.common.comm.util.FrameUtils;
import org.apache.hyracks.dataflow.common.data.partition.FieldHashPartitionComputerFactory;
import org.apache.hyracks.dataflow.std.base.AbstractActivityNode;
@@ -52,6 +51,7 @@
import org.apache.hyracks.dataflow.std.base.AbstractUnaryInputUnaryOutputOperatorNodePushable;
import org.apache.hyracks.dataflow.std.structures.ISerializableTable;
import org.apache.hyracks.dataflow.std.structures.SerializableHashTable;
+import org.apache.hyracks.dataflow.std.util.FrameTuplePairComparator;
public class InMemoryHashJoinOperatorDescriptor extends AbstractOperatorDescriptor {
private static final long serialVersionUID = 1L;
@@ -61,7 +61,7 @@
private final IBinaryComparatorFactory[] comparatorFactories;
private final IPredicateEvaluatorFactory predEvaluatorFactory;
private final boolean isLeftOuter;
- private final INullWriterFactory[] nullWriterFactories1;
+ private final IMissingWriterFactory[] nonMatchWriterFactories;
private final int tableSize;
public InMemoryHashJoinOperatorDescriptor(IOperatorDescriptorRegistry spec, int[] keys0, int[] keys1,
@@ -75,14 +75,14 @@
this.predEvaluatorFactory = predEvalFactory;
recordDescriptors[0] = recordDescriptor;
this.isLeftOuter = false;
- this.nullWriterFactories1 = null;
+ this.nonMatchWriterFactories = null;
this.tableSize = tableSize;
}
public InMemoryHashJoinOperatorDescriptor(IOperatorDescriptorRegistry spec, int[] keys0, int[] keys1,
IBinaryHashFunctionFactory[] hashFunctionFactories, IBinaryComparatorFactory[] comparatorFactories,
IPredicateEvaluatorFactory predEvalFactory, RecordDescriptor recordDescriptor, boolean isLeftOuter,
- INullWriterFactory[] nullWriterFactories1, int tableSize) {
+ IMissingWriterFactory[] missingWriterFactories1, int tableSize) {
super(spec, 2, 1);
this.keys0 = keys0;
this.keys1 = keys1;
@@ -91,7 +91,7 @@
this.predEvaluatorFactory = predEvalFactory;
recordDescriptors[0] = recordDescriptor;
this.isLeftOuter = isLeftOuter;
- this.nullWriterFactories1 = nullWriterFactories1;
+ this.nonMatchWriterFactories = missingWriterFactories1;
this.tableSize = tableSize;
}
@@ -103,7 +103,7 @@
public InMemoryHashJoinOperatorDescriptor(IOperatorDescriptorRegistry spec, int[] keys0, int[] keys1,
IBinaryHashFunctionFactory[] hashFunctionFactories, IBinaryComparatorFactory[] comparatorFactories,
- RecordDescriptor recordDescriptor, boolean isLeftOuter, INullWriterFactory[] nullWriterFactories1,
+ RecordDescriptor recordDescriptor, boolean isLeftOuter, IMissingWriterFactory[] nullWriterFactories1,
int tableSize) {
this(spec, keys0, keys1, hashFunctionFactories, comparatorFactories, null, recordDescriptor, isLeftOuter,
nullWriterFactories1, tableSize);
@@ -167,10 +167,11 @@
for (int i = 0; i < comparatorFactories.length; ++i) {
comparators[i] = comparatorFactories[i].createBinaryComparator();
}
- final INullWriter[] nullWriters1 = isLeftOuter ? new INullWriter[nullWriterFactories1.length] : null;
+ final IMissingWriter[] nullWriters1 = isLeftOuter ? new IMissingWriter[nonMatchWriterFactories.length]
+ : null;
if (isLeftOuter) {
- for (int i = 0; i < nullWriterFactories1.length; i++) {
- nullWriters1[i] = nullWriterFactories1[i].createNullWriter();
+ for (int i = 0; i < nonMatchWriterFactories.length; i++) {
+ nullWriters1[i] = nonMatchWriterFactories[i].createMissingWriter();
}
}
final IPredicateEvaluator predEvaluator = (predEvaluatorFactory == null ? null
diff --git a/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/NestedLoopJoin.java b/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/NestedLoopJoin.java
index 2ad89cf..202aac6 100644
--- a/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/NestedLoopJoin.java
+++ b/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/NestedLoopJoin.java
@@ -25,7 +25,7 @@
import org.apache.hyracks.api.comm.IFrameWriter;
import org.apache.hyracks.api.comm.VSizeFrame;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.INullWriter;
+import org.apache.hyracks.api.dataflow.value.IMissingWriter;
import org.apache.hyracks.api.dataflow.value.IPredicateEvaluator;
import org.apache.hyracks.api.dataflow.value.ITuplePairComparator;
import org.apache.hyracks.api.exceptions.HyracksDataException;
@@ -53,14 +53,14 @@
private RunFileReader runFileReader;
private final RunFileWriter runFileWriter;
private final boolean isLeftOuter;
- private final ArrayTupleBuilder nullTupleBuilder;
+ private final ArrayTupleBuilder missingTupleBuilder;
private final IPredicateEvaluator predEvaluator;
private boolean isReversed; //Added for handling correct calling for predicate-evaluator upon recursive calls (in OptimizedHybridHashJoin) that cause role-reversal
private BufferInfo tempInfo = new BufferInfo(null, -1, -1);
public NestedLoopJoin(IHyracksTaskContext ctx, FrameTupleAccessor accessorOuter, FrameTupleAccessor accessorInner,
ITuplePairComparator comparatorsOuter2Inner, int memSize, IPredicateEvaluator predEval, boolean isLeftOuter,
- INullWriter[] nullWriters1) throws HyracksDataException {
+ IMissingWriter[] missingWriters) throws HyracksDataException {
this.accessorInner = accessorInner;
this.accessorOuter = accessorOuter;
this.appender = new FrameTupleAppender();
@@ -81,14 +81,14 @@
this.isLeftOuter = isLeftOuter;
if (isLeftOuter) {
int innerFieldCount = this.accessorInner.getFieldCount();
- nullTupleBuilder = new ArrayTupleBuilder(innerFieldCount);
- DataOutput out = nullTupleBuilder.getDataOutput();
+ missingTupleBuilder = new ArrayTupleBuilder(innerFieldCount);
+ DataOutput out = missingTupleBuilder.getDataOutput();
for (int i = 0; i < innerFieldCount; i++) {
- nullWriters1[i].writeNull(out);
- nullTupleBuilder.addFieldEndOffset();
+ missingWriters[i].writeMissing(out);
+ missingTupleBuilder.addFieldEndOffset();
}
} else {
- nullTupleBuilder = null;
+ missingTupleBuilder = null;
}
FileReference file = ctx.getJobletContext()
@@ -138,9 +138,9 @@
}
if (!matchFound && isLeftOuter) {
- final int[] ntFieldEndOffsets = nullTupleBuilder.getFieldEndOffsets();
- final byte[] ntByteArray = nullTupleBuilder.getByteArray();
- final int ntSize = nullTupleBuilder.getSize();
+ final int[] ntFieldEndOffsets = missingTupleBuilder.getFieldEndOffsets();
+ final byte[] ntByteArray = missingTupleBuilder.getByteArray();
+ final int ntSize = missingTupleBuilder.getSize();
FrameUtils.appendConcatToWriter(writer, appender, accessorOuter, i, ntFieldEndOffsets, ntByteArray, 0,
ntSize);
}
diff --git a/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/NestedLoopJoinOperatorDescriptor.java b/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/NestedLoopJoinOperatorDescriptor.java
index dc7d256..09207b9 100644
--- a/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/NestedLoopJoinOperatorDescriptor.java
+++ b/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/NestedLoopJoinOperatorDescriptor.java
@@ -29,8 +29,8 @@
import org.apache.hyracks.api.dataflow.IActivityGraphBuilder;
import org.apache.hyracks.api.dataflow.IOperatorNodePushable;
import org.apache.hyracks.api.dataflow.TaskId;
-import org.apache.hyracks.api.dataflow.value.INullWriter;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriter;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.IPredicateEvaluator;
import org.apache.hyracks.api.dataflow.value.IPredicateEvaluatorFactory;
import org.apache.hyracks.api.dataflow.value.IRecordDescriptorProvider;
@@ -57,18 +57,18 @@
private final int memSize;
private final IPredicateEvaluatorFactory predEvaluatorFactory;
private final boolean isLeftOuter;
- private final INullWriterFactory[] nullWriterFactories1;
+ private final IMissingWriterFactory[] nullWriterFactories1;
public NestedLoopJoinOperatorDescriptor(IOperatorDescriptorRegistry spec,
ITuplePairComparatorFactory comparatorFactory, RecordDescriptor recordDescriptor, int memSize,
- boolean isLeftOuter, INullWriterFactory[] nullWriterFactories1) {
+ boolean isLeftOuter, IMissingWriterFactory[] nullWriterFactories1) {
this(spec, comparatorFactory, recordDescriptor, memSize, null, isLeftOuter, nullWriterFactories1);
}
public NestedLoopJoinOperatorDescriptor(IOperatorDescriptorRegistry spec,
ITuplePairComparatorFactory comparatorFactory, RecordDescriptor recordDescriptor, int memSize,
IPredicateEvaluatorFactory predEvalFactory, boolean isLeftOuter,
- INullWriterFactory[] nullWriterFactories1) {
+ IMissingWriterFactory[] nullWriterFactories1) {
super(spec, 2, 1);
this.comparatorFactory = comparatorFactory;
this.recordDescriptors[0] = recordDescriptor;
@@ -135,10 +135,10 @@
final IPredicateEvaluator predEvaluator = ((predEvaluatorFactory != null)
? predEvaluatorFactory.createPredicateEvaluator() : null);
- final INullWriter[] nullWriters1 = isLeftOuter ? new INullWriter[nullWriterFactories1.length] : null;
+ final IMissingWriter[] nullWriters1 = isLeftOuter ? new IMissingWriter[nullWriterFactories1.length] : null;
if (isLeftOuter) {
for (int i = 0; i < nullWriterFactories1.length; i++) {
- nullWriters1[i] = nullWriterFactories1[i].createNullWriter();
+ nullWriters1[i] = nullWriterFactories1[i].createMissingWriter();
}
}
diff --git a/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/OptimizedHybridHashJoin.java b/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/OptimizedHybridHashJoin.java
index 810039b..b80059b 100644
--- a/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/OptimizedHybridHashJoin.java
+++ b/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/OptimizedHybridHashJoin.java
@@ -28,8 +28,8 @@
import org.apache.hyracks.api.comm.VSizeFrame;
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.dataflow.value.IBinaryComparator;
-import org.apache.hyracks.api.dataflow.value.INullWriter;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriter;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.IPredicateEvaluator;
import org.apache.hyracks.api.dataflow.value.ITuplePartitionComputer;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
@@ -82,7 +82,7 @@
private final IPredicateEvaluator predEvaluator;
private final boolean isLeftOuter;
- private final INullWriter[] nullWriters;
+ private final IMissingWriter[] nonMatchWriters;
private final BitSet spilledStatus; //0=resident, 1=spilled
private final int numOfPartitions;
@@ -108,7 +108,7 @@
String buildRelName, int[] probeKeys, int[] buildKeys, IBinaryComparator[] comparators,
RecordDescriptor probeRd, RecordDescriptor buildRd, ITuplePartitionComputer probeHpc,
ITuplePartitionComputer buildHpc, IPredicateEvaluator predEval, boolean isLeftOuter,
- INullWriterFactory[] nullWriterFactories1) {
+ IMissingWriterFactory[] nullWriterFactories1) {
this.ctx = ctx;
this.memForJoin = memForJoin;
this.buildRd = buildRd;
@@ -134,10 +134,10 @@
this.spilledStatus = new BitSet(numOfPartitions);
- this.nullWriters = isLeftOuter ? new INullWriter[nullWriterFactories1.length] : null;
+ this.nonMatchWriters = isLeftOuter ? new IMissingWriter[nullWriterFactories1.length] : null;
if (isLeftOuter) {
for (int i = 0; i < nullWriterFactories1.length; i++) {
- nullWriters[i] = nullWriterFactories1[i].createNullWriter();
+ nonMatchWriters[i] = nullWriterFactories1[i].createMissingWriter();
}
}
}
@@ -313,7 +313,7 @@
ISerializableTable table = new SerializableHashTable(inMemTupCount, ctx);
this.inMemJoiner = new InMemoryHashJoin(ctx, inMemTupCount, new FrameTupleAccessor(probeRd), probeHpc,
new FrameTupleAccessor(buildRd), buildHpc,
- new FrameTuplePairComparator(probeKeys, buildKeys, comparators), isLeftOuter, nullWriters, table,
+ new FrameTuplePairComparator(probeKeys, buildKeys, comparators), isLeftOuter, nonMatchWriters, table,
predEvaluator, isReversed);
}
diff --git a/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/OptimizedHybridHashJoinOperatorDescriptor.java b/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/OptimizedHybridHashJoinOperatorDescriptor.java
index 22ad91f..183d7f6 100644
--- a/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/OptimizedHybridHashJoinOperatorDescriptor.java
+++ b/hyracks-fullstack/hyracks/hyracks-dataflow-std/src/main/java/org/apache/hyracks/dataflow/std/join/OptimizedHybridHashJoinOperatorDescriptor.java
@@ -36,8 +36,8 @@
import org.apache.hyracks.api.dataflow.value.IBinaryComparator;
import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
import org.apache.hyracks.api.dataflow.value.IBinaryHashFunctionFamily;
-import org.apache.hyracks.api.dataflow.value.INullWriter;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriter;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.IPredicateEvaluator;
import org.apache.hyracks.api.dataflow.value.IPredicateEvaluatorFactory;
import org.apache.hyracks.api.dataflow.value.IRecordDescriptorProvider;
@@ -124,7 +124,7 @@
private final IPredicateEvaluatorFactory predEvaluatorFactory;
private final boolean isLeftOuter;
- private final INullWriterFactory[] nullWriterFactories1;
+ private final IMissingWriterFactory[] nonMatchWriterFactories;
//Flags added for test purpose
private static boolean skipInMemoryHJ = false;
@@ -138,7 +138,7 @@
IBinaryComparatorFactory[] comparatorFactories, RecordDescriptor recordDescriptor,
ITuplePairComparatorFactory tupPaircomparatorFactory01,
ITuplePairComparatorFactory tupPaircomparatorFactory10, IPredicateEvaluatorFactory predEvaluatorFactory,
- boolean isLeftOuter, INullWriterFactory[] nullWriterFactories1) throws HyracksDataException {
+ boolean isLeftOuter, IMissingWriterFactory[] nonMatchWriterFactories) throws HyracksDataException {
super(spec, 2, 1);
this.frameLimit = frameLimit;
@@ -153,7 +153,7 @@
recordDescriptors[0] = recordDescriptor;
this.predEvaluatorFactory = predEvaluatorFactory;
this.isLeftOuter = isLeftOuter;
- this.nullWriterFactories1 = nullWriterFactories1;
+ this.nonMatchWriterFactories = nonMatchWriterFactories;
}
public OptimizedHybridHashJoinOperatorDescriptor(IOperatorDescriptorRegistry spec, int frameLimit, int inputsize0,
@@ -162,9 +162,9 @@
ITuplePairComparatorFactory tupPaircomparatorFactory01,
ITuplePairComparatorFactory tupPaircomparatorFactory10, IPredicateEvaluatorFactory predEvaluatorFactory)
throws HyracksDataException {
- this(spec, frameLimit, inputsize0, factor, keys0, keys1, hashFunctionGeneratorFactories,
- comparatorFactories, recordDescriptor, tupPaircomparatorFactory01, tupPaircomparatorFactory10,
- predEvaluatorFactory, false, null);
+ this(spec, frameLimit, inputsize0, factor, keys0, keys1, hashFunctionGeneratorFactories, comparatorFactories,
+ recordDescriptor, tupPaircomparatorFactory01, tupPaircomparatorFactory10, predEvaluatorFactory, false,
+ null);
}
@Override
@@ -284,7 +284,7 @@
nPartitions);
state.hybridHJ = new OptimizedHybridHashJoin(ctx, state.memForJoin, state.numOfPartitions,
PROBE_REL, BUILD_REL, probeKeys, buildKeys, comparators, probeRd, buildRd, probeHpc,
- buildHpc, predEvaluator, isLeftOuter, nullWriterFactories1);
+ buildHpc, predEvaluator, isLeftOuter, nonMatchWriterFactories);
state.hybridHJ.initBuild();
if (LOGGER.isLoggable(Level.FINE)) {
@@ -301,7 +301,7 @@
@Override
public void close() throws HyracksDataException {
state.hybridHJ.closeBuild();
- if (isFailed){
+ if (isFailed) {
state.hybridHJ.clearBuildTempFiles();
} else {
ctx.setStateObject(state);
@@ -343,7 +343,7 @@
@Override
public IOperatorNodePushable createPushRuntime(final IHyracksTaskContext ctx,
IRecordDescriptorProvider recordDescProvider, final int partition, final int nPartitions)
- throws HyracksDataException {
+ throws HyracksDataException {
final RecordDescriptor buildRd = recordDescProvider.getInputRecordDescriptor(buildAid, 0);
final RecordDescriptor probeRd = recordDescProvider.getInputRecordDescriptor(getActivityId(), 0);
@@ -352,22 +352,22 @@
.createTuplePairComparator(ctx);
final ITuplePairComparator nljComparatorBuild2Probe = tuplePairComparatorFactoryBuild2Probe
.createTuplePairComparator(ctx);
- final IPredicateEvaluator predEvaluator = (predEvaluatorFactory == null ? null : predEvaluatorFactory
- .createPredicateEvaluator());
+ final IPredicateEvaluator predEvaluator = predEvaluatorFactory == null ? null
+ : predEvaluatorFactory.createPredicateEvaluator();
for (int i = 0; i < comparatorFactories.length; i++) {
comparators[i] = comparatorFactories[i].createBinaryComparator();
}
- final INullWriter[] nullWriters1 = isLeftOuter ? new INullWriter[nullWriterFactories1.length] : null;
- final ArrayTupleBuilder nullTupleBuild = isLeftOuter ?
- new ArrayTupleBuilder(buildRd.getFieldCount()) :
- null;
+ final IMissingWriter[] nonMatchWriter = isLeftOuter ? new IMissingWriter[nonMatchWriterFactories.length]
+ : null;
+ final ArrayTupleBuilder nullTupleBuild = isLeftOuter ? new ArrayTupleBuilder(buildRd.getFieldCount())
+ : null;
if (isLeftOuter) {
DataOutput out = nullTupleBuild.getDataOutput();
- for (int i = 0; i < nullWriterFactories1.length; i++) {
- nullWriters1[i] = nullWriterFactories1[i].createNullWriter();
- nullWriters1[i].writeNull(out);
+ for (int i = 0; i < nonMatchWriterFactories.length; i++) {
+ nonMatchWriter[i] = nonMatchWriterFactories[i].createMissingWriter();
+ nonMatchWriter[i].writeMissing(out);
nullTupleBuild.addFieldEndOffset();
}
}
@@ -381,8 +381,8 @@
@Override
public void open() throws HyracksDataException {
- state = (BuildAndPartitionTaskState) ctx.getStateObject(new TaskId(new ActivityId(getOperatorId(),
- BUILD_AND_PARTITION_ACTIVITY_ID), partition));
+ state = (BuildAndPartitionTaskState) ctx.getStateObject(
+ new TaskId(new ActivityId(getOperatorId(), BUILD_AND_PARTITION_ACTIVITY_ID), partition));
writer.open();
state.hybridHJ.initProbe();
@@ -410,7 +410,8 @@
BitSet partitionStatus = state.hybridHJ.getPartitionStatus();
rPartbuff.reset();
- for (int pid = partitionStatus.nextSetBit(0); pid >= 0; pid = partitionStatus.nextSetBit(pid + 1)) {
+ for (int pid = partitionStatus.nextSetBit(0); pid >= 0; pid = partitionStatus
+ .nextSetBit(pid + 1)) {
RunFileReader bReader = state.hybridHJ.getBuildRFReader(pid);
RunFileReader pReader = state.hybridHJ.getProbeRFReader(pid);
@@ -435,8 +436,7 @@
//The buildSideReader should be always the original buildSideReader, so should the probeSideReader
private void joinPartitionPair(RunFileReader buildSideReader, RunFileReader probeSideReader,
- int buildSizeInTuple, int probeSizeInTuple, int level)
- throws HyracksDataException {
+ int buildSizeInTuple, int probeSizeInTuple, int level) throws HyracksDataException {
ITuplePartitionComputer probeHpc = new FieldHashPartitionComputerFamily(probeKeys,
hashFunctionGeneratorFactories).createPartitioner(level);
ITuplePartitionComputer buildHpc = new FieldHashPartitionComputerFamily(buildKeys,
@@ -447,21 +447,18 @@
int beforeMax = Math.max(buildSizeInTuple, probeSizeInTuple);
if (LOGGER.isLoggable(Level.FINE)) {
- LOGGER.fine(
- "\n>>>Joining Partition Pairs (thread_id " + Thread.currentThread().getId() + ") (pid "
- + ") - (level " + level + ")"
- + " - BuildSize:\t" + buildPartSize + "\tProbeSize:\t" + probePartSize
- + " - MemForJoin "
- + (state.memForJoin)
- + " - LeftOuter is " + isLeftOuter);
+ LOGGER.fine("\n>>>Joining Partition Pairs (thread_id " + Thread.currentThread().getId()
+ + ") (pid " + ") - (level " + level + ")" + " - BuildSize:\t" + buildPartSize
+ + "\tProbeSize:\t" + probePartSize + " - MemForJoin " + (state.memForJoin)
+ + " - LeftOuter is " + isLeftOuter);
}
//Apply in-Mem HJ if possible
if (!skipInMemoryHJ && ((buildPartSize < state.memForJoin)
|| (probePartSize < state.memForJoin && !isLeftOuter))) {
int tabSize = -1;
- if (!forceRR && (isLeftOuter || (buildPartSize
- < probePartSize))) { //Case 1.1 - InMemHJ (wout Role-Reversal)
+ if (!forceRR && (isLeftOuter || (buildPartSize < probePartSize))) {
+ //Case 1.1 - InMemHJ (wout Role-Reversal)
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine("\t>>>Case 1.1 (IsLeftOuter || buildSize<probe) AND ApplyInMemHJ - [Level "
+ level + "]");
@@ -472,8 +469,8 @@
"Trying to join an empty partition. Invalid table size for inMemoryHashJoin.");
}
//Build Side is smaller
- applyInMemHashJoin(buildKeys, probeKeys, tabSize, buildRd, probeRd, buildHpc,
- probeHpc, buildSideReader, probeSideReader); // checked-confirmed
+ applyInMemHashJoin(buildKeys, probeKeys, tabSize, buildRd, probeRd, buildHpc, probeHpc,
+ buildSideReader, probeSideReader); // checked-confirmed
} else { //Case 1.2 - InMemHJ with Role Reversal
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine(
@@ -486,8 +483,8 @@
"Trying to join an empty partition. Invalid table size for inMemoryHashJoin.");
}
//Probe Side is smaller
- applyInMemHashJoin(probeKeys, buildKeys, tabSize, probeRd, buildRd, probeHpc,
- buildHpc, probeSideReader, buildSideReader); // checked-confirmed
+ applyInMemHashJoin(probeKeys, buildKeys, tabSize, probeRd, buildRd, probeHpc, buildHpc,
+ probeSideReader, buildSideReader); // checked-confirmed
}
}
//Apply (Recursive) HHJ
@@ -495,8 +492,8 @@
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine("\t>>>Case 2. ApplyRecursiveHHJ - [Level " + level + "]");
}
- if (!forceRR && (isLeftOuter
- || buildPartSize < probePartSize)) { //Case 2.1 - Recursive HHJ (wout Role-Reversal)
+ if (!forceRR && (isLeftOuter || buildPartSize < probePartSize)) {
+ //Case 2.1 - Recursive HHJ (wout Role-Reversal)
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine("\t\t>>>Case 2.1 - RecursiveHHJ WITH (isLeftOuter || build<probe) - [Level "
+ level + "]");
@@ -519,13 +516,11 @@
}
}
- private void applyHybridHashJoin(int tableSize,
- final String PROBE_REL, final String BUILD_REL,
- final int[] probeKeys, final int[] buildKeys,
- final RecordDescriptor probeRd, final RecordDescriptor buildRd,
- final ITuplePartitionComputer probeHpc, final ITuplePartitionComputer buildHpc,
- RunFileReader probeSideReader, RunFileReader buildSideReader,
- final int level, final long beforeMax)
+ private void applyHybridHashJoin(int tableSize, final String PROBE_REL, final String BUILD_REL,
+ final int[] probeKeys, final int[] buildKeys, final RecordDescriptor probeRd,
+ final RecordDescriptor buildRd, final ITuplePartitionComputer probeHpc,
+ final ITuplePartitionComputer buildHpc, RunFileReader probeSideReader,
+ RunFileReader buildSideReader, final int level, final long beforeMax)
throws HyracksDataException {
boolean isReversed = probeKeys == OptimizedHybridHashJoinOperatorDescriptor.this.buildKeys
@@ -534,11 +529,10 @@
assert isLeftOuter ? !isReversed : true : "LeftOut Join can not reverse roles";
OptimizedHybridHashJoin rHHj;
- int n = getNumberOfPartitions(state.memForJoin, tableSize, fudgeFactor,
- nPartitions);
- rHHj = new OptimizedHybridHashJoin(ctx, state.memForJoin, n, PROBE_REL, BUILD_REL,
- probeKeys, buildKeys, comparators, probeRd, buildRd, probeHpc, buildHpc,
- predEvaluator, isLeftOuter, nullWriterFactories1); //checked-confirmed
+ int n = getNumberOfPartitions(state.memForJoin, tableSize, fudgeFactor, nPartitions);
+ rHHj = new OptimizedHybridHashJoin(ctx, state.memForJoin, n, PROBE_REL, BUILD_REL, probeKeys,
+ buildKeys, comparators, probeRd, buildRd, probeHpc, buildHpc, predEvaluator, isLeftOuter,
+ nonMatchWriterFactories); //checked-confirmed
rHHj.setIsReversed(isReversed);
buildSideReader.open();
@@ -564,8 +558,7 @@
int afterMax = Math.max(maxAfterBuildSize, maxAfterProbeSize);
BitSet rPStatus = rHHj.getPartitionStatus();
- if (!forceNLJ && (afterMax < (NLJ_SWITCH_THRESHOLD
- * beforeMax))) { //Case 2.1.1 - Keep applying HHJ
+ if (!forceNLJ && (afterMax < (NLJ_SWITCH_THRESHOLD * beforeMax))) { //Case 2.1.1 - Keep applying HHJ
if (LOGGER.isLoggable(Level.FINE)) {
LOGGER.fine(
"\t\t>>>Case 2.1.1 - KEEP APPLYING RecursiveHHJ WITH (isLeftOuter || build<probe) - [Level "
@@ -652,7 +645,7 @@
ISerializableTable table = new SerializableHashTable(tabSize, ctx);
InMemoryHashJoin joiner = new InMemoryHashJoin(ctx, tabSize, new FrameTupleAccessor(probeRDesc),
hpcRepProbe, new FrameTupleAccessor(buildRDesc), hpcRepBuild,
- new FrameTuplePairComparator(pKeys, bKeys, comparators), isLeftOuter, nullWriters1, table,
+ new FrameTuplePairComparator(pKeys, bKeys, comparators), isLeftOuter, nonMatchWriter, table,
predEvaluator, isReversed);
bReader.open();
@@ -677,18 +670,15 @@
}
private void applyNestedLoopJoin(RecordDescriptor outerRd, RecordDescriptor innerRd, int memorySize,
- RunFileReader outerReader, RunFileReader innerReader)
- throws HyracksDataException {
+ RunFileReader outerReader, RunFileReader innerReader) throws HyracksDataException {
// The nested loop join result is outer + inner. All the other operator is probe + build. Hence the reverse relation is different
boolean isReversed = outerRd == buildRd && innerRd == probeRd;
assert isLeftOuter ? !isReversed : true : "LeftOut Join can not reverse roles";
- ITuplePairComparator nljComptorOuterInner = isReversed ?
- nljComparatorBuild2Probe :
- nljComparatorProbe2Build;
- NestedLoopJoin nlj = new NestedLoopJoin(ctx,
- new FrameTupleAccessor(outerRd),
- new FrameTupleAccessor(innerRd), nljComptorOuterInner, memorySize,
- predEvaluator, isLeftOuter, nullWriters1);
+ ITuplePairComparator nljComptorOuterInner = isReversed ? nljComparatorBuild2Probe
+ : nljComparatorProbe2Build;
+ NestedLoopJoin nlj = new NestedLoopJoin(ctx, new FrameTupleAccessor(outerRd),
+ new FrameTupleAccessor(innerRd), nljComptorOuterInner, memorySize, predEvaluator,
+ isLeftOuter, nonMatchWriter);
nlj.setIsReversed(isReversed);
IFrame cacheBuff = new VSizeFrame(ctx);
diff --git a/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/integration/TPCHCustomerOrderHashJoinTest.java b/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/integration/TPCHCustomerOrderHashJoinTest.java
index 8232a62..c8e6f59 100644
--- a/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/integration/TPCHCustomerOrderHashJoinTest.java
+++ b/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/integration/TPCHCustomerOrderHashJoinTest.java
@@ -27,7 +27,7 @@
import org.apache.hyracks.api.dataflow.IOperatorDescriptor;
import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
import org.apache.hyracks.api.dataflow.value.IBinaryHashFunctionFactory;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
import org.apache.hyracks.api.dataset.ResultSetId;
@@ -53,7 +53,7 @@
import org.apache.hyracks.dataflow.std.join.InMemoryHashJoinOperatorDescriptor;
import org.apache.hyracks.dataflow.std.misc.MaterializingOperatorDescriptor;
import org.apache.hyracks.dataflow.std.result.ResultWriterOperatorDescriptor;
-import org.apache.hyracks.tests.util.NoopNullWriterFactory;
+import org.apache.hyracks.tests.util.NoopMissingWriterFactory;
import org.apache.hyracks.tests.util.ResultSerializerFactoryProvider;
public class TPCHCustomerOrderHashJoinTest extends AbstractIntegrationTest {
@@ -365,9 +365,9 @@
UTF8StringParserFactory.INSTANCE }, '|'), custDesc);
PartitionConstraintHelper.addAbsoluteLocationConstraint(spec, custScanner, NC1_ID);
- INullWriterFactory[] nullWriterFactories = new INullWriterFactory[ordersDesc.getFieldCount()];
- for (int j = 0; j < nullWriterFactories.length; j++) {
- nullWriterFactories[j] = NoopNullWriterFactory.INSTANCE;
+ IMissingWriterFactory[] nonMatchWriterFactories = new IMissingWriterFactory[ordersDesc.getFieldCount()];
+ for (int j = 0; j < nonMatchWriterFactories.length; j++) {
+ nonMatchWriterFactories[j] = NoopMissingWriterFactory.INSTANCE;
}
InMemoryHashJoinOperatorDescriptor join = new InMemoryHashJoinOperatorDescriptor(
@@ -376,7 +376,7 @@
new int[] { 1 },
new IBinaryHashFunctionFactory[] { PointableBinaryHashFunctionFactory.of(UTF8StringPointable.FACTORY) },
new IBinaryComparatorFactory[] { PointableBinaryComparatorFactory.of(UTF8StringPointable.FACTORY) },
- null, custOrderJoinDesc, true, nullWriterFactories, 128);
+ null, custOrderJoinDesc, true, nonMatchWriterFactories, 128);
PartitionConstraintHelper.addAbsoluteLocationConstraint(spec, join, NC1_ID);
ResultSetId rsId = new ResultSetId(1);
@@ -449,9 +449,9 @@
UTF8StringParserFactory.INSTANCE }, '|'), custDesc);
PartitionConstraintHelper.addAbsoluteLocationConstraint(spec, custScanner, NC1_ID);
- INullWriterFactory[] nullWriterFactories = new INullWriterFactory[ordersDesc.getFieldCount()];
- for (int j = 0; j < nullWriterFactories.length; j++) {
- nullWriterFactories[j] = NoopNullWriterFactory.INSTANCE;
+ IMissingWriterFactory[] nonMatchWriterFactories = new IMissingWriterFactory[ordersDesc.getFieldCount()];
+ for (int j = 0; j < nonMatchWriterFactories.length; j++) {
+ nonMatchWriterFactories[j] = NoopMissingWriterFactory.INSTANCE;
}
GraceHashJoinOperatorDescriptor join = new GraceHashJoinOperatorDescriptor(
@@ -464,7 +464,7 @@
new int[] { 1 },
new IBinaryHashFunctionFactory[] { PointableBinaryHashFunctionFactory.of(UTF8StringPointable.FACTORY) },
new IBinaryComparatorFactory[] { PointableBinaryComparatorFactory.of(UTF8StringPointable.FACTORY) },
- custOrderJoinDesc, true, nullWriterFactories, null);
+ custOrderJoinDesc, true, nonMatchWriterFactories, null);
PartitionConstraintHelper.addAbsoluteLocationConstraint(spec, join, NC1_ID);
ResultSetId rsId = new ResultSetId(1);
@@ -537,9 +537,9 @@
UTF8StringParserFactory.INSTANCE }, '|'), custDesc);
PartitionConstraintHelper.addAbsoluteLocationConstraint(spec, custScanner, NC1_ID);
- INullWriterFactory[] nullWriterFactories = new INullWriterFactory[ordersDesc.getFieldCount()];
- for (int j = 0; j < nullWriterFactories.length; j++) {
- nullWriterFactories[j] = NoopNullWriterFactory.INSTANCE;
+ IMissingWriterFactory[] nonMatchWriterFactories = new IMissingWriterFactory[ordersDesc.getFieldCount()];
+ for (int j = 0; j < nonMatchWriterFactories.length; j++) {
+ nonMatchWriterFactories[j] = NoopMissingWriterFactory.INSTANCE;
}
HybridHashJoinOperatorDescriptor join = new HybridHashJoinOperatorDescriptor(
@@ -552,7 +552,7 @@
new int[] { 1 },
new IBinaryHashFunctionFactory[] { PointableBinaryHashFunctionFactory.of(UTF8StringPointable.FACTORY) },
new IBinaryComparatorFactory[] { PointableBinaryComparatorFactory.of(UTF8StringPointable.FACTORY) },
- custOrderJoinDesc, null, true, nullWriterFactories);
+ custOrderJoinDesc, null, true, nonMatchWriterFactories);
PartitionConstraintHelper.addAbsoluteLocationConstraint(spec, join, NC1_ID);
ResultSetId rsId = new ResultSetId(1);
diff --git a/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/integration/TPCHCustomerOrderNestedLoopJoinTest.java b/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/integration/TPCHCustomerOrderNestedLoopJoinTest.java
index c28e496..c568306 100644
--- a/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/integration/TPCHCustomerOrderNestedLoopJoinTest.java
+++ b/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/integration/TPCHCustomerOrderNestedLoopJoinTest.java
@@ -29,7 +29,7 @@
import org.apache.hyracks.api.dataflow.IOperatorDescriptor;
import org.apache.hyracks.api.dataflow.value.IBinaryComparator;
import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.ISerializerDeserializer;
import org.apache.hyracks.api.dataflow.value.ITuplePairComparator;
import org.apache.hyracks.api.dataflow.value.ITuplePairComparatorFactory;
@@ -52,7 +52,7 @@
import org.apache.hyracks.dataflow.std.file.IFileSplitProvider;
import org.apache.hyracks.dataflow.std.join.NestedLoopJoinOperatorDescriptor;
import org.apache.hyracks.dataflow.std.result.ResultWriterOperatorDescriptor;
-import org.apache.hyracks.tests.util.NoopNullWriterFactory;
+import org.apache.hyracks.tests.util.NoopMissingWriterFactory;
import org.apache.hyracks.tests.util.ResultSerializerFactoryProvider;
public class TPCHCustomerOrderNestedLoopJoinTest extends AbstractIntegrationTest {
@@ -405,14 +405,14 @@
UTF8StringParserFactory.INSTANCE }, '|'), custDesc);
PartitionConstraintHelper.addAbsoluteLocationConstraint(spec, custScanner, NC1_ID, NC2_ID);
- INullWriterFactory[] nullWriterFactories = new INullWriterFactory[ordersDesc.getFieldCount()];
- for (int j = 0; j < nullWriterFactories.length; j++) {
- nullWriterFactories[j] = NoopNullWriterFactory.INSTANCE;
+ IMissingWriterFactory[] nonMatchWriterFactories = new IMissingWriterFactory[ordersDesc.getFieldCount()];
+ for (int j = 0; j < nonMatchWriterFactories.length; j++) {
+ nonMatchWriterFactories[j] = NoopMissingWriterFactory.INSTANCE;
}
NestedLoopJoinOperatorDescriptor join = new NestedLoopJoinOperatorDescriptor(spec, new JoinComparatorFactory(
PointableBinaryComparatorFactory.of(UTF8StringPointable.FACTORY), 1, 0), custOrderJoinDesc, 5, true,
- nullWriterFactories);
+ nonMatchWriterFactories);
PartitionConstraintHelper.addAbsoluteLocationConstraint(spec, join, NC1_ID, NC2_ID);
ResultSetId rsId = new ResultSetId(1);
diff --git a/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/util/NoopNullWriterFactory.java b/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/util/NoopMissingWriterFactory.java
similarity index 71%
rename from hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/util/NoopNullWriterFactory.java
rename to hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/util/NoopMissingWriterFactory.java
index e86d3ff..a71be20 100644
--- a/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/util/NoopNullWriterFactory.java
+++ b/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/util/NoopMissingWriterFactory.java
@@ -21,23 +21,23 @@
import java.io.DataOutput;
import java.io.IOException;
-import org.apache.hyracks.api.dataflow.value.INullWriter;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriter;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.exceptions.HyracksDataException;
-public class NoopNullWriterFactory implements INullWriterFactory {
+public class NoopMissingWriterFactory implements IMissingWriterFactory {
private static final long serialVersionUID = 1L;
- public static final NoopNullWriterFactory INSTANCE = new NoopNullWriterFactory();
+ public static final NoopMissingWriterFactory INSTANCE = new NoopMissingWriterFactory();
- private NoopNullWriterFactory() {
+ private NoopMissingWriterFactory() {
}
@Override
- public INullWriter createNullWriter() {
- return new INullWriter() {
+ public IMissingWriter createMissingWriter() {
+ return new IMissingWriter() {
@Override
- public void writeNull(DataOutput out) throws HyracksDataException {
+ public void writeMissing(DataOutput out) throws HyracksDataException {
try {
out.writeShort(0);
} catch (IOException e) {
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/dataflow/BTreeSearchOperatorDescriptor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/dataflow/BTreeSearchOperatorDescriptor.java
index 5a079b1..21a2441 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/dataflow/BTreeSearchOperatorDescriptor.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/main/java/org/apache/hyracks/storage/am/btree/dataflow/BTreeSearchOperatorDescriptor.java
@@ -22,7 +22,7 @@
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.dataflow.IOperatorNodePushable;
import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.IRecordDescriptorProvider;
import org.apache.hyracks.api.dataflow.value.ITypeTraits;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
@@ -52,12 +52,12 @@
IFileSplitProvider fileSplitProvider, ITypeTraits[] typeTraits,
IBinaryComparatorFactory[] comparatorFactories, int[] bloomFilterKeyFields, int[] lowKeyFields,
int[] highKeyFields, boolean lowKeyInclusive, boolean highKeyInclusive,
- IIndexDataflowHelperFactory dataflowHelperFactory, boolean retainInput, boolean retainNull,
- INullWriterFactory nullWriterFactory, ISearchOperationCallbackFactory searchOpCallbackProvider,
+ IIndexDataflowHelperFactory dataflowHelperFactory, boolean retainInput, boolean retainMissing,
+ IMissingWriterFactory missingWriterFactory, ISearchOperationCallbackFactory searchOpCallbackProvider,
int[] minFilterFieldIndexes, int[] maxFilterFieldIndexes) {
super(spec, 1, 1, recDesc, storageManager, lifecycleManagerProvider, fileSplitProvider, typeTraits,
- comparatorFactories, bloomFilterKeyFields, dataflowHelperFactory, null, retainInput, retainNull,
- nullWriterFactory, NoOpLocalResourceFactoryProvider.INSTANCE, searchOpCallbackProvider,
+ comparatorFactories, bloomFilterKeyFields, dataflowHelperFactory, null, retainInput, retainMissing,
+ missingWriterFactory, NoOpLocalResourceFactoryProvider.INSTANCE, searchOpCallbackProvider,
NoOpOperationCallbackFactory.INSTANCE);
this.lowKeyFields = lowKeyFields;
this.highKeyFields = highKeyFields;
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/test/java/org/apache/hyracks/storage/am/btree/test/FramewriterTest.java b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/test/java/org/apache/hyracks/storage/am/btree/test/FramewriterTest.java
index 378ea65..d713a92 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/test/java/org/apache/hyracks/storage/am/btree/test/FramewriterTest.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-btree/src/test/java/org/apache/hyracks/storage/am/btree/test/FramewriterTest.java
@@ -436,7 +436,7 @@
AbstractTreeIndexOperatorDescriptor opDesc = Mockito.mock(AbstractTreeIndexOperatorDescriptor.class);
Mockito.when(opDesc.getIndexDataflowHelperFactory()).thenReturn(indexDataflowHelperFactories[i]);
Mockito.when(opDesc.getRetainInput()).thenReturn(false);
- Mockito.when(opDesc.getRetainNull()).thenReturn(false);
+ Mockito.when(opDesc.getRetainMissing()).thenReturn(false);
Mockito.when(opDesc.getSearchOpCallbackFactory()).thenReturn(searchOpCallbackFactories[j]);
opDescs[k] = opDesc;
k++;
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/AbstractIndexOperatorDescriptor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/AbstractIndexOperatorDescriptor.java
index 8590014..ebe6383 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/AbstractIndexOperatorDescriptor.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/AbstractIndexOperatorDescriptor.java
@@ -19,7 +19,7 @@
package org.apache.hyracks.storage.am.common.dataflow;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
import org.apache.hyracks.api.job.IOperatorDescriptorRegistry;
import org.apache.hyracks.dataflow.std.base.AbstractSingleActivityOperatorDescriptor;
@@ -43,7 +43,7 @@
protected final ITupleFilterFactory tupleFilterFactory;
protected final boolean retainInput;
protected final boolean retainNull;
- protected final INullWriterFactory nullWriterFactory;
+ protected final IMissingWriterFactory nullWriterFactory;
protected final ISearchOperationCallbackFactory searchOpCallbackFactory;
protected final IModificationOperationCallbackFactory modificationOpCallbackFactory;
protected final ILocalResourceFactoryProvider localResourceFactoryProvider;
@@ -52,7 +52,7 @@
RecordDescriptor recDesc, IStorageManagerInterface storageManager,
IIndexLifecycleManagerProvider lifecycleManagerProvider, IFileSplitProvider fileSplitProvider,
IIndexDataflowHelperFactory dataflowHelperFactory, ITupleFilterFactory tupleFilterFactory,
- boolean retainInput, boolean retainNull, INullWriterFactory nullWriterFactory,
+ boolean retainInput, boolean retainNull, IMissingWriterFactory nullWriterFactory,
ILocalResourceFactoryProvider localResourceFactoryProvider,
ISearchOperationCallbackFactory searchOpCallbackFactory,
IModificationOperationCallbackFactory modificationOpCallbackFactory) {
@@ -104,12 +104,12 @@
}
@Override
- public boolean getRetainNull() {
+ public boolean getRetainMissing() {
return retainNull;
}
@Override
- public INullWriterFactory getNullWriterFactory() {
+ public IMissingWriterFactory getMissingWriterFactory() {
return nullWriterFactory;
}
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/AbstractTreeIndexOperatorDescriptor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/AbstractTreeIndexOperatorDescriptor.java
index 868725e..2020a15 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/AbstractTreeIndexOperatorDescriptor.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/AbstractTreeIndexOperatorDescriptor.java
@@ -20,7 +20,7 @@
package org.apache.hyracks.storage.am.common.dataflow;
import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.ITypeTraits;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
import org.apache.hyracks.api.job.IOperatorDescriptorRegistry;
@@ -45,7 +45,7 @@
IIndexLifecycleManagerProvider lifecycleManagerProvider, IFileSplitProvider fileSplitProvider,
ITypeTraits[] typeTraits, IBinaryComparatorFactory[] comparatorFactories, int[] bloomFilterKeyFields,
IIndexDataflowHelperFactory dataflowHelperFactory, ITupleFilterFactory tupleFilterFactory,
- boolean retainInput, boolean retainNull, INullWriterFactory nullWriterFactory,
+ boolean retainInput, boolean retainNull, IMissingWriterFactory nullWriterFactory,
ILocalResourceFactoryProvider localResourceFactoryProvider,
ISearchOperationCallbackFactory searchOpCallbackFactory,
IModificationOperationCallbackFactory modificationOpCallbackFactory) {
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/IIndexOperatorDescriptor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/IIndexOperatorDescriptor.java
index c90c466..f59c5fd 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/IIndexOperatorDescriptor.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/IIndexOperatorDescriptor.java
@@ -20,7 +20,7 @@
package org.apache.hyracks.storage.am.common.dataflow;
import org.apache.hyracks.api.dataflow.IActivity;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
import org.apache.hyracks.dataflow.std.file.IFileSplitProvider;
import org.apache.hyracks.storage.am.common.api.IIndexLifecycleManagerProvider;
@@ -43,9 +43,9 @@
public boolean getRetainInput();
- public boolean getRetainNull();
+ public boolean getRetainMissing();
- public INullWriterFactory getNullWriterFactory();
+ public IMissingWriterFactory getMissingWriterFactory();
public ISearchOperationCallbackFactory getSearchOpCallbackFactory();
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/IndexSearchOperatorNodePushable.java b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/IndexSearchOperatorNodePushable.java
index 650dcfa..4f9e6c4 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/IndexSearchOperatorNodePushable.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-common/src/main/java/org/apache/hyracks/storage/am/common/dataflow/IndexSearchOperatorNodePushable.java
@@ -24,7 +24,7 @@
import org.apache.hyracks.api.comm.VSizeFrame;
import org.apache.hyracks.api.context.IHyracksTaskContext;
-import org.apache.hyracks.api.dataflow.value.INullWriter;
+import org.apache.hyracks.api.dataflow.value.IMissingWriter;
import org.apache.hyracks.api.dataflow.value.IRecordDescriptorProvider;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
import org.apache.hyracks.api.exceptions.HyracksDataException;
@@ -63,9 +63,9 @@
protected final boolean retainInput;
protected FrameTupleReference frameTuple;
- protected final boolean retainNull;
- protected ArrayTupleBuilder nullTupleBuild;
- protected INullWriter nullWriter;
+ protected final boolean retainMissing;
+ protected ArrayTupleBuilder nonMatchTupleBuild;
+ protected IMissingWriter nonMatchWriter;
protected final int[] minFilterFieldIndexes;
protected final int[] maxFilterFieldIndexes;
@@ -78,9 +78,9 @@
this.ctx = ctx;
this.indexHelper = opDesc.getIndexDataflowHelperFactory().createIndexDataflowHelper(opDesc, ctx, partition);
this.retainInput = opDesc.getRetainInput();
- this.retainNull = opDesc.getRetainNull();
- if (this.retainNull) {
- this.nullWriter = opDesc.getNullWriterFactory().createNullWriter();
+ this.retainMissing = opDesc.getRetainMissing();
+ if (this.retainMissing) {
+ this.nonMatchWriter = opDesc.getMissingWriterFactory().createMissingWriter();
}
this.inputRecDesc = recordDescProvider.getInputRecordDescriptor(opDesc.getActivityId(), 0);
this.minFilterFieldIndexes = minFilterFieldIndexes;
@@ -111,20 +111,20 @@
indexHelper.open();
index = indexHelper.getIndexInstance();
accessor = new FrameTupleAccessor(inputRecDesc);
- if (retainNull) {
+ if (retainMissing) {
int fieldCount = getFieldCount();
- nullTupleBuild = new ArrayTupleBuilder(fieldCount);
- DataOutput out = nullTupleBuild.getDataOutput();
+ nonMatchTupleBuild = new ArrayTupleBuilder(fieldCount);
+ DataOutput out = nonMatchTupleBuild.getDataOutput();
for (int i = 0; i < fieldCount; i++) {
try {
- nullWriter.writeNull(out);
+ nonMatchWriter.writeMissing(out);
} catch (IOException e) {
e.printStackTrace();
}
- nullTupleBuild.addFieldEndOffset();
+ nonMatchTupleBuild.addFieldEndOffset();
}
} else {
- nullTupleBuild = null;
+ nonMatchTupleBuild = null;
}
try {
@@ -165,9 +165,10 @@
FrameUtils.appendToWriter(writer, appender, tb.getFieldEndOffsets(), tb.getByteArray(), 0, tb.getSize());
}
- if (!matched && retainInput && retainNull) {
- FrameUtils.appendConcatToWriter(writer, appender, accessor, tupleIndex, nullTupleBuild.getFieldEndOffsets(),
- nullTupleBuild.getByteArray(), 0, nullTupleBuild.getSize());
+ if (!matched && retainInput && retainMissing) {
+ FrameUtils.appendConcatToWriter(writer, appender, accessor, tupleIndex,
+ nonMatchTupleBuild.getFieldEndOffsets(), nonMatchTupleBuild.getByteArray(), 0,
+ nonMatchTupleBuild.getSize());
}
}
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/dataflow/LSMTreeIndexInsertUpdateDeleteOperatorDescriptor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/dataflow/LSMTreeIndexInsertUpdateDeleteOperatorDescriptor.java
index 2a088d0..9d1deaf 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/dataflow/LSMTreeIndexInsertUpdateDeleteOperatorDescriptor.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-common/src/main/java/org/apache/hyracks/storage/am/lsm/common/dataflow/LSMTreeIndexInsertUpdateDeleteOperatorDescriptor.java
@@ -22,7 +22,7 @@
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.dataflow.IOperatorNodePushable;
import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.IRecordDescriptorProvider;
import org.apache.hyracks.api.dataflow.value.ITypeTraits;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
@@ -51,12 +51,12 @@
IFileSplitProvider fileSplitProvider, ITypeTraits[] typeTraits,
IBinaryComparatorFactory[] comparatorFactories, int[] bloomFilterKeyFields, int[] fieldPermutation,
IndexOperation op, IIndexDataflowHelperFactory dataflowHelperFactory,
- ITupleFilterFactory tupleFilterFactory, INullWriterFactory nullWriterFactory,
+ ITupleFilterFactory tupleFilterFactory, IMissingWriterFactory missingWriterFactory,
IModificationOperationCallbackFactory modificationOpCallbackProvider,
ISearchOperationCallbackFactory searchOpCallbackProvider) {
super(spec, 1, 1, recDesc, storageManager, lifecycleManagerProvider, fileSplitProvider, typeTraits,
comparatorFactories, bloomFilterKeyFields, dataflowHelperFactory, tupleFilterFactory, false, false,
- nullWriterFactory, NoOpLocalResourceFactoryProvider.INSTANCE, searchOpCallbackProvider,
+ missingWriterFactory, NoOpLocalResourceFactoryProvider.INSTANCE, searchOpCallbackProvider,
modificationOpCallbackProvider);
this.fieldPermutation = fieldPermutation;
this.op = op;
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/dataflow/AbstractLSMInvertedIndexOperatorDescriptor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/dataflow/AbstractLSMInvertedIndexOperatorDescriptor.java
index 1c16dfe..34037c7 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/dataflow/AbstractLSMInvertedIndexOperatorDescriptor.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/dataflow/AbstractLSMInvertedIndexOperatorDescriptor.java
@@ -20,7 +20,7 @@
package org.apache.hyracks.storage.am.lsm.invertedindex.dataflow;
import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.ITypeTraits;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
import org.apache.hyracks.api.job.IOperatorDescriptorRegistry;
@@ -54,7 +54,7 @@
ITypeTraits[] invListsTypeTraits, IBinaryComparatorFactory[] invListComparatorFactories,
IBinaryTokenizerFactory tokenizerFactory, IIndexDataflowHelperFactory dataflowHelperFactory,
ITupleFilterFactory tupleFilterFactory, boolean retainInput, boolean retainNull,
- INullWriterFactory nullWriterFactory, ILocalResourceFactoryProvider localResourceFactoryProvider,
+ IMissingWriterFactory nullWriterFactory, ILocalResourceFactoryProvider localResourceFactoryProvider,
ISearchOperationCallbackFactory searchOpCallbackFactory,
IModificationOperationCallbackFactory modificationOpCallbackFactory) {
super(spec, inputArity, outputArity, recDesc, storageManager, lifecycleManagerProvider, fileSplitProvider,
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/dataflow/LSMInvertedIndexSearchOperatorDescriptor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/dataflow/LSMInvertedIndexSearchOperatorDescriptor.java
index a9afb54..bec95d5 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/dataflow/LSMInvertedIndexSearchOperatorDescriptor.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-lsm-invertedindex/src/main/java/org/apache/hyracks/storage/am/lsm/invertedindex/dataflow/LSMInvertedIndexSearchOperatorDescriptor.java
@@ -22,7 +22,7 @@
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.dataflow.IOperatorNodePushable;
import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.IRecordDescriptorProvider;
import org.apache.hyracks.api.dataflow.value.ITypeTraits;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
@@ -54,7 +54,7 @@
IBinaryComparatorFactory[] invListComparatorFactories,
IIndexDataflowHelperFactory btreeDataflowHelperFactory, IBinaryTokenizerFactory queryTokenizerFactory,
IInvertedIndexSearchModifierFactory searchModifierFactory, RecordDescriptor recDesc, boolean retainInput,
- boolean retainNull, INullWriterFactory nullWriterFactory,
+ boolean retainNull, IMissingWriterFactory nullWriterFactory,
ISearchOperationCallbackFactory searchOpCallbackProvider, int[] minFilterFieldIndexes,
int[] maxFilterFieldIndexes) {
diff --git a/hyracks-fullstack/hyracks/hyracks-storage-am-rtree/src/main/java/org/apache/hyracks/storage/am/rtree/dataflow/RTreeSearchOperatorDescriptor.java b/hyracks-fullstack/hyracks/hyracks-storage-am-rtree/src/main/java/org/apache/hyracks/storage/am/rtree/dataflow/RTreeSearchOperatorDescriptor.java
index e1922d0..42cd4a2 100644
--- a/hyracks-fullstack/hyracks/hyracks-storage-am-rtree/src/main/java/org/apache/hyracks/storage/am/rtree/dataflow/RTreeSearchOperatorDescriptor.java
+++ b/hyracks-fullstack/hyracks/hyracks-storage-am-rtree/src/main/java/org/apache/hyracks/storage/am/rtree/dataflow/RTreeSearchOperatorDescriptor.java
@@ -22,7 +22,7 @@
import org.apache.hyracks.api.context.IHyracksTaskContext;
import org.apache.hyracks.api.dataflow.IOperatorNodePushable;
import org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory;
-import org.apache.hyracks.api.dataflow.value.INullWriterFactory;
+import org.apache.hyracks.api.dataflow.value.IMissingWriterFactory;
import org.apache.hyracks.api.dataflow.value.IRecordDescriptorProvider;
import org.apache.hyracks.api.dataflow.value.ITypeTraits;
import org.apache.hyracks.api.dataflow.value.RecordDescriptor;
@@ -49,7 +49,7 @@
IFileSplitProvider fileSplitProvider, ITypeTraits[] typeTraits,
IBinaryComparatorFactory[] comparatorFactories, int[] keyFields,
IIndexDataflowHelperFactory dataflowHelperFactory, boolean retainInput, boolean retainNull,
- INullWriterFactory nullWriterFactory, ISearchOperationCallbackFactory searchOpCallbackFactory,
+ IMissingWriterFactory nullWriterFactory, ISearchOperationCallbackFactory searchOpCallbackFactory,
int[] minFilterFieldIndexes, int[] maxFilterFieldIndexes) {
super(spec, 1, 1, recDesc, storageManager, lifecycleManagerProvider, fileSplitProvider, typeTraits,