Package com.hp.hpl.jena.sparql.algebra.op

Examples of com.hp.hpl.jena.sparql.algebra.op.OpOrder


            OpProject project = (OpProject) subOp;
            // At the project stage everything is a simple variable
            // Inner operation must be an ORDER BY
            if (project.getSubOp() instanceof OpOrder) {
                List<Var> projectVars = project.getVars();
                OpOrder order = (OpOrder) project.getSubOp();

                // Everything we wish to order by must only use variables that
                // appear in the project list
                boolean ok = true;
                for (SortCondition condition : order.getConditions()) {
                    if (!isValidSortCondition(condition, projectVars)) {
                        ok = false;
                        break;
                    }
                }

                // Everything checks out so we can make the change
                if (ok) {
                    OpProject newProject = new OpProject(order.getSubOp(), project.getVars());
                    OpDistinct newDistinct = new OpDistinct(newProject);
                    return new OpOrder(newDistinct, order.getConditions());
                }
            }
        }

        // If we reach here then this transform is not applicable
View Full Code Here


            OpProject project = (OpProject) subOp;
            // At the project stage everything is a simple variable
            // Inner operation must be an ORDER BY
            if (project.getSubOp() instanceof OpOrder) {
                List<Var> projectVars = project.getVars();
                OpOrder order = (OpOrder) project.getSubOp();

                // Everything we wish to order by must only use variables that
                // appear in the project list
                boolean ok = true;
                for (SortCondition condition : order.getConditions()) {
                    if (!isValidSortCondition(condition, projectVars)) {
                        ok = false;
                        break;
                    }
                }

                // Everything checks out so we can make the change
                if (ok) {
                    OpProject newProject = new OpProject(order.getSubOp(), project.getVars());
                    Op newReduced = OpReduced.create(newProject);
                    return new OpOrder(newReduced, order.getConditions());
                }
            }
        }

        // If we reach here then this transform is not applicable
