Skip to content
Snippets Groups Projects
Commit 77ba04e7 authored by Reiner Jung's avatar Reiner Jung
Browse files

Updated sort order in json files.

parent f7e0fb75
No related branches found
No related tags found
No related merge requests found
package moobench.tools.results.data;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
public class Chart {
final String name;
final List<String> headers = new ArrayList<>();
final List<ValueTuple> values = new ArrayList<ValueTuple>();
public Chart(String name) {
this.name = name;
}
public String getName() {
return name;
}
public List<String> getHeaders() {
return headers;
}
public List<ValueTuple> getValues() {
return values;
}
final String name;
final List<String> headers = new ArrayList<>();
final List<ValueTuple> values = new ArrayList<ValueTuple>();
public Chart(final String name) {
this.name = name;
}
public String getName() {
return this.name;
}
public List<String> getHeaders() {
return this.headers;
}
public List<ValueTuple> getValues() {
return this.values;
}
public void sort() {
Collections.sort(this.values, new Comparator<ValueTuple>() {
@Override
public int compare(final ValueTuple left, final ValueTuple right) {
if (left.getTimestamp() < right.getTimestamp()) {
return -1;
} else if (left.getTimestamp() > right.getTimestamp()) {
return 1;
} else {
return 0;
}
}
});
}
}
......@@ -4,20 +4,20 @@ import java.util.ArrayList;
import java.util.List;
public class ValueTuple {
long timestamp;
List<Double> values = new ArrayList<>();
public ValueTuple(long timestamp) {
this.timestamp = timestamp;
}
public long getTimestamp() {
return timestamp;
}
public List<Double> getValues() {
return values;
}
private final long timestamp;
List<Double> values = new ArrayList<>();
public ValueTuple(final long timestamp) {
this.timestamp = timestamp;
}
public long getTimestamp() {
return this.timestamp;
}
public List<Double> getValues() {
return this.values;
}
}
......@@ -28,7 +28,10 @@ public class JsonChartSink extends AbstractConsumerStage<Chart> {
final ObjectNode node = mapper.createObjectNode();
final ArrayNode arrayNode = node.putArray("results");
chart.sort();
for(final ValueTuple value : chart.getValues()) {
System.err.printf("time %d\n", value.getTimestamp());
final ObjectNode objectNode = mapper.createObjectNode();
for (int i = 0;i < chart.getHeaders().size();i++) {
final String name = chart.getHeaders().get(i);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment