What is the difference between QueryConditions and ContentFilteredTopics?

RTI Connext supports two ways of filtering data: using QueryConditions and ContentFilteredTopics. These two options differ in the moment when DDS applies the filter.

  • QueryConditions filter data after the DataReader has received and queued it. That means that the application will receive all samples but only take those that match the query.
  • ContentFilteredTopics filter data during the exchange between the DataWriter and the DataReader, since the DataReader declares the subset it wants to receive.

Then, does the data filtering method affect the reception of data? It depends on the method.

  • QueryConditions don't affect the reception of data - i.e., the DataReader receives all samples.
  • Using ContentFilteredTopics does affect the reception of data, since the DataReader will be interested only in a subset of the samples. If the configuration1 allows writer-side filtering, the DataWriter will apply the filter and send only the samples that pass it. If not the DataReader will drop the samples that don't pass the filter before queuing them.

Summary table:

 Affect the reception of dataFilter on 
QueryConditionsNO: DataReader stores all samples and applies the filter on themLocally available (already received) data
ContentFilteredTopicsYES: DataReader stores only the subset of the samples that meet the filtering criteriaThe exchanged samples from the DataWriter to the DataReader

 

1. Where Filtering is Applied—Publishing vs. Subscribing Side

Comments

What is the implication on the DataReader's queue when using query condition?

Let say, if I only do query_condition to get the sample I am interested in, and when the sample filtered arrives I call take(), will only those filtred sample be taken from the queue, and the other being left on the queue?

If so, the queue may reach its resource limit eventually. Do I need to purge the queue from time to time?

Hi Tao,

The query condition is applied on the locally available (already received) data, which means that the DataReader is going to receive all the samples but takes only the ones that match with the query.

As you pointed out, using QueryConditions but taking only a subset of the received samples could end up producing issues related to resource limits. For example, if you are using Reliable Reliability, the DataWriter will send to the DataReader all the samples and will wait until the DataReader confirms every one of them. If you are not taking all the samples from the DataReader queue, at some point depending on the resource limits, the queues could get full and the entities will block.

Using QueryConditions or ContentFilteredTopics really depends on your use case and application logic. If you are only interested in a subset of the samples based on the filter and the rest can be discarded, you could consider using a ContentFilteredTopic in the DataReader instead of the QueryCondition. Using a ContentFilteredTopic the DataReader will only receive the samples that pass the filter and drop the rest.

Regards,

Sandra