max_samples_per_read and query condition

2 posts / 0 new
Last post
Offline
Last seen: 6 years 9 months ago
Joined: 07/12/2012
Posts: 51
max_samples_per_read and query condition

I would like to understand how the QoS setting, max_samples_per_read  relate to a read with a query condition. Will max_samples_per_read specify the total samples in the reader or the samples that satisfy the query ?

From my limited testing it seems max_samples_per_read specifies the total number of samples that will be read including the samples that do not satisfy the query. 

By an example. Say I have 5000 samples in a reader, max_samples_per_read is set to 2000 and I make a read with a query_condition where 1500 samples satisfy the query. I expected to get all 1500 samples, but do not. Setting max_samples_per_read to 5000 will return the full 1500. I would like to know  if this is the expected behaviour.

 

Edit: Here is more information on the use case.

 

A reader with a large number of samples in its cache but the cache does not get updated often. The nature of the data is configuration data so it is typically published only when the system start up.The application needs to query the data repeatedly with different queries. It seems to me the first read()  will set state of the samples such that SampleStateKind cannot be used (or am I mistaken ?). So far I used a large enough  max_samples_per_read together with SampleStateKind.ANY_SAMPLE_STATE on each query to insure all data is returned in a read(). Is there a better way to do this ?

Thanks 

Organization:
Offline
Last seen: 1 month 2 weeks ago
Joined: 10/22/2018
Posts: 91

Hi Nico,

I've run a small reproducer to test your issue and my observations differ from yours.

I created a DataWriter which published 20 samples with a value of either '1' or '0'. My DataReader then received these samples and had in its queue the following:
0,0,0,1,1,1,1,0,0,1,...
I used read_w_condition() such that only samples with a value of '0' were read.
With max_samples_per_read set to 5, my first read() returned samples 1, 2, 3, 8 and 9.

Could you give me some more details on how you tested your observation?

Sam