public int compareTo(BoundaryDef other) { int c = getDirection().compareTo(other.getDirection()); if (c != 0) { return c; } return this.direction == Direction.PRECEDING ? other.amt - this.amt : this.amt - other.amt; }
public int compareTo(BoundaryDef other) { int c = getDirection().compareTo(other.getDirection()); if (c != 0) { return c; } return this.direction == Direction.PRECEDING ? other.amt - this.amt : this.amt - other.amt; }
public WindowFrameDef(WindowType windowType, BoundaryDef start, BoundaryDef end) { this.windowType = windowType; this.start = start; this.end = end; // Calculate window size if (start.getDirection() == end.getDirection()) { windowSize = Math.abs(end.getAmt() - start.getAmt()) + 1; } else { windowSize = end.getAmt() + start.getAmt() + 1; } }
public WindowFrameDef(WindowType windowType, BoundaryDef start, BoundaryDef end) { this.windowType = windowType; this.start = start; this.end = end; // Calculate window size if (start.getDirection() == end.getDirection()) { windowSize = Math.abs(end.getAmt() - start.getAmt()) + 1; } else { windowSize = end.getAmt() + start.getAmt() + 1; } }
private static int getRowBoundaryStart(BoundaryDef b, int currRow) throws HiveException { Direction d = b.getDirection(); int amt = b.getAmt(); switch(d) { case PRECEDING: if (amt == BoundarySpec.UNBOUNDED_AMOUNT) { return 0; } else { return currRow - amt; } case CURRENT: return currRow; case FOLLOWING: return currRow + amt; } throw new HiveException("Unknown Start Boundary Direction: " + d); }
@Override public int computeStart(int rowIdx, PTFPartition p) throws HiveException { switch(start.getDirection()) { case PRECEDING: return computeStartPreceding(rowIdx, p); case CURRENT: return computeStartCurrentRow(rowIdx, p); case FOLLOWING: default: return computeStartFollowing(rowIdx, p); } }
@Override public int computeEnd(int rowIdx, PTFPartition p) throws HiveException { switch(end.getDirection()) { case PRECEDING: return computeEndPreceding(rowIdx, p); case CURRENT: return computeEndCurrentRow(rowIdx, p); case FOLLOWING: default: return computeEndFollowing(rowIdx, p); } }
@Override public int computeEnd(int rowIdx, PTFPartition p) throws HiveException { switch(end.getDirection()) { case PRECEDING: throw new HiveException( "PRECEDING not allowed for finishing RANGE with multiple expressions in ORDER BY"); case CURRENT: return computeEndCurrentRow(rowIdx, p); case FOLLOWING: default: return computeEndFollowing(rowIdx, p); } }
private static int getRowBoundaryStart(BoundaryDef b, int currRow) throws HiveException { Direction d = b.getDirection(); int amt = b.getAmt(); switch(d) { case PRECEDING: if (amt == BoundarySpec.UNBOUNDED_AMOUNT) { return 0; } else { return currRow - amt; } case CURRENT: return currRow; case FOLLOWING: return currRow + amt; } throw new HiveException("Unknown Start Boundary Direction: " + d); }
@Override public int computeStart(int rowIdx, PTFPartition p) throws HiveException { switch(start.getDirection()) { case PRECEDING: return computeStartPreceding(rowIdx, p); case CURRENT: return computeStartCurrentRow(rowIdx, p); case FOLLOWING: default: throw new HiveException( "FOLLOWING not allowed for starting RANGE with multiple expressions in ORDER BY"); } }
@Override public int computeEnd(int rowIdx, PTFPartition p) throws HiveException { switch(end.getDirection()) { case PRECEDING: return computeEndPreceding(rowIdx, p); case CURRENT: return computeEndCurrentRow(rowIdx, p); case FOLLOWING: default: return computeEndFollowing(rowIdx, p); } }
@Override public int computeStart(int rowIdx, PTFPartition p) throws HiveException { switch(start.getDirection()) { case PRECEDING: return computeStartPreceding(rowIdx, p); case CURRENT: return computeStartCurrentRow(rowIdx, p); case FOLLOWING: default: throw new HiveException( "FOLLOWING not allowed for starting RANGE with multiple expressions in ORDER BY"); } }
@Override public int computeStart(int rowIdx, PTFPartition p) throws HiveException { switch(start.getDirection()) { case PRECEDING: return computeStartPreceding(rowIdx, p); case CURRENT: return computeStartCurrentRow(rowIdx, p); case FOLLOWING: default: return computeStartFollowing(rowIdx, p); } }
@Override public int computeEnd(int rowIdx, PTFPartition p) throws HiveException { switch(end.getDirection()) { case PRECEDING: throw new HiveException( "PRECEDING not allowed for finishing RANGE with multiple expressions in ORDER BY"); case CURRENT: return computeEndCurrentRow(rowIdx, p); case FOLLOWING: default: return computeEndFollowing(rowIdx, p); } }
private static int getRowBoundaryEnd(BoundaryDef b, int currRow, PTFPartition p) throws HiveException { Direction d = b.getDirection(); int amt = b.getAmt(); switch(d) { case PRECEDING: if ( amt == 0 ) { return currRow + 1; } return currRow - amt + 1; case CURRENT: return currRow + 1; case FOLLOWING: if (amt == BoundarySpec.UNBOUNDED_AMOUNT) { return p.size(); } else { return currRow + amt + 1; } } throw new HiveException("Unknown End Boundary Direction: " + d); }
private static int getRowBoundaryEnd(BoundaryDef b, int currRow, PTFPartition p) throws HiveException { Direction d = b.getDirection(); int amt = b.getAmt(); switch(d) { case PRECEDING: if ( amt == 0 ) { return currRow + 1; } return currRow - amt + 1; case CURRENT: return currRow + 1; case FOLLOWING: if (amt == BoundarySpec.UNBOUNDED_AMOUNT) { return p.size(); } else { return currRow + amt + 1; } } throw new HiveException("Unknown End Boundary Direction: " + d); }
private boolean canPushLimitToReduceSink(WindowTableFunctionDef wTFn) { for(WindowFunctionDef wFnDef : wTFn.getWindowFunctions() ) { if ( (wFnDef.getWFnEval() instanceof GenericUDAFRankEvaluator) || (wFnDef.getWFnEval() instanceof GenericUDAFDenseRankEvaluator ) || (wFnDef.getWFnEval() instanceof GenericUDAFLeadEvaluator ) ) { continue; } WindowFrameDef wdwFrame = wFnDef.getWindowFrame(); BoundaryDef end = wdwFrame.getEnd(); if (wdwFrame.getWindowType() == WindowType.RANGE) { return false; } if ( end.getDirection() == Direction.FOLLOWING ) { return false; } } return true; }
private boolean canPushLimitToReduceSink(WindowTableFunctionDef wTFn) { for(WindowFunctionDef wFnDef : wTFn.getWindowFunctions() ) { if ( (wFnDef.getWFnEval() instanceof GenericUDAFRankEvaluator) || (wFnDef.getWFnEval() instanceof GenericUDAFDenseRankEvaluator ) || (wFnDef.getWFnEval() instanceof GenericUDAFLeadEvaluator ) ) { continue; } WindowFrameDef wdwFrame = wFnDef.getWindowFrame(); BoundaryDef end = wdwFrame.getEnd(); if (wdwFrame.getWindowType() == WindowType.RANGE) { return false; } if ( end.getDirection() == Direction.FOLLOWING ) { return false; } } return true; }
protected int computeStart(int rowIdx, PTFPartition p) throws HiveException { switch(bndDef.getDirection()) { case PRECEDING: return computeStartPreceding(rowIdx, p); case CURRENT: return computeStartCurrentRow(rowIdx, p); case FOLLOWING: default: return computeStartFollowing(rowIdx, p); } }
protected int computeEnd(int rowIdx, PTFPartition p) throws HiveException { switch(bndDef.getDirection()) { case PRECEDING: return computeEndPreceding(rowIdx, p); case CURRENT: return computeEndCurrentRow(rowIdx, p); case FOLLOWING: default: return computeEndFollowing(rowIdx, p); } }