worker24h commented on a change in pull request #1173: load data from Parquet 
file (Issues #911)
URL: https://github.com/apache/incubator-doris/pull/1173#discussion_r289669288
 
 

 ##########
 File path: be/src/exec/parquet_reader.h
 ##########
 @@ -0,0 +1,105 @@
+// 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 <stdint.h>
+
+#include <string>
+#include <map>
+#include <arrow/api.h>
+#include <arrow/io/api.h>
+#include <arrow/io/file.h>
+#include <arrow/io/interfaces.h>
+#include <arrow/buffer.h>
+#include <parquet/api/reader.h>
+#include <parquet/api/writer.h>
+#include <parquet/arrow/reader.h>
+#include <parquet/arrow/writer.h>
+#include <parquet/exception.h>
+
+#include "common/status.h"
+#include "gen_cpp/Types_types.h"
+#include "gen_cpp/PaloBrokerService_types.h"
+#include "gen_cpp/PlanNodes_types.h"
+
+
+namespace doris {
+
+class ExecEnv;
+class TBrokerRangeDesc;
+class TNetworkAddress;
+class RuntimeState;
+class Tuple;
+class SlotDescriptor;
+class MemPool;
+class FileReader;
+
+class ParquetFile : public arrow::io::RandomAccessFile {
+public:
+    ParquetFile(FileReader *file);
+    virtual ~ParquetFile();
+    arrow::Status Read(int64_t nbytes, int64_t* bytes_read, void* buffer) 
override;
+    arrow::Status ReadAt(int64_t position, int64_t nbytes, int64_t* bytes_read,
+                  void* out) override;
+    arrow::Status GetSize(int64_t* size) override;
+    arrow::Status Seek(int64_t position) override;
+    arrow::Status Read(int64_t nbytes, std::shared_ptr<arrow::Buffer>* out) 
override;
+    arrow::Status Tell(int64_t* position) const override;
+    arrow::Status Close() override;
+    bool closed() const override;
+private:
+    FileReader *_file;
+};
+
+// Reader of broker parquet file
+class ParquetReaderWrap {
+public:
+    ParquetReaderWrap(FileReader *file_reader);
+    virtual ~ParquetReaderWrap();
+
+    // Read 
+    Status read(Tuple* tuple, const std::vector<SlotDescriptor*>& 
tuple_slot_descs, MemPool* mem_pool, bool* eof);
+    void close();
+    Status size(int64_t* size);
+    void inital_parquet_reader();
+
+private:
+    void fill_solt(Tuple* tuple, SlotDescriptor* slot_desc, MemPool* mem_pool, 
const uint8_t* value, int32_t len);
+    Status column_indices(const std::vector<SlotDescriptor*>& 
tuple_slot_descs);
+    void set_filed_null(Tuple* tuple, const SlotDescriptor* slot_desc);
+    Status read_record_batch(const std::vector<SlotDescriptor*>& 
tuple_slot_descs, bool* eof);
+private:
+    parquet::ReaderProperties _properties;
+    std::shared_ptr<ParquetFile> _parquet;
+
+    // parquet file reader object
+    std::shared_ptr<::arrow::RecordBatchReader> rb_batch;
+    std::shared_ptr<arrow::RecordBatch> batch;
 
 Review comment:
   ok

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

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

Reply via email to