From: Sebastian Harl Date: Wed, 20 May 2015 08:34:27 +0000 (+0200) Subject: store: Add the timeseries field to metrics. X-Git-Tag: sysdb-0.8.0~75 X-Git-Url: https://git.tokkee.org/?p=sysdb.git;a=commitdiff_plain;h=bbd1b997cf153d54878efebc182bd88f1c64d45c store: Add the timeseries field to metrics. This is a boolean field that specifies whether a timeseries for the metric is known to SysDB. --- diff --git a/src/core/store.c b/src/core/store.c index eb58ad8..bf12a93 100644 --- a/src/core/store.c +++ b/src/core/store.c @@ -946,6 +946,11 @@ sdb_store_get_field(sdb_store_obj_t *obj, int field, sdb_data_t *res) if (! res) return 0; return sdb_data_copy(res, &ATTR(obj)->value); + case SDB_FIELD_TIMESERIES: + if (obj->type != SDB_METRIC) + return -1; + tmp.type = SDB_TYPE_BOOLEAN; + tmp.data.boolean = METRIC(obj)->store.type != NULL; default: return -1; } diff --git a/src/core/store_expr.c b/src/core/store_expr.c index 6e39305..80c1f4a 100644 --- a/src/core/store_expr.c +++ b/src/core/store_expr.c @@ -167,7 +167,7 @@ sdb_store_expr_fieldvalue(int field) sdb_data_t value = { SDB_TYPE_INTEGER, { .integer = field } }; sdb_store_expr_t *e; - if ((field < SDB_FIELD_NAME) || (SDB_FIELD_VALUE < field)) + if ((field < SDB_FIELD_NAME) || (SDB_FIELD_TIMESERIES < field)) return NULL; e = SDB_STORE_EXPR(sdb_object_create("store-fieldvalue", expr_type, FIELD_VALUE, NULL, NULL, &value)); diff --git a/src/include/core/store.h b/src/include/core/store.h index c051252..c52299e 100644 --- a/src/include/core/store.h +++ b/src/include/core/store.h @@ -62,6 +62,7 @@ enum { SDB_FIELD_INTERVAL, /* type: datetime */ SDB_FIELD_BACKEND, /* type: array of strings */ SDB_FIELD_VALUE, /* attributes only; type: type of the value */ + SDB_FIELD_TIMESERIES, /* metrics only; type: boolean */ }; #define SDB_STORE_TYPE_TO_NAME(t) \ (((t) == SDB_HOST) ? "host" \ @@ -80,6 +81,7 @@ enum { : ((f) == SDB_FIELD_INTERVAL) ? "interval" \ : ((f) == SDB_FIELD_BACKEND) ? "backend" \ : ((f) == SDB_FIELD_VALUE) ? "value" \ + : ((f) == SDB_FIELD_TIMESERIES) ? "timeseries" \ : "unknown") #define SDB_FIELD_TYPE(f) \ @@ -89,6 +91,7 @@ enum { : ((f) == SDB_FIELD_INTERVAL) ? SDB_TYPE_DATETIME \ : ((f) == SDB_FIELD_BACKEND) ? (SDB_TYPE_ARRAY | SDB_TYPE_STRING) \ : ((f) == SDB_FIELD_VALUE) ? -1 /* unknown */ \ + : ((f) == SDB_FIELD_TIMESERIES) ? SDB_TYPE_BOOLEAN \ : -1) /* @@ -335,8 +338,6 @@ sdb_store_get_child(sdb_store_obj_t *host, int type, const char *name); * the returned value. If 'res' is NULL, the function will return whether the * field exists. * - * Note: Retrieving the backend this way is not currently supported. - * * Returns: * - 0 on success * - a negative value else