github-actions[bot] commented on code in PR #24461:
URL: https://github.com/apache/doris/pull/24461#discussion_r1335627258


##########
be/src/vec/common/columns_hashing.h:
##########
@@ -151,9 +154,7 @@
         return KeyHolderType {key, pool};
     }
 
-    std::span<StringRef> get_keys(size_t rows_number) const {
-        return std::span<StringRef>(keys, rows_number);
-    }
+    std::span<StringRef> get_keys() const { return std::span<StringRef>(keys, 
keys_size); }

Review Comment:
   warning: function 'get_keys' should be marked [[nodiscard]] 
[modernize-use-nodiscard]
   
   ```suggestion
       [[nodiscard]] std::span<StringRef> get_keys() const { return 
std::span<StringRef>(keys, keys_size); }
   ```
   



##########
be/src/vec/common/columns_hashing.h:
##########
@@ -91,25 +88,31 @@
 
     const IColumn::Offset* offsets;
     const UInt8* chars;
+    std::vector<StringRef> keys;
 
     HashMethodString(const ColumnRawPtrs& key_columns, const Sizes& 
/*key_sizes*/,
                      const HashMethodContextPtr&) {
         const IColumn& column = *key_columns[0];
         const ColumnString& column_string = assert_cast<const 
ColumnString&>(column);
         offsets = column_string.get_offsets().data();
         chars = column_string.get_chars().data();
+
+        keys.resize(column_string.size());
+        for (size_t row = 0; row < column_string.size(); row++) {
+            keys[row] = StringRef(chars + offsets[row - 1], offsets[row] - 
offsets[row - 1]);
+        }
     }
 
     auto get_key_holder(ssize_t row, [[maybe_unused]] Arena& pool) const {
-        StringRef key(chars + offsets[row - 1], offsets[row] - offsets[row - 
1]);
-
         if constexpr (place_string_to_arena) {
-            return ArenaKeyHolder {key, pool};
+            return ArenaKeyHolder {keys[row], pool};
         } else {
-            return key;
+            return keys[row];
         }
     }
 
+    const std::vector<StringRef>& get_keys() const { return keys; }

Review Comment:
   warning: function 'get_keys' should be marked [[nodiscard]] 
[modernize-use-nodiscard]
   
   ```suggestion
       [[nodiscard]] const std::vector<StringRef>& get_keys() const { return 
keys; }
   ```
   



##########
be/src/vec/common/columns_hashing.h:
##########
@@ -202,22 +203,20 @@
 
     const Sizes& key_sizes;
     size_t keys_size;
+    std::vector<Key> keys;
 
     HashMethodKeysFixed(const ColumnRawPtrs& key_columns, const Sizes& 
key_sizes_,
                         const HashMethodContextPtr&)
-            : Base(key_columns), key_sizes(key_sizes_), 
keys_size(key_columns.size()) {}
-
-    ALWAYS_INLINE Key get_key_holder(size_t row, Arena&) const {
-        return pack_fixed<Key>(row, keys_size, Base::get_actual_columns(), 
key_sizes,
-                               Base::get_nullmap_columns());
+            : Base(key_columns), key_sizes(key_sizes_), 
keys_size(key_columns.size()) {
+        keys = pack_fixeds<Key>(key_columns[0]->size(), 
Base::get_actual_columns(), key_sizes,
+                                Base::get_nullmap_columns());
     }
 
+    ALWAYS_INLINE Key get_key_holder(size_t row, Arena&) const { return 
keys[row]; }
+
     Key pack_key_holder(Key key, Arena& pool) const { return key; }
 
-    std::vector<Key> get_keys(size_t rows_number) const {
-        return pack_fixeds<Key>(rows_number, Base::get_actual_columns(), 
key_sizes,
-                                Base::get_nullmap_columns());
-    }
+    const std::vector<Key>& get_keys() const { return keys; }

Review Comment:
   warning: function 'get_keys' should be marked [[nodiscard]] 
[modernize-use-nodiscard]
   
   ```suggestion
       [[nodiscard]] const std::vector<Key>& get_keys() const { return keys; }
   ```
   



##########
be/src/vec/common/columns_hashing.h:
##########
@@ -69,16 +71,11 @@ struct HashMethodOneNumber : public 
columns_hashing_impl::HashMethodBase<
     using Base::find_key; /// (Data & data, size_t row, Arena & pool) -> 
FindResult
     using Base::find_key_with_hash;
 
-    /// Get hash value of row.
-    using Base::get_hash; /// (const Data & data, size_t row, Arena & pool) -> 
size_t
-
     /// Is used for default implementation in HashMethodBase.
     FieldType get_key_holder(size_t row, Arena&) const { return 
((FieldType*)(vec))[row]; }
     FieldType pack_key_holder(FieldType key, Arena&) const { return key; }
 
-    std::span<FieldType> get_keys(size_t rows_number) const {
-        return std::span<FieldType>((FieldType*)vec, rows_number);
-    }
+    std::span<FieldType> get_keys() const { return 
std::span<FieldType>((FieldType*)vec, size); }

Review Comment:
   warning: function 'get_keys' should be marked [[nodiscard]] 
[modernize-use-nodiscard]
   
   ```suggestion
       [[nodiscard]] std::span<FieldType> get_keys() const { return 
std::span<FieldType>((FieldType*)vec, size); }
   ```
   



-- 
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: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to