RTI Connext Modern C++ API  Version 7.0.0
Filter Use Cases

Working with data filters. More...

Working with data filters.

Introduction

RTI Connext supports filtering data either during the exchange from dds::pub::DataWriter to dds::sub::DataReader, or after the data has been stored at the dds::sub::DataReader.

Filtering during the exchange process is performed by a dds::topic::ContentFilteredTopic, which is created by the dds::sub::DataReader as a way of specifying a subset of the data samples that it wishes to receive.

Filtering samples that have already been received by the dds::sub::DataReader is performed by creating a dds::sub::cond::QueryCondition, which can then used to check for matching samples, be alerted when matching samples arrive, or retrieve matching samples.

Filtering may be performed on any topic, either keyed or un-keyed, except the built-in topics. Filtering may be performed on any field, subset of fields, or combination of fields, subject only to the limitations of the filter syntax.

Code Examples

The following #includes are needed for the examples on this page

#include <iostream>
#include <dds/topic/ddstopic.hpp>
#include <dds/sub/ddssub.hpp>
#include "Foo.hpp"

Filtering with ContentFilteredTopic

Filtering with Query Conditions

Filtering Performance

Although RTI Connext supports filtering on any field or combination of fields using the SQL syntax of the built-in filter, filters for keyed topics that filter solely on the contents of key fields have the potential for much higher performance. This is because for key-only filters, the dds::sub::DataReader caches the results of the filter (pass or not pass) for each instance. When another sample of the same instance is seen at the dds::sub::DataReader, the filter results are retrieved from the cache, dispensing with the need to call the filter function.

This optimization applies to all filtering using the built-in SQL filter, performed by the dds::sub::DataReader, for either dds::topic::ContentFilteredTopic or dds::sub::cond::QueryCondition. This does not apply to filtering perfomed for dds::topic::ContentFilteredTopic by the dds::pub::DataWriter.