summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2023-10-13 17:27:58 +0200
committerLeah Neukirchen <leah@vuxu.org>2023-10-13 17:27:58 +0200
commitc20301e5803d84dd097ab0f5f309889854f4120b (patch)
treef1f94d8ece6c09807522589f01d37fadbc4263f1
parentc4d638581aa4a9cfa4b622ce8547b6fc98896bd1 (diff)
downloadmico-c20301e5803d84dd097ab0f5f309889854f4120b.tar.gz
mico-c20301e5803d84dd097ab0f5f309889854f4120b.tar.xz
mico-c20301e5803d84dd097ab0f5f309889854f4120b.zip
explicitly store time series length
-rw-r--r--mico-dump.c15
-rw-r--r--mico-store.c3
2 files changed, 15 insertions, 3 deletions
diff --git a/mico-dump.c b/mico-dump.c
index ce13a3e..37ed025 100644
--- a/mico-dump.c
+++ b/mico-dump.c
@@ -1,6 +1,7 @@
 #include <assert.h>
 #include <stdint.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 
 #include <zip.h>
@@ -105,9 +106,17 @@ main()
 		int64_t t = 0, td = 0;
 		double v = 0.0;
 
-		while (!ts.eof) {
-			int32_t tdd = get1(&ts);
-			int32_t vd = get1(&vs);
+		int64_t len = get1(&ts);
+		int64_t lenv = get1(&vs);
+
+		if (len != lenv) {
+			fprintf(stderr, "time and value length don't agree");
+			exit(-1);
+		}
+
+		for (int64_t j = 0; j < len; j++) {
+			int64_t tdd = get1(&ts);
+			int64_t vd = get1(&vs);
 
 			td += tdd;
 			t += td;
diff --git a/mico-store.c b/mico-store.c
index f2dd221..b39c258 100644
--- a/mico-store.c
+++ b/mico-store.c
@@ -178,6 +178,9 @@ main()
 		int64_t t, pt = 0, ppt = 0;
 		double v, pv = 0.0;
 
+		put1(&ts, arrlen(metrics[m].value));
+		put1(&vs, arrlen(metrics[m].value));
+
 		for (ssize_t i = 0; i < arrlen(metrics[m].value); i++) {
 			t = metrics[m].value[i].t;
 			v = metrics[m].value[i].v;