PItr(int start, int end) { this.idx = start; this.start = start; this.end = end; createTimeSz = PTFPartition.this.size(); }
PItr(int start, int end) { this.idx = start; this.start = start; this.end = end; createTimeSz = PTFPartition.this.size(); }
final void checkForComodification() { if (createTimeSz != PTFPartition.this.size()) { throw new ConcurrentModificationException(); } }
final void checkForComodification() { if (createTimeSz != PTFPartition.this.size()) { throw new ConcurrentModificationException(); } }
ArrayList<Object> executeFnwithWindow( WindowFunctionDef wFnDef, PTFPartition iPart) throws HiveException { ArrayList<Object> vals = new ArrayList<Object>(); for(int i=0; i < iPart.size(); i++) { Object out = evaluateWindowFunction(wFnDef, i, iPart); vals.add(out); } return vals; }
@Override public boolean hasNext() { if ( rnkLimit != null && rnkLimit.limitReached() ) { return false; } return currIdx < iPart.size(); }
public PTFPartitionIterator<Object> range(int start, int end) { assert (start >= 0); assert (end <= size()); assert (start <= end); return new PItr(start, end); }
ArrayList<Object> executeFnwithWindow( WindowFunctionDef wFnDef, PTFPartition iPart) throws HiveException { ArrayList<Object> vals = new ArrayList<Object>(); for(int i=0; i < iPart.size(); i++) { Object out = evaluateWindowFunction(wFnDef, i, iPart); vals.add(out); } return vals; }
public PTFPartitionIterator<Object> range(int start, int end) { assert (start >= 0); assert (end <= size()); assert (start <= end); return new PItr(start, end); }
@Override public boolean hasNext() { if ( rnkLimit != null && rnkLimit.limitReached() ) { return false; } return currIdx < iPart.size(); }
public PTFPartitionIterator<Object> iterator() throws HiveException { elems.first(); return new PItr(0, size()); }
protected int computeEndFollowing(int rowIdx, PTFPartition p) throws HiveException { int amt = end.getAmt(); if ( amt == BoundarySpec.UNBOUNDED_AMOUNT ) { return p.size(); } throw new HiveException( "FOLLOWING needs UNBOUNDED for RANGE with multiple expressions in ORDER BY"); }
protected int computeEndFollowing(int rowIdx, PTFPartition p) throws HiveException { int amt = end.getAmt(); if ( amt == BoundarySpec.UNBOUNDED_AMOUNT ) { return p.size(); } throw new HiveException( "FOLLOWING needs UNBOUNDED for RANGE with multiple expressions in ORDER BY"); }
public PTFPartitionIterator<Object> iterator() throws HiveException { elems.first(); return new PItr(0, size()); }
protected int computeEndCurrentRow(int rowIdx, PTFPartition p) throws HiveException { Object[] sortKey = computeValues(p.getAt(rowIdx)); Object[] rowVal = sortKey; int r = rowIdx; while (r < p.size() && isEqual(sortKey, rowVal) ) { r++; if ( r < p.size() ) { rowVal = computeValues(p.getAt(r)); } } return r; }
protected int computeEndCurrentRow(int rowIdx, PTFPartition p) throws HiveException { Object sortKey = computeValue(p.getAt(rowIdx)); // Use Case 6. if ( sortKey == null ) { while ( sortKey == null && rowIdx < p.size() ) { ++rowIdx; if ( rowIdx < p.size() ) { sortKey = computeValue(p.getAt(rowIdx)); } } return rowIdx; } Object rowVal = sortKey; int r = rowIdx; // Use Case 7. while (r < p.size() && isEqual(sortKey, rowVal) ) { r++; if ( r < p.size() ) { rowVal = computeValue(p.getAt(r)); } } return r; }
protected int computeEndCurrentRow(int rowIdx, PTFPartition p) throws HiveException { Object[] sortKey = computeValues(p.getAt(rowIdx)); Object[] rowVal = sortKey; int r = rowIdx; while (r < p.size() && isEqual(sortKey, rowVal) ) { r++; if ( r < p.size() ) { rowVal = computeValues(p.getAt(r)); } } return r; }
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); }
protected static Range getRange(WindowFrameDef winFrame, int currRow, PTFPartition p, boolean nullsLast) throws HiveException { BoundaryDef startB = winFrame.getStart(); BoundaryDef endB = winFrame.getEnd(); int start, end; if (winFrame.getWindowType() == WindowType.ROWS) { start = getRowBoundaryStart(startB, currRow); end = getRowBoundaryEnd(endB, currRow, p); } else { ValueBoundaryScanner vbs = ValueBoundaryScanner.getScanner(winFrame, nullsLast); start = vbs.computeStart(currRow, p); end = vbs.computeEnd(currRow, p); } start = start < 0 ? 0 : start; end = end > p.size() ? p.size() : end; return new Range(start, end, p); }
protected static Range getRange(WindowFrameDef winFrame, int currRow, PTFPartition p) throws HiveException { BoundaryDef startB = winFrame.getStart(); BoundaryDef endB = winFrame.getEnd(); int start, end; if (winFrame.getWindowType() == WindowType.ROWS) { start = getRowBoundaryStart(startB, currRow); end = getRowBoundaryEnd(endB, currRow, p); } else { ValueBoundaryScanner vbs = ValueBoundaryScanner.getScanner(winFrame); start = vbs.computeStart(currRow, p); end = vbs.computeEnd(currRow, p); } start = start < 0 ? 0 : start; end = end > p.size() ? p.size() : end; return new Range(start, end, p); }