nserver

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | LICENSE

commit aacbbb88ab9adade60b3b2c18be191add9a1c065
parent e6f4ddb3eba6e475df7796b7a4e2fa2b07df755e
Author: rsiddharth <s@ricketyspace.net>
Date:   Mon,  3 Feb 2020 23:23:37 -0500

nserver/src/protocol.c: Add ssample_parent.

* nserver/src/protocol.c (ssample_parent): New function.

Diffstat:
nserver/src/protocol.c | 22++++++++++++++++++++++
1 file changed, 22 insertions(+), 0 deletions(-)

diff --git a/nserver/src/protocol.c b/nserver/src/protocol.c @@ -74,6 +74,28 @@ int ssdelete(char *key) return -1; } +int ssample_parent(char *key, double s) +{ + check(key != NULL || strlen(key) < 1, "key invalid"); + check(tst != NULL, "tstree not initialized"); + + // 1. Try to get Record with key prefix. + Record *rec = (Record *) TSTree_search_prefix(tst, key, strlen(key)); + + if (rec == NULL) { + // No record with key prefix. + return 0; + } + check(rec->st != NULL, "record's st invalid"); + + // 2. Sample! + Stats_sample(rec->st, s); + + return 1; + error: + return -1; +} + double sssample(char *key, double s) { check(key != NULL || strlen(key) < 1, "key invalid");