-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[fix](column) Fix incorrect for-loop #62517
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
+1,083
−1
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
ffa7cb7
[fix](column) Fix incorrect for-loop
Gabriel39 22c0504
update
Gabriel39 637a72a
update
Gabriel39 c8ab680
update
Gabriel39 4c47a78
Update be/test/core/column/predicate_column_test.cpp
Gabriel39 ff57b77
update
Gabriel39 1714a0a
Update be/test/core/column/predicate_column_test.cpp
Gabriel39 1f1d8d8
update
Gabriel39 384f223
update
Gabriel39 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
Some comments aren't visible on the classic Files Changed page.
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 |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| // Licensed to the Apache Software Foundation (ASF) under one | ||
| // or more contributor license agreements. See the NOTICE file | ||
| // distributed with this work for additional information | ||
| // regarding copyright ownership. The ASF licenses this file | ||
| // to you under the Apache License, Version 2.0 (the | ||
| // "License"); you may not use this file except in compliance | ||
| // with the License. You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, | ||
| // software distributed under the License is distributed on an | ||
| // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| // KIND, either express or implied. See the License for the | ||
| // specific language governing permissions and limitations | ||
| // under the License. | ||
|
|
||
| #include "core/column/predicate_column.h" | ||
|
|
||
| #include <gtest/gtest-message.h> | ||
| #include <gtest/gtest-test-part.h> | ||
| #include <gtest/gtest.h> | ||
|
|
||
| #include "common/status.h" | ||
| #include "core/column/column_nullable.h" | ||
| #include "core/data_type/data_type.h" | ||
| #include "core/data_type/data_type_number.h" | ||
| #include "core/data_type/define_primitive_type.h" | ||
| #include "core/field.h" | ||
| #include "core/types.h" | ||
| #include "testutil/column_helper.h" | ||
|
|
||
| namespace doris { | ||
|
|
||
| TEST(PredicateColumnTest, InsertDuplicateFieldsString) { | ||
| auto column = PredicateColumnType<TYPE_STRING>::create(); | ||
| column->reserve(10); | ||
|
|
||
| // Test with a simple string - insert 5 duplicates | ||
| std::string test_str = "hello"; | ||
| Field field = Field::create_field<TYPE_STRING>(test_str); | ||
| column->insert_duplicate_fields(field, 5); | ||
|
|
||
| EXPECT_EQ(column->size(), 5); | ||
| for (size_t i = 0; i < 5; i++) { | ||
| StringRef ref = column->get_data()[i]; | ||
| EXPECT_EQ(ref.size, test_str.size()); | ||
| EXPECT_EQ(std::string(ref.data, ref.size), test_str); | ||
| } | ||
|
|
||
| // Insert another batch to verify memory doesn't overlap | ||
| std::string str2 = "world"; | ||
| Field field2 = Field::create_field<TYPE_STRING>(str2); | ||
| column->insert_duplicate_fields(field2, 3); | ||
|
|
||
| EXPECT_EQ(column->size(), 8); | ||
| // Verify first batch is still correct | ||
| for (size_t i = 0; i < 5; i++) { | ||
| StringRef ref = column->get_data()[i]; | ||
| EXPECT_EQ(std::string(ref.data, ref.size), test_str); | ||
| } | ||
| // Verify second batch | ||
| for (size_t i = 5; i < 8; i++) { | ||
| StringRef ref = column->get_data()[i]; | ||
| EXPECT_EQ(std::string(ref.data, ref.size), str2); | ||
| } | ||
| } | ||
|
|
||
| TEST(PredicateColumnTest, InsertDuplicateFieldsInt) { | ||
| auto column = PredicateColumnType<TYPE_INT>::create(); | ||
| column->reserve(10); | ||
|
|
||
| Int32 val = 42; | ||
| Field field = Field::create_field<TYPE_INT>(val); | ||
| column->insert_duplicate_fields(field, 5); | ||
|
|
||
| EXPECT_EQ(column->size(), 5); | ||
| for (size_t i = 0; i < 5; i++) { | ||
| EXPECT_EQ(column->get_data()[i], 42); | ||
| } | ||
| } | ||
|
|
||
| TEST(PredicateColumnTest, InsertDuplicateFieldsLargeInt) { | ||
| auto column = PredicateColumnType<TYPE_LARGEINT>::create(); | ||
| column->reserve(10); | ||
|
|
||
| Int128 val = Int128(123456789012345LL) * Int128(1000000000LL); | ||
| Field field = Field::create_field<TYPE_LARGEINT>(val); | ||
| column->insert_duplicate_fields(field, 3); | ||
|
|
||
| EXPECT_EQ(column->size(), 3); | ||
| for (size_t i = 0; i < 3; i++) { | ||
| EXPECT_EQ(column->get_data()[i], val); | ||
| } | ||
| } | ||
|
|
||
| } // namespace doris | ||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add more test to predicate column to coverer all the path of the class.
And add more type to the test especially for datev1 and decimalv2, string.