Skip to content

Commit a16f9be

Browse files
Fixed serialized minimum sample size callback (#196)
1 parent f8d42bd commit a16f9be

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

rmw_connextdds_common/src/ndds/rmw_type_support_ndds.cpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -646,20 +646,31 @@ RMW_Connext_TypePlugin_get_serialized_sample_min_size(
646646
RTIEncapsulationId encapsulation_id,
647647
unsigned int current_alignment)
648648
{
649+
PRESTypePluginDefaultEndpointData *const epd =
650+
reinterpret_cast<PRESTypePluginDefaultEndpointData *>(endpoint_data);
651+
RMW_Connext_MessageTypeSupport *const type_support =
652+
reinterpret_cast<RMW_Connext_MessageTypeSupport *>(epd->userData);
653+
649654
// The serialized sample min size is not currently available. As a workaround,
650-
// we set it equal to the serialized sample max size.
655+
// we set it equal to the serialized sample max size in case the type is
656+
// bounded, or a fix value of 32 in the case the type is unbounded.
657+
//
658+
// A proper solution would require generating code to retrieve the minimum
659+
// serialized size of a sample.
651660
//
652-
// This effectively limits the number of samples in a batch to one when
653-
// batching is constrained by max_data_bytes
661+
// For bounded types, this effectively limits the number of samples in a batch
662+
// to one when batching is constrained by max_data_bytes
654663
// (writer_qos.batching.max_data_bytes).
655664
//
656665
// To allow multiple samples per batch, the user must configure batching based
657666
// on the number of samples instead (writer_qos.batching.max_samples).
658-
return RMW_Connext_TypePlugin_get_serialized_sample_max_size(
659-
endpoint_data,
660-
include_encapsulation,
661-
encapsulation_id,
662-
current_alignment);
667+
return (type_support->unbounded()) ?
668+
32 :
669+
RMW_Connext_TypePlugin_get_serialized_sample_max_size(
670+
endpoint_data,
671+
include_encapsulation,
672+
encapsulation_id,
673+
current_alignment);
663674
}
664675

665676
static

0 commit comments

Comments
 (0)