Made the JSON output more readable.
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 a0d07a4..1b62b2e 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
@@ -29,6 +29,7 @@
import org.json.JSONObject;
import edu.uci.ics.hyracks.api.constraints.Constraint;
+import edu.uci.ics.hyracks.api.constraints.expressions.ConstantExpression;
import edu.uci.ics.hyracks.api.constraints.expressions.PartitionCountExpression;
import edu.uci.ics.hyracks.api.constraints.expressions.PartitionLocationExpression;
import edu.uci.ics.hyracks.api.dataflow.ConnectorDescriptorId;
@@ -334,27 +335,48 @@
JSONObject op = e.getValue().toJSON();
if (!userConstraints.isEmpty()) {
// Add operator partition constraints to each JSON operator.
+ JSONObject pcObject = new JSONObject();
JSONObject pleObject = new JSONObject();
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()) {
- op.put("partition-count", constraint.getRValue().toString());
+ pcObject.put("count", value);
}
break;
case PARTITION_LOCATION:
PartitionLocationExpression ple = (PartitionLocationExpression) constraint.getLValue();
if (e.getKey() == ple.getOperatorDescriptorId()) {
- pleObject.put(Integer.toString(ple.getPartition()), constraint.getRValue().toString());
+ pleObject.put(Integer.toString(ple.getPartition()), value);
}
break;
}
}
if (pleObject.length() > 0) {
- op.put("partition-location", pleObject);
+ pcObject.put("location", pleObject);
+ }
+ if (pcObject.length() > 0) {
+ op.put("partition-constraints", pcObject);
}
}
jopArray.put(op);