Coverage Report

Created: 2024-11-20 21:49

/root/doris/be/src/util/arrow/utils.h
Line
Count
Source (jump to first uncovered line)
1
// Licensed to the Apache Software Foundation (ASF) under one
2
// or more contributor license agreements.  See the NOTICE file
3
// distributed with this work for additional information
4
// regarding copyright ownership.  The ASF licenses this file
5
// to you under the Apache License, Version 2.0 (the
6
// "License"); you may not use this file except in compliance
7
// with the License.  You may obtain a copy of the License at
8
//
9
//   http://www.apache.org/licenses/LICENSE-2.0
10
//
11
// Unless required by applicable law or agreed to in writing,
12
// software distributed under the License is distributed on an
13
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
// KIND, either express or implied.  See the License for the
15
// specific language governing permissions and limitations
16
// under the License.
17
18
#pragma once
19
20
#include <iostream>
21
22
#include "common/status.h"
23
24
// This files contains some utilities to convert Doris internal
25
// data format into/from Apache Arrow format. When Doris needs
26
// to share data with others we can leverage Arrow's ability.
27
// We can convert our internal data into Arrow's memory format
28
// and then convert to other format, for example Parquet. Because
29
// Arrow have already implemented this functions. And what's more
30
// Arrow support multiple languages, so it will make it easy to
31
// handle Doris data in other languages.
32
33
// Forward declaration of arrow class
34
namespace arrow {
35
class Array;
36
class RecordBatch;
37
class Status;
38
} // namespace arrow
39
40
namespace doris {
41
42
#define RETURN_ARROW_STATUS_IF_ERROR(stmt)                  \
43
    do {                                                    \
44
        Status _status_ = (stmt);                           \
45
        if (UNLIKELY(!_status_.ok())) {                     \
46
            ARROW_RETURN_NOT_OK(to_arrow_status(_status_)); \
47
        }                                                   \
48
    } while (false)
49
50
#define RETURN_DORIS_STATUS_IF_ERROR(stmt)    \
51
0
    do {                                      \
52
0
        arrow::Status _status_ = (stmt);      \
53
0
        if (UNLIKELY(!_status_.ok())) {       \
54
0
            return to_doris_status(_status_); \
55
0
        }                                     \
56
0
    } while (false)
57
58
// Pretty print a arrow RecordBatch.
59
Status arrow_pretty_print(const arrow::RecordBatch& rb, std::ostream* os);
60
Status arrow_pretty_print(const arrow::Array& rb, std::ostream* os);
61
62
Status to_doris_status(const arrow::Status& status);
63
arrow::Status to_arrow_status(const Status& status);
64
65
} // namespace doris