Code performance readability update for JSON partition constraints.
diff --git a/hyracks/hyracks-api/src/main/java/edu/uci/ics/hyracks/api/job/JobSpecification.java b/hyracks/hyracks-api/src/main/java/edu/uci/ics/hyracks/api/job/JobSpecification.java
index 1b62b2e..128978b 100644
--- a/hyracks/hyracks-api/src/main/java/edu/uci/ics/hyracks/api/job/JobSpecification.java
+++ b/hyracks/hyracks-api/src/main/java/edu/uci/ics/hyracks/api/job/JobSpecification.java
@@ -340,34 +340,18 @@
Iterator<Constraint> test = userConstraints.iterator();
while (test.hasNext()) {
Constraint constraint = test.next();
- String value = "";
- // Right Value
- switch (constraint.getRValue().getTag()) {
- case CONSTANT:
- ConstantExpression ce = (ConstantExpression) constraint.getRValue();
- value = ce.getValue().toString();
- break;
- case PARTITION_COUNT:
- PartitionCountExpression pce = (PartitionCountExpression) constraint.getRValue();
- value = pce.toString();
- break;
- case PARTITION_LOCATION:
- PartitionLocationExpression ple = (PartitionLocationExpression) constraint.getRValue();
- value = ple.toString();
- break;
- }
- // Left Value
switch (constraint.getLValue().getTag()) {
case PARTITION_COUNT:
PartitionCountExpression pce = (PartitionCountExpression) constraint.getLValue();
if (e.getKey() == pce.getOperatorDescriptorId()) {
- pcObject.put("count", value);
+ pcObject.put("count", getConstraintExpressionRValue(constraint));
}
break;
case PARTITION_LOCATION:
PartitionLocationExpression ple = (PartitionLocationExpression) constraint.getLValue();
if (e.getKey() == ple.getOperatorDescriptorId()) {
- pleObject.put(Integer.toString(ple.getPartition()), value);
+ pleObject.put(Integer.toString(ple.getPartition()),
+ getConstraintExpressionRValue(constraint));
}
break;
}
@@ -401,4 +385,14 @@
return jjob;
}
+
+ private static String getConstraintExpressionRValue(Constraint constraint) {
+ switch (constraint.getRValue().getTag()) {
+ case CONSTANT:
+ ConstantExpression ce = (ConstantExpression) constraint.getRValue();
+ return ce.getValue().toString();
+ default:
+ return constraint.getRValue().toString();
+ }
+ }
}
\ No newline at end of file