View Full Code Here

    //@Override
    public Op transform1(OpDistinct opDistinct, Op subOp) {
        if (subOp instanceof OpProject) {
            OpProject opProject = (OpProject) subOp;
            if (opProject.getSubOp() instanceof OpOrder) {
                OpOrder opOrder = (OpOrder) opProject.getSubOp();
                Set<Var> projectVars = new HashSet<Var>(opProject.getVars()) ;
                if (isSafe(projectVars, opOrder)) {
                    return OpReduced.create(subOp);
                }
            }
View Full Code Here

   
   
    @Override
    public Op transform(OpDistinct opDistinct, Op subOp) {
       
        OpOrder opOrder = null ;
        Set<Var> projectVars = null ;
        /*   SELECT DISTINCT * {} ORDER BY
         * giving an alegbra expression of the form: 
         *   (distinct
         *     (order
View Full Code Here

            OpProject project = (OpProject) subOp;
            // At the project stage everything is a simple variable
            // Inner operation must be an ORDER BY
            if (project.getSubOp() instanceof OpOrder) {
                List<Var> projectVars = project.getVars();
                OpOrder order = (OpOrder) project.getSubOp();

                // Everything we wish to order by must only use variables that
                // appear in the project list
                boolean ok = true;
                for (SortCondition condition : order.getConditions()) {
                    if (!isValidSortCondition(condition, projectVars)) {
                        ok = false;
                        break;
                    }
                }

                // Everything checks out so we can make the change
                if (ok) {
                    OpProject newProject = new OpProject(order.getSubOp(), project.getVars());
                    OpDistinct newDistinct = new OpDistinct(newProject);
                    return new OpOrder(newDistinct, order.getConditions());
                }
            }
        }

        // If we reach here then this transform is not applicable
View Full Code Here

            OpProject project = (OpProject) subOp;
            // At the project stage everything is a simple variable
            // Inner operation must be an ORDER BY
            if (project.getSubOp() instanceof OpOrder) {
                List<Var> projectVars = project.getVars();
                OpOrder order = (OpOrder) project.getSubOp();

                // Everything we wish to order by must only use variables that
                // appear in the project list
                boolean ok = true;
                for (SortCondition condition : order.getConditions()) {
                    if (!isValidSortCondition(condition, projectVars)) {
                        ok = false;
                        break;
                    }
                }

                // Everything checks out so we can make the change
                if (ok) {
                    OpProject newProject = new OpProject(order.getSubOp(), project.getVars());
                    Op newReduced = OpReduced.create(newProject);
                    return new OpOrder(newReduced, order.getConditions());
                }
            }
        }

        // If we reach here then this transform is not applicable
View Full Code Here

            return super.transform(opSlice, subOp) ;
           
        if ( subOp instanceof OpOrder )
        {
            // First case: slice-order
            OpOrder opOrder = (OpOrder)subOp ;
            OpTopN opTopN = new OpTopN( opOrder.getSubOp(), (int)(offset+opSlice.getLength()), opOrder.getConditions() ) ;
            if ( offset == 0 ) {
                return opTopN ;
            } else {
                return new OpSlice( opTopN, offset, Query.NOLIMIT ) ;                 
            }
        }

        if ( subOp instanceof OpDistinct || subOp instanceof OpReduced )
        {
            // Second case: slice-distinct-order or slice-reduced-order
            Op subSubOp = ((Op1)subOp).getSubOp() ;
            if ( subSubOp instanceof OpOrder ) {
                OpOrder opOrder = (OpOrder)subSubOp ;
                Op opDistinct2 = OpDistinct.create(opOrder.getSubOp()) ;
                OpTopN opTopN = new OpTopN( opDistinct2, (int)(offset+opSlice.getLength()), opOrder.getConditions() ) ;
                if ( offset == 0 ) {
                    return opTopN ;
                } else {
                    return new OpSlice( opTopN, offset, Query.NOLIMIT ) ;                      
                }
            }
        }

        if ( subOp instanceof OpProject )
        {
            // Third case: slice-project-order
            Op subSubOp = ((Op1)subOp).getSubOp() ;
            if ( subSubOp instanceof OpOrder )
            {
                OpProject opProject = (OpProject)subOp ;
                OpOrder opOrder = (OpOrder)subSubOp ;
                // NB leave project over topN, unlike the distinct case where distinct goes under topN.
                OpTopN opTopN = new OpTopN( opOrder.getSubOp(), (int)(offset+opSlice.getLength()), opOrder.getConditions() ) ;
                Op proj = new OpProject(opTopN, opProject.getVars()) ;
                if ( offset == 0 ) {
                    return proj ;
                } else {
                    return new OpSlice( proj, offset, Query.NOLIMIT ) ;                      
View Full Code Here

                Expr e = sc.getExpression() ;
                e = ExprLib.replaceAggregateByVariable(e) ;
                scList.add(new SortCondition(e, sc.getDirection())) ;
               
            }
            op = new OpOrder(op, scList) ;
        }
       
        // ---- PROJECT
        // No projection => initial variables are exposed.
        // Needed for CONSTRUCT and initial bindings + SELECT *
 
View Full Code Here

   * rewrites the subop of order.
   */
  @Override
  public void visit( final OpOrder opOrder )
  {
    addOp(new OpOrder(rewriteOp1(opOrder), opOrder.getConditions()));
  }
View Full Code Here

    //@Override
    public Op transform1(OpDistinct opDistinct, Op subOp) {
        if (subOp instanceof OpProject) {
            OpProject opProject = (OpProject) subOp;
            if (opProject.getSubOp() instanceof OpOrder) {
                OpOrder opOrder = (OpOrder) opProject.getSubOp();
                Set<Var> projectVars = new HashSet<>(opProject.getVars()) ;
                if (isSafe(projectVars, opOrder)) {
                    return OpReduced.create(subOp);
                }
            }
View Full Code Here

TOP

Related Classes of com.hp.hpl.jena.sparql.algebra.op.OpOrder

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.