diff --git a/src/contacts.c b/src/contacts.c index 77af3e9..3296db7 100644 --- a/src/contacts.c +++ b/src/contacts.c @@ -59,7 +59,7 @@ int get_number_of_infected_for_multiple_intervals(infected_for_period_key_ctx_t* for (int i = 0; i < count; i++) { int rc = ens_records_iterator_init_timerange(&iterator, &ctx[i].search_start, &ctx[i].search_end); if (rc) { - return rc; + continue; } while (!iterator.finished) { if (memcmp(&iterator.current.rolling_proximity_identifier, &ctx[i].interval_identifier, @@ -85,7 +85,7 @@ void setup_test_data() { en_derive_period_identifier_key(&dummyPik, &dummyPeriodKey); for (int i = 0; i < EN_TEK_ROLLING_PERIOD; i++) { - // create infected record which + // create infected record record_t infectedRecord; infectedRecord.timestamp = i * EN_INTERVAL_LENGTH; en_derive_interval_identifier((ENIntervalIdentifier*)&infectedRecord.rolling_proximity_identifier, &infectedPik, @@ -93,10 +93,8 @@ void setup_test_data() { record_t dummyRecord; en_derive_interval_identifier((ENIntervalIdentifier*)&dummyRecord.rolling_proximity_identifier, &dummyPik, i); int rc; - if (i % 3 == 0) { - if ((rc = add_record(&infectedRecord))) { - printk("err %d\n", rc); - } + if ((rc = add_record(&infectedRecord))) { + printk("err %d\n", rc); } int spread = 4; @@ -110,6 +108,20 @@ void setup_test_data() { printk("period %d\n", i); } + // setup our ordered array with infected RPIs + infected_for_period_key_ctx_t infectedIntervals[10]; + for (int i = 0; i < 10; i++) { + int intervalNumber = (i + 2) * 2; + float offset = 1.5; + infectedIntervals[i].infected = 0; + infectedIntervals[i].search_start = + (intervalNumber - offset) * EN_INTERVAL_LENGTH; // start one and a half interval before + infectedIntervals[i].search_end = + (intervalNumber + offset) * EN_INTERVAL_LENGTH; // end one and a half interval after + en_derive_interval_identifier((ENIntervalIdentifier*)&infectedIntervals[i].interval_identifier, &infectedPik, + intervalNumber); + } + printk("starting measurement\n"); timing_t start_time, end_time; @@ -120,10 +132,14 @@ void setup_test_data() { timing_start(); start_time = timing_counter_get(); - // printk("found %d infected\n", get_number_of_infected_for_period(&infectedPeriodKey, 200)); + get_number_of_infected_for_multiple_intervals(infectedIntervals, 10); end_time = timing_counter_get(); + for (int i = 0; i < 10; i++) { + printk("ctx: %d infected: %d\n", i, infectedIntervals[i].infected); + } + total_cycles = timing_cycles_get(&start_time, &end_time); total_ns = timing_cycles_to_ns(total_cycles); diff --git a/src/contacts.h b/src/contacts.h index fc7ffa6..3aaa0ac 100644 --- a/src/contacts.h +++ b/src/contacts.h @@ -16,7 +16,7 @@ #include "exposure-notification.h" typedef struct infected_for_period_key_ctx { - ENIntervalIdentifier* interval_identifier; + ENIntervalIdentifier interval_identifier; int infected; time_t search_start; time_t search_end; @@ -48,7 +48,6 @@ int get_number_of_infected_for_period(ENPeriodKey* key, time_t timestamp); * Get the number of infected records for multiple IntervalIdentifier. * * @param ctx array of period keys and timestamps with field "infected" for the number of infected records - * @param timestamp the timestamp of the period * @param count the number of periods in the array * * @returns 0 in case of success, -ERRNO in case of an error diff --git a/src/main.c b/src/main.c index 1f3250e..846c0a9 100644 --- a/src/main.c +++ b/src/main.c @@ -47,7 +47,7 @@ void main(void) { printk("init storage failed (err %d)\n", err); return; } - // setup_test_data(); + setup_test_data(); #endif err = bloom_init();