-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[fix](ip) fix datatype serde for ipv6 with rowstore #43065
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
aa17b10
fix ipv6 with rowstore
cf0ea2d
add regress tests
b40e54a
add "store_row_column" = "true"
5d14451
update ipvalue with int128
4d3a889
delete file
e64765c
format file
bc2cced
fix ut for ipv6 serde
77e21a0
fix ipserde
48311fd
update ip
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 | ||||
|---|---|---|---|---|---|---|
|
|
@@ -220,4 +220,66 @@ TEST(DataTypeSerDeTest, DataTypeScalaSerDeTest) { | |||||
| serialize_and_deserialize_pb_test(); | ||||||
| } | ||||||
|
|
||||||
| TEST(DataTypeSerDeTest, DataTypeRowStoreSerDeTest) { | ||||||
| // ipv6 | ||||||
| { | ||||||
| std::string ip = "5be8:dde9:7f0b:d5a7:bd01:b3be:9c69:573b"; | ||||||
| auto vec = vectorized::ColumnVector<IPv6>::create(); | ||||||
| IPv6Value ipv6; | ||||||
| EXPECT_TRUE(ipv6.from_string(ip)); | ||||||
amorynan marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| vec->insert(ipv6.value()); | ||||||
|
|
||||||
| vectorized::DataTypePtr data_type(std::make_shared<vectorized::DataTypeIPv6>()); | ||||||
| auto serde = data_type->get_serde(0); | ||||||
| JsonbWriterT<JsonbOutStream> jsonb_writer; | ||||||
| Arena pool; | ||||||
| jsonb_writer.writeStartObject(); | ||||||
| serde->write_one_cell_to_jsonb(*vec, jsonb_writer, &pool, 0, 0); | ||||||
| jsonb_writer.writeEndObject(); | ||||||
| auto jsonb_column = ColumnString::create(); | ||||||
| jsonb_column->insert_data(jsonb_writer.getOutput()->getBuffer(), | ||||||
| jsonb_writer.getOutput()->getSize()); | ||||||
| StringRef jsonb_data = jsonb_column->get_data_at(0); | ||||||
| auto pdoc = JsonbDocument::createDocument(jsonb_data.data, jsonb_data.size); | ||||||
|
Contributor
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. warning: 'auto pdoc' can be declared as 'auto *pdoc' [readability-qualified-auto]
Suggested change
|
||||||
| JsonbDocument& doc = *pdoc; | ||||||
| for (auto it = doc->begin(); it != doc->end(); ++it) { | ||||||
| serde->read_one_cell_from_jsonb(*vec, it->value()); | ||||||
| } | ||||||
| EXPECT_TRUE(vec->size() == 2); | ||||||
| IPv6 data = vec->get_element(1); | ||||||
| IPv6Value ipv6_value(data); | ||||||
| EXPECT_EQ(ipv6_value.to_string(), ip); | ||||||
| } | ||||||
|
|
||||||
| // ipv4 | ||||||
| { | ||||||
| std::string ip = "192.0.0.1"; | ||||||
| auto vec = vectorized::ColumnVector<IPv4>::create(); | ||||||
| IPv4Value ipv4; | ||||||
| EXPECT_TRUE(ipv4.from_string(ip)); | ||||||
amorynan marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| vec->insert(ipv4.value()); | ||||||
|
|
||||||
| vectorized::DataTypePtr data_type(std::make_shared<vectorized::DataTypeIPv4>()); | ||||||
| auto serde = data_type->get_serde(0); | ||||||
| JsonbWriterT<JsonbOutStream> jsonb_writer; | ||||||
| Arena pool; | ||||||
| jsonb_writer.writeStartObject(); | ||||||
| serde->write_one_cell_to_jsonb(*vec, jsonb_writer, &pool, 0, 0); | ||||||
| jsonb_writer.writeEndObject(); | ||||||
| auto jsonb_column = ColumnString::create(); | ||||||
| jsonb_column->insert_data(jsonb_writer.getOutput()->getBuffer(), | ||||||
| jsonb_writer.getOutput()->getSize()); | ||||||
| StringRef jsonb_data = jsonb_column->get_data_at(0); | ||||||
| auto pdoc = JsonbDocument::createDocument(jsonb_data.data, jsonb_data.size); | ||||||
amorynan marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| JsonbDocument& doc = *pdoc; | ||||||
| for (auto it = doc->begin(); it != doc->end(); ++it) { | ||||||
| serde->read_one_cell_from_jsonb(*vec, it->value()); | ||||||
| } | ||||||
| EXPECT_TRUE(vec->size() == 2); | ||||||
| IPv4 data = vec->get_element(1); | ||||||
| IPv4Value ipv4_value(data); | ||||||
| EXPECT_EQ(ipv4_value.to_string(), ip); | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| } // namespace doris::vectorized | ||||||
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.