![]() |
|
|||
File indexing completed on 2025-08-28 08:26:59
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 // Public API for the "Feather" file format, originally created at 0019 // http://github.com/wesm/feather 0020 0021 #pragma once 0022 0023 #include <cstdint> 0024 #include <memory> 0025 #include <string> 0026 #include <vector> 0027 0028 #include "arrow/ipc/options.h" 0029 #include "arrow/type_fwd.h" 0030 #include "arrow/util/compression.h" 0031 #include "arrow/util/visibility.h" 0032 0033 namespace arrow { 0034 0035 class Schema; 0036 class Status; 0037 class Table; 0038 0039 namespace io { 0040 0041 class OutputStream; 0042 class RandomAccessFile; 0043 0044 } // namespace io 0045 0046 namespace ipc { 0047 namespace feather { 0048 0049 static constexpr const int kFeatherV1Version = 2; 0050 static constexpr const int kFeatherV2Version = 3; 0051 0052 // ---------------------------------------------------------------------- 0053 // Metadata accessor classes 0054 0055 /// \class Reader 0056 /// \brief An interface for reading columns from Feather files 0057 class ARROW_EXPORT Reader { 0058 public: 0059 virtual ~Reader() = default; 0060 0061 /// \brief Open a Feather file from a RandomAccessFile interface 0062 /// 0063 /// \param[in] source a RandomAccessFile instance 0064 /// \return the table reader 0065 static Result<std::shared_ptr<Reader>> Open( 0066 const std::shared_ptr<io::RandomAccessFile>& source); 0067 0068 /// \brief Open a Feather file from a RandomAccessFile interface 0069 /// with IPC Read options 0070 /// 0071 /// \param[in] source a RandomAccessFile instance 0072 /// \param[in] options IPC Read options 0073 /// \return the table reader 0074 static Result<std::shared_ptr<Reader>> Open( 0075 const std::shared_ptr<io::RandomAccessFile>& source, const IpcReadOptions& options); 0076 0077 /// \brief Return the version number of the Feather file 0078 virtual int version() const = 0; 0079 0080 virtual std::shared_ptr<Schema> schema() const = 0; 0081 0082 /// \brief Read all columns from the file as an arrow::Table. 0083 /// 0084 /// \param[out] out the returned table 0085 /// \return Status 0086 /// 0087 /// This function is zero-copy if the file source supports zero-copy reads 0088 virtual Status Read(std::shared_ptr<Table>* out) = 0; 0089 0090 /// \brief Read only the specified columns from the file as an arrow::Table. 0091 /// 0092 /// \param[in] indices the column indices to read 0093 /// \param[out] out the returned table 0094 /// \return Status 0095 /// 0096 /// This function is zero-copy if the file source supports zero-copy reads 0097 virtual Status Read(const std::vector<int>& indices, std::shared_ptr<Table>* out) = 0; 0098 0099 /// \brief Read only the specified columns from the file as an arrow::Table. 0100 /// 0101 /// \param[in] names the column names to read 0102 /// \param[out] out the returned table 0103 /// \return Status 0104 /// 0105 /// This function is zero-copy if the file source supports zero-copy reads 0106 virtual Status Read(const std::vector<std::string>& names, 0107 std::shared_ptr<Table>* out) = 0; 0108 }; 0109 0110 struct ARROW_EXPORT WriteProperties { 0111 static WriteProperties Defaults(); 0112 0113 static WriteProperties DefaultsV1() { 0114 WriteProperties props = Defaults(); 0115 props.version = kFeatherV1Version; 0116 return props; 0117 } 0118 0119 /// Feather file version number 0120 /// 0121 /// version 2: "Feather V1" Apache Arrow <= 0.16.0 0122 /// version 3: "Feather V2" Apache Arrow > 0.16.0 0123 int version = kFeatherV2Version; 0124 0125 // Parameters for Feather V2 only 0126 0127 /// Number of rows per intra-file chunk. Use smaller chunksize when you need 0128 /// faster random row access 0129 int64_t chunksize = 1LL << 16; 0130 0131 /// Compression type to use. Only UNCOMPRESSED, LZ4_FRAME, and ZSTD are 0132 /// supported. The default compression returned by Defaults() is LZ4 if the 0133 /// project is built with support for it, otherwise 0134 /// UNCOMPRESSED. UNCOMPRESSED is set as the object default here so that if 0135 /// WriteProperties::Defaults() is not used, the default constructor for 0136 /// WriteProperties will work regardless of the options used to build the C++ 0137 /// project. 0138 Compression::type compression = Compression::UNCOMPRESSED; 0139 0140 /// Compressor-specific compression level 0141 int compression_level = ::arrow::util::kUseDefaultCompressionLevel; 0142 }; 0143 0144 ARROW_EXPORT 0145 Status WriteTable(const Table& table, io::OutputStream* dst, 0146 const WriteProperties& properties = WriteProperties::Defaults()); 0147 0148 } // namespace feather 0149 } // namespace ipc 0150 } // namespace arrow
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |