Code

store: Add the timeseries field to metrics.
authorSebastian Harl <sh@tokkee.org>
Wed, 20 May 2015 08:34:27 +0000 (10:34 +0200)
committerSebastian Harl <sh@tokkee.org>
Wed, 20 May 2015 08:34:27 +0000 (10:34 +0200)
This is a boolean field that specifies whether a timeseries for the metric is
known to SysDB.

src/core/store.c
src/core/store_expr.c
src/include/core/store.h

index eb58ad83b1ba2cd36b5fba803e42313758ea3d38..bf12a9378eb228e811a87ea268eb8fa403991672 100644 (file)
@@ -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;
        }
index 6e39305a89ecd18718ad7984a4e7cc85f407728d..80c1f4ac25c756383d579a1a92042045f5df6cec 100644 (file)
@@ -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));
index c051252f771616ad3df65eba06fbf9fe1bd3f447..c52299e806314a951df6fbb670e7b098f7e371cd 100644 (file)
@@ -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