You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by GitBox <gi...@apache.org> on 2021/08/03 01:54:24 UTC
[GitHub] [arrow] edponce opened a new pull request #10857: ARROW-12944: [C++] String capitalize kernel
edponce opened a new pull request #10857:
URL: https://github.com/apache/arrow/pull/10857
This PR adds scalar compute functions for string capitalization, namely "ascii_capitalize" and "utf8_capitalize".
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou closed pull request #10857: ARROW-12944: [C++] String capitalize kernel
Posted by GitBox <gi...@apache.org>.
pitrou closed pull request #10857:
URL: https://github.com/apache/arrow/pull/10857
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] edponce commented on pull request #10857: ARROW-12944: [C++] String capitalize kernel
Posted by GitBox <gi...@apache.org>.
edponce commented on pull request #10857:
URL: https://github.com/apache/arrow/pull/10857#issuecomment-893411107
Some tests invoke the incorrect kernel (ASCII test uses `utf8_capitalize` and viceversa). These "typos" are fixed in https://github.com/apache/arrow/pull/10869
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] edponce commented on a change in pull request #10857: ARROW-12944: [C++] String capitalize kernel
Posted by GitBox <gi...@apache.org>.
edponce commented on a change in pull request #10857:
URL: https://github.com/apache/arrow/pull/10857#discussion_r681705870
##########
File path: cpp/src/arrow/compute/kernels/scalar_string.cc
##########
@@ -443,6 +443,24 @@ struct AsciiLower {
}
};
+struct AsciiCapitalizeTransform : public StringTransformBase {
+ int64_t Transform(const uint8_t* input, int64_t input_string_ncodeunits,
+ uint8_t* output) {
+ if (input_string_ncodeunits > 0) {
+ output[0] = ascii_toupper(input[0]);
+ std::memcpy(output + 1, input + 1, input_string_ncodeunits - 1);
+ }
+ return input_string_ncodeunits;
+ }
+
+ Status InvalidStatus() override {
Review comment:
An artifact of copy-paste from another compute function...removed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on pull request #10857: ARROW-12944: [C++] String capitalize kernel
Posted by GitBox <gi...@apache.org>.
pitrou commented on pull request #10857:
URL: https://github.com/apache/arrow/pull/10857#issuecomment-892606845
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] edponce commented on a change in pull request #10857: ARROW-12944: [C++] String capitalize kernel
Posted by GitBox <gi...@apache.org>.
edponce commented on a change in pull request #10857:
URL: https://github.com/apache/arrow/pull/10857#discussion_r681661295
##########
File path: cpp/src/arrow/compute/kernels/scalar_string.cc
##########
@@ -4018,6 +4036,13 @@ const FunctionDoc ascii_lower_doc(
"non-ASCII characters, use \"utf8_lower\" instead."),
{"strings"});
+const FunctionDoc ascii_capitalize_doc(
+ "Capilatize the first character of ASCII input",
+ ("For each string in `strings`, return a capitalized version.\n\n"
+ "This function assumes the input is fully ASCII. If it may contain\n"
+ "non-ASCII characters, use \"utf8_capitalize\" instead."),
Review comment:
Working on it locally, I should have made a draft PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on a change in pull request #10857: ARROW-12944: [C++] String capitalize kernel
Posted by GitBox <gi...@apache.org>.
pitrou commented on a change in pull request #10857:
URL: https://github.com/apache/arrow/pull/10857#discussion_r682534410
##########
File path: cpp/src/arrow/compute/kernels/scalar_string.cc
##########
@@ -4028,17 +4087,14 @@ const FunctionDoc utf8_lower_doc(
"Transform input to lowercase",
("For each string in `strings`, return a lowercase version."), {"strings"});
-const FunctionDoc ascii_reverse_doc(
- "Reverse ASCII input",
- ("For each ASCII string in `strings`, return a reversed version.\n\n"
- "This function assumes the input is fully ASCII. If it may contain\n"
- "non-ASCII characters, use \"utf8_reverse\" instead."),
- {"strings"});
+const FunctionDoc utf8_capitalize_doc(
+ "Capitalize the first codepoint of UTF8 input",
+ ("For each UTF8 string in `strings`, return a capitalized version."), {"strings"});
Review comment:
Nit, but no need to specify "UTF8". The input is of string type, so UTF8 by definition.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] edponce commented on pull request #10857: ARROW-12944: [C++] String capitalize kernel
Posted by GitBox <gi...@apache.org>.
edponce commented on pull request #10857:
URL: https://github.com/apache/arrow/pull/10857#issuecomment-892624242
@pitrou I pushed a change after you rebased, so I will fix conflicts and re-push.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on pull request #10857: ARROW-12944: [C++] String capitalize kernel
Posted by GitBox <gi...@apache.org>.
pitrou commented on pull request #10857:
URL: https://github.com/apache/arrow/pull/10857#issuecomment-892606845
Rebased, will merge if green.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on pull request #10857: ARROW-12944: [C++] String capitalize kernel
Posted by GitBox <gi...@apache.org>.
pitrou commented on pull request #10857:
URL: https://github.com/apache/arrow/pull/10857#issuecomment-892624713
Hmm, another commit was lost then...
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on a change in pull request #10857: ARROW-12944: [C++] String capitalize kernel
Posted by GitBox <gi...@apache.org>.
pitrou commented on a change in pull request #10857:
URL: https://github.com/apache/arrow/pull/10857#discussion_r682534410
##########
File path: cpp/src/arrow/compute/kernels/scalar_string.cc
##########
@@ -4028,17 +4087,14 @@ const FunctionDoc utf8_lower_doc(
"Transform input to lowercase",
("For each string in `strings`, return a lowercase version."), {"strings"});
-const FunctionDoc ascii_reverse_doc(
- "Reverse ASCII input",
- ("For each ASCII string in `strings`, return a reversed version.\n\n"
- "This function assumes the input is fully ASCII. If it may contain\n"
- "non-ASCII characters, use \"utf8_reverse\" instead."),
- {"strings"});
+const FunctionDoc utf8_capitalize_doc(
+ "Capitalize the first codepoint of UTF8 input",
+ ("For each UTF8 string in `strings`, return a capitalized version."), {"strings"});
Review comment:
Nit, but no need to specify "UTF8". The input is of string type, so UTF8 by definition.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou closed pull request #10857: ARROW-12944: [C++] String capitalize kernel
Posted by GitBox <gi...@apache.org>.
pitrou closed pull request #10857:
URL: https://github.com/apache/arrow/pull/10857
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on pull request #10857: ARROW-12944: [C++] String capitalize kernel
Posted by GitBox <gi...@apache.org>.
pitrou commented on pull request #10857:
URL: https://github.com/apache/arrow/pull/10857#issuecomment-892625287
Recommend starting from https://github.com/apache/arrow/commit/9d7f298bf1515c0014b2cd138c475e7bc1deda87 and then applying the buffer overflow fix.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] edponce commented on pull request #10857: ARROW-12944: [C++] String capitalize kernel
Posted by GitBox <gi...@apache.org>.
edponce commented on pull request #10857:
URL: https://github.com/apache/arrow/pull/10857#issuecomment-892624242
@pitrou I pushed a change after you rebased, so I will fix conflicts and re-push.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] pitrou commented on a change in pull request #10857: ARROW-12944: [C++] String capitalize kernel
Posted by GitBox <gi...@apache.org>.
pitrou commented on a change in pull request #10857:
URL: https://github.com/apache/arrow/pull/10857#discussion_r681623417
##########
File path: cpp/src/arrow/compute/kernels/scalar_string_test.cc
##########
@@ -395,6 +395,13 @@ TYPED_TEST(TestStringKernels, AsciiLower) {
"[\"aaazzæÆ&\", null, \"\", \"bbb\"]");
}
+TYPED_TEST(TestStringKernels, AsciiCapitalize) {
+ this->CheckUnary("ascii_capitalize", "[]", this->type(), "[]");
+ this->CheckUnary("ascii_capitalize",
+ "[\"aAazZæÆ&\", null, \"\", \"bBB\", \"one word\"]", this->type(),
+ "[\"AAazZæÆ&\", null, \"\", \"BBB\", \"One word\"]");
Review comment:
Can you test a bit more thoroughly?
For example in Python:
```python
>>> "hEllo world".capitalize()
'Hello world'
```
##########
File path: cpp/src/arrow/compute/kernels/scalar_string.cc
##########
@@ -443,6 +443,24 @@ struct AsciiLower {
}
};
+struct AsciiCapitalizeTransform : public StringTransformBase {
+ int64_t Transform(const uint8_t* input, int64_t input_string_ncodeunits,
+ uint8_t* output) {
+ if (input_string_ncodeunits > 0) {
+ output[0] = ascii_toupper(input[0]);
+ std::memcpy(output + 1, input + 1, input_string_ncodeunits - 1);
+ }
+ return input_string_ncodeunits;
+ }
+
+ Status InvalidStatus() override {
Review comment:
It's not clear to me why this function is being overriden if the function always returns successfully.
##########
File path: cpp/src/arrow/compute/kernels/scalar_string.cc
##########
@@ -4018,6 +4036,13 @@ const FunctionDoc ascii_lower_doc(
"non-ASCII characters, use \"utf8_lower\" instead."),
{"strings"});
+const FunctionDoc ascii_capitalize_doc(
+ "Capilatize the first character of ASCII input",
+ ("For each string in `strings`, return a capitalized version.\n\n"
+ "This function assumes the input is fully ASCII. If it may contain\n"
+ "non-ASCII characters, use \"utf8_capitalize\" instead."),
Review comment:
I don't see utf8_capitalize in this PR. Is this an oversight?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [arrow] github-actions[bot] commented on pull request #10857: ARROW-12944: [C++] String capitalize kernel
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #10857:
URL: https://github.com/apache/arrow/pull/10857#issuecomment-891449570
https://issues.apache.org/jira/browse/ARROW-12944
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org