baibaichen commented on code in PR #4634:
URL: https://github.com/apache/incubator-gluten/pull/4634#discussion_r1529573912


##########
cpp-ch/local-engine/Storages/Parquet/VectorizedParquetRecordReader.h:
##########
@@ -0,0 +1,254 @@
+/*
+ * 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.
+ */
+#pragma once
+#include <config.h>
+
+#if USE_PARQUET
+
+#include <Formats/FormatSettings.h>
+#include <Processors/Formats/IInputFormat.h>
+#include <Processors/Formats/Impl/ArrowColumnToCHColumn.h>
+#include <Storages/Parquet/ArrowUtils.h>
+#include <Storages/Parquet/ColumnIndexFilter.h>
+#include <parquet/arrow/reader_internal.h>
+#include <parquet/arrow/schema.h>
+
+namespace parquet
+{
+struct PageLocation;
+}
+namespace DB
+{
+class Block;
+}
+
+namespace arrow
+{
+class ChunkedArray;
+}
+namespace local_engine
+{
+class RowRanges;
+using ReadRanges = std::vector<arrow::io::ReadRange>;
+using ReadSequence = std::vector<int64_t>;
+using ColumnReadState = std::pair<ReadRanges, ReadSequence>;
+using ColumnChunkPageRead = std::pair<std::unique_ptr<parquet::PageReader>, 
ReadSequence>;
+using ColumnChunkPageReadStore = std::unordered_map<int32_t, 
ColumnChunkPageRead>;
+using ColumnChunkPageReadStorePtr = std::unique_ptr<ColumnChunkPageReadStore>;
+
+class ColumnIndexFilter;
+class VectorizedParquetBlockInputFormat;
+
+ColumnReadState buildAllRead(int64_t rg_count, const arrow::io::ReadRange & 
chunk_range);
+ColumnReadState buildRead(
+    int64_t rg_count,
+    const arrow::io::ReadRange & chunk_range,
+    const std::vector<parquet::PageLocation> & page_locations,
+    const RowRanges & row_ranges);
+std::shared_ptr<parquet::ArrowInputStream>
+getStream(arrow::io::RandomAccessFile & reader, const 
std::vector<arrow::io::ReadRange> & ranges);
+
+class ParquetReadState
+{
+    ReadSequence read_sequence_;
+    int index_ = 0;
+
+    void advance(const int64_t read_or_skip)
+    {
+        assert(hasMoreRead());
+        assert(read_sequence_[index_] >= read_or_skip);
+        read_sequence_[index_] -= read_or_skip;
+        if (read_sequence_[index_] == 0)
+            ++index_;
+    }
+
+public:
+    explicit ParquetReadState(const ReadSequence & read_sequence) : 
read_sequence_(read_sequence) { }
+    int64_t currentRead() const
+    {
+        assert(hasMoreRead());
+        return read_sequence_[index_];
+    }
+
+    std::optional<int64_t> hasLastSkip() const
+    {
+        assert(!hasMoreRead());
+        if (read_sequence_.back() < 0)
+            return read_sequence_.back();
+        return std::nullopt;
+    }
+
+    bool hasMoreRead() const
+    {
+        if (read_sequence_.back() < 0)
+            return index_ < read_sequence_.size() - 1;
+        return index_ < read_sequence_.size();
+    }
+
+    void skip(const int64_t skip)
+    {
+        assert(skip > 0);
+        advance(-skip);
+    }
+
+    void read(const int64_t read)
+    {
+        assert(read > 0);
+        advance(read);
+    }
+};
+
+using BuildRead = std::function<ColumnReadState(const arrow::io::ReadRange & 
col_range)>;
+class PageIterator;
+
+class ParquetFileReaderExt
+{
+    friend class PageIterator;
+    std::shared_ptr<::arrow::io::RandomAccessFile> source_;

Review Comment:
   It's intended, It's weird that function parameter with `_`. 
   
   We can fix them later, if it is indeed necessary to keep consistency with ch.



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