Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 3.9k
[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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
aa17b10cf0ea2db40e54a5d144514d3a889e64765cbc2cced77e21a048311fdFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| 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.
Uh oh!There was an error while loading. Please reload this page. | ||||||
| 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.
Uh oh!There was an error while loading. Please reload this page. | ||||||
| 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.
Uh oh!There was an error while loading. Please reload this page. | ||||||
| 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 | ||||||
Uh oh!
There was an error while loading. Please reload this page.