| package edu.uci.ics.asterix.om.typecomputer.impl; |
| |
| import edu.uci.ics.asterix.om.typecomputer.base.IResultTypeComputer; |
| import edu.uci.ics.asterix.om.types.AbstractCollectionType; |
| import edu.uci.ics.asterix.om.types.IAType; |
| import edu.uci.ics.hyracks.algebricks.common.exceptions.AlgebricksException; |
| import edu.uci.ics.hyracks.algebricks.core.algebra.base.ILogicalExpression; |
| import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.AbstractFunctionCallExpression; |
| import edu.uci.ics.hyracks.algebricks.core.algebra.expressions.IVariableTypeEnvironment; |
| import edu.uci.ics.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(); |
| } |
| |
| } |