use of org.apache.hadoop.hive.ql.parse.WindowingSpec.Direction in project hive by apache.
the class BasePartitionEvaluator method getRowBoundaryEnd.
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);
}
use of org.apache.hadoop.hive.ql.parse.WindowingSpec.Direction in project hive by apache.
the class BasePartitionEvaluator method getRowBoundaryStart.
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);
}
use of org.apache.hadoop.hive.ql.parse.WindowingSpec.Direction in project hive by apache.
the class ExprNodeConverter method getWindowBound.
private BoundarySpec getWindowBound(RexWindowBound wb) {
BoundarySpec boundarySpec;
if (wb.isCurrentRow()) {
boundarySpec = new BoundarySpec(Direction.CURRENT);
} else {
final Direction direction;
final int amt;
if (wb.isPreceding()) {
direction = Direction.PRECEDING;
} else {
direction = Direction.FOLLOWING;
}
if (wb.isUnbounded()) {
amt = BoundarySpec.UNBOUNDED_AMOUNT;
} else {
amt = RexLiteral.intValue(wb.getOffset());
}
boundarySpec = new BoundarySpec(direction, amt);
}
return boundarySpec;
}
Aggregations