Skip to content

Commit 6fb6f29

Browse files
committed
expr filtering without typelib build
Support for content filtering without typelib dependency, which allow user to use filtering via expressions on `key` fields only.
1 parent 8442316 commit 6fb6f29

File tree

10 files changed

+101
-45
lines changed

10 files changed

+101
-45
lines changed

src/core/cdr/include/dds/cdr/dds_cdrstream.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ typedef struct dds_cdrstream_allocator {
117117
} dds_cdrstream_allocator_t;
118118

119119
typedef struct dds_cdrstream_desc_key {
120+
char *name; /* Name of key field */
120121
uint32_t ops_offs; /* Offset for key ops */
121122
uint32_t idx; /* Key index in containing type (definition order) */
122123
} dds_cdrstream_desc_key_t;

src/core/cdr/src/dds_cdrstream.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6919,6 +6919,7 @@ static void copy_desc_keys (dds_cdrstream_desc_key_t **dst, const struct dds_cdr
69196919
*dst = allocator->malloc (nkeys * sizeof (**dst));
69206920
for (uint32_t i = 0; i < nkeys; i++)
69216921
{
6922+
(*dst)[i].name = ddsrt_strdup(keys[i].m_name);
69226923
(*dst)[i].ops_offs = keys[i].m_offset;
69236924
(*dst)[i].idx = keys[i].m_idx;
69246925
}
@@ -7036,6 +7037,12 @@ void dds_cdrstream_desc_fini (struct dds_cdrstream_desc *desc, const struct dds_
70367037
{
70377038
if (desc->keys.nkeys > 0)
70387039
{
7040+
for (size_t i = 0; i < desc->keys.nkeys; i++) {
7041+
if (desc->keys.keys != NULL)
7042+
allocator->free (desc->keys.keys[i].name);
7043+
if (desc->keys.keys_definition_order != NULL)
7044+
allocator->free (desc->keys.keys_definition_order[i].name);
7045+
}
70397046
if (desc->keys.keys != NULL)
70407047
allocator->free (desc->keys.keys);
70417048
if (desc->keys.keys_definition_order != NULL)

src/core/ddsc/src/dds__types.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,17 @@
1414
/* DDS internal type definitions */
1515

1616
#include "dds/dds.h"
17+
#include "dds/ddsrt/avl.h"
1718
#include "dds/ddsrt/sync.h"
1819
#include "dds/ddsi/ddsi_protocol.h"
1920
#include "dds/ddsi/ddsi_domaingv.h"
21+
#include "dds/ddsi/ddsi_builtin_topic_if.h"
2022
#ifdef DDS_HAS_TOPIC_DISCOVERY
21-
#include "dds/ddsi/ddsi_typewrap.h"
23+
#include "dds/ddsi/ddsi_typewrap.h"
2224
#endif
23-
#include "dds/ddsrt/avl.h"
24-
#include "dds/ddsi/ddsi_builtin_topic_if.h"
2525
#include "dds/ddsc/dds_psmx.h"
26+
#include "dds/cdr/dds_cdrstream.h"
2627
#include "dds__handles.h"
27-
#include "dds__loaned_sample.h"
2828

2929

3030
#if defined (__cplusplus)
@@ -459,7 +459,6 @@ struct dds_expression_filter {
459459
char *expression;
460460
struct dds_sql_expr *expr; // pre-build expression a.k.a full described.
461461
struct dds_sql_expr *bin_expr; // build/optimized expression with params.
462-
struct dds_topic_descriptor *desc; // newly constructed descriptor.
463462
struct ddsi_sertype *st; // newly constructed sertype.
464463
};
465464

src/core/ddsc/src/dds_filter.c

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,13 @@
1212

1313
#include "dds/dds.h"
1414

15-
#include "dds/ddsi/ddsi_typebuilder.h"
1615
#include "dds/ddsrt/heap.h"
1716
#include "dds/ddsrt/string.h"
1817
#include "dds/ddsi/ddsi_sertype.h"
19-
#include "dds/ddsi/ddsi_typelib.h"
18+
#include "dds/ddsi/ddsi_typebuilder.h"
19+
#ifdef DDS_HAS_TYPELIB
20+
#include "dds/ddsi/ddsi_typelib.h"
21+
#endif
2022

2123
#include "dds__domain.h"
2224
#include "dds__filter.h"
@@ -178,15 +180,16 @@ static dds_return_t expr_var_set (const struct dds_expression_filter *filter, co
178180
static dds_return_t topic_expr_filter_vars_apply(const struct dds_expression_filter *filter, const void *sample)
179181
{
180182
dds_return_t ret = DDS_RETCODE_OK;
181-
const dds_topic_descriptor_t *desc = filter->desc;
183+
const struct dds_sertype_default *st = (const struct dds_sertype_default *)filter->st;
184+
const struct dds_cdrstream_desc desc = st->type;
182185

183-
for (size_t i = 0; i < desc->m_nkeys; i++)
186+
for (size_t i = 0; i < desc.keys.nkeys; i++)
184187
{
185-
dds_key_descriptor_t msg_field = desc->m_keys[i];
186-
const uint32_t *op = desc->m_ops + msg_field.m_offset;
188+
const struct dds_cdrstream_desc_key msg_field = desc.keys.keys[i];
189+
const uint32_t *op = desc.ops.ops + msg_field.ops_offs;
187190
size_t offset = 0U, op_id = 1;
188-
const uint32_t *ops = (desc->m_ops + op[op_id]);
189-
if ((ret = expr_var_set (filter, sample, (uintptr_t)msg_field.m_name, op, ops, &offset, &op_id)) != DDS_RETCODE_OK)
191+
const uint32_t *ops = (desc.ops.ops + op[op_id]);
192+
if ((ret = expr_var_set (filter, sample, (uintptr_t)msg_field.name, op, ops, &offset, &op_id)) != DDS_RETCODE_OK)
190193
goto err;
191194
}
192195

@@ -256,7 +259,6 @@ static void topic_expr_filter_free(struct dds_filter *filter)
256259
ddsrt_free(ef->expression);
257260
if (ef->bin_expr != NULL) dds_sql_expr_fini(ef->bin_expr);
258261
if (ef->expr != NULL) dds_sql_expr_fini(ef->expr);
259-
if (ef->desc != NULL) {ddsi_topic_descriptor_fini(ef->desc); ddsrt_free(ef->desc);}
260262
if (ef->st != NULL) ddsi_sertype_unref(ef->st);
261263
ddsrt_free(ef);
262264
}
@@ -306,12 +308,6 @@ static dds_return_t topic_expr_filter_param_rebind (struct dds_filter *a, const
306308
dds_sql_expr_fini(ef->bin_expr);
307309
ef->bin_expr = exp;
308310

309-
ddsi_typeid_t *id = ddsi_sertype_typeid(st, DDSI_TYPEID_KIND_COMPLETE);
310-
struct ddsi_domaingv *gv = ddsrt_atomic_ldvoidp (&st->gv);
311-
struct ddsi_type *type = ddsi_type_lookup(gv, id);
312-
ddsi_typeid_fini (id);
313-
ddsrt_free (id);
314-
315311
const char **fields = ddsrt_malloc(sizeof(*fields)*ef->bin_expr->nparams);
316312
size_t nfields = ef->bin_expr->nparams;
317313

@@ -320,12 +316,22 @@ static dds_return_t topic_expr_filter_param_rebind (struct dds_filter *a, const
320316
for (dds_sql_param_t *param = ddsrt_hh_iter_first(ef->bin_expr->param_tokens, &it); param != NULL; param = ddsrt_hh_iter_next(&it))
321317
fields[i++] = param->token.s;
322318

319+
#ifndef NDEBUG
323320
assert (i == nfields);
321+
#else
322+
(void) nfields;
323+
#endif
324+
325+
#ifdef DDS_HAS_TYPELIB
326+
ddsi_typeid_t *id = ddsi_sertype_typeid(st, DDSI_TYPEID_KIND_COMPLETE);
327+
struct ddsi_domaingv *gv = ddsrt_atomic_ldvoidp (&st->gv);
328+
struct ddsi_type *type = ddsi_type_lookup(gv, id);
329+
ddsi_typeid_fini (id);
330+
ddsrt_free (id);
324331

325332
struct ddsi_type *res_type = ddsi_type_dup_with_keys(type, fields, nfields);
326-
ddsrt_free (fields);
327333
if (ef->desc != NULL)
328-
ddsi_topic_descriptor_fini(ef->desc);
334+
dds_delete_topic_descriptor(ef->desc);
329335
ef->desc = ddsrt_malloc(sizeof(*ef->desc));
330336
ret = ddsi_topic_descriptor_from_type (gv, ef->desc, res_type);
331337
assert (ret == DDS_RETCODE_OK);
@@ -359,6 +365,11 @@ static dds_return_t topic_expr_filter_param_rebind (struct dds_filter *a, const
359365
* type?
360366
* */
361367
ddsi_type_unref (gv, res_type);
368+
#else
369+
ef->st = ddsi_sertype_ref(st);
370+
#endif
371+
372+
ddsrt_free (fields);
362373

363374
err:
364375
return ret;
@@ -373,7 +384,6 @@ static dds_return_t expression_filter_create (dds_domainid_t domain_id, const st
373384
dds_return_t ret = DDS_RETCODE_OK;
374385
struct dds_expression_filter *ef = (struct dds_expression_filter *) ddsrt_malloc(sizeof(*ef));
375386
ef->st = NULL;
376-
ef->desc = NULL;
377387
ef->expr = NULL;
378388
ef->bin_expr = NULL;
379389
ef->expression = ddsrt_strdup(cflt->expression);

src/core/ddsc/src/dds_reader.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "dds/ddsi/ddsi_tkmap.h"
2929
#include "dds/ddsc/dds_rhc.h"
3030
#include "dds/ddsc/dds_internal_api.h"
31+
#include "dds__loaned_sample.h"
3132
#include "dds__participant.h"
3233
#include "dds__subscriber.h"
3334
#include "dds__reader.h"

src/core/ddsc/src/dds_sql_expr.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1841,6 +1841,8 @@ dds_return_t dds_sql_expr_bind_integer(const struct dds_sql_expr *ex, uintptr_t
18411841
if (ex->param_kind == DDS_SQL_EXPR_KIND_PARAMETER) tmpl.id.index = (uint64_t)i;
18421842
else if (ex->param_kind == DDS_SQL_EXPR_KIND_VARIABLE) tmpl.id.str = ddsrt_strdup((char *)(void *)i);
18431843
else goto err;
1844+
/* FIXME: not found? no worries it's optimized or DDS_HAS_TYPELIB missing. */
1845+
retcode = (ex->param_kind == DDS_SQL_EXPR_KIND_VARIABLE)? DDS_RETCODE_OK: DDS_RETCODE_BAD_PARAMETER;
18441846
struct dds_sql_param *param = ddsrt_hh_lookup(ex->param_tokens, &tmpl);
18451847
if (param == NULL) goto err_not_found;
18461848
struct dds_sql_token *t = (struct dds_sql_token *)param;
@@ -1863,6 +1865,8 @@ dds_return_t dds_sql_expr_bind_real(const struct dds_sql_expr *ex, uintptr_t i,
18631865
if (ex->param_kind == DDS_SQL_EXPR_KIND_PARAMETER) tmpl.id.index = (uint64_t)i;
18641866
else if (ex->param_kind == DDS_SQL_EXPR_KIND_VARIABLE) tmpl.id.str = ddsrt_strdup((char *)(void *)i);
18651867
else goto err;
1868+
/* FIXME: not found? no worries it's optimized or DDS_HAS_TYPELIB missing. */
1869+
retcode = (ex->param_kind == DDS_SQL_EXPR_KIND_VARIABLE)? DDS_RETCODE_OK: DDS_RETCODE_BAD_PARAMETER;
18661870
struct dds_sql_param *param = ddsrt_hh_lookup(ex->param_tokens, &tmpl);
18671871
if (param == NULL) goto err_not_found;
18681872
struct dds_sql_token *t = (struct dds_sql_token *)param;
@@ -1885,6 +1889,8 @@ dds_return_t dds_sql_expr_bind_string(const struct dds_sql_expr *ex, uintptr_t i
18851889
if (ex->param_kind == DDS_SQL_EXPR_KIND_PARAMETER) tmpl.id.index = (uint64_t)i;
18861890
else if (ex->param_kind == DDS_SQL_EXPR_KIND_VARIABLE) tmpl.id.str = ddsrt_strdup((char *)(void *)i);
18871891
else goto err;
1892+
/* FIXME: not found? no worries it's optimized or DDS_HAS_TYPELIB missing. */
1893+
retcode = (ex->param_kind == DDS_SQL_EXPR_KIND_VARIABLE)? DDS_RETCODE_OK: DDS_RETCODE_BAD_PARAMETER;
18881894
struct dds_sql_param *param = ddsrt_hh_lookup(ex->param_tokens, &tmpl);
18891895
if (param == NULL) goto err_not_found;
18901896
struct dds_sql_token *t = (struct dds_sql_token *)param;
@@ -1910,6 +1916,8 @@ dds_return_t dds_sql_expr_bind_blob(const struct dds_sql_expr *ex, uintptr_t i,
19101916
if (ex->param_kind == DDS_SQL_EXPR_KIND_PARAMETER) tmpl.id.index = (uint64_t)i;
19111917
else if (ex->param_kind == DDS_SQL_EXPR_KIND_VARIABLE) tmpl.id.str = ddsrt_strdup((char *)(void *)i);
19121918
else goto err;
1919+
/* FIXME: not found? no worries it's optimized or DDS_HAS_TYPELIB missing. */
1920+
retcode = (ex->param_kind == DDS_SQL_EXPR_KIND_VARIABLE)? DDS_RETCODE_OK: DDS_RETCODE_BAD_PARAMETER;
19131921
struct dds_sql_param *param = ddsrt_hh_lookup(ex->param_tokens, &tmpl);
19141922
if (param == NULL) goto err_not_found;
19151923
struct dds_sql_token *t = (struct dds_sql_token *)param;

src/core/ddsc/src/dds_writer.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
#include "dds/cdr/dds_cdrstream.h"
3030
#include "dds/ddsc/dds_internal_api.h"
3131
#include "dds__filter.h"
32+
#include "dds__loaned_sample.h"
3233
#include "dds__writer.h"
3334
#include "dds__listener.h"
3435
#include "dds__init.h"

src/core/ddsc/tests/Space.idl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@
99
// SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause
1010

1111
module Space {
12+
struct Type0 {
13+
@key
14+
long long_1;
15+
@key
16+
long long_2;
17+
long long_3;
18+
};
19+
1220
struct Type1 {
1321
@key
1422
long long_1;

src/core/ddsc/tests/filter.c

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "dds/ddsrt/heap.h"
1818
#include "dds/ddsrt/string.h"
19+
#include "dds__serdata_default.h"
1920
#include "dds__filter.h"
2021
#include "dds__types.h"
2122
#include "dds__sql_expr.h"
@@ -126,17 +127,27 @@ CU_Test(ddsc_expr_filter, accept)
126127
const void *sample;
127128
const bool result;
128129
} test[] = {
129-
{{ .expr="`e1`=0", .param="", .tdesc=Space_invalid_data_desc }, .sample=&(struct Space_invalid_data){.e1= Space_IDE0}, .result = true },
130-
{{ .expr="`bm1`=(1 << 0)", .param="", .tdesc=Space_invalid_data_desc }, .sample=&(struct Space_invalid_data){.bm1=Space_IDB0}, .result = true },
131-
/* {{ .expr="`um_sub1.m_int32`=0", .param="", .tdesc=dunion_desc }, .sample=&(struct dunion){._d=16,._u.um_sub1.m_int32=0}, .result = false }, */
132-
{{ .expr="e.z.a = d.z.a", .param="", .tdesc=SerdataKeyNestedFinalImplicit_desc }, .sample=&(struct SerdataKeyNestedFinalImplicit){.e.z.a=1U,.d.z.a=0U}, .result = false },
133-
{{ .expr="b = by OR by = bx.ny", .param="", .tdesc=SerdataKeyInheritMutable_desc }, .sample=&(struct SerdataKeyInheritMutable){.b=1U,.parent={.by=0U,.bx.ny=0U}}, .result = true },
134-
{{ .expr="b == \'abc\'", .param="", .tdesc=SerdataKeyStringBounded_desc }, .sample=&(struct SerdataKeyStringBounded){.a=1U,.b="abc"}, .result = true },
135-
{{ .expr="b == \'abcd\'", .param="", .tdesc=SerdataKeyString_desc }, .sample=&(struct SerdataKeyString){.a=1U,.b="abcd"}, .result = true },
136-
{{ .expr="a + b", .param="", .tdesc=SerdataKeyOrder_desc }, .sample=&(struct SerdataKeyOrder){.a=1U,.b=1U,.c=0U}, .result = true },
137-
{{ .expr="a + b OR ?1 * c", .param="0", .tdesc=SerdataKeyOrderId_desc }, .sample=&(struct SerdataKeyOrderId){.a=1U,.b=0U,.c=0U}, .result = true },
138-
{{ .expr="x AND y OR z.b", .param="", .tdesc=SerdataKeyOrderFinalNestedMutable_desc }, .sample=&(struct SerdataKeyOrderFinalNestedMutable){.x=0U,.y=0U,.z.b=1U}, .result = true },
139-
{{ .expr="d.x AND d.z.c OR e.x", .param="", .tdesc=SerdataKeyNestedFinalImplicit_desc }, .sample=&(struct SerdataKeyNestedFinalImplicit){.d.x=1U,.d.z.c=0U,.e.x=0U}, .result = false },
130+
{{ .expr="`e1`=0", .param="", .tdesc=Space_invalid_data_desc }, .sample=&(struct Space_invalid_data){.e1= Space_IDE0}, .result = true },
131+
{{ .expr="`bm1`=(1 << 0)", .param="", .tdesc=Space_invalid_data_desc }, .sample=&(struct Space_invalid_data){.bm1=Space_IDB0}, .result = true },
132+
{{ .expr="b == \'abc\'", .param="", .tdesc=SerdataKeyStringBounded_desc }, .sample=&(struct SerdataKeyStringBounded){.a=1U,.b="abc"}, .result = true },
133+
{{ .expr="b == \'abcd\'", .param="", .tdesc=SerdataKeyString_desc }, .sample=&(struct SerdataKeyString){.a=1U,.b="abcd"}, .result = true },
134+
/* FIXME: unsupported case because of "union" keys limitation.
135+
* {{ .expr="`um_sub1.m_int32`=0", .param="", .tdesc=dunion_desc }, .sample=&(struct dunion){._d=16,._u.um_sub1.m_int32=0}, .result = false }, */
136+
#ifdef DDS_HAS_TYPELIB
137+
{{ .expr="e.z.a = d.z.a", .param="", .tdesc=SerdataKeyNestedFinalImplicit_desc }, .sample=&(struct SerdataKeyNestedFinalImplicit){.e.z.a=1U,.d.z.a=0U}, .result = false },
138+
{{ .expr="b = by OR by = bx.ny", .param="", .tdesc=SerdataKeyInheritMutable_desc }, .sample=&(struct SerdataKeyInheritMutable){.b=1U,.parent={.by=0U,.bx.ny=0U}}, .result = true },
139+
{{ .expr="a + b", .param="", .tdesc=SerdataKeyOrder_desc }, .sample=&(struct SerdataKeyOrder){.a=1U,.b=1U,.c=0U}, .result = true },
140+
{{ .expr="a + b OR ?1 * c", .param="0", .tdesc=SerdataKeyOrderId_desc }, .sample=&(struct SerdataKeyOrderId){.a=1U,.b=0U,.c=0U}, .result = true },
141+
{{ .expr="x AND y OR z.b", .param="", .tdesc=SerdataKeyOrderFinalNestedMutable_desc }, .sample=&(struct SerdataKeyOrderFinalNestedMutable){.x=0U,.y=0U,.z.b=1U}, .result = true },
142+
{{ .expr="d.x AND d.z.c OR e.x", .param="", .tdesc=SerdataKeyNestedFinalImplicit_desc }, .sample=&(struct SerdataKeyNestedFinalImplicit){.d.x=1U,.d.z.c=0U,.e.x=0U}, .result = false },
143+
#else
144+
{{ .expr="d.z.a = d.z.c", .param="", .tdesc=SerdataKeyNestedFinalImplicit_desc }, .sample=&(struct SerdataKeyNestedFinalImplicit){.d.z.a=1U,.d.z.c=0U}, .result = false },
145+
{{ .expr="bx.nz=bz OR bz=bx.nx", .param="", .tdesc=SerdataKeyInheritMutable_desc }, .sample=&(struct SerdataKeyInheritMutable){.parent={.bz=1U,.bx.nz=1U,.bx.nx=1U}}, .result = true },
146+
{{ .expr="a + c", .param="", .tdesc=SerdataKeyOrder_desc }, .sample=&(struct SerdataKeyOrder){.a=1U,.c=0U}, .result = true },
147+
{{ .expr="a + c OR ?1 * c", .param="0", .tdesc=SerdataKeyOrderId_desc }, .sample=&(struct SerdataKeyOrderId){.a=1U,.c=0U}, .result = true },
148+
{{ .expr="x AND z.c OR z.a", .param="", .tdesc=SerdataKeyOrderFinalNestedMutable_desc }, .sample=&(struct SerdataKeyOrderFinalNestedMutable){.x=0U,.z.c=0U,.z.b=1U}, .result = false },
149+
{{ .expr="d.x AND d.z.c OR f", .param="", .tdesc=SerdataKeyNestedFinalImplicit_desc }, .sample=&(struct SerdataKeyNestedFinalImplicit){.d.x=1U,.d.z.c=0U,.f=0U}, .result = false },
150+
#endif
140151
};
141152

142153
size_t ntest = sizeof(test) / sizeof(test[0]);
@@ -150,9 +161,11 @@ CU_Test(ddsc_expr_filter, accept)
150161
ret = init_dds_expression_filter (participant, &test[i].b, &flt);
151162
CU_ASSERT (ret == DDS_RETCODE_OK);
152163

164+
#ifdef DDS_HAS_TYPELIB
153165
/* validate that result descriptor created correctly */
154-
const dds_topic_descriptor_t *new_desc = ((struct dds_expression_filter *)flt)->desc;
155-
CU_ASSERT (((struct dds_expression_filter *)flt)->bin_expr->nparams == new_desc->m_nkeys);
166+
const struct dds_cdrstream_desc new_desc = ((struct dds_sertype_default *)(((struct dds_expression_filter *)flt)->st))->type;
167+
CU_ASSERT (((struct dds_expression_filter *)flt)->bin_expr->nparams == new_desc.keys.nkeys);
168+
#endif
156169

157170
bool res = dds_filter_writer_accept (flt, NULL, test[i].sample);
158171
CU_ASSERT (res == test[i].result);
@@ -171,9 +184,15 @@ CU_Test(ddsc_expr_filter, init_fini)
171184
char *fields; // keyed field on a result type sep. by ' '
172185
} expec;
173186
} test[] = {
174-
{{ .expr="a + b + c", .param="", .tdesc=SerdataKeyOrder_desc }, .expec={"`a` `b` `c`" } },
175-
{{ .expr="a + b OR ?1 * c", .param="0", .tdesc=SerdataKeyOrderId_desc }, .expec={"`a` `b`" } },
176-
{{ .expr="x AND y OR z.b", .param="", .tdesc=SerdataKeyOrderFinalNestedMutable_desc }, .expec={"`x` `y` `z.b`" } }
187+
#ifdef DDS_HAS_TYPELIB
188+
{{ .expr="a + b + c", .param="", .tdesc=SerdataKeyOrder_desc }, .expec={"`a` `b` `c`" } },
189+
{{ .expr="a + b OR ?1 * c", .param="0", .tdesc=SerdataKeyOrderId_desc }, .expec={"`a` `b`" } },
190+
{{ .expr="x AND y OR z.b", .param="", .tdesc=SerdataKeyOrderFinalNestedMutable_desc }, .expec={"`x` `y` `z.b`" } }
191+
#else
192+
{{ .expr="a", .param="", .tdesc=SerdataKeyOrder_desc }, .expec={"`a` `c`" } },
193+
{{ .expr="a OR ?1 * c", .param="0", .tdesc=SerdataKeyOrderId_desc }, .expec={"`a` `c`" } },
194+
{{ .expr="x OR z.a", .param="", .tdesc=SerdataKeyOrderFinalNestedMutable_desc }, .expec={"`x` `z.a` `z.c`" } }
195+
#endif
177196
};
178197

179198
size_t ntest = sizeof(test) / sizeof(test[0]);
@@ -188,8 +207,10 @@ CU_Test(ddsc_expr_filter, init_fini)
188207
CU_ASSERT (ret == DDS_RETCODE_OK);
189208

190209
/* validate that result descriptor created correctly */
191-
const dds_topic_descriptor_t *new_desc = ((struct dds_expression_filter *)flt)->desc;
192-
CU_ASSERT (((struct dds_expression_filter *)flt)->bin_expr->nparams == new_desc->m_nkeys);
210+
const struct dds_cdrstream_desc new_desc = ((struct dds_sertype_default *)(((struct dds_expression_filter *)flt)->st))->type;
211+
#ifdef DDS_HAS_TYPELIB
212+
CU_ASSERT (((struct dds_expression_filter *)flt)->bin_expr->nparams == new_desc.keys.nkeys);
213+
#endif
193214

194215
int token = 0;
195216
int token_sz = 0;
@@ -199,7 +220,7 @@ CU_Test(ddsc_expr_filter, init_fini)
199220
char *field = ddsrt_strndup((const char *)(cursor - token_sz + 1U), (size_t)token_sz - 2U);
200221

201222
bool found = false;
202-
for (size_t j = 0; j < new_desc->m_nkeys && !(found = !strcmp(field, new_desc->m_keys[j].m_name)); j++) {}
223+
for (size_t j = 0; j < new_desc.keys.nkeys && !(found = !strcmp(field, new_desc.keys.keys[j].name)); j++) {}
203224
CU_ASSERT (found);
204225
ddsrt_free (field);
205226
}

src/core/ddsc/tests/topic_filter.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,7 @@ CU_Test (ddsc_content_filter, basic)
682682
CU_ASSERT_FATAL (dp[i] > 0);
683683
for (int j = 0; j < 2; j++)
684684
{
685-
tp[i][j] = dds_create_topic (dp[i], &Space_Type1_desc, topicname, qos, NULL);
685+
tp[i][j] = dds_create_topic (dp[i], &Space_Type0_desc, topicname, qos, NULL);
686686
CU_ASSERT_FATAL (tp[i][j] > 0);
687687
if (j == 0)
688688
{
@@ -718,9 +718,9 @@ CU_Test (ddsc_content_filter, basic)
718718
{
719719
for (int j = 0; j < 2; j++)
720720
{
721-
ret = dds_write (wr[i][j], &(Space_Type1){1,i,j});
721+
ret = dds_write (wr[i][j], &(Space_Type0){1,i,j});
722722
CU_ASSERT_FATAL (ret == 0);
723-
ret = dds_write (wr[i][j], &(Space_Type1){2,i,j});
723+
ret = dds_write (wr[i][j], &(Space_Type0){2,i,j});
724724
CU_ASSERT_FATAL (ret == 0);
725725
}
726726
}

0 commit comments

Comments
 (0)