[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [onionoo/master] Also include somewhat redundant graph histories.
commit 59085fc5ad183bf7671e2bef5e066f737e8625b3
Author: Karsten Loesing <karsten.loesing@xxxxxxx>
Date: Sun Jan 19 11:13:19 2020 +0100
Also include somewhat redundant graph histories.
Fixes #28871.
---
CHANGELOG.md | 7 ++++++-
.../onionoo/writer/GraphHistoryCompiler.java | 23 ++++++++++++----------
2 files changed, 19 insertions(+), 11 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fce8f43..c4f9c30 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,4 +1,9 @@
-# Changes in version 7.?-1.??-? - 2020-??-??
+# Changes in version 8.0-1.2?.? - 20??-??-??
+
+ * Major changes
+ - Include graph history objects even if the time period they cover
+ are already contained in other graph history objects with shorter
+ time periods and higher data resolutions.
# Changes in version 7.1-1.24.1 - 2020-02-14
diff --git a/src/main/java/org/torproject/metrics/onionoo/writer/GraphHistoryCompiler.java b/src/main/java/org/torproject/metrics/onionoo/writer/GraphHistoryCompiler.java
index ae5231f..a9227bb 100644
--- a/src/main/java/org/torproject/metrics/onionoo/writer/GraphHistoryCompiler.java
+++ b/src/main/java/org/torproject/metrics/onionoo/writer/GraphHistoryCompiler.java
@@ -125,11 +125,18 @@ public class GraphHistoryCompiler {
/* Iterate over all history entries and see which ones we need for this
* graph. */
+ boolean compileNextGraph = false;
for (Map.Entry<long[], Double> h : this.history.entrySet()) {
long startMillis = h.getKey()[0];
long endMillis = h.getKey()[1];
double value = h.getValue();
+ /* If the history entry starts before this graph starts, remember that
+ * we'll have to compile the next graph. */
+ if (startMillis <= graphStartMillis) {
+ compileNextGraph = true;
+ }
+
/* If a history entry ends before this graph starts or starts before
* this graph ends, skip it. */
if (endMillis <= graphStartMillis || startMillis >= graphEndMillis) {
@@ -211,16 +218,6 @@ public class GraphHistoryCompiler {
long firstDataPointMillis = graphStartMillis + firstNonNullIndex
* dataPointInterval + dataPointInterval / 2L;
- /* If the graph doesn't contain anything new that wasn't already contained
- * in previously compiled graphs, skip this graph. */
- if (graphIntervalIndex > 0 && !graphs.isEmpty()
- && firstDataPointMillis >= LocalDateTime.ofEpochSecond(
- graphEndMillis / 1000L, 0, ZoneOffset.UTC)
- .minus(this.graphIntervals.get(graphIntervalIndex - 1))
- .toEpochSecond(ZoneOffset.UTC) * 1000L) {
- continue;
- }
-
/* Put together the list of values that will go into the graph. */
List<Integer> values = new ArrayList<>();
for (int dataPointIndex = firstNonNullIndex;
@@ -245,6 +242,12 @@ public class GraphHistoryCompiler {
graphHistory.setCount(lastNonNullIndex - firstNonNullIndex + 1);
graphHistory.setValues(values);
graphs.put(graphName, graphHistory);
+
+ /* If all history entries ended after this graph started, stop compiling
+ * more graphs for this history. */
+ if (!compileNextGraph) {
+ break;
+ }
}
/* We're done. Return the map of compiled graphs. */
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits