@Override public Op transform(OpSlice opSlice, Op subOp) { // (slice (project...)) ==> (project (slice ...)) if ( subOp instanceof OpProject ) { OpProject p = (OpProject)subOp ; Op sub = p.getSubOp() ; Op x = new OpSlice(sub, opSlice.getStart(), opSlice.getLength()) ; x = new OpProject(x, p.getVars()) ; return x ; } return super.transform(opSlice, subOp) ; } }
@Override public Op1 copy(Op subOp) { return new OpSlice(subOp, start, length) ; }
@Override public int hashCode() { return getSubOp().hashCode() ^ (int)(start&0xFFFFFFFF) ^ (int)(length&0xFFFFFFFF) ; }
if ( opSlice.getLength() == Query.NOLIMIT ) return doNothing(opSlice, inSubOp) ; long limit = opSlice.getLength() ; long offset = ( opSlice.getStart() != Query.NOLIMIT ) ? opSlice.getStart() : 0L ; long N = limit+offset ; newOp = new OpProject(newOp, projection) ; if ( opSlice.getStart() > 0 ) newOp = new OpSlice(newOp, opSlice.getStart(), Query.NOLIMIT) ;
public static Op applyRange(Op op, Range<Long> range) { long start = rangeToOffset(range); long length = rangeToLimit(range); Op result = start == Query.NOLIMIT && length == Query.NOLIMIT ? op : new OpSlice(op, start, length); return result; }
void info() { if ( opSlice != null ) System.out.printf("slice: (%d, %d)\n", opSlice.getStart(), opSlice.getLength()) ; if ( opDistinct != null ) System.out.printf("distinct\n") ; if ( opReduced != null ) System.out.printf("reduced\n") ; if ( opProject != null ) System.out.printf("project: %s\n", opProject.getVars()) ; if ( opOrder != null ) System.out.printf("order: %s\n", opOrder.getConditions()) ; if ( opHaving != null ) System.out.printf("having: %s\n", opHaving.getExprs()) ; if ( opExtends != null && !opExtends.isEmpty() ) { List<VarExprList> z = opExtends.stream().map(x -> x.getVarExprList()).collect(Collectors.toList()) ; System.out.printf("assigns: %s\n", z) ; } if ( opGroup != null ) { List<ExprAggregator> aggregators = opGroup.getAggregators() ; List<Var> aggVars = aggregators.stream().map(x -> x.getAggVar().asVar()).collect(Collectors.toList()) ; System.out.printf("group: %s |-| %s\n", opGroup.getGroupVars(), opGroup.getAggregators()) ; System.out.printf("group agg vars: %s\n", aggVars) ; } }
@Override public Op make(ItemList list) { BuilderLib.checkLength(4, list, "slice") ; long start = BuilderNode.buildLong(list, 1, -1) ; long length = BuilderNode.buildLong(list, 2, -1) ; if ( start == -1 ) start = Query.NOLIMIT ; if ( length == -1 ) length = Query.NOLIMIT ; Op sub = build(list, 3) ; return new OpSlice(sub, start, length) ; } } ;
@Override public void visit(OpSlice opSlice) { mergeVars(opSlice.getSubOp()) ; }