Copilot commented on code in PR #9248:
URL: https://github.com/apache/incubator-gluten/pull/9248#discussion_r2032723862


##########
cpp-ch/local-engine/Storages/SubstraitSource/Delta/DeltaWriter.cpp:
##########
@@ -0,0 +1,252 @@
+/*
+ * 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 "DeltaWriter.h"
+
+#include <zlib.h>
+#include <Columns/ColumnNullable.h>
+#include <Columns/ColumnString.h>
+#include <Columns/ColumnsNumber.h>
+#include <Columns/IColumn.h>
+#include <Core/Block_fwd.h>
+#include <Core/Range.h>
+#include <DataTypes/DataTypeNullable.h>
+#include <DataTypes/DataTypeTuple.h>
+#include <DataTypes/DataTypesNumber.h>
+#include <Formats/JSONUtils.h>
+#include <IO/WriteBuffer.h>
+#include <IO/WriteHelpers.h>
+#include <Storages/Output/WriteBufferBuilder.h>
+#include <Storages/SubstraitSource/Delta/DeltaUtil.h>
+#include <rapidjson/document.h>
+#include <Poco/URI.h>
+
+namespace local_engine::delta
+{
+
+String getRandomPrefix(const size_t & length)
+{
+    static const char alphanum[] = "0123456789"
+                                   "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+                                   "abcdefghijklmnopqrstuvwxyz";
+
+    String res;
+    for (size_t i = 0; i < length; ++i)
+        res += alphanum[rand() % (sizeof(alphanum) - 1)];
+    return res;
+}
+
+DB::DataTypePtr getDeletionVectorType()
+{
+    DB::DataTypes dv_descriptor_types;
+    auto storageType = std::make_shared<DB::DataTypeString>();
+    auto pathOrInlineDv = std::make_shared<DB::DataTypeString>();
+    auto offset = std::make_shared<DB::DataTypeInt32>();
+    auto offset_nullable = std::make_shared<DB::DataTypeNullable>(offset);
+    auto sizeInBytes = std::make_shared<DB::DataTypeInt32>();
+    auto cardinality = std::make_shared<DB::DataTypeInt64>();
+    auto maxRowIndex = std::make_shared<DB::DataTypeInt64>();
+    auto maxRowIndex_nullable = 
std::make_shared<DB::DataTypeNullable>(maxRowIndex);
+
+    dv_descriptor_types.emplace_back(storageType);
+    dv_descriptor_types.emplace_back(pathOrInlineDv);
+    dv_descriptor_types.emplace_back(offset_nullable);
+    dv_descriptor_types.emplace_back(sizeInBytes);
+    dv_descriptor_types.emplace_back(cardinality);
+    dv_descriptor_types.emplace_back(maxRowIndex_nullable);
+
+    DB::Strings dv_descriptor_names;
+    dv_descriptor_names.emplace_back("storageType");
+    dv_descriptor_names.emplace_back("pathOrInlineDv");
+    dv_descriptor_names.emplace_back("offset");
+    dv_descriptor_names.emplace_back("sizeInBytes");
+    dv_descriptor_names.emplace_back("cardinality");
+    dv_descriptor_names.emplace_back("maxRowIndex");
+
+    return std::make_shared<DB::DataTypeTuple>(dv_descriptor_types, 
dv_descriptor_names);
+}
+
+
+void DeltaWriter::writeDeletionVector(const DB::Block & block)
+{
+    const auto & file_path_columns = block.getByPosition(0);
+    const auto & deletion_vector_id_columns = block.getByPosition(1);
+    const auto & bitmap_columns = block.getByPosition(2);
+    const auto & cardinality_src_columns = block.getByPosition(3);
+
+    for (size_t row_idx = 0; row_idx < block.rows(); row_idx++)
+    {
+        const auto file_path = file_path_columns.column->getDataAt(row_idx);
+        auto bitmap = bitmap_columns.column->getDataAt(row_idx);
+        auto cardinality = cardinality_src_columns.column->get64(row_idx); // 
alisa deletedRowIndexCount
+

Review Comment:
   [nitpick] Consider correcting the comment from 'alisa' to 'alias' for 
clarity.
   ```suggestion
           auto cardinality = cardinality_src_columns.column->get64(row_idx); 
// alias deletedRowIndexCount
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to