summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 98439da)
raw | patch | inline | side by side (parent: 98439da)
author | Sebastian Harl <sh@tokkee.org> | |
Fri, 9 Oct 2015 16:56:12 +0000 (18:56 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Fri, 9 Oct 2015 16:56:12 +0000 (18:56 +0200) |
That is, exclude any attributes or child objects.
Use this to simplify the TIMESERIES fetcher which no longer requires an
attribute callback.
Use this to simplify the TIMESERIES fetcher which no longer requires an
attribute callback.
index 802e70ce5f2fcd789fa90c7a51376f6d23cba56d..ce8f8251dc32851a341013d506d0e748f99d1b5e 100644 (file)
--- a/src/core/memstore_exec.c
+++ b/src/core/memstore_exec.c
static int
exec_fetch(sdb_memstore_t *store,
sdb_store_writer_t *w, sdb_object_t *wd, sdb_strbuf_t *errbuf,
- int type, const char *hostname, const char *name,
+ int type, const char *hostname, const char *name, bool full,
sdb_memstore_matcher_t *filter)
{
sdb_memstore_obj_t *host;
if (type != SDB_HOST)
status = sdb_memstore_emit(obj->parent, w, wd);
- if (status || sdb_memstore_emit_full(obj, filter, w, wd)) {
+ if (! status) {
+ if (full)
+ status = sdb_memstore_emit_full(obj, filter, w, wd);
+ else
+ status = sdb_memstore_emit(obj, w, wd);
+ }
+ if (status) {
sdb_log(SDB_LOG_ERR, "memstore: Failed to serialize "
"%s %s.%s to JSON", SDB_STORE_TYPE_TO_NAME(type),
hostname, name);
case SDB_AST_TYPE_FETCH:
return exec_fetch(store, w, wd, errbuf, SDB_AST_FETCH(ast)->obj_type,
SDB_AST_FETCH(ast)->hostname, SDB_AST_FETCH(ast)->name,
- q->filter);
+ SDB_AST_FETCH(ast)->full, q->filter);
case SDB_AST_TYPE_LIST:
return exec_list(store, w, wd, errbuf, SDB_AST_LIST(ast)->obj_type,
diff --git a/src/frontend/query.c b/src/frontend/query.c
index 9a157fb892d10888e35a74c84d77d5a18e635599..28e1e31c2b006fc7fb947e073456f7c5afa79df3 100644 (file)
--- a/src/frontend/query.c
+++ b/src/frontend/query.c
/*
* metric fetcher:
* Implements the callbacks necessary to read a metric object.
- * TODO: FETCH should allow to ignore child elements (attributes); then, we'd
- * only need store_host/store_metric.
*/
typedef struct {
return 0;
} /* metric_fetcher_metric */
-static int
-metric_fetcher_attr(sdb_store_attribute_t __attribute__((unused)) *attr,
- sdb_object_t __attribute__((unused)) *user_data)
-{
- return 0;
-} /* metric_fetcher_attr */
-
static sdb_store_writer_t metric_fetcher = {
- metric_fetcher_host, NULL, metric_fetcher_metric, metric_fetcher_attr,
+ metric_fetcher_host, NULL, metric_fetcher_metric, NULL,
};
/*
ast = sdb_ast_fetch_create((int)type,
hostname[0] ? strdup(hostname) : NULL,
name[0] ? strdup(name) : NULL,
- /* filter = */ NULL);
+ /* full */ 1, /* filter = */ NULL);
status = exec_cmd(conn, ast);
sdb_object_deref(SDB_OBJ(ast));
return status;
index 8533fc705e6467b91840ce97b86cc20a09f14b14..0736876ae1b464d0100958ad04c73b41a08e31b6 100644 (file)
--- a/src/include/parser/ast.h
+++ b/src/include/parser/ast.h
int obj_type;
char *hostname; /* optional */
char *name;
+ /* whether to include the full object, that is,
+ * including all attributes and all children */
+ bool full;
sdb_ast_node_t *filter; /* optional */
} sdb_ast_fetch_t;
#define SDB_AST_FETCH(obj) ((sdb_ast_fetch_t *)(obj))
#define SDB_AST_FETCH_INIT \
- { { SDB_OBJECT_INIT, SDB_AST_TYPE_FETCH, -1 }, -1, NULL, NULL, NULL }
+ { { SDB_OBJECT_INIT, SDB_AST_TYPE_FETCH, -1 }, -1, NULL, NULL, 0, NULL }
/*
* sdb_ast_list_t represents a LIST command.
* takes ownership of the strings and the filter node.
*/
sdb_ast_node_t *
-sdb_ast_fetch_create(int obj_type, char *hostname, char *name,
+sdb_ast_fetch_create(int obj_type, char *hostname, char *name, bool full,
sdb_ast_node_t *filter);
/*
diff --git a/src/parser/ast.c b/src/parser/ast.c
index 81a4c343e37e4d2edf5e80e2f9398c510d6da1c1..43fcd41f0464a19c2c7fb559556b736193feb084 100644 (file)
--- a/src/parser/ast.c
+++ b/src/parser/ast.c
} /* sdb_ast_value_create */
sdb_ast_node_t *
-sdb_ast_fetch_create(int obj_type, char *hostname, char *name,
+sdb_ast_fetch_create(int obj_type, char *hostname, char *name, bool full,
sdb_ast_node_t *filter)
{
sdb_ast_fetch_t *fetch;
fetch->obj_type = obj_type;
fetch->hostname = hostname;
fetch->name = name;
+ fetch->full = full;
fetch->filter = filter;
return SDB_AST_NODE(fetch);
} /* sdb_ast_fetch_create */
diff --git a/src/parser/grammar.y b/src/parser/grammar.y
index 1b6d208c385736bdb828adeedc4bb460d7d35782..b94300af2d47991b3ca27f5424320e0b1bcc8871 100644 (file)
--- a/src/parser/grammar.y
+++ b/src/parser/grammar.y
fetch_statement:
FETCH object_type STRING filter_clause
{
- $$ = sdb_ast_fetch_create($2, NULL, $3, $4);
+ $$ = sdb_ast_fetch_create($2, NULL, $3, 1, $4);
CK_OOM($$);
}
|
FETCH object_type STRING '.' STRING filter_clause
{
- $$ = sdb_ast_fetch_create($2, $3, $5, $6);
+ $$ = sdb_ast_fetch_create($2, $3, $5, 1, $6);
CK_OOM($$);
}
;