Skip to content

s3select: add trim operator , fix substring and bypass boost::spirit rescan#39

Merged
galsalomon66 merged 4 commits intoceph:masterfrom
albin-antony:substr-fix
Dec 26, 2020
Merged

s3select: add trim operator , fix substring and bypass boost::spirit rescan#39
galsalomon66 merged 4 commits intoceph:masterfrom
albin-antony:substr-fix

Conversation

@albin-antony
Copy link

Align ceph s3select with aws.

Signed-off-by: Albin Antony aantony@redhat.com

@albin-antony albin-antony force-pushed the substr-fix branch 2 times, most recently from 35dc415 to c5caf63 Compare December 2, 2020 10:15

substr_one_arg = (bsc::str_p("substring") >> '(' >> (arithmetic_expression >> bsc::str_p(",") >> arithmetic_expression) >> ')') [BOOST_BIND_ACTION(push_substr_one_arg)];

substr_two_arg = (bsc::str_p("substring") >> '(' >> (arithmetic_expression >> bsc::str_p(",") >> arithmetic_expression >> bsc::str_p(",") >> arithmetic_expression) >> ')') [BOOST_BIND_ACTION(push_substr_two_arg)];

Choose a reason for hiding this comment

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

no need for substr_one_arg / substr_two_arg rules.
the rule for function accept both rules , the operator will handle those different functions.

Copy link
Author

Choose a reason for hiding this comment

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

Argument order reverses for push_substr_from and push_substr_from_for in operator. I have modified substring operator to accommodate that. Should I create new operator for 'from' and 'from_for'?

Choose a reason for hiding this comment

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

it better to do it in single operator (re-use code).
main consideration is performance.
the /operator()/ is very intensive , thus code should be compact as possible.

@albin-antony albin-antony force-pushed the substr-fix branch 2 times, most recently from 011396e to 7c5daee Compare December 3, 2020 10:50
{"float", s3select_func_En_t::TO_FLOAT},
{"substr", s3select_func_En_t::SUBSTR},
{"substring", s3select_func_En_t::SUBSTR},
{"substring_from", s3select_func_En_t::SUBSTR_FROM},
Copy link

@galsalomon66 galsalomon66 Dec 4, 2020

Choose a reason for hiding this comment

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

must "hide" those functions with '#' ( "#substring_from#")

self->getAction()->exprQ.pop_back();
func->push_argument(inp_expr);

base_statement* inp_exp = self->getAction()->exprQ.back();

Choose a reason for hiding this comment

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

typo:
use better name for variables , it makes the code more readable
in this case, it will describe the order of parameters and their roles.

iter++;
to = *iter;
v_to = to->eval();
if (v_to.is_string())

Choose a reason for hiding this comment

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

better to use /is_number()/

iter++;
str = *iter;
v_to = to->eval();
if (v_to.is_string())

Choose a reason for hiding this comment

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

better to use /is_number()/

int str_length = strlen(v_str.str());

v_from = from->eval();
if(v_from.is_string())

Choose a reason for hiding this comment

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

better to use /is_number()/


substr_from = (bsc::str_p("substring") >> '(' >> (arithmetic_expression >> bsc::str_p("from") >> arithmetic_expression) >> ')') [BOOST_BIND_ACTION(push_substr_from)];

substr_from_for = (bsc::str_p("substring") >> '(' >> (arithmetic_expression >> bsc::str_p("from") >> arithmetic_expression >> bsc::str_p("for") >> arithmetic_expression) >> ')') [BOOST_BIND_ACTION(push_substr_from_for)];

Choose a reason for hiding this comment

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

ok,
those rules accepts the uniq syntax for substring function.

@galsalomon66
Copy link

galsalomon66 commented Dec 4, 2020

looks good.
i added some comments.

@albin-antony
Copy link
Author

Thanks. I have addressed the comments.

@galsalomon66
Copy link

substr::operator() and substr_from::operator
are actually identical , as should (and duplicated).
it seems that order of parameters is the only difference, and this can be arrange.
duplicate code , is error-prone.
one solution could be, that both operators will inherit from the same base.

… to bind-action more than once per the same text)

Signed-off-by: gal salomon <gal.salomon@gmail.com>
Align ceph s3select with aws.

Signed-off-by: Albin Antony <aantony@redhat.com>
@albin-antony albin-antony changed the title s3select: fix substring s3select: add trim operator , fix substring and bypass boost::spirit rescan Dec 15, 2020
}
}

void push_trim_remove_type::builder(s3select* self, const char* a, const char* b) const

Choose a reason for hiding this comment

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

push_trim_type identical to push_trim_remove_type

Copy link
Author

Choose a reason for hiding this comment

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

Thanks! I have missed it

albin-antony and others added 2 commits December 16, 2020 13:59
Signed-off-by: Albin Antony <aantony@redhat.com>
Signed-off-by: Albin Antony <aantony@redhat.com>
Copy link

@galsalomon66 galsalomon66 left a comment

Choose a reason for hiding this comment

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

good coverage

@galsalomon66 galsalomon66 merged commit 0ca1e85 into ceph:master Dec 26, 2020
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.

2 participants