From 2dde0202c5590eeb051c1346f2b66293d83b87ce Mon Sep 17 00:00:00 2001 From: David Barksdale Date: Sun, 19 Mar 2017 15:55:32 -0500 Subject: [datastore] Fix #3743 This change adds support for key == NULL to the datastore plugins and replaces the offset argument with a next_uid and random arguments to increase performance in the key == NULL case. With the offset argument a datastore plugin would have to count all matching keys before fetching the key at the right offset, which would iterate over the entire database in the case of key == NULL. The offset argument was used in two ways: to iterate over a set of matching values and to start iteration at a random matching value. The new API seperates these into two arguments: if random is true it will return a random matching value, otherwise next_uid can be set to uid + 1 to return the next matching value. The random argument was not added to get_zero_anonymity. This function is used to periodically insert zero anonymity values into the DHT. I don't think it's necessary to randomize this. --- src/datastore/test_datastore_api_management.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'src/datastore/test_datastore_api_management.c') diff --git a/src/datastore/test_datastore_api_management.c b/src/datastore/test_datastore_api_management.c index 9a3e5446bf..de4dc657ff 100644 --- a/src/datastore/test_datastore_api_management.c +++ b/src/datastore/test_datastore_api_management.c @@ -58,7 +58,6 @@ struct CpsRunContext const struct GNUNET_CONFIGURATION_Handle *cfg; void *data; enum RunPhase phase; - uint64_t offset; }; @@ -159,7 +158,6 @@ check_value (void *cls, const struct GNUNET_HashCode * key, size_t size, GNUNET_assert (priority == get_priority (i)); GNUNET_assert (anonymity == get_anonymity (i)); GNUNET_assert (expiration.abs_value_us == get_expiration (i).abs_value_us); - crc->offset++; crc->i--; if (crc->i == 0) crc->phase = RP_DONE; @@ -221,8 +219,13 @@ run_continuation (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "GET", crc->i); GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); - GNUNET_DATASTORE_get_key (datastore, crc->offset++, &crc->key, - get_type (crc->i), 1, 1, + GNUNET_DATASTORE_get_key (datastore, + 0, + false, + &crc->key, + get_type (crc->i), + 1, + 1, &check_value, crc); break; @@ -230,8 +233,13 @@ run_continuation (void *cls) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Executing `%s' number %u\n", "GET(f)", crc->i); GNUNET_CRYPTO_hash (&crc->i, sizeof (int), &crc->key); - GNUNET_DATASTORE_get_key (datastore, crc->offset++, &crc->key, - get_type (crc->i), 1, 1, + GNUNET_DATASTORE_get_key (datastore, + 0, + false, + &crc->key, + get_type (crc->i), + 1, + 1, &check_nothing, crc); break; -- cgit v1.2.3-70-g09d2