Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

to support a feature of content filtered topic #1

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

iuhilnehc-ynos
Copy link
Owner

temporary PR in my repository

rcl/include/rcl/subscription.h Outdated Show resolved Hide resolved
rcl/include/rcl/subscription.h Outdated Show resolved Hide resolved
Chen Lihui added 2 commits December 3, 2020 15:58
Signed-off-by: Chen Lihui <[email protected]>
Signed-off-by: Chen Lihui <[email protected]>
*
* \param[in] option The structure which its resources have to be deallocated.
* \return `RCL_RET_OK` if the memory was successfully freed, or
* \return `RCL_RET_INVALID_ARGUMENT` if log_levels is NULL, or
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* \return `RCL_RET_INVALID_ARGUMENT` if log_levels is NULL, or
* \return `RCL_RET_INVALID_ARGUMENT` if option is NULL, or

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

* Lock-Free | Maybe [1]
*
* \param[in] subscription the subscription object to inspect.
* \param[in] filter_expression An filter expression to set.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* \param[in] filter_expression An filter expression to set.
* \param[in] filter_expression A filter expression to set.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

* it can be NULL if there is no placeholder in filter_expression.
* \return `RCL_RET_OK` if the query was successful, or
* \return `RCL_RET_INVALID_ARGUMENT` if `subscription` is NULL, or
* \return `RCL_RET_INVALID_ARGUMENT` if `filter_expression` is NULL, or
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How we can reset the filtering on subscription? i think that there should be a way to do that, since the application is likely to do the following.

  1. create subscription.
  2. receive messages via subscription.
  3. set content filtering.
  4. receive messages via cft subscription.
  5. reset content filtering.
  6. receive messages via subsciption.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking as following,

  1. If a subscription can be filtered, users should set this subscription with filter_expression(""), not NULL.
  2. receive all messages
  3. update filter_expression with custom value by rcl_subscription_set_cft_expression_parameters, such as "data MATCH 'Hello World: 5'"
  4. receive messages via cft subscription
  5. set filter_expression("") to reset.
  6. receive all messages

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, i see and it works

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, i see and it works

I am sorry. After checking and trying to reproduce the above case, I found it's not supported.

Currently,
User must set content filter topic with a non-empty string for subscription at the beginning, and then update with a new filter (not empty string).
it means if users create a subscription without a content filter expression, this subscription can't subscribe to the content filter topic anymore.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't be 😄 we just trying some new stuff, there will be something like this.

okay that is said, the followings should be done in user application aspect?

  • user creates normal subscription.
  • if user wants to use contentfilter, application provides the filtering expression and parameters which are not NULL. (actually this is the 1st time to create contentfilteredtopic based on the parent topic)
  • user can only have events from contentfilteredtopic but not from parent topic.
  • user can change and modify the filtering expression and parameters which are not NULL.
  • if the user wants to use normal topic (in other words, parent topic) user can specify NULL filtering expression and parameters? rmw takes NULL expression and then in the backend it will delete the contentfilteredtopic?

i am not sure if anything like this feasible, but if we do, it just appears to be the filtering expression and parameters interfaces only for user application. in other words, it can conceal creating/destroying contentfilteredtopic to user application, but rmw should take care of.

* \return `RCL_RET_OK` if the query was successful, or
* \return `RCL_RET_INVALID_ARGUMENT` if `subscription` is NULL, or
* \return `RCL_RET_INVALID_ARGUMENT` if `filter_expression` is NULL, or
* \return `RCL_RET_INCORRECT_RMW_IMPLEMENTATION` if the `node` implementation
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RCL_RET_INCORRECT_RMW_IMPLEMENTATION is going to be defined in rcl later? i do not see this is already supported in rcl. and actually never used.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll remove it

subscription->impl->options = *options;
ret = rcl_subscription_options_copy(options, &subscription->impl->options);
if (RCL_RET_OK != ret) {
ret = RCL_RET_ERROR;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why we need to overwrite the error code here?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

@@ -116,8 +119,12 @@ rcl_subscription_init(
}
subscription->impl->actual_qos.avoid_ros_namespace_conventions =
options->qos.avoid_ros_namespace_conventions;
// options
subscription->impl->options = *options;
ret = rcl_subscription_options_copy(options, &subscription->impl->options);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think at this time, calling rnw_create_subscription is to create parent subscription for content filtering. so actually it just saves filter_expression and expression_parameters, not to be used during creating subscription. am i understanding right? and beside, at this moment, it is likely that filter_expression and expression_parameters are empty, right? because rcl_subscription_set_cft_expression_parameters cannot be called before.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think at this time, calling rnw_create_subscription is to create parent subscription for content filtering. so actually it just saves filter_expression and expression_parameters, not to be used during creating subscription. am i understanding right?

The concrete rmw(rmw_connextdds) had already directly used filter_expression and expression_parameters

subscription->impl->rmw_handle = rmw_create_subscription(
,
I thought that these two parameters should be backed up into rcl_subscription_impl_t, so it can prevent from accessing a pointer that might be changed outside.

and beside, at this moment, it is likely that filter_expression and expression_parameters are empty, right? because rcl_subscription_set_cft_expression_parameters cannot be called before.

Yes.

}
}

if (src->rmw_subscription_options.expression_parameters) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably return error if filter_expression is not null but expression_parameters is null. i believe this case cannot exist.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll move it inside the above if statement.

Copy link
Owner Author

@iuhilnehc-ynos iuhilnehc-ynos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your review, I'll update it

@@ -116,8 +119,12 @@ rcl_subscription_init(
}
subscription->impl->actual_qos.avoid_ros_namespace_conventions =
options->qos.avoid_ros_namespace_conventions;
// options
subscription->impl->options = *options;
ret = rcl_subscription_options_copy(options, &subscription->impl->options);
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think at this time, calling rnw_create_subscription is to create parent subscription for content filtering. so actually it just saves filter_expression and expression_parameters, not to be used during creating subscription. am i understanding right?

The concrete rmw(rmw_connextdds) had already directly used filter_expression and expression_parameters

subscription->impl->rmw_handle = rmw_create_subscription(
,
I thought that these two parameters should be backed up into rcl_subscription_impl_t, so it can prevent from accessing a pointer that might be changed outside.

and beside, at this moment, it is likely that filter_expression and expression_parameters are empty, right? because rcl_subscription_set_cft_expression_parameters cannot be called before.

Yes.

}
}

if (src->rmw_subscription_options.expression_parameters) {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll move it inside the above if statement.

*
* \param[in] option The structure which its resources have to be deallocated.
* \return `RCL_RET_OK` if the memory was successfully freed, or
* \return `RCL_RET_INVALID_ARGUMENT` if log_levels is NULL, or
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

* Lock-Free | Maybe [1]
*
* \param[in] subscription the subscription object to inspect.
* \param[in] filter_expression An filter expression to set.
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

Signed-off-by: Chen Lihui <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants