summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4a5eb5e)
raw | patch | inline | side by side (parent: 4a5eb5e)
author | Sebastian Harl <sh@tokkee.org> | |
Wed, 22 Oct 2014 09:26:45 +0000 (11:26 +0200) | ||
committer | Sebastian Harl <sh@tokkee.org> | |
Wed, 22 Oct 2014 09:26:45 +0000 (11:26 +0200) |
… now that these names have become available again.
index 6e232ddf145fcc6b76816c98e1bbadd9291288aa..717f89392e4e325478b36c39e7d74a728efc0db3 100644 (file)
--- a/src/core/store-private.h
+++ b/src/core/store-private.h
MATCHER_SERVICE,
MATCHER_METRIC,
MATCHER_ATTRIBUTE,
- MATCHER_CMP_LT,
- MATCHER_CMP_LE,
- MATCHER_CMP_EQ,
- MATCHER_CMP_NE,
- MATCHER_CMP_GE,
- MATCHER_CMP_GT,
+ MATCHER_LT,
+ MATCHER_LE,
+ MATCHER_EQ,
+ MATCHER_NE,
+ MATCHER_GE,
+ MATCHER_GT,
MATCHER_IN,
MATCHER_REGEX,
MATCHER_NREGEX,
: ((t) == MATCHER_SERVICE) ? "SERVICE" \
: ((t) == MATCHER_METRIC) ? "METRIC" \
: ((t) == MATCHER_ATTRIBUTE) ? "ATTRIBUTE" \
- : ((t) == MATCHER_CMP_NE) ? "!=" \
+ : ((t) == MATCHER_LT) ? "<" \
+ : ((t) == MATCHER_LE) ? "<=" \
+ : ((t) == MATCHER_EQ) ? "=" \
+ : ((t) == MATCHER_NE) ? "!=" \
+ : ((t) == MATCHER_GE) ? ">=" \
+ : ((t) == MATCHER_GT) ? ">" \
: ((t) == MATCHER_IN) ? "IN" \
: ((t) == MATCHER_REGEX) ? "=~" \
: ((t) == MATCHER_NREGEX) ? "!~" \
index 05e6b74d51b70117bc01a06b1b17ca9ef0f77f50..7f9605707576f4c45efbcd71cefab5abb43a584c 100644 (file)
--- a/src/core/store_lookup.c
+++ b/src/core/store_lookup.c
} /* cmp_expr */
static int
-match_cmp_lt(sdb_store_matcher_t *m, sdb_store_obj_t *obj,
+match_lt(sdb_store_matcher_t *m, sdb_store_obj_t *obj,
sdb_store_matcher_t *filter)
{
int status;
- assert(m->type == MATCHER_CMP_LT);
+ assert(m->type == MATCHER_LT);
status = cmp_expr(CMP_M(m)->left, CMP_M(m)->right, obj, filter);
return (status != INT_MAX) && (status < 0);
-} /* match_cmp_lt */
+} /* match_lt */
static int
-match_cmp_le(sdb_store_matcher_t *m, sdb_store_obj_t *obj,
+match_le(sdb_store_matcher_t *m, sdb_store_obj_t *obj,
sdb_store_matcher_t *filter)
{
int status;
- assert(m->type == MATCHER_CMP_LE);
+ assert(m->type == MATCHER_LE);
status = cmp_expr(CMP_M(m)->left, CMP_M(m)->right, obj, filter);
return (status != INT_MAX) && (status <= 0);
-} /* match_cmp_le */
+} /* match_le */
static int
-match_cmp_eq(sdb_store_matcher_t *m, sdb_store_obj_t *obj,
+match_eq(sdb_store_matcher_t *m, sdb_store_obj_t *obj,
sdb_store_matcher_t *filter)
{
int status;
- assert(m->type == MATCHER_CMP_EQ);
+ assert(m->type == MATCHER_EQ);
status = cmp_expr(CMP_M(m)->left, CMP_M(m)->right, obj, filter);
return (status != INT_MAX) && (! status);
-} /* match_cmp_eq */
+} /* match_eq */
static int
-match_cmp_ne(sdb_store_matcher_t *m, sdb_store_obj_t *obj,
+match_ne(sdb_store_matcher_t *m, sdb_store_obj_t *obj,
sdb_store_matcher_t *filter)
{
int status;
- assert(m->type == MATCHER_CMP_NE);
+ assert(m->type == MATCHER_NE);
status = cmp_expr(CMP_M(m)->left, CMP_M(m)->right, obj, filter);
return (status != INT_MAX) && status;
-} /* match_cmp_ne */
+} /* match_ne */
static int
-match_cmp_ge(sdb_store_matcher_t *m, sdb_store_obj_t *obj,
+match_ge(sdb_store_matcher_t *m, sdb_store_obj_t *obj,
sdb_store_matcher_t *filter)
{
int status;
- assert(m->type == MATCHER_CMP_GE);
+ assert(m->type == MATCHER_GE);
status = cmp_expr(CMP_M(m)->left, CMP_M(m)->right, obj, filter);
return (status != INT_MAX) && (status >= 0);
-} /* match_cmp_ge */
+} /* match_ge */
static int
-match_cmp_gt(sdb_store_matcher_t *m, sdb_store_obj_t *obj,
+match_gt(sdb_store_matcher_t *m, sdb_store_obj_t *obj,
sdb_store_matcher_t *filter)
{
int status;
- assert(m->type == MATCHER_CMP_GT);
+ assert(m->type == MATCHER_GT);
status = cmp_expr(CMP_M(m)->left, CMP_M(m)->right, obj, filter);
return (status != INT_MAX) && (status > 0);
-} /* match_cmp_gt */
+} /* match_gt */
static int
match_in(sdb_store_matcher_t *m, sdb_store_obj_t *obj,
match_child,
match_child,
match_child,
- match_cmp_lt,
- match_cmp_le,
- match_cmp_eq,
- match_cmp_ne,
- match_cmp_ge,
- match_cmp_gt,
+ match_lt,
+ match_le,
+ match_eq,
+ match_ne,
+ match_ge,
+ match_gt,
match_in,
match_regex,
match_regex,
return M(sdb_object_create("any-matcher", child_type, type, m));
} /* sdb_store_child_matcher */
-/*
- * TODO: Rename sdb_store_cmp_* to sdb_store_* once the old code is unused and
- * has been removed.
- */
-
sdb_store_matcher_t *
-sdb_store_cmp_lt(sdb_store_expr_t *left, sdb_store_expr_t *right)
+sdb_store_lt_matcher(sdb_store_expr_t *left, sdb_store_expr_t *right)
{
return M(sdb_object_create("lt-matcher", cmp_type,
- MATCHER_CMP_LT, left, right));
-} /* sdb_store_cmp_lt */
+ MATCHER_LT, left, right));
+} /* sdb_store_lt_matcher */
sdb_store_matcher_t *
-sdb_store_cmp_le(sdb_store_expr_t *left, sdb_store_expr_t *right)
+sdb_store_le_matcher(sdb_store_expr_t *left, sdb_store_expr_t *right)
{
return M(sdb_object_create("le-matcher", cmp_type,
- MATCHER_CMP_LE, left, right));
-} /* sdb_store_cmp_le */
+ MATCHER_LE, left, right));
+} /* sdb_store_le_matcher */
sdb_store_matcher_t *
-sdb_store_cmp_eq(sdb_store_expr_t *left, sdb_store_expr_t *right)
+sdb_store_eq_matcher(sdb_store_expr_t *left, sdb_store_expr_t *right)
{
return M(sdb_object_create("eq-matcher", cmp_type,
- MATCHER_CMP_EQ, left, right));
-} /* sdb_store_cmp_eq */
+ MATCHER_EQ, left, right));
+} /* sdb_store_eq_matcher */
sdb_store_matcher_t *
-sdb_store_cmp_ne(sdb_store_expr_t *left, sdb_store_expr_t *right)
+sdb_store_ne_matcher(sdb_store_expr_t *left, sdb_store_expr_t *right)
{
return M(sdb_object_create("ne-matcher", cmp_type,
- MATCHER_CMP_NE, left, right));
-} /* sdb_store_cmp_ne */
+ MATCHER_NE, left, right));
+} /* sdb_store_ne_matcher */
sdb_store_matcher_t *
-sdb_store_cmp_ge(sdb_store_expr_t *left, sdb_store_expr_t *right)
+sdb_store_ge_matcher(sdb_store_expr_t *left, sdb_store_expr_t *right)
{
return M(sdb_object_create("ge-matcher", cmp_type,
- MATCHER_CMP_GE, left, right));
-} /* sdb_store_cmp_ge */
+ MATCHER_GE, left, right));
+} /* sdb_store_ge_matcher */
sdb_store_matcher_t *
-sdb_store_cmp_gt(sdb_store_expr_t *left, sdb_store_expr_t *right)
+sdb_store_gt_matcher(sdb_store_expr_t *left, sdb_store_expr_t *right)
{
return M(sdb_object_create("gt-matcher", cmp_type,
- MATCHER_CMP_GT, left, right));
-} /* sdb_store_cmp_gt */
+ MATCHER_GT, left, right));
+} /* sdb_store_gt_matcher */
sdb_store_matcher_t *
sdb_store_in_matcher(sdb_store_expr_t *left, sdb_store_expr_t *right)
sdb_store_parse_matcher_op(const char *op)
{
if (! strcasecmp(op, "<"))
- return sdb_store_cmp_lt;
+ return sdb_store_lt_matcher;
else if (! strcasecmp(op, "<="))
- return sdb_store_cmp_le;
+ return sdb_store_le_matcher;
else if (! strcasecmp(op, "="))
- return sdb_store_cmp_eq;
+ return sdb_store_eq_matcher;
else if (! strcasecmp(op, "!="))
- return sdb_store_cmp_ne;
+ return sdb_store_ne_matcher;
else if (! strcasecmp(op, ">="))
- return sdb_store_cmp_ge;
+ return sdb_store_ge_matcher;
else if (! strcasecmp(op, ">"))
- return sdb_store_cmp_gt;
+ return sdb_store_gt_matcher;
else if (! strcasecmp(op, "=~"))
return sdb_store_regex_matcher;
else if (! strcasecmp(op, "!~"))
index cef3d063cf0f41f18aad997eedf92971d7cf93ac..a3bb2b7941cc640a6bf755794c377366d3d7e291 100644 (file)
--- a/src/include/core/store.h
+++ b/src/include/core/store.h
/*
* sdb_store_lt_matcher, sdb_store_le_matcher, sdb_store_eq_matcher,
* sdb_store_ge_matcher, sdb_store_gt_matcher:
- * Creates a matcher based on a conditional. The matcher matches objects for
- * which the conditional evaluates the object to compare less than, less or
- * equal, equal, greater or equal, or greater than the conditional's value
- * repsectively.
+ * Create conditional matchers comparing the values of two expressions. The
+ * matcher matches if the left expression compres less than, less or equal
+ * than, equal to, not equal to, greater or equal than, or greater than the
+ * right expression.
*/
sdb_store_matcher_t *
-sdb_store_cmp_lt(sdb_store_expr_t *left, sdb_store_expr_t *right);
+sdb_store_lt_matcher(sdb_store_expr_t *left, sdb_store_expr_t *right);
sdb_store_matcher_t *
-sdb_store_cmp_le(sdb_store_expr_t *left, sdb_store_expr_t *right);
+sdb_store_le_matcher(sdb_store_expr_t *left, sdb_store_expr_t *right);
sdb_store_matcher_t *
-sdb_store_cmp_eq(sdb_store_expr_t *left, sdb_store_expr_t *right);
+sdb_store_eq_matcher(sdb_store_expr_t *left, sdb_store_expr_t *right);
sdb_store_matcher_t *
-sdb_store_cmp_ne(sdb_store_expr_t *left, sdb_store_expr_t *right);
+sdb_store_ne_matcher(sdb_store_expr_t *left, sdb_store_expr_t *right);
sdb_store_matcher_t *
-sdb_store_cmp_ge(sdb_store_expr_t *left, sdb_store_expr_t *right);
+sdb_store_ge_matcher(sdb_store_expr_t *left, sdb_store_expr_t *right);
sdb_store_matcher_t *
-sdb_store_cmp_gt(sdb_store_expr_t *left, sdb_store_expr_t *right);
+sdb_store_gt_matcher(sdb_store_expr_t *left, sdb_store_expr_t *right);
/*
* sdb_store_in_matcher:
index 38162d2dae93f223a5d0c0ee066eea0252c41440..d80a5990b4dbd4a52efb2248419e1af58c0ac63c 100644 (file)
sdb_store_expr_t *);
int expected;
} tests[] = {
- { sdb_store_cmp_lt, golden_data[i].expected_lt },
- { sdb_store_cmp_le, golden_data[i].expected_le },
- { sdb_store_cmp_eq, golden_data[i].expected_eq },
- { sdb_store_cmp_ge, golden_data[i].expected_ge },
- { sdb_store_cmp_gt, golden_data[i].expected_gt },
+ { sdb_store_lt_matcher, golden_data[i].expected_lt },
+ { sdb_store_le_matcher, golden_data[i].expected_le },
+ { sdb_store_eq_matcher, golden_data[i].expected_eq },
+ { sdb_store_ge_matcher, golden_data[i].expected_ge },
+ { sdb_store_gt_matcher, golden_data[i].expected_gt },
};
sdb_data_format(&golden_data[i].value,
sdb_store_expr_t *);
int expected;
} tests[] = {
- { sdb_store_cmp_lt, golden_data[i].expected_lt },
- { sdb_store_cmp_le, golden_data[i].expected_le },
- { sdb_store_cmp_eq, golden_data[i].expected_eq },
- { sdb_store_cmp_ge, golden_data[i].expected_ge },
- { sdb_store_cmp_gt, golden_data[i].expected_gt },
+ { sdb_store_lt_matcher, golden_data[i].expected_lt },
+ { sdb_store_le_matcher, golden_data[i].expected_le },
+ { sdb_store_eq_matcher, golden_data[i].expected_eq },
+ { sdb_store_ge_matcher, golden_data[i].expected_ge },
+ { sdb_store_gt_matcher, golden_data[i].expected_gt },
};
char *op_str[] = { "<", "<=", "=", ">=", ">" };
index df07fff6382540a0f35ea705dd303c0fa7a9dce2..f459b6e0afd461be0754fb64cd192928e8b3e2c9 100644 (file)
--- a/t/unit/core/store_test.c
+++ b/t/unit/core/store_test.c
"{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
"\"update_interval\": \"0s\", \"backends\": []}"
"]" },
- { { sdb_store_cmp_eq, SDB_FIELD_NAME,
+ { { sdb_store_eq_matcher, SDB_FIELD_NAME,
{ SDB_TYPE_STRING, { .string = "h1" } } }, 0,
"["
"{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
"\"update_interval\": \"0s\", \"backends\": [], "
"\"attributes\": [], \"metrics\": [], \"services\": []}"
"]" },
- { { sdb_store_cmp_gt, SDB_FIELD_LAST_UPDATE,
+ { { sdb_store_gt_matcher, SDB_FIELD_LAST_UPDATE,
{ SDB_TYPE_DATETIME, { .datetime = 1 } } }, 0,
"["
"{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
"]}"
"]}"
"]" },
- { { sdb_store_cmp_le, SDB_FIELD_LAST_UPDATE,
+ { { sdb_store_le_matcher, SDB_FIELD_LAST_UPDATE,
{ SDB_TYPE_DATETIME, { .datetime = 1 } } }, 0,
"["
"{\"name\": \"h1\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
"], "
"\"services\": []}"
"]" },
- { { sdb_store_cmp_ge, SDB_FIELD_LAST_UPDATE,
+ { { sdb_store_ge_matcher, SDB_FIELD_LAST_UPDATE,
{ SDB_TYPE_DATETIME, { .datetime = 3 } } }, 0,
"["
"{\"name\": \"h2\", \"last_update\": \"1970-01-01 00:00:00 +0000\", "
index 0112da69d28c37f381d911c719fb05c360a8272c..e251d7116e73c350c44afa124436219b72b02d12 100644 (file)
"service =~ 'pattern'", -1, MATCHER_OR },
{ "NOT host = 'host'", -1, MATCHER_NOT },
/* numeric expressions */
- { "attribute['foo'] < 123", -1, MATCHER_CMP_LT },
- { "attribute['foo'] <= 123", -1, MATCHER_CMP_LE },
- { "attribute['foo'] = 123", -1, MATCHER_CMP_EQ },
- { "attribute['foo'] >= 123", -1, MATCHER_CMP_GE },
- { "attribute['foo'] > 123", -1, MATCHER_CMP_GT },
+ { "attribute['foo'] < 123", -1, MATCHER_LT },
+ { "attribute['foo'] <= 123", -1, MATCHER_LE },
+ { "attribute['foo'] = 123", -1, MATCHER_EQ },
+ { "attribute['foo'] >= 123", -1, MATCHER_GE },
+ { "attribute['foo'] > 123", -1, MATCHER_GT },
/* datetime expressions */
{ "attribute['foo'] = "
- "2014-08-16", -1, MATCHER_CMP_EQ },
+ "2014-08-16", -1, MATCHER_EQ },
{ "attribute['foo'] = "
- "17:23", -1, MATCHER_CMP_EQ },
+ "17:23", -1, MATCHER_EQ },
{ "attribute['foo'] = "
- "17:23:53", -1, MATCHER_CMP_EQ },
+ "17:23:53", -1, MATCHER_EQ },
{ "attribute['foo'] = "
- "17:23:53.123", -1, MATCHER_CMP_EQ },
+ "17:23:53.123", -1, MATCHER_EQ },
{ "attribute['foo'] = "
- "17:23:53.123456789", -1, MATCHER_CMP_EQ },
+ "17:23:53.123456789", -1, MATCHER_EQ },
{ "attribute['foo'] = "
- "2014-08-16 17:23", -1, MATCHER_CMP_EQ },
+ "2014-08-16 17:23", -1, MATCHER_EQ },
{ "attribute['foo'] = "
- "2014-08-16 17:23:53", -1, MATCHER_CMP_EQ },
+ "2014-08-16 17:23:53", -1, MATCHER_EQ },
/* NULL; while this is an implementation detail,
* IS NULL currently maps to an equality matcher */
{ "attribute['foo'] IS NULL", -1, MATCHER_ISNULL },
{ "attribute['foo'] IS NOT NULL", -1, MATCHER_ISNNULL },
/* object field matchers */
- { ".name < 'a'", -1, MATCHER_CMP_LT },
- { ".name <= 'a'", -1, MATCHER_CMP_LE },
- { ".name = 'a'", -1, MATCHER_CMP_EQ },
- { ".name != 'a'", -1, MATCHER_CMP_NE },
- { ".name >= 'a'", -1, MATCHER_CMP_GE },
- { ".name > 'a'", -1, MATCHER_CMP_GT },
- { ".last_update < 2014-10-01", -1, MATCHER_CMP_LT },
- { ".last_update <= 2014-10-01", -1, MATCHER_CMP_LE },
- { ".last_update = 2014-10-01", -1, MATCHER_CMP_EQ },
- { ".last_update != 2014-10-01", -1, MATCHER_CMP_NE },
- { ".last_update >= 2014-10-01", -1, MATCHER_CMP_GE },
- { ".last_update > 2014-10-01", -1, MATCHER_CMP_GT },
- { ".Last_Update >= 24D", -1, MATCHER_CMP_GE },
- { ".age < 20s", -1, MATCHER_CMP_LT },
- { ".age <= 20s", -1, MATCHER_CMP_LE },
- { ".age = 20s", -1, MATCHER_CMP_EQ },
- { ".age != 20s", -1, MATCHER_CMP_NE },
- { ".age >= 20s", -1, MATCHER_CMP_GE },
- { ".age > 20s", -1, MATCHER_CMP_GT },
- { ".AGE <= 1m", -1, MATCHER_CMP_LE },
- { ".age > 1M", -1, MATCHER_CMP_GT },
- { ".age != 20Y", -1, MATCHER_CMP_NE },
- { ".age <= 2 * .interval", -1, MATCHER_CMP_LE },
- { ".interval < 20s", -1, MATCHER_CMP_LT },
- { ".interval <= 20s", -1, MATCHER_CMP_LE },
- { ".interval = 20s", -1, MATCHER_CMP_EQ },
- { ".interval != 20s", -1, MATCHER_CMP_NE },
- { ".interval >= 20s", -1, MATCHER_CMP_GE },
- { ".interval > 20s", -1, MATCHER_CMP_GT },
+ { ".name < 'a'", -1, MATCHER_LT },
+ { ".name <= 'a'", -1, MATCHER_LE },
+ { ".name = 'a'", -1, MATCHER_EQ },
+ { ".name != 'a'", -1, MATCHER_NE },
+ { ".name >= 'a'", -1, MATCHER_GE },
+ { ".name > 'a'", -1, MATCHER_GT },
+ { ".last_update < 2014-10-01", -1, MATCHER_LT },
+ { ".last_update <= 2014-10-01", -1, MATCHER_LE },
+ { ".last_update = 2014-10-01", -1, MATCHER_EQ },
+ { ".last_update != 2014-10-01", -1, MATCHER_NE },
+ { ".last_update >= 2014-10-01", -1, MATCHER_GE },
+ { ".last_update > 2014-10-01", -1, MATCHER_GT },
+ { ".Last_Update >= 24D", -1, MATCHER_GE },
+ { ".age < 20s", -1, MATCHER_LT },
+ { ".age <= 20s", -1, MATCHER_LE },
+ { ".age = 20s", -1, MATCHER_EQ },
+ { ".age != 20s", -1, MATCHER_NE },
+ { ".age >= 20s", -1, MATCHER_GE },
+ { ".age > 20s", -1, MATCHER_GT },
+ { ".AGE <= 1m", -1, MATCHER_LE },
+ { ".age > 1M", -1, MATCHER_GT },
+ { ".age != 20Y", -1, MATCHER_NE },
+ { ".age <= 2 * .interval", -1, MATCHER_LE },
+ { ".interval < 20s", -1, MATCHER_LT },
+ { ".interval <= 20s", -1, MATCHER_LE },
+ { ".interval = 20s", -1, MATCHER_EQ },
+ { ".interval != 20s", -1, MATCHER_NE },
+ { ".interval >= 20s", -1, MATCHER_GE },
+ { ".interval > 20s", -1, MATCHER_GT },
{ "'be' IN .backend", -1, MATCHER_IN },
/* check operator precedence */