Coverage Report

Created: 2026-03-12 17:15

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
be/src/format/text/text_reader.h
Line
Count
Source
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 <gen_cpp/PlanNodes_types.h>
21
#include <gen_cpp/internal_service.pb.h>
22
23
#include <cstddef>
24
#include <string>
25
#include <vector>
26
27
#include "common/status.h"
28
#include "format/csv/csv_reader.h"
29
#include "io/file_factory.h"
30
31
namespace doris {
32
#include "common/compile_check_begin.h"
33
34
class HiveTextFieldSplitter : public BaseCsvTextFieldSplitter<HiveTextFieldSplitter> {
35
public:
36
    explicit HiveTextFieldSplitter(bool trim_tailing_space, bool trim_ends, std::string value_sep,
37
                                   size_t value_sep_len = 1, char trimming_char = 0,
38
                                   char escape_char = 0)
39
5.07k
            : BaseCsvTextFieldSplitter(trim_tailing_space, trim_ends, value_sep_len, trimming_char),
40
5.07k
              _value_sep(std::move(value_sep)),
41
5.07k
              _escape_char(escape_char) {}
42
43
    void do_split(const Slice& line, std::vector<Slice>* splitted_values);
44
45
private:
46
    void _split_field_single_char(const Slice& line, std::vector<Slice>* splitted_values);
47
    void _split_field_multi_char(const Slice& line, std::vector<Slice>* splitted_values);
48
49
    std::string _value_sep;
50
    char _escape_char;
51
};
52
53
class TextReader : public CsvReader {
54
    ENABLE_FACTORY_CREATOR(TextReader);
55
56
public:
57
    TextReader(RuntimeState* state, RuntimeProfile* profile, ScannerCounter* counter,
58
               const TFileScanRangeParams& params, const TFileRangeDesc& range,
59
               const std::vector<SlotDescriptor*>& file_slot_descs, io::IOContext* io_ctx);
60
61
    ~TextReader() override = default;
62
63
private:
64
    Status _init_options() override;
65
    Status _create_line_reader() override;
66
    Status _deserialize_one_cell(DataTypeSerDeSPtr serde, IColumn& column, Slice& slice) override;
67
    Status _validate_line(const Slice& line, bool* success) override;
68
    Status _deserialize_nullable_string(IColumn& column, Slice& slice) override;
69
};
70
71
#include "common/compile_check_end.h"
72
} // namespace doris