plan,
(Double) lhs.getValue() + (Double) rhs.getValue(),
parent.getFieldSchema());
break;
default:
throw new FrontendException("Invalid type");
}
}
else if (parent instanceof SubtractExpression) {
byte type = parent.getFieldSchema().type;
switch (type) {
case DataType.INTEGER:
newExp = new ConstantExpression(
plan,
(Integer) lhs.getValue() - (Integer) rhs.getValue(),
parent.getFieldSchema());
break;
case DataType.LONG:
newExp = new ConstantExpression(
plan,
(Long) lhs.getValue() - (Long) rhs.getValue(),
parent.getFieldSchema());
break;
case DataType.FLOAT:
newExp = new ConstantExpression(
plan,
(Float) lhs.getValue() - (Float) rhs.getValue(),
parent.getFieldSchema());
break;
case DataType.DOUBLE:
newExp = new ConstantExpression(
plan,
(Double) lhs.getValue() - (Double) rhs.getValue(),
parent.getFieldSchema());
break;
default:
throw new FrontendException("Invalid type");
}
}
else if (parent instanceof MultiplyExpression) {
byte type = parent.getFieldSchema().type;
switch (type) {
case DataType.INTEGER:
newExp = new ConstantExpression(
plan,
(Integer) lhs.getValue() * (Integer) rhs.getValue(),
parent.getFieldSchema());
break;
case DataType.LONG:
newExp = new ConstantExpression(
plan,
(Long) lhs.getValue() * (Long) rhs.getValue(),
parent.getFieldSchema());
break;
case DataType.FLOAT:
newExp = new ConstantExpression(
plan,
(Float) lhs.getValue() * (Float) rhs.getValue(),
parent.getFieldSchema());
break;
case DataType.DOUBLE:
newExp = new ConstantExpression(
plan,
(Double) lhs.getValue() * (Double) rhs.getValue(),
parent.getFieldSchema());
break;
default:
throw new FrontendException("Invalid type");
}
}
else if (parent instanceof ModExpression) {
byte type = parent.getFieldSchema().type;
switch (type) {
case DataType.INTEGER:
newExp = new ConstantExpression(
plan,
(Integer) lhs.getValue() % (Integer) rhs.getValue(),
parent.getFieldSchema());
break;
case DataType.LONG:
newExp = new ConstantExpression(
plan,
(Long) lhs.getValue() % (Long) rhs.getValue(),
parent.getFieldSchema());
break;
default:
throw new FrontendException("Invalid type");
}
}
else if (parent instanceof DivideExpression) {
byte type = parent.getFieldSchema().type;
switch (type) {
case DataType.INTEGER:
if ((Integer) rhs.getValue() != 0)
newExp = new ConstantExpression(
plan,
(Integer) lhs.getValue() / (Integer) rhs.getValue(),
parent.getFieldSchema());
break;
case DataType.LONG:
if ((Long) rhs.getValue() != 0)
newExp = new ConstantExpression(
plan,
(Long) lhs.getValue() / (Long) rhs.getValue(),
parent.getFieldSchema());
break;
case DataType.FLOAT:
if ((Float) rhs.getValue() != 0)
newExp = new ConstantExpression(
plan,
(Float) lhs.getValue() / (Float) rhs.getValue(),
parent.getFieldSchema());
break;
case DataType.DOUBLE:
if ((Double) rhs.getValue() != 0)
newExp = new ConstantExpression(
plan,
(Double) lhs.getValue() / (Double) rhs.getValue(),
parent.getFieldSchema());
break;
default:
throw new FrontendException("Invalid type");
}
}
else throw new FrontendException("Invalid instance type.");
if (newExp != null) {
plan.disconnect(parent, rhs);
plan.remove(rhs);
plan.disconnect(parent, lhs);
plan.remove(lhs);