Repository: asterixdb Updated Branches: refs/heads/master f4485553d -> 05802cc33
http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/evaluators/functions/binary/SubBinaryFromToDescriptor.java ---------------------------------------------------------------------- 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 d91c0f4..961edbf 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 @@ -22,8 +22,10 @@ package org.apache.asterix.runtime.evaluators.functions.binary; import org.apache.asterix.om.functions.BuiltinFunctions; import org.apache.asterix.om.functions.IFunctionDescriptor; import org.apache.asterix.om.functions.IFunctionDescriptorFactory; +import org.apache.asterix.om.functions.IFunctionTypeInferer; import org.apache.asterix.om.types.hierachy.ATypeHierarchy; -import org.apache.asterix.runtime.evaluators.base.AbstractScalarFunctionDynamicDescriptor; +import org.apache.asterix.runtime.evaluators.functions.AbstractStringOffsetConfigurableDescriptor; +import org.apache.asterix.runtime.functions.FunctionTypeInferers; 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; @@ -31,13 +33,18 @@ import org.apache.hyracks.api.context.IHyracksTaskContext; import org.apache.hyracks.api.exceptions.HyracksDataException; import org.apache.hyracks.dataflow.common.data.accessors.IFrameTupleReference; -public class SubBinaryFromToDescriptor extends AbstractScalarFunctionDynamicDescriptor { +public class SubBinaryFromToDescriptor extends AbstractStringOffsetConfigurableDescriptor { private static final long serialVersionUID = 1L; public static final IFunctionDescriptorFactory FACTORY = new IFunctionDescriptorFactory() { @Override public IFunctionDescriptor createFunctionDescriptor() { return new SubBinaryFromToDescriptor(); } + + @Override + public IFunctionTypeInferer createFunctionTypeInferer() { + return FunctionTypeInferers.SET_STRING_OFFSET; + } }; @Override @@ -50,10 +57,12 @@ public class SubBinaryFromToDescriptor extends AbstractScalarFunctionDynamicDesc return new IScalarEvaluatorFactory() { private static final long serialVersionUID = 1L; + private final int baseOffset = stringOffset; + @Override public IScalarEvaluator createScalarEvaluator(final IHyracksTaskContext ctx) throws HyracksDataException { - return new AbstractSubBinaryEvaluator(ctx, args, getIdentifier().getName()) { + return new AbstractSubBinaryEvaluator(ctx, args, baseOffset, getIdentifier().getName()) { @Override protected int getSubLength(IFrameTupleReference tuple) throws HyracksDataException { return ATypeHierarchy.getIntegerValue(getIdentifier().getName(), 2, http://git-wip-us.apache.org/repos/asf/asterixdb/blob/05802cc3/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/functions/FunctionTypeInferers.java ---------------------------------------------------------------------- diff --git a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/functions/FunctionTypeInferers.java b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/functions/FunctionTypeInferers.java index 00a5ec8..b8d9778 100644 --- a/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/functions/FunctionTypeInferers.java +++ b/asterixdb/asterix-runtime/src/main/java/org/apache/asterix/runtime/functions/FunctionTypeInferers.java @@ -19,6 +19,7 @@ package org.apache.asterix.runtime.functions; +import org.apache.asterix.common.config.CompilerProperties; import org.apache.asterix.om.base.AOrderedList; import org.apache.asterix.om.base.AString; import org.apache.asterix.om.constants.AsterixConstantValue; @@ -53,16 +54,24 @@ public final class FunctionTypeInferers { public static final IFunctionTypeInferer SET_EXPRESSION_TYPE = new IFunctionTypeInferer() { @Override - public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context) - throws AlgebricksException { + public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context, + CompilerProperties compilerProps) throws AlgebricksException { fd.setImmutableStates(context.getType(expr)); } }; + public static final IFunctionTypeInferer SET_STRING_OFFSET = new IFunctionTypeInferer() { + @Override + public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context, + CompilerProperties compilerProps) { + fd.setImmutableStates(compilerProps.getStringOffset()); + } + }; + public static final class CastTypeInferer implements IFunctionTypeInferer { @Override - public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context) - throws AlgebricksException { + public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context, + CompilerProperties compilerProps) throws AlgebricksException { AbstractFunctionCallExpression funcExpr = (AbstractFunctionCallExpression) expr; IAType rt = TypeCastUtils.getRequiredType(funcExpr); IAType it = (IAType) context.getType(funcExpr.getArguments().get(0).getValue()); @@ -72,8 +81,8 @@ public final class FunctionTypeInferers { public static final class DeepEqualityTypeInferer implements IFunctionTypeInferer { @Override - public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context) - throws AlgebricksException { + public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context, + CompilerProperties compilerProps) throws AlgebricksException { AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expr; IAType type0 = (IAType) context.getType(f.getArguments().get(0).getValue()); IAType type1 = (IAType) context.getType(f.getArguments().get(1).getValue()); @@ -83,8 +92,8 @@ public final class FunctionTypeInferers { public static final class FieldAccessByIndexTypeInferer implements IFunctionTypeInferer { @Override - public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context) - throws AlgebricksException { + public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context, + CompilerProperties compilerProps) throws AlgebricksException { AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expr; IAType t = (IAType) context.getType(fce.getArguments().get(0).getValue()); switch (t.getTypeTag()) { @@ -112,8 +121,8 @@ public final class FunctionTypeInferers { public static final class FieldAccessNestedTypeInferer implements IFunctionTypeInferer { @Override - public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context) - throws AlgebricksException { + public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context, + CompilerProperties compilerProps) throws AlgebricksException { AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expr; IAType t = (IAType) context.getType(fce.getArguments().get(0).getValue()); AOrderedList fieldPath = @@ -141,8 +150,8 @@ public final class FunctionTypeInferers { public static final class GetRecordFieldsTypeInferer implements IFunctionTypeInferer { @Override - public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context) - throws AlgebricksException { + public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context, + CompilerProperties compilerProps) throws AlgebricksException { AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expr; IAType t = (IAType) context.getType(fce.getArguments().get(0).getValue()); ATypeTag typeTag = t.getTypeTag(); @@ -158,8 +167,8 @@ public final class FunctionTypeInferers { public static final class GetRecordFieldValueTypeInferer implements IFunctionTypeInferer { @Override - public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context) - throws AlgebricksException { + public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context, + CompilerProperties compilerProps) throws AlgebricksException { AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expr; IAType t = (IAType) context.getType(fce.getArguments().get(0).getValue()); ATypeTag typeTag = t.getTypeTag(); @@ -175,8 +184,8 @@ public final class FunctionTypeInferers { public static final class OpenRecordConstructorTypeInferer implements IFunctionTypeInferer { @Override - public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context) - throws AlgebricksException { + public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context, + CompilerProperties compilerProps) throws AlgebricksException { ARecordType rt = (ARecordType) context.getType(expr); fd.setImmutableStates(rt, computeOpenFields((AbstractFunctionCallExpression) expr, rt)); } @@ -204,8 +213,8 @@ public final class FunctionTypeInferers { public static final class RecordAddFieldsTypeInferer implements IFunctionTypeInferer { @Override - public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context) - throws AlgebricksException { + public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context, + CompilerProperties compilerProps) throws AlgebricksException { AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expr; IAType outType = (IAType) context.getType(expr); IAType type0 = (IAType) context.getType(f.getArguments().get(0).getValue()); @@ -223,8 +232,8 @@ public final class FunctionTypeInferers { public static final class RecordMergeTypeInferer implements IFunctionTypeInferer { @Override - public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context) - throws AlgebricksException { + public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context, + CompilerProperties compilerProps) throws AlgebricksException { AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expr; IAType outType = (IAType) context.getType(expr); IAType type0 = (IAType) context.getType(f.getArguments().get(0).getValue()); @@ -235,8 +244,8 @@ public final class FunctionTypeInferers { public static final class RecordPairsTypeInferer implements IFunctionTypeInferer { @Override - public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context) - throws AlgebricksException { + public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context, + CompilerProperties compilerProps) throws AlgebricksException { AbstractFunctionCallExpression fce = (AbstractFunctionCallExpression) expr; IAType t = (IAType) context.getType(fce.getArguments().get(0).getValue()); ATypeTag typeTag = t.getTypeTag(); @@ -252,8 +261,8 @@ public final class FunctionTypeInferers { public static final class RecordRemoveFieldsTypeInferer implements IFunctionTypeInferer { @Override - public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context) - throws AlgebricksException { + public void infer(ILogicalExpression expr, IFunctionDescriptor fd, IVariableTypeEnvironment context, + CompilerProperties compilerProps) throws AlgebricksException { AbstractFunctionCallExpression f = (AbstractFunctionCallExpression) expr; IAType outType = (IAType) context.getType(expr); IAType type0 = (IAType) context.getType(f.getArguments().get(0).getValue());
