MCPcopy Create free account
hub / github.com/apache/arrow / ReadLine

Method ReadLine

cpp/src/arrow/csv/chunker.cc:81–237  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79
80 template <bool UseBulkFilter = true>
81 const char* ReadLine(const char* data, const char* data_end) {
82 // The parsing state machine
83 char c;
84 DCHECK_GT(data_end - data, 0);
85 if (ARROW_PREDICT_TRUE(state_ == FIELD_START)) {
86 goto FieldStart;
87 }
88 switch (state_) {
89 case FIELD_START:
90 goto FieldStart;
91 case IN_FIELD:
92 goto InField;
93 case AT_ESCAPE:
94 // will never reach here if escaping = false
95 // just to hint the compiler to remove dead code
96 if constexpr (!SpecializedOptions::escaping) return nullptr;
97 goto AtEscape;
98 case IN_QUOTED_FIELD:
99 if constexpr (!SpecializedOptions::quoting) return nullptr;
100 goto InQuotedField;
101 case AT_QUOTED_QUOTE:
102 if constexpr (!SpecializedOptions::quoting) return nullptr;
103 goto AtQuotedQuote;
104 case AT_QUOTED_ESCAPE:
105 if constexpr (!SpecializedOptions::quoting) return nullptr;
106 goto AtQuotedEscape;
107 }
108
109 FieldStart:
110 if constexpr (!SpecializedOptions::quoting) {
111 goto InField;
112 } else {
113 // At the start of a field
114 if (ARROW_PREDICT_FALSE(data == data_end)) {
115 state_ = FIELD_START;
116 goto AbortLine;
117 }
118 // Quoting is only recognized at start of field
119 if (*data == options_.quote_char) {
120 data++;
121 goto InQuotedField;
122 } else {
123 goto InField;
124 }
125 }
126
127 InField:
128 // Inside a non-quoted part of a field
129 if (UseBulkFilter) {
130 const char* bulk_end = RunBulkFilter(data, data_end);
131 if (ARROW_PREDICT_FALSE(bulk_end == nullptr)) {
132 state_ = IN_FIELD;
133 goto AbortLine;
134 }
135 data = bulk_end;
136 } else {
137 if (ARROW_PREDICT_FALSE(data == data_end)) {
138 state_ = IN_FIELD;

Callers 1

FindNthMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected