Skip to content

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

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

galsalomon66 merged 4 commits into
ceph:masterfrom
albin-antony:substr-fix

Conversation

@albin-antony

Copy link
Copy Markdown

Align ceph s3select with aws.

Signed-off-by: Albin Antony [email protected]

@albin-antony
albin-antony force-pushed the substr-fix branch 2 times, most recently from 35dc415 to c5caf63 Compare December 2, 2020 10:15
Comment thread include/s3select.h Outdated

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)];

Copy link
Copy Markdown

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
Copy Markdown
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'?

Copy link
Copy Markdown

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
Comment thread include/s3select_functions.h Outdated
{"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},

@galsalomon66 galsalomon66 Dec 4, 2020 •

Copy link
Copy Markdown

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#")

Comment thread include/s3select.h Outdated
self->getAction()->exprQ.pop_back();
func->push_argument(inp_expr);

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

Copy link
Copy Markdown

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.

Comment thread include/s3select_functions.h Outdated
iter++;
to = *iter;
v_to = to->eval();
if (v_to.is_string())

Copy link
Copy Markdown

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()/

Comment thread include/s3select_functions.h Outdated
iter++;
str = *iter;
v_to = to->eval();
if (v_to.is_string())

Copy link
Copy Markdown

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()/

Comment thread include/s3select_functions.h Outdated
int str_length = strlen(v_str.str());

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

Copy link
Copy Markdown

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()/

Comment thread include/s3select.h

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)];

Copy link
Copy Markdown

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

galsalomon66 commented Dec 4, 2020 •

Copy link
Copy Markdown

looks good.
i added some comments.

@albin-antony

Copy link
Copy Markdown
Author

Thanks. I have addressed the comments.

@galsalomon66

Copy link
Copy Markdown

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 <[email protected]>
Align ceph s3select with aws.

Signed-off-by: Albin Antony <[email protected]>
@albin-antony albin-antony changed the title s3select: fix substring s3select: add trim operator , fix substring and bypass boost::spirit rescan Dec 15, 2020
Comment thread include/s3select.h Outdated
}
}

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

Copy link
Copy Markdown

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
Copy Markdown
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 <[email protected]>
Signed-off-by: Albin Antony <[email protected]>

@galsalomon66 galsalomon66 left a comment

Copy link
Copy Markdown

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