Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-08-28 08:26:57

0001 // Licensed to the Apache Software Foundation (ASF) under one
0002 // or more contributor license agreements.  See the NOTICE file
0003 // distributed with this work for additional information
0004 // regarding copyright ownership.  The ASF licenses this file
0005 // to you under the Apache License, Version 2.0 (the
0006 // "License"); you may not use this file except in compliance
0007 // with the License.  You may obtain a copy of the License at
0008 //
0009 //   http://www.apache.org/licenses/LICENSE-2.0
0010 //
0011 // Unless required by applicable law or agreed to in writing,
0012 // software distributed under the License is distributed on an
0013 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
0014 // KIND, either express or implied.  See the License for the
0015 // specific language governing permissions and limitations
0016 // under the License.
0017 
0018 #pragma once
0019 
0020 #include <functional>
0021 #include <string_view>
0022 
0023 namespace arrow {
0024 namespace csv {
0025 
0026 /// \brief Description of an invalid row
0027 struct InvalidRow {
0028   /// \brief Number of columns expected in the row
0029   int32_t expected_columns;
0030   /// \brief Actual number of columns found in the row
0031   int32_t actual_columns;
0032   /// \brief The physical row number if known or -1
0033   ///
0034   /// This number is one-based and also accounts for non-data rows (such as
0035   /// CSV header rows).
0036   int64_t number;
0037   /// \brief View of the entire row. Memory will be freed after callback returns
0038   const std::string_view text;
0039 };
0040 
0041 /// \brief Result returned by an InvalidRowHandler
0042 enum class InvalidRowResult {
0043   // Generate an error describing this row
0044   Error,
0045   // Skip over this row
0046   Skip
0047 };
0048 
0049 /// \brief callback for handling a row with an invalid number of columns while parsing
0050 /// \return result indicating if an error should be returned from the parser or the row is
0051 /// skipped
0052 using InvalidRowHandler = std::function<InvalidRowResult(const InvalidRow&)>;
0053 
0054 }  // namespace csv
0055 }  // namespace arrow