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


##########
be/src/util/bit_util.h:
##########
@@ -98,6 +98,26 @@ class BitUtil {
         return (v << n) >> n;
     }
 
+    template <typename T>
+    static std::string IntToByteBuffer(T input) {
+        std::string buffer;
+        T value = input;
+        for (int i = 0; i < sizeof(value); ++i) {
+            // Applies a mask for a byte range on the input.
+            char value_to_save = value & 0XFF;
+            buffer.push_back(value_to_save);
+            // Remove the just processed part from the input so that we can 
exit early if there
+            // is nothing left to process.
+            value >>= 8;
+            if (value == 0 && value_to_save >= 0) { break;
+}
+            if (value == -1 && value_to_save < 0) { break;

Review Comment:
   warning: statement should be inside braces 
[readability-braces-around-statements]
   
   ```suggestion
               if (value == -1 && value_to_save < 0) { break;
   }
   ```
   



##########
be/src/vec/sink/writer/iceberg/partition_transformers .cpp:
##########
@@ -0,0 +1,275 @@
+// 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 <any>
+
+#include "vec/core/types.h"
+#include "vec/exec/format/table/iceberg/partition_spec.h"
+#include "vec/sink/writer/iceberg/partition_transformers.h"
+
+namespace doris::vectorized {
+

Review Comment:
   warning: nested namespaces can be concatenated 
[modernize-concat-nested-namespaces]
   
   ```suggestion
   namespace doris::vectorized {
   ```
   
   be/src/vec/sink/writer/iceberg/partition_transformers .cpp:274:
   ```diff
   - } // namespace vectorized
   - } // namespace doris
   + } // namespace doris
   ```
   



##########
be/src/vec/sink/writer/iceberg/partition_transformers.h:
##########
@@ -43,38 +43,1259 @@ class PartitionColumnTransforms {
             const doris::iceberg::PartitionField& field, const TypeDescriptor& 
source_type);
 };
 
+class PartitionColumnTransformUtils {
+public:
+    static DateV2Value<DateV2ValueType>& epoch_date() {
+        static DateV2Value<DateV2ValueType> epoch_date;
+        static bool initialized = false;
+        if (!initialized) {
+            epoch_date.from_date_str("1970-01-01 00:00:00", 19);
+            initialized = true;
+        }
+        return epoch_date;
+    }
+
+    static DateV2Value<DateTimeV2ValueType>& epoch_datetime() {
+        static DateV2Value<DateTimeV2ValueType> epoch_datetime;
+        static bool initialized = false;
+        if (!initialized) {
+            epoch_datetime.from_date_str("1970-01-01 00:00:00", 19);
+            initialized = true;
+        }
+        return epoch_datetime;
+    }
+
+    static std::string human_year(int year_ordinal) {
+        auto year = std::chrono::year_month_day(
+                            
std::chrono::sys_days(std::chrono::floor<std::chrono::days>(
+                                    EPOCH + std::chrono::years(year_ordinal))))
+                            .year();
+        return std::to_string(static_cast<int>(year));
+    }
+
+    static std::string human_month(int month_ordinal) {
+        auto ymd = std::chrono::year_month_day(std::chrono::sys_days(
+                std::chrono::floor<std::chrono::days>(EPOCH + 
std::chrono::months(month_ordinal))));
+        return fmt::format("{:04d}-{:02d}", static_cast<int>(ymd.year()),
+                           static_cast<unsigned>(ymd.month()));
+    }
+
+    static std::string human_day(int day_ordinal) {
+        auto ymd = std::chrono::year_month_day(std::chrono::sys_days(
+                std::chrono::floor<std::chrono::days>(EPOCH + 
std::chrono::days(day_ordinal))));
+        return fmt::format("{:04d}-{:02d}-{:02d}", 
static_cast<int>(ymd.year()),
+                           static_cast<unsigned>(ymd.month()), 
static_cast<unsigned>(ymd.day()));
+    }
+
+    static std::string human_hour(int hour_ordinal) {
+        int day_value = hour_ordinal / 24;
+        int housr_value = hour_ordinal % 24;
+        auto ymd = std::chrono::year_month_day(std::chrono::sys_days(
+                std::chrono::floor<std::chrono::days>(EPOCH + 
std::chrono::days(day_value))));
+        return fmt::format("{:04d}-{:02d}-{:02d}-{:02d}", 
static_cast<int>(ymd.year()),
+                           static_cast<unsigned>(ymd.month()), 
static_cast<unsigned>(ymd.day()),
+                           housr_value);
+    }
+
+private:
+    static const std::chrono::time_point<std::chrono::system_clock> EPOCH;
+    PartitionColumnTransformUtils() = default;

Review Comment:
   warning: use '= default' to define a trivial default constructor 
[modernize-use-equals-default]
   
   ```suggestion
       PartitionColumnTransformUtils() = default;
   ```
   



##########
be/src/vec/sink/writer/iceberg/partition_transformers .cpp:
##########
@@ -0,0 +1,275 @@
+// 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 <any>
+
+#include "vec/core/types.h"
+#include "vec/exec/format/table/iceberg/partition_spec.h"
+#include "vec/sink/writer/iceberg/partition_transformers.h"
+
+namespace doris::vectorized {
+
+const std::chrono::time_point<std::chrono::system_clock> 
PartitionColumnTransformUtils::EPOCH =
+        std::chrono::system_clock::from_time_t(0);
+
+std::unique_ptr<PartitionColumnTransform> PartitionColumnTransforms::create(
+        const doris::iceberg::PartitionField& field, const TypeDescriptor& 
source_type) {

Review Comment:
   warning: function 'create' exceeds recommended size/complexity thresholds 
[readability-function-size]
   ```cpp
   std::unique_ptr<PartitionColumnTransform> PartitionColumnTransforms::create(
                                                                        ^
   ```
   <details>
   <summary>Additional context</summary>
   
   **be/src/vec/sink/writer/iceberg/partition_transformers .cpp:29:** 158 lines 
including whitespace and comments (threshold 80)
   ```cpp
   std::unique_ptr<PartitionColumnTransform> PartitionColumnTransforms::create(
                                                                        ^
   ```
   
   </details>
   



-- 
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