} while (isOperand);
Expression e;
//Verify the operand number
if (functionIdx.intValue() > 0 && functionIdx.intValue() < 10) {
if (operands.size() != 1) {
throw new SpeedoException(
"Bad number of operand for the function "
+ getFunctionAsString(functionIdx
.intValue())
+ ", expected 1 operand, found "
+ operands.size());
}
}
//instanciate the medor Operator corresponding to the function
Object operand = operands.get(0);
if (operand instanceof Expression) {
e = (Expression) operand;
} else if (operand instanceof Field) {
e = new BasicFieldOperand((Field) operand);
} else {
throw new SpeedoException("Unexpect operand: " + operand);
}
getFieldsFromExpression(e, groupedFields);
hasAggregate = true;
switch (functionIdx.intValue() / 2) {
case 0:
e = new Count(e, distinctOnOperand);
break;
case 1:
e = new Sum(e, distinctOnOperand);
break;
case 2:
e = new Min(e, distinctOnOperand);
break;
case 3:
e = new Max(e, distinctOnOperand);
break;
case 4:
e = new Avg(e, distinctOnOperand);
break;
default:
throw new SpeedoException("Unknown function identifier: "
+ functionIdx.intValue());
}
stack.push(e);
}