-
Notifications
You must be signed in to change notification settings - Fork 4k
ARROW-12713 [C++] String reverse kernel #10317
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
Closed
Closed
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
50eb552
adding basic impl for string reverse
nirandaperera 9911529
adding basic test case
nirandaperera f8fe15d
separating ascii and utf8 reverse kernels
nirandaperera c84ac03
minor changes
nirandaperera 124730e
making minor changes
nirandaperera 5ca7594
editing tests
nirandaperera b8a4bb3
adding review changes
nirandaperera 55e39ac
adding review changes
nirandaperera 24a6088
adding rst docs
nirandaperera 2fd1cc3
adding review comments
nirandaperera 1af4985
adding python docs rst
nirandaperera 0bbefa8
Update cpp/src/arrow/compute/kernels/scalar_string_test.cc
nirandaperera 2c18619
fixing lint problems
nirandaperera 6b27e54
moving ValidUtf8CodepointByteSize to util/utf8.h
nirandaperera 7311300
fixing lint issues
nirandaperera File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,6 +91,31 @@ TYPED_TEST(TestStringKernels, AsciiLower) { | |
| "[\"aaazzæÆ&\", null, \"\", \"bbb\"]"); | ||
| } | ||
|
|
||
| TYPED_TEST(TestStringKernels, AsciiReverse) { | ||
| this->CheckUnary("ascii_reverse", "[]", this->type(), "[]"); | ||
| this->CheckUnary("ascii_reverse", R"(["abcd", null, "", "bbb"])", this->type(), | ||
| R"(["dcba", null, "", "bbb"])"); | ||
|
|
||
| Datum invalid_input = ArrayFromJSON(this->type(), R"(["aAazZæÆ&", null, "", "bbb"])"); | ||
| EXPECT_RAISES_WITH_MESSAGE_THAT(Invalid, | ||
| testing::HasSubstr("Non-ASCII sequence in input"), | ||
| CallFunction("ascii_reverse", {invalid_input})); | ||
| } | ||
|
|
||
| TYPED_TEST(TestStringKernels, Utf8Reverse) { | ||
| this->CheckUnary("utf8_reverse", "[]", this->type(), "[]"); | ||
| this->CheckUnary("utf8_reverse", R"(["abcd", null, "", "bbb"])", this->type(), | ||
| R"(["dcba", null, "", "bbb"])"); | ||
| this->CheckUnary("utf8_reverse", R"(["aAazZæÆ&", null, "", "bbb", "ɑɽⱤæÆ"])", | ||
| this->type(), R"(["&ÆæZzaAa", null, "", "bbb", "ÆæⱤɽɑ"])"); | ||
|
|
||
| // inputs with malformed utf8 chars would produce garbage output, but the end result | ||
| // would produce arrays with same lengths. Hence checking offset buffer equality | ||
| auto malformed_input = ArrayFromJSON(this->type(), "[\"ɑ\xFFɑa\", \"ɽ\xe1\xbdɽa\"]"); | ||
| const Result<Datum>& res = CallFunction("utf8_reverse", {malformed_input}); | ||
| ASSERT_TRUE(res->array()->buffers[1]->Equals(*malformed_input->data()->buffers[1])); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a nit, but FTR we probably have a |
||
| } | ||
nirandaperera marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| TEST(TestStringKernels, LARGE_MEMORY_TEST(Utf8Upper32bitGrowth)) { | ||
| // 0x7fff * 0xffff is the max a 32 bit string array can hold | ||
| // since the utf8_upper kernel can grow it by 3/2, the max we should accept is is | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.