[tor-commits] [onionoo/master] Fix compressing bandwidth and weights histories.
karsten at torproject.org
karsten at torproject.org
Tue Mar 11 07:53:28 UTC 2014
commit b8db05c28eeaec8b69a4bc63c1df12d2191b36ae
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date: Thu Mar 6 16:13:21 2014 +0100
Fix compressing bandwidth and weights histories.
We compress histories by merging adjacent intervals to save disk space,
unless we want intervals to stay distinct. For example, we might want to
compress all intervals on the same UTC day but not want to merge intervals
with the previous or next UTC day. However, we had an off-by-one error
which made us merge the wrong intervals. For example, we merged intervals
from 23:00:00 on one day to 23:00:00 the next day.
---
src/org/torproject/onionoo/BandwidthDataWriter.java | 4 ++--
src/org/torproject/onionoo/WeightsDataWriter.java | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/org/torproject/onionoo/BandwidthDataWriter.java b/src/org/torproject/onionoo/BandwidthDataWriter.java
index 4291bdd..68bf59a 100644
--- a/src/org/torproject/onionoo/BandwidthDataWriter.java
+++ b/src/org/torproject/onionoo/BandwidthDataWriter.java
@@ -196,8 +196,8 @@ public class BandwidthDataWriter implements DataWriter,
intervalLengthMillis = 10L * 24L * 60L * 60L * 1000L;
}
if (lastEndMillis == startMillis &&
- (lastEndMillis / intervalLengthMillis) ==
- (endMillis / intervalLengthMillis)) {
+ ((lastEndMillis - 1L) / intervalLengthMillis) ==
+ ((endMillis - 1L) / intervalLengthMillis)) {
lastEndMillis = endMillis;
lastBandwidth += bandwidth;
} else {
diff --git a/src/org/torproject/onionoo/WeightsDataWriter.java b/src/org/torproject/onionoo/WeightsDataWriter.java
index 40c85ed..81b412c 100644
--- a/src/org/torproject/onionoo/WeightsDataWriter.java
+++ b/src/org/torproject/onionoo/WeightsDataWriter.java
@@ -387,8 +387,8 @@ public class WeightsDataWriter implements DataWriter, DescriptorListener {
intervalLengthMillis = 10L * 24L * 60L * 60L * 1000L;
}
if (lastEndMillis == startMillis &&
- (lastEndMillis / intervalLengthMillis) ==
- (endMillis / intervalLengthMillis)) {
+ ((lastEndMillis - 1L) / intervalLengthMillis) ==
+ ((endMillis - 1L) / intervalLengthMillis)) {
double lastIntervalInHours = (double) ((lastEndMillis
- lastStartMillis) / 60L * 60L * 1000L);
double currentIntervalInHours = (double) ((endMillis
More information about the tor-commits
mailing list