public State(AggregationBuffer buf) { super(buf); maxChain = new ArrayDeque<Object[]>(wFrameDef.isStartUnbounded() ? 1 : wFrameDef.getWindowSize()); }
public State(AggregationBuffer buf) { super(buf); valueChain = new ArrayDeque<ValIndexPair>(wFrameDef.isStartUnbounded() ? 1 : wFrameDef.getWindowSize()); }
public State(AggregationBuffer buf) { super(buf); maxChain = new ArrayDeque<Object[]>(wFrameDef.isStartUnbounded() ? 1 : wFrameDef.getWindowSize()); }
public State(AggregationBuffer buf) { super(buf); valueChain = new ArrayDeque<ValIndexPair>(wFrameDef.isStartUnbounded() ? 1 : wFrameDef.getWindowSize()); }
@Override public int estimate() { if (!(wrappedBuf instanceof AbstractAggregationBuffer)) { return -1; } int underlying = ((AbstractAggregationBuffer) wrappedBuf).estimate(); if (underlying == -1) { return -1; } if (wFrameDef.isStartUnbounded()) { return -1; } /* * sz Estimate = sz needed by underlying AggBuffer + sz for results + sz * for maxChain + 3 * JavaDataModel.PRIMITIVES1 sz of results = sz of * underlying * wdwSz sz of maxChain = sz of underlying * wdwSz */ int wdwSz = wFrameDef.getWindowSize(); return underlying + (underlying * wdwSz) + (underlying * wdwSz) + (3 * JavaDataModel.PRIMITIVES1); }
@Override public int estimate() { if (!(wrappedBuf instanceof AbstractAggregationBuffer)) { return -1; } int underlying = ((AbstractAggregationBuffer) wrappedBuf).estimate(); if (underlying == -1) { return -1; } if (wFrameDef.isStartUnbounded()) { return -1; } /* * sz Estimate = sz needed by underlying AggBuffer + sz for results + sz * for maxChain + 3 * JavaDataModel.PRIMITIVES1 sz of results = sz of * underlying * wdwSz sz of maxChain = sz of underlying * wdwSz */ int wdwSz = wFrameDef.getWindowSize(); return underlying + (underlying * wdwSz) + (underlying * wdwSz) + (3 * JavaDataModel.PRIMITIVES1); }
@Override public int estimate() { if (!(wrappedBuf instanceof AbstractAggregationBuffer)) { return -1; } int underlying = ((AbstractAggregationBuffer) wrappedBuf).estimate(); if (underlying == -1) { return -1; } if (wFrameDef.isStartUnbounded()) { return -1; } /* * sz Estimate = sz needed by underlying AggBuffer + sz for results + sz * for maxChain + 3 * JavaDataModel.PRIMITIVES1 sz of results = sz of * underlying * wdwSz sz of maxChain = sz of underlying * wdwSz */ int wdwSz = wFrameDef.getWindowSize(); return underlying + (underlying * wdwSz) + (underlying * wdwSz) + (3 * JavaDataModel.PRIMITIVES1); }
@Override public int estimate() { if (!(wrappedBuf instanceof AbstractAggregationBuffer)) { return -1; } int underlying = ((AbstractAggregationBuffer) wrappedBuf).estimate(); if (underlying == -1) { return -1; } if (wFrameDef.isStartUnbounded()) { return -1; } /* * sz Estimate = sz needed by underlying AggBuffer + sz for results + sz * for maxChain + 3 * JavaDataModel.PRIMITIVES1 sz of results = sz of * underlying * wdwSz sz of maxChain = sz of underlying * wdwSz */ int wdwSz = wFrameDef.getWindowSize(); return underlying + (underlying * wdwSz) + (underlying * wdwSz) + (3 * JavaDataModel.PRIMITIVES1); }
@Override public Object terminate(AggregationBuffer agg) throws HiveException { State s = (State) agg; Object[] r = s.maxChain.isEmpty() ? null : s.maxChain.getFirst(); // After all the rows are processed, continue to generate results for the rows that results haven't generated. // For the case: X following and Y following, process first Y-X results and then insert X nulls. // For the case X preceding and Y following, process Y results. for (int i = Math.max(0, wFrameDef.getStart().getRelativeOffset()); i < wFrameDef.getEnd().getRelativeOffset(); i++) { if (s.hasResultReady()) { s.results.add(r == null ? null : r[0]); } s.numRows++; if (r != null) { int fIdx = (Integer) r[1]; if (!wFrameDef.isStartUnbounded() && s.numRows >= fIdx + wFrameDef.getWindowSize() && !s.maxChain.isEmpty()) { s.maxChain.removeFirst(); r = !s.maxChain.isEmpty() ? s.maxChain.getFirst() : null; } } } for (int i = 0; i < wFrameDef.getStart().getRelativeOffset(); i++) { if (s.hasResultReady()) { s.results.add(null); } s.numRows++; } return null; }
&& s.numRows >= fIdx + wFrameDef.getWindowSize()) { s.maxChain.removeFirst();
@Override public Object terminate(AggregationBuffer agg) throws HiveException { State s = (State) agg; ValIndexPair r = s.valueChain.size() == 0 ? null : s.valueChain.getFirst(); // After all the rows are processed, continue to generate results for the rows that results haven't generated. // For the case: X following and Y following, process first Y-X results and then insert X nulls. // For the case X preceding and Y following, process Y results. for (int i = Math.max(0, wFrameDef.getStart().getRelativeOffset()); i < wFrameDef.getEnd().getRelativeOffset(); i++) { if (s.hasResultReady()) { s.results.add(r == null ? null : r.val); } s.numRows++; if (r != null) { int fIdx = (Integer) r.idx; if (!wFrameDef.isStartUnbounded() && s.numRows >= fIdx + wFrameDef.getWindowSize() && !s.valueChain.isEmpty()) { s.valueChain.removeFirst(); r = !s.valueChain.isEmpty() ? s.valueChain.getFirst() : r; } } } for (int i = 0; i < wFrameDef.getStart().getRelativeOffset(); i++) { if (s.hasResultReady()) { s.results.add(null); } s.numRows++; } return null; }
&& s.numRows >= fIdx + wFrameDef.getWindowSize()) { s.maxChain.removeFirst();
@Override public Object terminate(AggregationBuffer agg) throws HiveException { State s = (State) agg; ValIndexPair r = s.valueChain.size() == 0 ? null : s.valueChain.getFirst(); // After all the rows are processed, continue to generate results for the rows that results haven't generated. // For the case: X following and Y following, process first Y-X results and then insert X nulls. // For the case X preceding and Y following, process Y results. for (int i = Math.max(0, wFrameDef.getStart().getRelativeOffset()); i < wFrameDef.getEnd().getRelativeOffset(); i++) { if (s.hasResultReady()) { s.results.add(r == null ? null : r.val); } s.numRows++; if (r != null) { int fIdx = (Integer) r.idx; if (!wFrameDef.isStartUnbounded() && s.numRows >= fIdx + wFrameDef.getWindowSize() && !s.valueChain.isEmpty()) { s.valueChain.removeFirst(); r = !s.valueChain.isEmpty() ? s.valueChain.getFirst() : r; } } } for (int i = 0; i < wFrameDef.getStart().getRelativeOffset(); i++) { if (s.hasResultReady()) { s.results.add(null); } s.numRows++; } return null; }
@Override public Object terminate(AggregationBuffer agg) throws HiveException { State s = (State) agg; Object[] r = s.maxChain.isEmpty() ? null : s.maxChain.getFirst(); // After all the rows are processed, continue to generate results for the rows that results haven't generated. // For the case: X following and Y following, process first Y-X results and then insert X nulls. // For the case X preceding and Y following, process Y results. for (int i = Math.max(0, wFrameDef.getStart().getRelativeOffset()); i < wFrameDef.getEnd().getRelativeOffset(); i++) { if (s.hasResultReady()) { s.results.add(r == null ? null : r[0]); } s.numRows++; if (r != null) { int fIdx = (Integer) r[1]; if (!wFrameDef.isStartUnbounded() && s.numRows >= fIdx + wFrameDef.getWindowSize() && !s.maxChain.isEmpty()) { s.maxChain.removeFirst(); r = !s.maxChain.isEmpty() ? s.maxChain.getFirst() : null; } } } for (int i = 0; i < wFrameDef.getStart().getRelativeOffset(); i++) { if (s.hasResultReady()) { s.results.add(null); } s.numRows++; } return null; }
int fIdx = (Integer) s.valueChain.getFirst().idx; if (!wFrameDef.isStartUnbounded() && s.numRows >= fIdx + wFrameDef.getWindowSize()) { s.valueChain.removeFirst();
int fIdx = (Integer) s.valueChain.getFirst().idx; if (!wFrameDef.isStartUnbounded() && s.numRows >= fIdx + wFrameDef.getWindowSize()) { s.valueChain.removeFirst();
@Override public Object terminate(AggregationBuffer agg) throws HiveException { State s = (State) agg; LastValueBuffer lb = (LastValueBuffer) s.wrappedBuf; if (lb.skipNulls && s.lastIdx != -1) { if (!wFrameDef.isStartUnbounded() && s.numRows >= s.lastIdx + wFrameDef.getWindowSize()) { s.lastValue = null; s.lastIdx = -1; } } // After all the rows are processed, continue to generate results for the rows that results haven't generated. // For the case: X following and Y following, process first Y-X results and then insert X nulls. // For the case X preceding and Y following, process Y results. for (int i = Math.max(0, wFrameDef.getStart().getRelativeOffset()); i < wFrameDef.getEnd().getRelativeOffset(); i++) { if (s.hasResultReady()) { s.results.add(s.lastValue); } s.numRows++; } for (int i = 0; i < wFrameDef.getStart().getRelativeOffset(); i++) { if (s.hasResultReady()) { s.results.add(null); } s.numRows++; } return null; }
} else if (lb.skipNulls && s.lastIdx != -1) { if (!wFrameDef.isStartUnbounded() && s.numRows >= s.lastIdx + wFrameDef.getWindowSize()) { s.lastValue = null; s.lastIdx = -1;
@Override public Object terminate(AggregationBuffer agg) throws HiveException { State s = (State) agg; LastValueBuffer lb = (LastValueBuffer) s.wrappedBuf; if (lb.skipNulls && s.lastIdx != -1) { if (!wFrameDef.isStartUnbounded() && s.numRows >= s.lastIdx + wFrameDef.getWindowSize()) { s.lastValue = null; s.lastIdx = -1; } } // After all the rows are processed, continue to generate results for the rows that results haven't generated. // For the case: X following and Y following, process first Y-X results and then insert X nulls. // For the case X preceding and Y following, process Y results. for (int i = Math.max(0, wFrameDef.getStart().getRelativeOffset()); i < wFrameDef.getEnd().getRelativeOffset(); i++) { if (s.hasResultReady()) { s.results.add(s.lastValue); } s.numRows++; } for (int i = 0; i < wFrameDef.getStart().getRelativeOffset(); i++) { if (s.hasResultReady()) { s.results.add(null); } s.numRows++; } return null; }
} else if (lb.skipNulls && s.lastIdx != -1) { if (!wFrameDef.isStartUnbounded() && s.numRows >= s.lastIdx + wFrameDef.getWindowSize()) { s.lastValue = null; s.lastIdx = -1;