Package ch.epfl.labos.iu.orm.queryll2.symbolic

Examples of ch.epfl.labos.iu.orm.queryll2.symbolic.ConstantValue$FloatConstant


         Map<MethodSignature, TypedValue.ComparisonValue.ComparisonOp> comparisonMethods)
   {
      List<TypedValue> newConditions = new ArrayList<TypedValue>();
      for (TypedValue cond: conditions)
      {
         TypedValue simpcond = cond.visit(new TypedValueRewriterWalker<Object, RuntimeException>(new SymbExSimplifier<Object>(comparisonMethods)), null);
         simpcond = simpcond.visit(new SymbExBooleanRewriter(), true);
         newConditions.add(simpcond);
      }
      return newConditions;
   }
View Full Code Here


         if (instruction.isBranch)
            pathConditions.isBranchTaken = instruction.isBranchTaken;
         frame.execute(instruction.node, interpreter);
      }
     
      TypedValue returnValue = interpreter.returnValue;
      List<TypedValue.ComparisonValue> conditions = pathConditions.conditions;
     
      PathAnalysis toReturn = new PathAnalysis(interpreter.sideEffects, returnValue, conditions);
      return toReturn;
   }
View Full Code Here

  
   protected ColumnExpressions<?> handleIndirectLambdaArg(int argIndex, Type argType) throws TypedValueVisitorException
   {
      // The actual value for the parameter is not available because this is a sub-lambda.
      // Extract the parent scope to see how the parameter is used in the parent lambda
      TypedValue paramVal = lambda.getIndirectCapturedArg(argIndex);
     
      // Right now, we only support sub-lambda parameters that are simply passthroughs for
      // parameters defined in the parent lambda.
      if (paramVal instanceof TypedValue.ArgValue)
      {
View Full Code Here

   protected ColumnExpressions<?> handleIndirectThisFieldRead(String name, Type argType) throws TypedValueVisitorException
   {
      // The actual value for the parameter is not available because this is a sub-lambda.
      // Extract the parent scope to see how the parameter is used in the parent lambda
      TypedValue paramVal = lambda.getIndirectFieldValue(name);
     
      // Right now, we only support sub-lambda parameters that are simply passthroughs for
      // parameters defined in the parent lambda.
      if (paramVal instanceof TypedValue.ArgValue)
      {
View Full Code Here

      Expression methodExpr = null;
      for (int n = 0; n < where.symbolicAnalysis.paths.size(); n++)
      {
         PathAnalysis path = where.symbolicAnalysis.paths.get(n);

         TypedValue returnVal = PathAnalysisSimplifier
               .simplifyBoolean(path.getReturnValue(), config.getComparisonMethods());
         SymbExPassDown returnPassdown = SymbExPassDown.with(null, true);
         ColumnExpressions<?> returnColumns = returnVal.visit(translator, returnPassdown);
         if (!returnColumns.isSingleColumn())
            throw new QueryTransformException("Expecting single column");
         Expression returnExpr = returnColumns.getOnlyColumn();

         if (returnVal instanceof ConstantValue.BooleanConstant)
View Full Code Here

   {
      if (!("=".equals(opString) || "<>".equals(opString)))
         throw new TypedValueVisitorException("Unhandled operation involving NULL");
      if (leftVal instanceof ConstantValue.NullConstant && rightVal instanceof ConstantValue.NullConstant)
         throw new TypedValueVisitorException("Cannot handle comparisons involving two NULLs");
      TypedValue operandVal;
      if (leftVal instanceof ConstantValue.NullConstant)
         operandVal = rightVal;
      else
         operandVal = leftVal;
      ColumnExpressions<U> operand = (ColumnExpressions<U>)operandVal.visit(this, passdown);
      if ("=".equals(opString))
         return ColumnExpressions.singleColumn(new SimpleRowReader<>(),
               UnaryExpression.postfix("IS NULL", operand.getOnlyColumn()));
      else
         return ColumnExpressions.singleColumn(new SimpleRowReader<>(),
View Full Code Here

                  FunctionExpression.singleParam("ABS", base.getOnlyColumn()));
         }
         else if (sig.equals(MethodChecker.mathSqrt))
         {
            SymbExPassDown passdown = SymbExPassDown.with(val, in.isExpectingConditional);
            TypedValue baseVal = val.args.get(0);
            if (isWideningCast(baseVal))
               baseVal = skipWideningCast(baseVal);
            ColumnExpressions<?> base = baseVal.visit(this, passdown);
            return ColumnExpressions.singleColumn(new SimpleRowReader<>(),
                  FunctionExpression.singleParam("SQRT", base.getOnlyColumn()));
         }
         throw new TypedValueVisitorException("Do not know how to translate the method " + sig + " into a JPQL function");
      }
View Full Code Here

   @Override public SQLColumnValues castValue(TypedValue.CastValue val, T in) throws TypedValueVisitorException
   {
      // Check if cast is consistent with the reader
      SQLColumnValues toReturn = val.operand.visit(this, in);
      if (!toReturn.reader.isCastConsistent(val.getType().getInternalName()))
         throw new TypedValueVisitorException("Attempting to cast to an inconsistent type");
      return toReturn;
   }
View Full Code Here

         return base;
      }
      else if (entityInfo.dbSetMethods.contains(sig))
      {
         if (lambdaContext.joins == null)
            throw new TypedValueVisitorException("Need a join handler here for subqueries just in case there's an embedded navigational query: " + val);
         // TODO: Handle checking out the constructor and verifying how
         // parameters pass through the constructor
         SQLQuery subQuery = val.base.visit(subQueryHandler, in);
         if (sig.equals(TransformationClassAnalyzer.dbsetSumInt)
               || sig.equals(TransformationClassAnalyzer.dbsetMaxInt))
         {
            // TODO: do subqueries need to be copied before being passed in here?
            SQLQuery<Integer> newQuery = null;
            if (sig.equals(TransformationClassAnalyzer.dbsetSumInt))
               newQuery = queryMethodHandler.sumInt(subQuery, val.args.get(0), lambdaContext.joins.getEntityManager());
            else if (sig.equals(TransformationClassAnalyzer.dbsetMaxInt))
               newQuery = queryMethodHandler.maxInt(subQuery, val.args.get(0), lambdaContext.joins.getEntityManager());
            if (newQuery == null) throw new TypedValueVisitorException("Could not decode a subquery " + val);
            if (newQuery instanceof SQLQuery.InternalGroup)
            {
               SQLQuery.InternalGroup<Integer> agg = (SQLQuery.InternalGroup<Integer>)newQuery;
               // TODO: This is probably correct but potentially bogus.
               // It should be thought through a bit more wrt what InternalGroup
               // means and whether that is sufficient to allow us to do this
               assert(agg.reader instanceof SQLReader.IntegerSQLReader);
               SQLColumnValues<Integer> toReturn = new SQLColumnValues<Integer>(agg.reader);
               toReturn.columns[0] = agg.columns.get(0);
               return toReturn;
            }
            else if (newQuery instanceof SQLQuery.SelectFromWhere)
            {
               SQLQuery.SelectFromWhere<Integer> subquery = (SQLQuery.SelectFromWhere<Integer>)newQuery;
               assert(subquery.reader instanceof SQLReader.IntegerSQLReader);
               SQLColumnValues<Integer> toReturn = new SQLColumnValues<Integer>(subquery.reader);
               toReturn.columns[0].add(new SQLSubstitution.ScalarSelectFromWhereSubQuery(subquery));
               return toReturn;
            }
            else
               throw new TypedValueVisitorException("Unhandled nesting of a query");
         }
         // TODO: Implement other aggregation functions
         throw new TypedValueVisitorException("Unhandled DBSet operation");
      }
      else if (entityInfo.N111Methods.containsKey(sig))
      {
         SQLColumnValues base = val.base.visit(this, in);
         ORMInformation.N111NavigationalLink link = entityInfo.N111Methods.get(sig);
         if (lambdaContext.joins == null)
            throw new TypedValueVisitorException("Cannot handle navigational queries in this context: " + val);
         assert(link.joinInfo.size() == 1);
         // See if we've already done this join and can reuse it
         List<SQLFragment> fromKey = new ArrayList<SQLFragment>();
         for (int n = 0; n < link.joinInfo.get(0).fromColumns.size(); n++)
         {
            String fromCol = link.joinInfo.get(0).fromColumns.get(n);
            int fromColIdx = base.reader.getColumnIndexForColumnName(fromCol);
            if (fromColIdx < 0) throw new TypedValueVisitorException("Cannot find column for navigational query: " + val);
            fromKey.add(base.getColumn(fromColIdx));
         }
         SQLSubstitution.FromReference from = lambdaContext.joins.findExistingJoin(link.fromEntity, link.name, fromKey);
         if (from == null)
         {
            from = lambdaContext.joins.addFrom(link.joinInfo.get(0).toTableName);
            for (int n = 0; n < link.joinInfo.get(0).fromColumns.size(); n++)
            {
               SQLFragment where = new SQLFragment();
               String fromCol = link.joinInfo.get(0).fromColumns.get(n);
               String toCol = link.joinInfo.get(0).toColumns.get(n);
               int fromColIdx = base.reader.getColumnIndexForColumnName(fromCol);
               if (fromColIdx < 0) throw new TypedValueVisitorException("Cannot find column for navigational query: " + val);
               where.add("(");
               where.add(base.getColumn(fromColIdx));
               where.add(") = (");
               where.add(from);
               where.add("." + toCol);
View Full Code Here

            // motion will be used to push those field accesses or method calls
            // outside the query where they will be evaluated and then passed in
            // as a parameter)
            Type t = val.getType();
            if (!allowedQueryParameterTypes.containsKey(t))
               throw new TypedValueVisitorException("Accessing a field with unhandled type");
           
            try
            {
               // TODO: Careful here. ParameterLocation is relative to the base
               // lambda, but if we arrive here from inside a nested query, "this"
               // might refer to a lambda nested inside the base lambda. (Of course,
               // nested queries with parameters aren't currently supported, so it
               // doesn't matter.)
               ParameterLocation paramLoc = ParameterLocation.createJava8LambdaArgAccess(val.getIndex(), lambdaIndex);
               SQLColumnValues toReturn = new SQLColumnValues(allowedQueryParameterTypes.get(t));
               assert(toReturn.getNumColumns() == 1);
               toReturn.columns[0].add(new SQLSubstitution.ExternalParameterLink(paramLoc));
               return toReturn;
            } catch (Exception e)
            {
               throw new TypedValueVisitorException(e);
            }
         }
         else
            return dataSource;
        
View Full Code Here

TOP

Related Classes of ch.epfl.labos.iu.orm.queryll2.symbolic.ConstantValue$FloatConstant

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.