Gabriel39 commented on code in PR #65135:
URL: https://github.com/apache/doris/pull/65135#discussion_r3518067875


##########
be/src/format/table/iceberg_position_delete_sys_table_reader.cpp:
##########
@@ -0,0 +1,475 @@
+// 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 "format/table/iceberg_position_delete_sys_table_reader.h"
+
+#include <gen_cpp/PlanNodes_types.h>
+
+#include <algorithm>
+#include <memory>
+#include <utility>
+
+#include "common/cast_set.h"
+#include "core/block/block.h"
+#include "core/column/column_nullable.h"
+#include "core/column/column_string.h"
+#include "core/column/column_vector.h"
+#include "core/data_type/data_type_nullable.h"
+#include "core/data_type/data_type_number.h"
+#include "core/data_type/data_type_string.h"
+#include "core/data_type_serde/data_type_serde.h"
+#include "core/types.h"
+#include "format/orc/vorc_reader.h"
+#include "format/parquet/schema_desc.h"
+#include "format/parquet/vparquet_reader.h"
+#include "format/table/parquet_utils.h"
+#include "runtime/runtime_state.h"
+
+namespace doris {
+
+namespace {
+
+constexpr const char* kFilePathColumn = "file_path";
+constexpr const char* kPosColumn = "pos";
+constexpr const char* kRowColumn = "row";
+constexpr const char* kPartitionColumn = "partition";
+constexpr const char* kSpecIdColumn = "spec_id";
+constexpr const char* kDeleteFilePathColumn = "delete_file_path";
+constexpr const char* kContentOffsetColumn = "content_offset";
+constexpr const char* kContentSizeInBytesColumn = "content_size_in_bytes";
+
+bool block_has_row(const Block& block, size_t row) {
+    return block.columns() > 0 && row < block.rows();
+}
+
+void insert_int64_nullable(MutableColumnPtr& column, const int64_t* value) {
+    if (value == nullptr) {
+        parquet_utils::insert_null(column);
+    } else {
+        parquet_utils::insert_int64(column, *value);
+    }
+}
+
+const ColumnString* get_string_column(const Block& block, const std::string& 
name) {
+    auto pos = block.get_position_by_name(name);
+    if (pos < 0) {
+        return nullptr;
+    }
+    return 
check_and_get_column<ColumnString>(block.get_by_position(pos).column.get());
+}
+
+const ColumnInt64* get_int64_column(const Block& block, const std::string& 
name) {
+    auto pos = block.get_position_by_name(name);
+    if (pos < 0) {
+        return nullptr;
+    }
+    return 
check_and_get_column<ColumnInt64>(block.get_by_position(pos).column.get());
+}
+
+} // namespace
+
+IcebergPositionDeleteSysTableReader::IcebergPositionDeleteSysTableReader(
+        const std::vector<SlotDescriptor*>& file_slot_descs, RuntimeState* 
state,
+        RuntimeProfile* profile, const TFileRangeDesc& range,
+        const TFileScanRangeParams* range_params, FileMetaCache* meta_cache)
+        : _file_slot_descs(file_slot_descs),
+          _state(state),
+          _profile(profile),
+          _range(range),
+          _range_params(range_params),
+          _io_context(state) {
+    _meta_cache = meta_cache;
+}
+
+IcebergPositionDeleteSysTableReader::~IcebergPositionDeleteSysTableReader() = 
default;
+
+Status IcebergPositionDeleteSysTableReader::_do_init_reader(ReaderInitContext* 
/*ctx*/) {
+    if (_state == nullptr || _profile == nullptr || _range_params == nullptr) {
+        return Status::InvalidArgument(
+                "invalid Iceberg position delete system table reader context");
+    }
+    if (!_range.__isset.table_format_params || 
!_range.table_format_params.__isset.iceberg_params) {
+        return Status::InternalError("Iceberg position delete system table 
range misses params");
+    }
+
+    _iceberg_file_desc = &_range.table_format_params.iceberg_params;
+    if (!_iceberg_file_desc->__isset.delete_files || 
_iceberg_file_desc->delete_files.size() != 1) {
+        return Status::InternalError(
+                "Iceberg position delete system table range should contain 
exactly one delete "
+                "file");
+    }
+    _delete_file_desc = &_iceberg_file_desc->delete_files[0];
+    _delete_file_kind = is_iceberg_deletion_vector(*_delete_file_desc)

Review Comment:
   if (is_iceberg_deletion_vector(...)) {
       _delete_file_kind = DELETION_VECTOR;
   } else if (content == POSITION_DELETE) {
       _delete_file_kind = POSITION_DELETE;
   } else {
       return Status::InternalError(...);
   }



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