summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nserver/src/protocol.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/nserver/src/protocol.c b/nserver/src/protocol.c
index 0872bdb..213179a 100644
--- 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");