Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/dataset/file_orc.h +75 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/dataset/file_parquet.h +410 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/dataset/parquet_encryption_config.h +75 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/dataset/partition.h +432 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/dataset/plan.h +33 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/dataset/projector.h +32 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/dataset/scanner.h +615 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/dataset/type_fwd.h +113 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/dataset/visibility.h +50 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/engine/substrait/options.h +135 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/engine/substrait/relation.h +71 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/engine/substrait/serde.h +331 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/engine/substrait/test_plan_builder.h +76 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/engine/substrait/test_util.h +45 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/engine/substrait/type_fwd.h +32 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/engine/substrait/util.h +83 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/engine/substrait/visibility.h +52 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/extension/fixed_shape_tensor.h +130 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/extension/json.h +57 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/extension/opaque.h +71 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/extension/uuid.h +63 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/filesystem/api.h +34 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/filesystem/azurefs.h +373 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/filesystem/filesystem.h +723 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/filesystem/filesystem_library.h +39 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/filesystem/gcsfs.h +242 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/filesystem/hdfs.h +117 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/filesystem/localfs.h +132 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/filesystem/mockfs.h +134 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/filesystem/path_util.h +178 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/filesystem/s3_test_util.h +108 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/filesystem/s3fs.h +467 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/filesystem/test_util.h +264 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/filesystem/type_fwd.h +53 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/api.h +30 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/client.h +430 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/client_auth.h +62 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/client_cookie_middleware.h +33 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/client_middleware.h +78 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/client_tracing_middleware.h +34 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/middleware.h +75 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/otel_logging.h +33 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/platform.h +31 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/server.h +327 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/server_auth.h +107 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/server_middleware.h +82 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/server_tracing_middleware.h +68 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/test_auth_handlers.h +89 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/test_definitions.h +318 -0
- venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/test_flight_server.h +92 -0
venv/lib/python3.10/site-packages/pyarrow/include/arrow/dataset/file_orc.h
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// This API is EXPERIMENTAL.
|
| 19 |
+
|
| 20 |
+
#pragma once
|
| 21 |
+
|
| 22 |
+
#include <memory>
|
| 23 |
+
#include <string>
|
| 24 |
+
|
| 25 |
+
#include "arrow/dataset/file_base.h"
|
| 26 |
+
#include "arrow/dataset/type_fwd.h"
|
| 27 |
+
#include "arrow/dataset/visibility.h"
|
| 28 |
+
#include "arrow/io/type_fwd.h"
|
| 29 |
+
#include "arrow/result.h"
|
| 30 |
+
|
| 31 |
+
namespace arrow {
|
| 32 |
+
namespace dataset {
|
| 33 |
+
|
| 34 |
+
/// \addtogroup dataset-file-formats
|
| 35 |
+
///
|
| 36 |
+
/// @{
|
| 37 |
+
|
| 38 |
+
constexpr char kOrcTypeName[] = "orc";
|
| 39 |
+
|
| 40 |
+
/// \brief A FileFormat implementation that reads from and writes to ORC files
|
| 41 |
+
class ARROW_DS_EXPORT OrcFileFormat : public FileFormat {
|
| 42 |
+
public:
|
| 43 |
+
OrcFileFormat();
|
| 44 |
+
|
| 45 |
+
std::string type_name() const override { return kOrcTypeName; }
|
| 46 |
+
|
| 47 |
+
bool Equals(const FileFormat& other) const override {
|
| 48 |
+
return type_name() == other.type_name();
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
Result<bool> IsSupported(const FileSource& source) const override;
|
| 52 |
+
|
| 53 |
+
/// \brief Return the schema of the file if possible.
|
| 54 |
+
Result<std::shared_ptr<Schema>> Inspect(const FileSource& source) const override;
|
| 55 |
+
|
| 56 |
+
Result<RecordBatchGenerator> ScanBatchesAsync(
|
| 57 |
+
const std::shared_ptr<ScanOptions>& options,
|
| 58 |
+
const std::shared_ptr<FileFragment>& file) const override;
|
| 59 |
+
|
| 60 |
+
Future<std::optional<int64_t>> CountRows(
|
| 61 |
+
const std::shared_ptr<FileFragment>& file, compute::Expression predicate,
|
| 62 |
+
const std::shared_ptr<ScanOptions>& options) override;
|
| 63 |
+
|
| 64 |
+
Result<std::shared_ptr<FileWriter>> MakeWriter(
|
| 65 |
+
std::shared_ptr<io::OutputStream> destination, std::shared_ptr<Schema> schema,
|
| 66 |
+
std::shared_ptr<FileWriteOptions> options,
|
| 67 |
+
fs::FileLocator destination_locator) const override;
|
| 68 |
+
|
| 69 |
+
std::shared_ptr<FileWriteOptions> DefaultWriteOptions() override;
|
| 70 |
+
};
|
| 71 |
+
|
| 72 |
+
/// @}
|
| 73 |
+
|
| 74 |
+
} // namespace dataset
|
| 75 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/dataset/file_parquet.h
ADDED
|
@@ -0,0 +1,410 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// This API is EXPERIMENTAL.
|
| 19 |
+
|
| 20 |
+
#pragma once
|
| 21 |
+
|
| 22 |
+
#include <memory>
|
| 23 |
+
#include <optional>
|
| 24 |
+
#include <string>
|
| 25 |
+
#include <unordered_set>
|
| 26 |
+
#include <utility>
|
| 27 |
+
#include <vector>
|
| 28 |
+
|
| 29 |
+
#include "arrow/dataset/discovery.h"
|
| 30 |
+
#include "arrow/dataset/file_base.h"
|
| 31 |
+
#include "arrow/dataset/type_fwd.h"
|
| 32 |
+
#include "arrow/dataset/visibility.h"
|
| 33 |
+
#include "arrow/io/caching.h"
|
| 34 |
+
|
| 35 |
+
namespace parquet {
|
| 36 |
+
class ParquetFileReader;
|
| 37 |
+
class Statistics;
|
| 38 |
+
class ColumnChunkMetaData;
|
| 39 |
+
class RowGroupMetaData;
|
| 40 |
+
class FileMetaData;
|
| 41 |
+
class FileDecryptionProperties;
|
| 42 |
+
class FileEncryptionProperties;
|
| 43 |
+
|
| 44 |
+
class ReaderProperties;
|
| 45 |
+
class ArrowReaderProperties;
|
| 46 |
+
|
| 47 |
+
class WriterProperties;
|
| 48 |
+
class ArrowWriterProperties;
|
| 49 |
+
|
| 50 |
+
namespace arrow {
|
| 51 |
+
class FileReader;
|
| 52 |
+
class FileWriter;
|
| 53 |
+
struct SchemaManifest;
|
| 54 |
+
} // namespace arrow
|
| 55 |
+
} // namespace parquet
|
| 56 |
+
|
| 57 |
+
namespace arrow {
|
| 58 |
+
namespace dataset {
|
| 59 |
+
|
| 60 |
+
struct ParquetDecryptionConfig;
|
| 61 |
+
struct ParquetEncryptionConfig;
|
| 62 |
+
|
| 63 |
+
/// \addtogroup dataset-file-formats
|
| 64 |
+
///
|
| 65 |
+
/// @{
|
| 66 |
+
|
| 67 |
+
constexpr char kParquetTypeName[] = "parquet";
|
| 68 |
+
|
| 69 |
+
/// \brief A FileFormat implementation that reads from Parquet files
|
| 70 |
+
class ARROW_DS_EXPORT ParquetFileFormat : public FileFormat {
|
| 71 |
+
public:
|
| 72 |
+
ParquetFileFormat();
|
| 73 |
+
|
| 74 |
+
/// Convenience constructor which copies properties from a parquet::ReaderProperties.
|
| 75 |
+
/// memory_pool will be ignored.
|
| 76 |
+
explicit ParquetFileFormat(const parquet::ReaderProperties& reader_properties);
|
| 77 |
+
|
| 78 |
+
std::string type_name() const override { return kParquetTypeName; }
|
| 79 |
+
|
| 80 |
+
bool Equals(const FileFormat& other) const override;
|
| 81 |
+
|
| 82 |
+
struct ReaderOptions {
|
| 83 |
+
/// \defgroup parquet-file-format-arrow-reader-properties properties which correspond
|
| 84 |
+
/// to members of parquet::ArrowReaderProperties.
|
| 85 |
+
///
|
| 86 |
+
/// We don't embed parquet::ReaderProperties directly because column names (rather
|
| 87 |
+
/// than indices) are used to indicate dictionary columns, and other options are
|
| 88 |
+
/// deferred to scan time.
|
| 89 |
+
///
|
| 90 |
+
/// @{
|
| 91 |
+
std::unordered_set<std::string> dict_columns;
|
| 92 |
+
arrow::TimeUnit::type coerce_int96_timestamp_unit = arrow::TimeUnit::NANO;
|
| 93 |
+
Type::type binary_type = Type::BINARY;
|
| 94 |
+
Type::type list_type = Type::LIST;
|
| 95 |
+
/// @}
|
| 96 |
+
} reader_options;
|
| 97 |
+
|
| 98 |
+
Result<bool> IsSupported(const FileSource& source) const override;
|
| 99 |
+
|
| 100 |
+
/// \brief Return the schema of the file if possible.
|
| 101 |
+
Result<std::shared_ptr<Schema>> Inspect(const FileSource& source) const override;
|
| 102 |
+
|
| 103 |
+
Result<RecordBatchGenerator> ScanBatchesAsync(
|
| 104 |
+
const std::shared_ptr<ScanOptions>& options,
|
| 105 |
+
const std::shared_ptr<FileFragment>& file) const override;
|
| 106 |
+
|
| 107 |
+
Future<std::optional<int64_t>> CountRows(
|
| 108 |
+
const std::shared_ptr<FileFragment>& file, compute::Expression predicate,
|
| 109 |
+
const std::shared_ptr<ScanOptions>& options) override;
|
| 110 |
+
|
| 111 |
+
using FileFormat::MakeFragment;
|
| 112 |
+
|
| 113 |
+
/// \brief Create a Fragment targeting all RowGroups.
|
| 114 |
+
Result<std::shared_ptr<FileFragment>> MakeFragment(
|
| 115 |
+
FileSource source, compute::Expression partition_expression,
|
| 116 |
+
std::shared_ptr<Schema> physical_schema) override;
|
| 117 |
+
|
| 118 |
+
/// \brief Create a Fragment, restricted to the specified row groups.
|
| 119 |
+
Result<std::shared_ptr<ParquetFileFragment>> MakeFragment(
|
| 120 |
+
FileSource source, compute::Expression partition_expression,
|
| 121 |
+
std::shared_ptr<Schema> physical_schema, std::vector<int> row_groups);
|
| 122 |
+
|
| 123 |
+
/// \brief Return a FileReader on the given source.
|
| 124 |
+
Result<std::shared_ptr<parquet::arrow::FileReader>> GetReader(
|
| 125 |
+
const FileSource& source, const std::shared_ptr<ScanOptions>& options) const;
|
| 126 |
+
|
| 127 |
+
Result<std::shared_ptr<parquet::arrow::FileReader>> GetReader(
|
| 128 |
+
const FileSource& source, const std::shared_ptr<ScanOptions>& options,
|
| 129 |
+
const std::shared_ptr<parquet::FileMetaData>& metadata) const;
|
| 130 |
+
|
| 131 |
+
Future<std::shared_ptr<parquet::arrow::FileReader>> GetReaderAsync(
|
| 132 |
+
const FileSource& source, const std::shared_ptr<ScanOptions>& options) const;
|
| 133 |
+
|
| 134 |
+
Future<std::shared_ptr<parquet::arrow::FileReader>> GetReaderAsync(
|
| 135 |
+
const FileSource& source, const std::shared_ptr<ScanOptions>& options,
|
| 136 |
+
const std::shared_ptr<parquet::FileMetaData>& metadata) const;
|
| 137 |
+
|
| 138 |
+
Result<std::shared_ptr<FileWriter>> MakeWriter(
|
| 139 |
+
std::shared_ptr<io::OutputStream> destination, std::shared_ptr<Schema> schema,
|
| 140 |
+
std::shared_ptr<FileWriteOptions> options,
|
| 141 |
+
fs::FileLocator destination_locator) const override;
|
| 142 |
+
|
| 143 |
+
std::shared_ptr<FileWriteOptions> DefaultWriteOptions() override;
|
| 144 |
+
};
|
| 145 |
+
|
| 146 |
+
/// \brief A FileFragment with parquet logic.
|
| 147 |
+
///
|
| 148 |
+
/// ParquetFileFragment provides a lazy (with respect to IO) interface to
|
| 149 |
+
/// scan parquet files. Any heavy IO calls are deferred to the Scan() method.
|
| 150 |
+
///
|
| 151 |
+
/// The caller can provide an optional list of selected RowGroups to limit the
|
| 152 |
+
/// number of scanned RowGroups, or to partition the scans across multiple
|
| 153 |
+
/// threads.
|
| 154 |
+
///
|
| 155 |
+
/// Metadata can be explicitly provided, enabling pushdown predicate benefits without
|
| 156 |
+
/// the potentially heavy IO of loading Metadata from the file system. This can induce
|
| 157 |
+
/// significant performance boost when scanning high latency file systems.
|
| 158 |
+
class ARROW_DS_EXPORT ParquetFileFragment : public FileFragment {
|
| 159 |
+
public:
|
| 160 |
+
Result<FragmentVector> SplitByRowGroup(compute::Expression predicate);
|
| 161 |
+
|
| 162 |
+
/// \brief Return the RowGroups selected by this fragment.
|
| 163 |
+
const std::vector<int>& row_groups() const {
|
| 164 |
+
if (row_groups_) return *row_groups_;
|
| 165 |
+
static std::vector<int> empty;
|
| 166 |
+
return empty;
|
| 167 |
+
}
|
| 168 |
+
|
| 169 |
+
/// \brief Return the FileMetaData associated with this fragment.
|
| 170 |
+
///
|
| 171 |
+
/// This may return nullptr if the fragment wasn't scanned yet, or if
|
| 172 |
+
/// `ScanOptions::cache_metadata` was disabled.
|
| 173 |
+
std::shared_ptr<parquet::FileMetaData> metadata();
|
| 174 |
+
|
| 175 |
+
/// \brief Ensure this fragment's FileMetaData is in memory.
|
| 176 |
+
Status EnsureCompleteMetadata(parquet::arrow::FileReader* reader = NULLPTR);
|
| 177 |
+
|
| 178 |
+
Status ClearCachedMetadata() override;
|
| 179 |
+
|
| 180 |
+
/// \brief Return fragment which selects a filtered subset of this fragment's RowGroups.
|
| 181 |
+
Result<std::shared_ptr<Fragment>> Subset(compute::Expression predicate);
|
| 182 |
+
Result<std::shared_ptr<Fragment>> Subset(std::vector<int> row_group_ids);
|
| 183 |
+
|
| 184 |
+
static std::optional<compute::Expression> EvaluateStatisticsAsExpression(
|
| 185 |
+
const Field& field, const parquet::Statistics& statistics);
|
| 186 |
+
|
| 187 |
+
static std::optional<compute::Expression> EvaluateStatisticsAsExpression(
|
| 188 |
+
const Field& field, const FieldRef& field_ref,
|
| 189 |
+
const parquet::Statistics& statistics);
|
| 190 |
+
|
| 191 |
+
private:
|
| 192 |
+
ParquetFileFragment(FileSource source, std::shared_ptr<FileFormat> format,
|
| 193 |
+
compute::Expression partition_expression,
|
| 194 |
+
std::shared_ptr<Schema> physical_schema,
|
| 195 |
+
std::optional<std::vector<int>> row_groups);
|
| 196 |
+
|
| 197 |
+
Status SetMetadata(std::shared_ptr<parquet::FileMetaData> metadata,
|
| 198 |
+
std::shared_ptr<parquet::arrow::SchemaManifest> manifest,
|
| 199 |
+
std::shared_ptr<parquet::FileMetaData> original_metadata = {});
|
| 200 |
+
|
| 201 |
+
// Overridden to opportunistically set metadata since a reader must be opened anyway.
|
| 202 |
+
Result<std::shared_ptr<Schema>> ReadPhysicalSchemaImpl() override {
|
| 203 |
+
ARROW_RETURN_NOT_OK(EnsureCompleteMetadata());
|
| 204 |
+
return physical_schema_;
|
| 205 |
+
}
|
| 206 |
+
|
| 207 |
+
/// Return a filtered subset of row group indices.
|
| 208 |
+
Result<std::vector<int>> FilterRowGroups(compute::Expression predicate);
|
| 209 |
+
/// Simplify the predicate against the statistics of each row group.
|
| 210 |
+
Result<std::vector<compute::Expression>> TestRowGroups(compute::Expression predicate);
|
| 211 |
+
/// Try to count rows matching the predicate using metadata. Expects
|
| 212 |
+
/// metadata to be present, and expects the predicate to have been
|
| 213 |
+
/// simplified against the partition expression already.
|
| 214 |
+
Result<std::optional<int64_t>> TryCountRows(compute::Expression predicate);
|
| 215 |
+
|
| 216 |
+
ParquetFileFormat& parquet_format_;
|
| 217 |
+
|
| 218 |
+
/// Indices of row groups selected by this fragment,
|
| 219 |
+
/// or std::nullopt if all row groups are selected.
|
| 220 |
+
std::optional<std::vector<int>> row_groups_;
|
| 221 |
+
|
| 222 |
+
// the expressions (combined for all columns for which statistics have been
|
| 223 |
+
// processed) are stored per column group
|
| 224 |
+
std::vector<compute::Expression> statistics_expressions_;
|
| 225 |
+
// statistics status are kept track of by Parquet Schema column indices
|
| 226 |
+
// (i.e. not Arrow schema field index)
|
| 227 |
+
std::vector<bool> statistics_expressions_complete_;
|
| 228 |
+
std::shared_ptr<parquet::FileMetaData> metadata_;
|
| 229 |
+
std::shared_ptr<parquet::arrow::SchemaManifest> manifest_;
|
| 230 |
+
// The FileMetaData that owns the SchemaDescriptor pointed by SchemaManifest.
|
| 231 |
+
std::shared_ptr<parquet::FileMetaData> original_metadata_;
|
| 232 |
+
|
| 233 |
+
friend class ParquetFileFormat;
|
| 234 |
+
friend class ParquetDatasetFactory;
|
| 235 |
+
};
|
| 236 |
+
|
| 237 |
+
/// \brief Per-scan options for Parquet fragments
|
| 238 |
+
class ARROW_DS_EXPORT ParquetFragmentScanOptions : public FragmentScanOptions {
|
| 239 |
+
public:
|
| 240 |
+
ParquetFragmentScanOptions();
|
| 241 |
+
std::string type_name() const override { return kParquetTypeName; }
|
| 242 |
+
|
| 243 |
+
/// Reader properties. Not all properties are respected: memory_pool comes from
|
| 244 |
+
/// ScanOptions.
|
| 245 |
+
std::shared_ptr<parquet::ReaderProperties> reader_properties;
|
| 246 |
+
/// Arrow reader properties. Not all properties are respected: batch_size comes from
|
| 247 |
+
/// ScanOptions. Additionally, other options come from ParquetFileFormat::ReaderOptions.
|
| 248 |
+
std::shared_ptr<parquet::ArrowReaderProperties> arrow_reader_properties;
|
| 249 |
+
/// A configuration structure that provides decryption properties for a dataset
|
| 250 |
+
std::shared_ptr<ParquetDecryptionConfig> parquet_decryption_config = NULLPTR;
|
| 251 |
+
};
|
| 252 |
+
|
| 253 |
+
class ARROW_DS_EXPORT ParquetFileWriteOptions : public FileWriteOptions {
|
| 254 |
+
public:
|
| 255 |
+
/// \brief Parquet writer properties.
|
| 256 |
+
std::shared_ptr<parquet::WriterProperties> writer_properties;
|
| 257 |
+
|
| 258 |
+
/// \brief Parquet Arrow writer properties.
|
| 259 |
+
std::shared_ptr<parquet::ArrowWriterProperties> arrow_writer_properties;
|
| 260 |
+
|
| 261 |
+
// A configuration structure that provides encryption properties for a dataset
|
| 262 |
+
std::shared_ptr<ParquetEncryptionConfig> parquet_encryption_config = NULLPTR;
|
| 263 |
+
|
| 264 |
+
protected:
|
| 265 |
+
explicit ParquetFileWriteOptions(std::shared_ptr<FileFormat> format)
|
| 266 |
+
: FileWriteOptions(std::move(format)) {}
|
| 267 |
+
|
| 268 |
+
friend class ParquetFileFormat;
|
| 269 |
+
};
|
| 270 |
+
|
| 271 |
+
class ARROW_DS_EXPORT ParquetFileWriter : public FileWriter {
|
| 272 |
+
public:
|
| 273 |
+
const std::shared_ptr<parquet::arrow::FileWriter>& parquet_writer() const {
|
| 274 |
+
return parquet_writer_;
|
| 275 |
+
}
|
| 276 |
+
|
| 277 |
+
Status Write(const std::shared_ptr<RecordBatch>& batch) override;
|
| 278 |
+
|
| 279 |
+
private:
|
| 280 |
+
ParquetFileWriter(std::shared_ptr<io::OutputStream> destination,
|
| 281 |
+
std::shared_ptr<parquet::arrow::FileWriter> writer,
|
| 282 |
+
std::shared_ptr<ParquetFileWriteOptions> options,
|
| 283 |
+
fs::FileLocator destination_locator);
|
| 284 |
+
|
| 285 |
+
Future<> FinishInternal() override;
|
| 286 |
+
|
| 287 |
+
std::shared_ptr<parquet::arrow::FileWriter> parquet_writer_;
|
| 288 |
+
|
| 289 |
+
friend class ParquetFileFormat;
|
| 290 |
+
};
|
| 291 |
+
|
| 292 |
+
/// \brief Options for making a FileSystemDataset from a Parquet _metadata file.
|
| 293 |
+
struct ParquetFactoryOptions {
|
| 294 |
+
/// Either an explicit Partitioning or a PartitioningFactory to discover one.
|
| 295 |
+
///
|
| 296 |
+
/// If a factory is provided, it will be used to infer a schema for partition fields
|
| 297 |
+
/// based on file and directory paths then construct a Partitioning. The default
|
| 298 |
+
/// is a Partitioning which will yield no partition information.
|
| 299 |
+
///
|
| 300 |
+
/// The (explicit or discovered) partitioning will be applied to discovered files
|
| 301 |
+
/// and the resulting partition information embedded in the Dataset.
|
| 302 |
+
PartitioningOrFactory partitioning{Partitioning::Default()};
|
| 303 |
+
|
| 304 |
+
/// For the purposes of applying the partitioning, paths will be stripped
|
| 305 |
+
/// of the partition_base_dir. Files not matching the partition_base_dir
|
| 306 |
+
/// prefix will be skipped for partition discovery. The ignored files will still
|
| 307 |
+
/// be part of the Dataset, but will not have partition information.
|
| 308 |
+
///
|
| 309 |
+
/// Example:
|
| 310 |
+
/// partition_base_dir = "/dataset";
|
| 311 |
+
///
|
| 312 |
+
/// - "/dataset/US/sales.csv" -> "US/sales.csv" will be given to the partitioning
|
| 313 |
+
///
|
| 314 |
+
/// - "/home/john/late_sales.csv" -> Will be ignored for partition discovery.
|
| 315 |
+
///
|
| 316 |
+
/// This is useful for partitioning which parses directory when ordering
|
| 317 |
+
/// is important, e.g. DirectoryPartitioning.
|
| 318 |
+
std::string partition_base_dir;
|
| 319 |
+
|
| 320 |
+
/// Assert that all ColumnChunk paths are consistent. The parquet spec allows for
|
| 321 |
+
/// ColumnChunk data to be stored in multiple files, but ParquetDatasetFactory
|
| 322 |
+
/// supports only a single file with all ColumnChunk data. If this flag is set
|
| 323 |
+
/// construction of a ParquetDatasetFactory will raise an error if ColumnChunk
|
| 324 |
+
/// data is not resident in a single file.
|
| 325 |
+
bool validate_column_chunk_paths = false;
|
| 326 |
+
};
|
| 327 |
+
|
| 328 |
+
/// \brief Create FileSystemDataset from custom `_metadata` cache file.
|
| 329 |
+
///
|
| 330 |
+
/// Dask and other systems will generate a cache metadata file by concatenating
|
| 331 |
+
/// the RowGroupMetaData of multiple parquet files into a single parquet file
|
| 332 |
+
/// that only contains metadata and no ColumnChunk data.
|
| 333 |
+
///
|
| 334 |
+
/// ParquetDatasetFactory creates a FileSystemDataset composed of
|
| 335 |
+
/// ParquetFileFragment where each fragment is pre-populated with the exact
|
| 336 |
+
/// number of row groups and statistics for each columns.
|
| 337 |
+
class ARROW_DS_EXPORT ParquetDatasetFactory : public DatasetFactory {
|
| 338 |
+
public:
|
| 339 |
+
/// \brief Create a ParquetDatasetFactory from a metadata path.
|
| 340 |
+
///
|
| 341 |
+
/// The `metadata_path` will be read from `filesystem`. Each RowGroup
|
| 342 |
+
/// contained in the metadata file will be relative to `dirname(metadata_path)`.
|
| 343 |
+
///
|
| 344 |
+
/// \param[in] metadata_path path of the metadata parquet file
|
| 345 |
+
/// \param[in] filesystem from which to open/read the path
|
| 346 |
+
/// \param[in] format to read the file with.
|
| 347 |
+
/// \param[in] options see ParquetFactoryOptions
|
| 348 |
+
static Result<std::shared_ptr<DatasetFactory>> Make(
|
| 349 |
+
const std::string& metadata_path, std::shared_ptr<fs::FileSystem> filesystem,
|
| 350 |
+
std::shared_ptr<ParquetFileFormat> format, ParquetFactoryOptions options);
|
| 351 |
+
|
| 352 |
+
/// \brief Create a ParquetDatasetFactory from a metadata source.
|
| 353 |
+
///
|
| 354 |
+
/// Similar to the previous Make definition, but the metadata can be a Buffer
|
| 355 |
+
/// and the base_path is explicit instead of inferred from the metadata
|
| 356 |
+
/// path.
|
| 357 |
+
///
|
| 358 |
+
/// \param[in] metadata source to open the metadata parquet file from
|
| 359 |
+
/// \param[in] base_path used as the prefix of every parquet files referenced
|
| 360 |
+
/// \param[in] filesystem from which to read the files referenced.
|
| 361 |
+
/// \param[in] format to read the file with.
|
| 362 |
+
/// \param[in] options see ParquetFactoryOptions
|
| 363 |
+
static Result<std::shared_ptr<DatasetFactory>> Make(
|
| 364 |
+
const FileSource& metadata, const std::string& base_path,
|
| 365 |
+
std::shared_ptr<fs::FileSystem> filesystem,
|
| 366 |
+
std::shared_ptr<ParquetFileFormat> format, ParquetFactoryOptions options);
|
| 367 |
+
|
| 368 |
+
Result<std::vector<std::shared_ptr<Schema>>> InspectSchemas(
|
| 369 |
+
InspectOptions options) override;
|
| 370 |
+
|
| 371 |
+
Result<std::shared_ptr<Dataset>> Finish(FinishOptions options) override;
|
| 372 |
+
|
| 373 |
+
protected:
|
| 374 |
+
ParquetDatasetFactory(
|
| 375 |
+
std::shared_ptr<fs::FileSystem> filesystem,
|
| 376 |
+
std::shared_ptr<ParquetFileFormat> format,
|
| 377 |
+
std::shared_ptr<parquet::FileMetaData> metadata,
|
| 378 |
+
std::shared_ptr<parquet::arrow::SchemaManifest> manifest,
|
| 379 |
+
std::shared_ptr<Schema> physical_schema, std::string base_path,
|
| 380 |
+
ParquetFactoryOptions options,
|
| 381 |
+
std::vector<std::pair<std::string, std::vector<int>>> paths_with_row_group_ids)
|
| 382 |
+
: filesystem_(std::move(filesystem)),
|
| 383 |
+
format_(std::move(format)),
|
| 384 |
+
metadata_(std::move(metadata)),
|
| 385 |
+
manifest_(std::move(manifest)),
|
| 386 |
+
physical_schema_(std::move(physical_schema)),
|
| 387 |
+
base_path_(std::move(base_path)),
|
| 388 |
+
options_(std::move(options)),
|
| 389 |
+
paths_with_row_group_ids_(std::move(paths_with_row_group_ids)) {}
|
| 390 |
+
|
| 391 |
+
std::shared_ptr<fs::FileSystem> filesystem_;
|
| 392 |
+
std::shared_ptr<ParquetFileFormat> format_;
|
| 393 |
+
std::shared_ptr<parquet::FileMetaData> metadata_;
|
| 394 |
+
std::shared_ptr<parquet::arrow::SchemaManifest> manifest_;
|
| 395 |
+
std::shared_ptr<Schema> physical_schema_;
|
| 396 |
+
std::string base_path_;
|
| 397 |
+
ParquetFactoryOptions options_;
|
| 398 |
+
std::vector<std::pair<std::string, std::vector<int>>> paths_with_row_group_ids_;
|
| 399 |
+
|
| 400 |
+
private:
|
| 401 |
+
Result<std::vector<std::shared_ptr<FileFragment>>> CollectParquetFragments(
|
| 402 |
+
const Partitioning& partitioning);
|
| 403 |
+
|
| 404 |
+
Result<std::shared_ptr<Schema>> PartitionSchema();
|
| 405 |
+
};
|
| 406 |
+
|
| 407 |
+
/// @}
|
| 408 |
+
|
| 409 |
+
} // namespace dataset
|
| 410 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/dataset/parquet_encryption_config.h
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 "arrow/dataset/type_fwd.h"
|
| 21 |
+
|
| 22 |
+
namespace parquet::encryption {
|
| 23 |
+
class CryptoFactory;
|
| 24 |
+
struct KmsConnectionConfig;
|
| 25 |
+
struct EncryptionConfiguration;
|
| 26 |
+
struct DecryptionConfiguration;
|
| 27 |
+
} // namespace parquet::encryption
|
| 28 |
+
|
| 29 |
+
namespace arrow {
|
| 30 |
+
namespace dataset {
|
| 31 |
+
|
| 32 |
+
/// \brief Core configuration class encapsulating parameters for high-level encryption
|
| 33 |
+
/// within Parquet framework.
|
| 34 |
+
///
|
| 35 |
+
/// ParquetEncryptionConfig serves as a bridge, passing encryption-related
|
| 36 |
+
/// parameters to appropriate components within the Parquet library. It holds references
|
| 37 |
+
/// to objects defining encryption strategy, Key Management Service (KMS) configuration,
|
| 38 |
+
/// and specific encryption configurations for Parquet data.
|
| 39 |
+
struct ARROW_DS_EXPORT ParquetEncryptionConfig {
|
| 40 |
+
/// Shared pointer to CryptoFactory object, responsible for creating cryptographic
|
| 41 |
+
/// components like encryptors and decryptors.
|
| 42 |
+
std::shared_ptr<parquet::encryption::CryptoFactory> crypto_factory;
|
| 43 |
+
|
| 44 |
+
/// Shared pointer to KmsConnectionConfig object, holding configuration parameters for
|
| 45 |
+
/// connecting to a Key Management Service (KMS).
|
| 46 |
+
std::shared_ptr<parquet::encryption::KmsConnectionConfig> kms_connection_config;
|
| 47 |
+
|
| 48 |
+
/// Shared pointer to EncryptionConfiguration object, defining specific encryption
|
| 49 |
+
/// settings for Parquet data, like keys for different columns.
|
| 50 |
+
std::shared_ptr<parquet::encryption::EncryptionConfiguration> encryption_config;
|
| 51 |
+
};
|
| 52 |
+
|
| 53 |
+
/// \brief Core configuration class encapsulating parameters for high-level decryption
|
| 54 |
+
/// within Parquet framework.
|
| 55 |
+
///
|
| 56 |
+
/// ParquetDecryptionConfig is designed to pass decryption-related parameters to
|
| 57 |
+
/// appropriate decryption components within Parquet library. It holds references to
|
| 58 |
+
/// objects defining decryption strategy, Key Management Service (KMS) configuration,
|
| 59 |
+
/// and specific decryption configurations for reading encrypted Parquet data.
|
| 60 |
+
struct ARROW_DS_EXPORT ParquetDecryptionConfig {
|
| 61 |
+
/// Shared pointer to CryptoFactory object, pivotal in creating cryptographic
|
| 62 |
+
/// components for decryption process.
|
| 63 |
+
std::shared_ptr<parquet::encryption::CryptoFactory> crypto_factory;
|
| 64 |
+
|
| 65 |
+
/// Shared pointer to KmsConnectionConfig object, containing parameters for connecting
|
| 66 |
+
/// to a Key Management Service (KMS) during decryption.
|
| 67 |
+
std::shared_ptr<parquet::encryption::KmsConnectionConfig> kms_connection_config;
|
| 68 |
+
|
| 69 |
+
/// Shared pointer to DecryptionConfiguration object, specifying decryption settings
|
| 70 |
+
/// for reading encrypted Parquet data.
|
| 71 |
+
std::shared_ptr<parquet::encryption::DecryptionConfiguration> decryption_config;
|
| 72 |
+
};
|
| 73 |
+
|
| 74 |
+
} // namespace dataset
|
| 75 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/dataset/partition.h
ADDED
|
@@ -0,0 +1,432 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// This API is EXPERIMENTAL.
|
| 19 |
+
|
| 20 |
+
#pragma once
|
| 21 |
+
|
| 22 |
+
#include <functional>
|
| 23 |
+
#include <iosfwd>
|
| 24 |
+
#include <memory>
|
| 25 |
+
#include <optional>
|
| 26 |
+
#include <string>
|
| 27 |
+
#include <unordered_map>
|
| 28 |
+
#include <utility>
|
| 29 |
+
#include <vector>
|
| 30 |
+
|
| 31 |
+
#include "arrow/compute/expression.h"
|
| 32 |
+
#include "arrow/dataset/type_fwd.h"
|
| 33 |
+
#include "arrow/dataset/visibility.h"
|
| 34 |
+
#include "arrow/util/compare.h"
|
| 35 |
+
|
| 36 |
+
namespace arrow {
|
| 37 |
+
|
| 38 |
+
namespace dataset {
|
| 39 |
+
|
| 40 |
+
constexpr char kFilenamePartitionSep = '_';
|
| 41 |
+
|
| 42 |
+
struct ARROW_DS_EXPORT PartitionPathFormat {
|
| 43 |
+
std::string directory, filename;
|
| 44 |
+
};
|
| 45 |
+
|
| 46 |
+
// ----------------------------------------------------------------------
|
| 47 |
+
// Partitioning
|
| 48 |
+
|
| 49 |
+
/// \defgroup dataset-partitioning Partitioning API
|
| 50 |
+
///
|
| 51 |
+
/// @{
|
| 52 |
+
|
| 53 |
+
/// \brief Interface for parsing partition expressions from string partition
|
| 54 |
+
/// identifiers.
|
| 55 |
+
///
|
| 56 |
+
/// For example, the identifier "foo=5" might be parsed to an equality expression
|
| 57 |
+
/// between the "foo" field and the value 5.
|
| 58 |
+
///
|
| 59 |
+
/// Some partitionings may store the field names in a metadata
|
| 60 |
+
/// store instead of in file paths, for example
|
| 61 |
+
/// dataset_root/2009/11/... could be used when the partition fields
|
| 62 |
+
/// are "year" and "month"
|
| 63 |
+
///
|
| 64 |
+
/// Paths are consumed from left to right. Paths must be relative to
|
| 65 |
+
/// the root of a partition; path prefixes must be removed before passing
|
| 66 |
+
/// the path to a partitioning for parsing.
|
| 67 |
+
class ARROW_DS_EXPORT Partitioning : public util::EqualityComparable<Partitioning> {
|
| 68 |
+
public:
|
| 69 |
+
virtual ~Partitioning() = default;
|
| 70 |
+
|
| 71 |
+
/// \brief The name identifying the kind of partitioning
|
| 72 |
+
virtual std::string type_name() const = 0;
|
| 73 |
+
|
| 74 |
+
//// \brief Return whether the partitionings are equal
|
| 75 |
+
virtual bool Equals(const Partitioning& other) const {
|
| 76 |
+
return schema_->Equals(other.schema_, /*check_metadata=*/false);
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
/// \brief If the input batch shares any fields with this partitioning,
|
| 80 |
+
/// produce sub-batches which satisfy mutually exclusive Expressions.
|
| 81 |
+
struct PartitionedBatches {
|
| 82 |
+
RecordBatchVector batches;
|
| 83 |
+
std::vector<compute::Expression> expressions;
|
| 84 |
+
};
|
| 85 |
+
virtual Result<PartitionedBatches> Partition(
|
| 86 |
+
const std::shared_ptr<RecordBatch>& batch) const = 0;
|
| 87 |
+
|
| 88 |
+
/// \brief Parse a path into a partition expression
|
| 89 |
+
virtual Result<compute::Expression> Parse(const std::string& path) const = 0;
|
| 90 |
+
|
| 91 |
+
virtual Result<PartitionPathFormat> Format(const compute::Expression& expr) const = 0;
|
| 92 |
+
|
| 93 |
+
/// \brief A default Partitioning which is a DirectoryPartitioning
|
| 94 |
+
/// with an empty schema.
|
| 95 |
+
static std::shared_ptr<Partitioning> Default();
|
| 96 |
+
|
| 97 |
+
/// \brief The partition schema.
|
| 98 |
+
const std::shared_ptr<Schema>& schema() const { return schema_; }
|
| 99 |
+
|
| 100 |
+
protected:
|
| 101 |
+
explicit Partitioning(std::shared_ptr<Schema> schema) : schema_(std::move(schema)) {}
|
| 102 |
+
|
| 103 |
+
std::shared_ptr<Schema> schema_;
|
| 104 |
+
};
|
| 105 |
+
|
| 106 |
+
/// \brief The encoding of partition segments.
|
| 107 |
+
enum class SegmentEncoding : int8_t {
|
| 108 |
+
/// No encoding.
|
| 109 |
+
None = 0,
|
| 110 |
+
/// Segment values are URL-encoded.
|
| 111 |
+
Uri = 1,
|
| 112 |
+
};
|
| 113 |
+
|
| 114 |
+
ARROW_DS_EXPORT
|
| 115 |
+
std::ostream& operator<<(std::ostream& os, SegmentEncoding segment_encoding);
|
| 116 |
+
|
| 117 |
+
/// \brief Options for key-value based partitioning (hive/directory).
|
| 118 |
+
struct ARROW_DS_EXPORT KeyValuePartitioningOptions {
|
| 119 |
+
/// After splitting a path into components, decode the path components
|
| 120 |
+
/// before parsing according to this scheme.
|
| 121 |
+
SegmentEncoding segment_encoding = SegmentEncoding::Uri;
|
| 122 |
+
};
|
| 123 |
+
|
| 124 |
+
/// \brief Options for inferring a partitioning.
|
| 125 |
+
struct ARROW_DS_EXPORT PartitioningFactoryOptions {
|
| 126 |
+
/// When inferring a schema for partition fields, yield dictionary encoded types
|
| 127 |
+
/// instead of plain. This can be more efficient when materializing virtual
|
| 128 |
+
/// columns, and Expressions parsed by the finished Partitioning will include
|
| 129 |
+
/// dictionaries of all unique inspected values for each field.
|
| 130 |
+
bool infer_dictionary = false;
|
| 131 |
+
/// Optionally, an expected schema can be provided, in which case inference
|
| 132 |
+
/// will only check discovered fields against the schema and update internal
|
| 133 |
+
/// state (such as dictionaries).
|
| 134 |
+
std::shared_ptr<Schema> schema;
|
| 135 |
+
/// After splitting a path into components, decode the path components
|
| 136 |
+
/// before parsing according to this scheme.
|
| 137 |
+
SegmentEncoding segment_encoding = SegmentEncoding::Uri;
|
| 138 |
+
|
| 139 |
+
KeyValuePartitioningOptions AsPartitioningOptions() const;
|
| 140 |
+
};
|
| 141 |
+
|
| 142 |
+
/// \brief Options for inferring a hive-style partitioning.
|
| 143 |
+
struct ARROW_DS_EXPORT HivePartitioningFactoryOptions : PartitioningFactoryOptions {
|
| 144 |
+
/// The hive partitioning scheme maps null to a hard coded fallback string.
|
| 145 |
+
std::string null_fallback;
|
| 146 |
+
|
| 147 |
+
HivePartitioningOptions AsHivePartitioningOptions() const;
|
| 148 |
+
};
|
| 149 |
+
|
| 150 |
+
/// \brief PartitioningFactory provides creation of a partitioning when the
|
| 151 |
+
/// specific schema must be inferred from available paths (no explicit schema is known).
|
| 152 |
+
class ARROW_DS_EXPORT PartitioningFactory {
|
| 153 |
+
public:
|
| 154 |
+
virtual ~PartitioningFactory() = default;
|
| 155 |
+
|
| 156 |
+
/// \brief The name identifying the kind of partitioning
|
| 157 |
+
virtual std::string type_name() const = 0;
|
| 158 |
+
|
| 159 |
+
/// Get the schema for the resulting Partitioning.
|
| 160 |
+
/// This may reset internal state, for example dictionaries of unique representations.
|
| 161 |
+
virtual Result<std::shared_ptr<Schema>> Inspect(
|
| 162 |
+
const std::vector<std::string>& paths) = 0;
|
| 163 |
+
|
| 164 |
+
/// Create a partitioning using the provided schema
|
| 165 |
+
/// (fields may be dropped).
|
| 166 |
+
virtual Result<std::shared_ptr<Partitioning>> Finish(
|
| 167 |
+
const std::shared_ptr<Schema>& schema) const = 0;
|
| 168 |
+
};
|
| 169 |
+
|
| 170 |
+
/// \brief Subclass for the common case of a partitioning which yields an equality
|
| 171 |
+
/// expression for each segment
|
| 172 |
+
class ARROW_DS_EXPORT KeyValuePartitioning : public Partitioning {
|
| 173 |
+
public:
|
| 174 |
+
/// An unconverted equality expression consisting of a field name and the representation
|
| 175 |
+
/// of a scalar value
|
| 176 |
+
struct Key {
|
| 177 |
+
std::string name;
|
| 178 |
+
std::optional<std::string> value;
|
| 179 |
+
};
|
| 180 |
+
|
| 181 |
+
Result<PartitionedBatches> Partition(
|
| 182 |
+
const std::shared_ptr<RecordBatch>& batch) const override;
|
| 183 |
+
|
| 184 |
+
Result<compute::Expression> Parse(const std::string& path) const override;
|
| 185 |
+
|
| 186 |
+
Result<PartitionPathFormat> Format(const compute::Expression& expr) const override;
|
| 187 |
+
|
| 188 |
+
const ArrayVector& dictionaries() const { return dictionaries_; }
|
| 189 |
+
|
| 190 |
+
SegmentEncoding segment_encoding() const { return options_.segment_encoding; }
|
| 191 |
+
|
| 192 |
+
bool Equals(const Partitioning& other) const override;
|
| 193 |
+
|
| 194 |
+
protected:
|
| 195 |
+
KeyValuePartitioning(std::shared_ptr<Schema> schema, ArrayVector dictionaries,
|
| 196 |
+
KeyValuePartitioningOptions options)
|
| 197 |
+
: Partitioning(std::move(schema)),
|
| 198 |
+
dictionaries_(std::move(dictionaries)),
|
| 199 |
+
options_(options) {
|
| 200 |
+
if (dictionaries_.empty()) {
|
| 201 |
+
dictionaries_.resize(schema_->num_fields());
|
| 202 |
+
}
|
| 203 |
+
}
|
| 204 |
+
|
| 205 |
+
virtual Result<std::vector<Key>> ParseKeys(const std::string& path) const = 0;
|
| 206 |
+
|
| 207 |
+
virtual Result<PartitionPathFormat> FormatValues(const ScalarVector& values) const = 0;
|
| 208 |
+
|
| 209 |
+
/// Convert a Key to a full expression.
|
| 210 |
+
Result<compute::Expression> ConvertKey(const Key& key) const;
|
| 211 |
+
|
| 212 |
+
Result<std::vector<std::string>> FormatPartitionSegments(
|
| 213 |
+
const ScalarVector& values) const;
|
| 214 |
+
Result<std::vector<Key>> ParsePartitionSegments(
|
| 215 |
+
const std::vector<std::string>& segments) const;
|
| 216 |
+
|
| 217 |
+
ArrayVector dictionaries_;
|
| 218 |
+
KeyValuePartitioningOptions options_;
|
| 219 |
+
};
|
| 220 |
+
|
| 221 |
+
/// \brief DirectoryPartitioning parses one segment of a path for each field in its
|
| 222 |
+
/// schema. All fields are required, so paths passed to DirectoryPartitioning::Parse
|
| 223 |
+
/// must contain segments for each field.
|
| 224 |
+
///
|
| 225 |
+
/// For example given schema<year:int16, month:int8> the path "/2009/11" would be
|
| 226 |
+
/// parsed to ("year"_ == 2009 and "month"_ == 11)
|
| 227 |
+
class ARROW_DS_EXPORT DirectoryPartitioning : public KeyValuePartitioning {
|
| 228 |
+
public:
|
| 229 |
+
/// If a field in schema is of dictionary type, the corresponding element of
|
| 230 |
+
/// dictionaries must be contain the dictionary of values for that field.
|
| 231 |
+
explicit DirectoryPartitioning(std::shared_ptr<Schema> schema,
|
| 232 |
+
ArrayVector dictionaries = {},
|
| 233 |
+
KeyValuePartitioningOptions options = {});
|
| 234 |
+
|
| 235 |
+
std::string type_name() const override { return "directory"; }
|
| 236 |
+
|
| 237 |
+
bool Equals(const Partitioning& other) const override;
|
| 238 |
+
|
| 239 |
+
/// \brief Create a factory for a directory partitioning.
|
| 240 |
+
///
|
| 241 |
+
/// \param[in] field_names The names for the partition fields. Types will be
|
| 242 |
+
/// inferred.
|
| 243 |
+
static std::shared_ptr<PartitioningFactory> MakeFactory(
|
| 244 |
+
std::vector<std::string> field_names, PartitioningFactoryOptions = {});
|
| 245 |
+
|
| 246 |
+
private:
|
| 247 |
+
Result<std::vector<Key>> ParseKeys(const std::string& path) const override;
|
| 248 |
+
|
| 249 |
+
Result<PartitionPathFormat> FormatValues(const ScalarVector& values) const override;
|
| 250 |
+
};
|
| 251 |
+
|
| 252 |
+
/// \brief The default fallback used for null values in a Hive-style partitioning.
|
| 253 |
+
static constexpr char kDefaultHiveNullFallback[] = "__HIVE_DEFAULT_PARTITION__";
|
| 254 |
+
|
| 255 |
+
struct ARROW_DS_EXPORT HivePartitioningOptions : public KeyValuePartitioningOptions {
|
| 256 |
+
std::string null_fallback = kDefaultHiveNullFallback;
|
| 257 |
+
|
| 258 |
+
static HivePartitioningOptions DefaultsWithNullFallback(std::string fallback) {
|
| 259 |
+
HivePartitioningOptions options;
|
| 260 |
+
options.null_fallback = std::move(fallback);
|
| 261 |
+
return options;
|
| 262 |
+
}
|
| 263 |
+
};
|
| 264 |
+
|
| 265 |
+
/// \brief Multi-level, directory based partitioning
|
| 266 |
+
/// originating from Apache Hive with all data files stored in the
|
| 267 |
+
/// leaf directories. Data is partitioned by static values of a
|
| 268 |
+
/// particular column in the schema. Partition keys are represented in
|
| 269 |
+
/// the form $key=$value in directory names.
|
| 270 |
+
/// Field order is ignored, as are missing or unrecognized field names.
|
| 271 |
+
///
|
| 272 |
+
/// For example given schema<year:int16, month:int8, day:int8> the path
|
| 273 |
+
/// "/day=321/ignored=3.4/year=2009" parses to ("year"_ == 2009 and "day"_ == 321)
|
| 274 |
+
class ARROW_DS_EXPORT HivePartitioning : public KeyValuePartitioning {
|
| 275 |
+
public:
|
| 276 |
+
/// If a field in schema is of dictionary type, the corresponding element of
|
| 277 |
+
/// dictionaries must be contain the dictionary of values for that field.
|
| 278 |
+
explicit HivePartitioning(std::shared_ptr<Schema> schema, ArrayVector dictionaries = {},
|
| 279 |
+
std::string null_fallback = kDefaultHiveNullFallback)
|
| 280 |
+
: KeyValuePartitioning(std::move(schema), std::move(dictionaries),
|
| 281 |
+
KeyValuePartitioningOptions()),
|
| 282 |
+
hive_options_(
|
| 283 |
+
HivePartitioningOptions::DefaultsWithNullFallback(std::move(null_fallback))) {
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
explicit HivePartitioning(std::shared_ptr<Schema> schema, ArrayVector dictionaries,
|
| 287 |
+
HivePartitioningOptions options)
|
| 288 |
+
: KeyValuePartitioning(std::move(schema), std::move(dictionaries), options),
|
| 289 |
+
hive_options_(options) {}
|
| 290 |
+
|
| 291 |
+
std::string type_name() const override { return "hive"; }
|
| 292 |
+
std::string null_fallback() const { return hive_options_.null_fallback; }
|
| 293 |
+
const HivePartitioningOptions& options() const { return hive_options_; }
|
| 294 |
+
|
| 295 |
+
static Result<std::optional<Key>> ParseKey(const std::string& segment,
|
| 296 |
+
const HivePartitioningOptions& options);
|
| 297 |
+
|
| 298 |
+
bool Equals(const Partitioning& other) const override;
|
| 299 |
+
|
| 300 |
+
/// \brief Create a factory for a hive partitioning.
|
| 301 |
+
static std::shared_ptr<PartitioningFactory> MakeFactory(
|
| 302 |
+
HivePartitioningFactoryOptions = {});
|
| 303 |
+
|
| 304 |
+
private:
|
| 305 |
+
const HivePartitioningOptions hive_options_;
|
| 306 |
+
Result<std::vector<Key>> ParseKeys(const std::string& path) const override;
|
| 307 |
+
|
| 308 |
+
Result<PartitionPathFormat> FormatValues(const ScalarVector& values) const override;
|
| 309 |
+
};
|
| 310 |
+
|
| 311 |
+
/// \brief Implementation provided by lambda or other callable
|
| 312 |
+
class ARROW_DS_EXPORT FunctionPartitioning : public Partitioning {
|
| 313 |
+
public:
|
| 314 |
+
using ParseImpl = std::function<Result<compute::Expression>(const std::string&)>;
|
| 315 |
+
|
| 316 |
+
using FormatImpl =
|
| 317 |
+
std::function<Result<PartitionPathFormat>(const compute::Expression&)>;
|
| 318 |
+
|
| 319 |
+
FunctionPartitioning(std::shared_ptr<Schema> schema, ParseImpl parse_impl,
|
| 320 |
+
FormatImpl format_impl = NULLPTR, std::string name = "function")
|
| 321 |
+
: Partitioning(std::move(schema)),
|
| 322 |
+
parse_impl_(std::move(parse_impl)),
|
| 323 |
+
format_impl_(std::move(format_impl)),
|
| 324 |
+
name_(std::move(name)) {}
|
| 325 |
+
|
| 326 |
+
std::string type_name() const override { return name_; }
|
| 327 |
+
|
| 328 |
+
bool Equals(const Partitioning& other) const override { return false; }
|
| 329 |
+
|
| 330 |
+
Result<compute::Expression> Parse(const std::string& path) const override {
|
| 331 |
+
return parse_impl_(path);
|
| 332 |
+
}
|
| 333 |
+
|
| 334 |
+
Result<PartitionPathFormat> Format(const compute::Expression& expr) const override {
|
| 335 |
+
if (format_impl_) {
|
| 336 |
+
return format_impl_(expr);
|
| 337 |
+
}
|
| 338 |
+
return Status::NotImplemented("formatting paths from ", type_name(), " Partitioning");
|
| 339 |
+
}
|
| 340 |
+
|
| 341 |
+
Result<PartitionedBatches> Partition(
|
| 342 |
+
const std::shared_ptr<RecordBatch>& batch) const override {
|
| 343 |
+
return Status::NotImplemented("partitioning batches from ", type_name(),
|
| 344 |
+
" Partitioning");
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
private:
|
| 348 |
+
ParseImpl parse_impl_;
|
| 349 |
+
FormatImpl format_impl_;
|
| 350 |
+
std::string name_;
|
| 351 |
+
};
|
| 352 |
+
|
| 353 |
+
class ARROW_DS_EXPORT FilenamePartitioning : public KeyValuePartitioning {
|
| 354 |
+
public:
|
| 355 |
+
/// \brief Construct a FilenamePartitioning from its components.
|
| 356 |
+
///
|
| 357 |
+
/// If a field in schema is of dictionary type, the corresponding element of
|
| 358 |
+
/// dictionaries must be contain the dictionary of values for that field.
|
| 359 |
+
explicit FilenamePartitioning(std::shared_ptr<Schema> schema,
|
| 360 |
+
ArrayVector dictionaries = {},
|
| 361 |
+
KeyValuePartitioningOptions options = {});
|
| 362 |
+
|
| 363 |
+
std::string type_name() const override { return "filename"; }
|
| 364 |
+
|
| 365 |
+
/// \brief Create a factory for a filename partitioning.
|
| 366 |
+
///
|
| 367 |
+
/// \param[in] field_names The names for the partition fields. Types will be
|
| 368 |
+
/// inferred.
|
| 369 |
+
static std::shared_ptr<PartitioningFactory> MakeFactory(
|
| 370 |
+
std::vector<std::string> field_names, PartitioningFactoryOptions = {});
|
| 371 |
+
|
| 372 |
+
bool Equals(const Partitioning& other) const override;
|
| 373 |
+
|
| 374 |
+
private:
|
| 375 |
+
Result<std::vector<Key>> ParseKeys(const std::string& path) const override;
|
| 376 |
+
|
| 377 |
+
Result<PartitionPathFormat> FormatValues(const ScalarVector& values) const override;
|
| 378 |
+
};
|
| 379 |
+
|
| 380 |
+
ARROW_DS_EXPORT std::string StripPrefix(const std::string& path,
|
| 381 |
+
const std::string& prefix);
|
| 382 |
+
|
| 383 |
+
/// \brief Extracts the directory and filename and removes the prefix of a path
|
| 384 |
+
///
|
| 385 |
+
/// e.g., `StripPrefixAndFilename("/data/year=2019/c.txt", "/data") ->
|
| 386 |
+
/// {"year=2019","c.txt"}`
|
| 387 |
+
ARROW_DS_EXPORT std::string StripPrefixAndFilename(const std::string& path,
|
| 388 |
+
const std::string& prefix);
|
| 389 |
+
|
| 390 |
+
/// \brief Vector version of StripPrefixAndFilename.
|
| 391 |
+
ARROW_DS_EXPORT std::vector<std::string> StripPrefixAndFilename(
|
| 392 |
+
const std::vector<std::string>& paths, const std::string& prefix);
|
| 393 |
+
|
| 394 |
+
/// \brief Vector version of StripPrefixAndFilename.
|
| 395 |
+
ARROW_DS_EXPORT std::vector<std::string> StripPrefixAndFilename(
|
| 396 |
+
const std::vector<fs::FileInfo>& files, const std::string& prefix);
|
| 397 |
+
|
| 398 |
+
/// \brief Either a Partitioning or a PartitioningFactory
|
| 399 |
+
class ARROW_DS_EXPORT PartitioningOrFactory {
|
| 400 |
+
public:
|
| 401 |
+
explicit PartitioningOrFactory(std::shared_ptr<Partitioning> partitioning)
|
| 402 |
+
: partitioning_(std::move(partitioning)) {}
|
| 403 |
+
|
| 404 |
+
explicit PartitioningOrFactory(std::shared_ptr<PartitioningFactory> factory)
|
| 405 |
+
: factory_(std::move(factory)) {}
|
| 406 |
+
|
| 407 |
+
PartitioningOrFactory& operator=(std::shared_ptr<Partitioning> partitioning) {
|
| 408 |
+
return *this = PartitioningOrFactory(std::move(partitioning));
|
| 409 |
+
}
|
| 410 |
+
|
| 411 |
+
PartitioningOrFactory& operator=(std::shared_ptr<PartitioningFactory> factory) {
|
| 412 |
+
return *this = PartitioningOrFactory(std::move(factory));
|
| 413 |
+
}
|
| 414 |
+
|
| 415 |
+
/// \brief The partitioning (if given).
|
| 416 |
+
const std::shared_ptr<Partitioning>& partitioning() const { return partitioning_; }
|
| 417 |
+
|
| 418 |
+
/// \brief The partition factory (if given).
|
| 419 |
+
const std::shared_ptr<PartitioningFactory>& factory() const { return factory_; }
|
| 420 |
+
|
| 421 |
+
/// \brief Get the partition schema, inferring it with the given factory if needed.
|
| 422 |
+
Result<std::shared_ptr<Schema>> GetOrInferSchema(const std::vector<std::string>& paths);
|
| 423 |
+
|
| 424 |
+
private:
|
| 425 |
+
std::shared_ptr<PartitioningFactory> factory_;
|
| 426 |
+
std::shared_ptr<Partitioning> partitioning_;
|
| 427 |
+
};
|
| 428 |
+
|
| 429 |
+
/// @}
|
| 430 |
+
|
| 431 |
+
} // namespace dataset
|
| 432 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/dataset/plan.h
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// This API is EXPERIMENTAL.
|
| 19 |
+
|
| 20 |
+
#include "arrow/dataset/visibility.h"
|
| 21 |
+
|
| 22 |
+
namespace arrow {
|
| 23 |
+
namespace dataset {
|
| 24 |
+
namespace internal {
|
| 25 |
+
|
| 26 |
+
/// Register dataset-based exec nodes with the exec node registry
|
| 27 |
+
///
|
| 28 |
+
/// This function must be called before using dataset ExecNode factories
|
| 29 |
+
ARROW_DS_EXPORT void Initialize();
|
| 30 |
+
|
| 31 |
+
} // namespace internal
|
| 32 |
+
} // namespace dataset
|
| 33 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/dataset/projector.h
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// This API is EXPERIMENTAL.
|
| 19 |
+
|
| 20 |
+
#pragma once
|
| 21 |
+
|
| 22 |
+
#include "arrow/dataset/visibility.h"
|
| 23 |
+
#include "arrow/type_fwd.h"
|
| 24 |
+
|
| 25 |
+
namespace arrow {
|
| 26 |
+
namespace dataset {
|
| 27 |
+
|
| 28 |
+
// FIXME this is superceded by compute::Expression::Bind
|
| 29 |
+
ARROW_DS_EXPORT Status CheckProjectable(const Schema& from, const Schema& to);
|
| 30 |
+
|
| 31 |
+
} // namespace dataset
|
| 32 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/dataset/scanner.h
ADDED
|
@@ -0,0 +1,615 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// This API is EXPERIMENTAL.
|
| 19 |
+
|
| 20 |
+
#pragma once
|
| 21 |
+
|
| 22 |
+
#include <functional>
|
| 23 |
+
#include <memory>
|
| 24 |
+
#include <string>
|
| 25 |
+
#include <utility>
|
| 26 |
+
#include <vector>
|
| 27 |
+
|
| 28 |
+
#include "arrow/acero/options.h"
|
| 29 |
+
#include "arrow/compute/expression.h"
|
| 30 |
+
#include "arrow/compute/type_fwd.h"
|
| 31 |
+
#include "arrow/dataset/dataset.h"
|
| 32 |
+
#include "arrow/dataset/type_fwd.h"
|
| 33 |
+
#include "arrow/dataset/visibility.h"
|
| 34 |
+
#include "arrow/io/interfaces.h"
|
| 35 |
+
#include "arrow/type_fwd.h"
|
| 36 |
+
#include "arrow/util/async_generator_fwd.h"
|
| 37 |
+
#include "arrow/util/iterator.h"
|
| 38 |
+
#include "arrow/util/type_fwd.h"
|
| 39 |
+
|
| 40 |
+
namespace arrow {
|
| 41 |
+
|
| 42 |
+
using RecordBatchGenerator = std::function<Future<std::shared_ptr<RecordBatch>>()>;
|
| 43 |
+
|
| 44 |
+
namespace dataset {
|
| 45 |
+
|
| 46 |
+
/// \defgroup dataset-scanning Scanning API
|
| 47 |
+
///
|
| 48 |
+
/// @{
|
| 49 |
+
|
| 50 |
+
constexpr int64_t kDefaultBatchSize = 1 << 17; // 128Ki rows
|
| 51 |
+
// This will yield 64 batches ~ 8Mi rows
|
| 52 |
+
constexpr int32_t kDefaultBatchReadahead = 16;
|
| 53 |
+
constexpr int32_t kDefaultFragmentReadahead = 4;
|
| 54 |
+
constexpr int32_t kDefaultBytesReadahead = 1 << 25; // 32MiB
|
| 55 |
+
|
| 56 |
+
/// Scan-specific options, which can be changed between scans of the same dataset.
|
| 57 |
+
struct ARROW_DS_EXPORT ScanOptions {
|
| 58 |
+
/// A row filter (which will be pushed down to partitioning/reading if supported).
|
| 59 |
+
compute::Expression filter = compute::literal(true);
|
| 60 |
+
/// A projection expression (which can add/remove/rename columns).
|
| 61 |
+
compute::Expression projection;
|
| 62 |
+
|
| 63 |
+
/// Schema with which batches will be read from fragments. This is also known as the
|
| 64 |
+
/// "reader schema" it will be used (for example) in constructing CSV file readers to
|
| 65 |
+
/// identify column types for parsing. Usually only a subset of its fields (see
|
| 66 |
+
/// MaterializedFields) will be materialized during a scan.
|
| 67 |
+
std::shared_ptr<Schema> dataset_schema;
|
| 68 |
+
|
| 69 |
+
/// Schema of projected record batches. This is independent of dataset_schema as its
|
| 70 |
+
/// fields are derived from the projection. For example, let
|
| 71 |
+
///
|
| 72 |
+
/// dataset_schema = {"a": int32, "b": int32, "id": utf8}
|
| 73 |
+
/// projection = project({equal(field_ref("a"), field_ref("b"))}, {"a_plus_b"})
|
| 74 |
+
///
|
| 75 |
+
/// (no filter specified). In this case, the projected_schema would be
|
| 76 |
+
///
|
| 77 |
+
/// {"a_plus_b": int32}
|
| 78 |
+
std::shared_ptr<Schema> projected_schema;
|
| 79 |
+
|
| 80 |
+
/// Maximum row count for scanned batches.
|
| 81 |
+
int64_t batch_size = kDefaultBatchSize;
|
| 82 |
+
|
| 83 |
+
/// How many batches to read ahead within a fragment.
|
| 84 |
+
///
|
| 85 |
+
/// Set to 0 to disable batch readahead
|
| 86 |
+
///
|
| 87 |
+
/// Note: May not be supported by all formats
|
| 88 |
+
/// Note: Will be ignored if use_threads is set to false
|
| 89 |
+
int32_t batch_readahead = kDefaultBatchReadahead;
|
| 90 |
+
|
| 91 |
+
/// How many files to read ahead
|
| 92 |
+
///
|
| 93 |
+
/// Set to 0 to disable fragment readahead
|
| 94 |
+
///
|
| 95 |
+
/// Note: May not be enforced by all scanners
|
| 96 |
+
/// Note: Will be ignored if use_threads is set to false
|
| 97 |
+
int32_t fragment_readahead = kDefaultFragmentReadahead;
|
| 98 |
+
|
| 99 |
+
/// A pool from which materialized and scanned arrays will be allocated.
|
| 100 |
+
MemoryPool* pool = arrow::default_memory_pool();
|
| 101 |
+
|
| 102 |
+
/// IOContext for any IO tasks
|
| 103 |
+
///
|
| 104 |
+
/// Note: The IOContext executor will be ignored if use_threads is set to false
|
| 105 |
+
io::IOContext io_context;
|
| 106 |
+
|
| 107 |
+
/// If true the scanner will scan in parallel
|
| 108 |
+
///
|
| 109 |
+
/// Note: If true, this will use threads from both the cpu_executor and the
|
| 110 |
+
/// io_context.executor
|
| 111 |
+
/// Note: This must be true in order for any readahead to happen
|
| 112 |
+
bool use_threads = false;
|
| 113 |
+
|
| 114 |
+
/// If true the scanner will add augmented fields to the output schema.
|
| 115 |
+
bool add_augmented_fields = true;
|
| 116 |
+
|
| 117 |
+
/// Whether to cache metadata when scanning.
|
| 118 |
+
///
|
| 119 |
+
/// Fragments may typically cache metadata to speed up repeated accesses.
|
| 120 |
+
/// However, in use cases where a single scan is done, or if memory use
|
| 121 |
+
/// is more critical than CPU time, setting this option to false can
|
| 122 |
+
/// lessen memory use.
|
| 123 |
+
bool cache_metadata = true;
|
| 124 |
+
|
| 125 |
+
/// Fragment-specific scan options.
|
| 126 |
+
std::shared_ptr<FragmentScanOptions> fragment_scan_options;
|
| 127 |
+
|
| 128 |
+
/// Return a vector of FieldRefs that require materialization.
|
| 129 |
+
///
|
| 130 |
+
/// This is usually the union of the fields referenced in the projection and the
|
| 131 |
+
/// filter expression. Examples:
|
| 132 |
+
///
|
| 133 |
+
/// - `SELECT a, b WHERE a < 2 && c > 1` => ["a", "b", "a", "c"]
|
| 134 |
+
/// - `SELECT a + b < 3 WHERE a > 1` => ["a", "b", "a"]
|
| 135 |
+
///
|
| 136 |
+
/// This is needed for expression where a field may not be directly
|
| 137 |
+
/// used in the final projection but is still required to evaluate the
|
| 138 |
+
/// expression.
|
| 139 |
+
///
|
| 140 |
+
/// This is used by Fragment implementations to apply the column
|
| 141 |
+
/// sub-selection optimization.
|
| 142 |
+
std::vector<FieldRef> MaterializedFields() const;
|
| 143 |
+
|
| 144 |
+
/// Parameters which control when the plan should pause for a slow consumer
|
| 145 |
+
acero::BackpressureOptions backpressure =
|
| 146 |
+
acero::BackpressureOptions::DefaultBackpressure();
|
| 147 |
+
};
|
| 148 |
+
|
| 149 |
+
/// Scan-specific options, which can be changed between scans of the same dataset.
|
| 150 |
+
///
|
| 151 |
+
/// A dataset consists of one or more individual fragments. A fragment is anything
|
| 152 |
+
/// that is independently scannable, often a file.
|
| 153 |
+
///
|
| 154 |
+
/// Batches from all fragments will be converted to a single schema. This unified
|
| 155 |
+
/// schema is referred to as the "dataset schema" and is the output schema for
|
| 156 |
+
/// this node.
|
| 157 |
+
///
|
| 158 |
+
/// Individual fragments may have schemas that are different from the dataset
|
| 159 |
+
/// schema. This is sometimes referred to as the physical or fragment schema.
|
| 160 |
+
/// Conversion from the fragment schema to the dataset schema is a process
|
| 161 |
+
/// known as evolution.
|
| 162 |
+
struct ARROW_DS_EXPORT ScanV2Options : public acero::ExecNodeOptions {
|
| 163 |
+
explicit ScanV2Options(std::shared_ptr<Dataset> dataset)
|
| 164 |
+
: dataset(std::move(dataset)) {}
|
| 165 |
+
|
| 166 |
+
/// \brief The dataset to scan
|
| 167 |
+
std::shared_ptr<Dataset> dataset;
|
| 168 |
+
/// \brief A row filter
|
| 169 |
+
///
|
| 170 |
+
/// The filter expression should be written against the dataset schema.
|
| 171 |
+
/// The filter must be unbound.
|
| 172 |
+
///
|
| 173 |
+
/// This is an opportunistic pushdown filter. Filtering capabilities will
|
| 174 |
+
/// vary between formats. If a format is not capable of applying the filter
|
| 175 |
+
/// then it will ignore it.
|
| 176 |
+
///
|
| 177 |
+
/// Each fragment will do its best to filter the data based on the information
|
| 178 |
+
/// (partitioning guarantees, statistics) available to it. If it is able to
|
| 179 |
+
/// apply some filtering then it will indicate what filtering it was able to
|
| 180 |
+
/// apply by attaching a guarantee to the batch.
|
| 181 |
+
///
|
| 182 |
+
/// For example, if a filter is x < 50 && y > 40 then a batch may be able to
|
| 183 |
+
/// apply a guarantee x < 50. Post-scan filtering would then only need to
|
| 184 |
+
/// consider y > 40 (for this specific batch). The next batch may not be able
|
| 185 |
+
/// to attach any guarantee and both clauses would need to be applied to that batch.
|
| 186 |
+
///
|
| 187 |
+
/// A single guarantee-aware filtering operation should generally be applied to all
|
| 188 |
+
/// resulting batches. The scan node is not responsible for this.
|
| 189 |
+
///
|
| 190 |
+
/// Fields that are referenced by the filter should be included in the `columns` vector.
|
| 191 |
+
/// The scan node will not automatically fetch fields referenced by the filter
|
| 192 |
+
/// expression. \see AddFieldsNeededForFilter
|
| 193 |
+
///
|
| 194 |
+
/// If the filter references fields that are not included in `columns` this may or may
|
| 195 |
+
/// not be an error, depending on the format.
|
| 196 |
+
compute::Expression filter = compute::literal(true);
|
| 197 |
+
|
| 198 |
+
/// \brief The columns to scan
|
| 199 |
+
///
|
| 200 |
+
/// This is not a simple list of top-level column indices but instead a set of paths
|
| 201 |
+
/// allowing for partial selection of columns
|
| 202 |
+
///
|
| 203 |
+
/// These paths refer to the dataset schema
|
| 204 |
+
///
|
| 205 |
+
/// For example, consider the following dataset schema:
|
| 206 |
+
/// schema({
|
| 207 |
+
/// field("score", int32()),
|
| 208 |
+
/// "marker", struct_({
|
| 209 |
+
/// field("color", utf8()),
|
| 210 |
+
/// field("location", struct_({
|
| 211 |
+
/// field("x", float64()),
|
| 212 |
+
/// field("y", float64())
|
| 213 |
+
/// })
|
| 214 |
+
/// })
|
| 215 |
+
/// })
|
| 216 |
+
///
|
| 217 |
+
/// If `columns` is {{0}, {1,1,0}} then the output schema is:
|
| 218 |
+
/// schema({field("score", int32()), field("x", float64())})
|
| 219 |
+
///
|
| 220 |
+
/// If `columns` is {{1,1,1}, {1,1}} then the output schema is:
|
| 221 |
+
/// schema({
|
| 222 |
+
/// field("y", float64()),
|
| 223 |
+
/// field("location", struct_({
|
| 224 |
+
/// field("x", float64()),
|
| 225 |
+
/// field("y", float64())
|
| 226 |
+
/// })
|
| 227 |
+
/// })
|
| 228 |
+
std::vector<FieldPath> columns;
|
| 229 |
+
|
| 230 |
+
/// \brief Target number of bytes to read ahead in a fragment
|
| 231 |
+
///
|
| 232 |
+
/// This limit involves some amount of estimation. Formats typically only know
|
| 233 |
+
/// batch boundaries in terms of rows (not decoded bytes) and so an estimation
|
| 234 |
+
/// must be done to guess the average row size. Other formats like CSV and JSON
|
| 235 |
+
/// must make even more generalized guesses.
|
| 236 |
+
///
|
| 237 |
+
/// This is a best-effort guide. Some formats may need to read ahead further,
|
| 238 |
+
/// for example, if scanning a parquet file that has batches with 100MiB of data
|
| 239 |
+
/// then the actual readahead will be at least 100MiB
|
| 240 |
+
///
|
| 241 |
+
/// Set to 0 to disable readahead. When disabled, the scanner will read the
|
| 242 |
+
/// dataset one batch at a time
|
| 243 |
+
///
|
| 244 |
+
/// This limit applies across all fragments. If the limit is 32MiB and the
|
| 245 |
+
/// fragment readahead allows for 20 fragments to be read at once then the
|
| 246 |
+
/// total readahead will still be 32MiB and NOT 20 * 32MiB.
|
| 247 |
+
int32_t target_bytes_readahead = kDefaultBytesReadahead;
|
| 248 |
+
|
| 249 |
+
/// \brief Number of fragments to read ahead
|
| 250 |
+
///
|
| 251 |
+
/// Higher readahead will potentially lead to more efficient I/O but will lead
|
| 252 |
+
/// to the scan operation using more RAM. The default is fairly conservative
|
| 253 |
+
/// and designed for fast local disks (or slow local spinning disks which cannot
|
| 254 |
+
/// handle much parallelism anyways). When using a highly parallel remote filesystem
|
| 255 |
+
/// you will likely want to increase these values.
|
| 256 |
+
///
|
| 257 |
+
/// Set to 0 to disable fragment readahead. When disabled the dataset will be scanned
|
| 258 |
+
/// one fragment at a time.
|
| 259 |
+
int32_t fragment_readahead = kDefaultFragmentReadahead;
|
| 260 |
+
/// \brief Options specific to the file format
|
| 261 |
+
const FragmentScanOptions* format_options = NULLPTR;
|
| 262 |
+
|
| 263 |
+
/// \brief Utility method to get a selection representing all columns in a dataset
|
| 264 |
+
static std::vector<FieldPath> AllColumns(const Schema& dataset_schema);
|
| 265 |
+
|
| 266 |
+
/// \brief Utility method to add fields needed for the current filter
|
| 267 |
+
///
|
| 268 |
+
/// This method adds any fields that are needed by `filter` which are not already
|
| 269 |
+
/// included in the list of columns. Any new fields added will be added to the end
|
| 270 |
+
/// in no particular order.
|
| 271 |
+
static Status AddFieldsNeededForFilter(ScanV2Options* options);
|
| 272 |
+
};
|
| 273 |
+
|
| 274 |
+
/// \brief Describes a projection
|
| 275 |
+
struct ARROW_DS_EXPORT ProjectionDescr {
|
| 276 |
+
/// \brief The projection expression itself
|
| 277 |
+
/// This expression must be a call to make_struct
|
| 278 |
+
compute::Expression expression;
|
| 279 |
+
/// \brief The output schema of the projection.
|
| 280 |
+
|
| 281 |
+
/// This can be calculated from the input schema and the expression but it
|
| 282 |
+
/// is cached here for convenience.
|
| 283 |
+
std::shared_ptr<Schema> schema;
|
| 284 |
+
|
| 285 |
+
/// \brief Create a ProjectionDescr by binding an expression to the dataset schema
|
| 286 |
+
///
|
| 287 |
+
/// expression must return a struct type
|
| 288 |
+
static Result<ProjectionDescr> FromStructExpression(
|
| 289 |
+
const compute::Expression& expression, const Schema& dataset_schema);
|
| 290 |
+
|
| 291 |
+
/// \brief Create a ProjectionDescr from expressions/names for each field
|
| 292 |
+
static Result<ProjectionDescr> FromExpressions(std::vector<compute::Expression> exprs,
|
| 293 |
+
std::vector<std::string> names,
|
| 294 |
+
const Schema& dataset_schema);
|
| 295 |
+
|
| 296 |
+
/// \brief Create a default projection referencing fields in the dataset schema
|
| 297 |
+
static Result<ProjectionDescr> FromNames(std::vector<std::string> names,
|
| 298 |
+
const Schema& dataset_schema,
|
| 299 |
+
bool add_augmented_fields = true);
|
| 300 |
+
|
| 301 |
+
/// \brief Make a projection that projects every field in the dataset schema
|
| 302 |
+
static Result<ProjectionDescr> Default(const Schema& dataset_schema,
|
| 303 |
+
bool add_augmented_fields = true);
|
| 304 |
+
};
|
| 305 |
+
|
| 306 |
+
/// \brief Utility method to set the projection expression and schema
|
| 307 |
+
ARROW_DS_EXPORT void SetProjection(ScanOptions* options, ProjectionDescr projection);
|
| 308 |
+
|
| 309 |
+
/// \brief Combines a record batch with the fragment that the record batch originated
|
| 310 |
+
/// from
|
| 311 |
+
///
|
| 312 |
+
/// Knowing the source fragment can be useful for debugging & understanding loaded
|
| 313 |
+
/// data
|
| 314 |
+
struct TaggedRecordBatch {
|
| 315 |
+
std::shared_ptr<RecordBatch> record_batch;
|
| 316 |
+
std::shared_ptr<Fragment> fragment;
|
| 317 |
+
|
| 318 |
+
friend inline bool operator==(const TaggedRecordBatch& left,
|
| 319 |
+
const TaggedRecordBatch& right) {
|
| 320 |
+
return left.record_batch == right.record_batch && left.fragment == right.fragment;
|
| 321 |
+
}
|
| 322 |
+
};
|
| 323 |
+
|
| 324 |
+
using TaggedRecordBatchGenerator = std::function<Future<TaggedRecordBatch>()>;
|
| 325 |
+
using TaggedRecordBatchIterator = Iterator<TaggedRecordBatch>;
|
| 326 |
+
|
| 327 |
+
/// \brief Combines a tagged batch with positional information
|
| 328 |
+
///
|
| 329 |
+
/// This is returned when scanning batches in an unordered fashion. This information is
|
| 330 |
+
/// needed if you ever want to reassemble the batches in order
|
| 331 |
+
struct EnumeratedRecordBatch {
|
| 332 |
+
Enumerated<std::shared_ptr<RecordBatch>> record_batch;
|
| 333 |
+
Enumerated<std::shared_ptr<Fragment>> fragment;
|
| 334 |
+
|
| 335 |
+
friend inline bool operator==(const EnumeratedRecordBatch& left,
|
| 336 |
+
const EnumeratedRecordBatch& right) {
|
| 337 |
+
return left.record_batch == right.record_batch && left.fragment == right.fragment;
|
| 338 |
+
}
|
| 339 |
+
};
|
| 340 |
+
|
| 341 |
+
using EnumeratedRecordBatchGenerator = std::function<Future<EnumeratedRecordBatch>()>;
|
| 342 |
+
using EnumeratedRecordBatchIterator = Iterator<EnumeratedRecordBatch>;
|
| 343 |
+
|
| 344 |
+
/// @}
|
| 345 |
+
|
| 346 |
+
} // namespace dataset
|
| 347 |
+
|
| 348 |
+
template <>
|
| 349 |
+
struct IterationTraits<dataset::TaggedRecordBatch> {
|
| 350 |
+
static dataset::TaggedRecordBatch End() {
|
| 351 |
+
return dataset::TaggedRecordBatch{NULLPTR, NULLPTR};
|
| 352 |
+
}
|
| 353 |
+
static bool IsEnd(const dataset::TaggedRecordBatch& val) {
|
| 354 |
+
return val.record_batch == NULLPTR;
|
| 355 |
+
}
|
| 356 |
+
};
|
| 357 |
+
|
| 358 |
+
template <>
|
| 359 |
+
struct IterationTraits<dataset::EnumeratedRecordBatch> {
|
| 360 |
+
static dataset::EnumeratedRecordBatch End() {
|
| 361 |
+
return dataset::EnumeratedRecordBatch{
|
| 362 |
+
IterationEnd<Enumerated<std::shared_ptr<RecordBatch>>>(),
|
| 363 |
+
IterationEnd<Enumerated<std::shared_ptr<dataset::Fragment>>>()};
|
| 364 |
+
}
|
| 365 |
+
static bool IsEnd(const dataset::EnumeratedRecordBatch& val) {
|
| 366 |
+
return IsIterationEnd(val.fragment);
|
| 367 |
+
}
|
| 368 |
+
};
|
| 369 |
+
|
| 370 |
+
namespace dataset {
|
| 371 |
+
|
| 372 |
+
/// \defgroup dataset-scanning Scanning API
|
| 373 |
+
///
|
| 374 |
+
/// @{
|
| 375 |
+
|
| 376 |
+
/// \brief A scanner glues together several dataset classes to load in data.
|
| 377 |
+
/// The dataset contains a collection of fragments and partitioning rules.
|
| 378 |
+
///
|
| 379 |
+
/// The fragments identify independently loadable units of data (i.e. each fragment has
|
| 380 |
+
/// a potentially unique schema and possibly even format. It should be possible to read
|
| 381 |
+
/// fragments in parallel if desired).
|
| 382 |
+
///
|
| 383 |
+
/// The fragment's format contains the logic necessary to actually create a task to load
|
| 384 |
+
/// the fragment into memory. That task may or may not support parallel execution of
|
| 385 |
+
/// its own.
|
| 386 |
+
///
|
| 387 |
+
/// The scanner is then responsible for creating scan tasks from every fragment in the
|
| 388 |
+
/// dataset and (potentially) sequencing the loaded record batches together.
|
| 389 |
+
///
|
| 390 |
+
/// The scanner should not buffer the entire dataset in memory (unless asked) instead
|
| 391 |
+
/// yielding record batches as soon as they are ready to scan. Various readahead
|
| 392 |
+
/// properties control how much data is allowed to be scanned before pausing to let a
|
| 393 |
+
/// slow consumer catchup.
|
| 394 |
+
///
|
| 395 |
+
/// Today the scanner also handles projection & filtering although that may change in
|
| 396 |
+
/// the future.
|
| 397 |
+
class ARROW_DS_EXPORT Scanner {
|
| 398 |
+
public:
|
| 399 |
+
virtual ~Scanner() = default;
|
| 400 |
+
|
| 401 |
+
/// \brief Apply a visitor to each RecordBatch as it is scanned. If multiple threads
|
| 402 |
+
/// are used (via use_threads), the visitor will be invoked from those threads and is
|
| 403 |
+
/// responsible for any synchronization.
|
| 404 |
+
virtual Status Scan(std::function<Status(TaggedRecordBatch)> visitor) = 0;
|
| 405 |
+
/// \brief Convert a Scanner into a Table.
|
| 406 |
+
///
|
| 407 |
+
/// Use this convenience utility with care. This will serially materialize the
|
| 408 |
+
/// Scan result in memory before creating the Table.
|
| 409 |
+
virtual Result<std::shared_ptr<Table>> ToTable() = 0;
|
| 410 |
+
/// \brief Scan the dataset into a stream of record batches. Each batch is tagged
|
| 411 |
+
/// with the fragment it originated from. The batches will arrive in order. The
|
| 412 |
+
/// order of fragments is determined by the dataset.
|
| 413 |
+
///
|
| 414 |
+
/// Note: The scanner will perform some readahead but will avoid materializing too
|
| 415 |
+
/// much in memory (this is goverended by the readahead options and use_threads option).
|
| 416 |
+
/// If the readahead queue fills up then I/O will pause until the calling thread catches
|
| 417 |
+
/// up.
|
| 418 |
+
virtual Result<TaggedRecordBatchIterator> ScanBatches() = 0;
|
| 419 |
+
virtual Result<TaggedRecordBatchGenerator> ScanBatchesAsync() = 0;
|
| 420 |
+
virtual Result<TaggedRecordBatchGenerator> ScanBatchesAsync(
|
| 421 |
+
::arrow::internal::Executor* cpu_thread_pool) = 0;
|
| 422 |
+
/// \brief Scan the dataset into a stream of record batches. Unlike ScanBatches this
|
| 423 |
+
/// method may allow record batches to be returned out of order. This allows for more
|
| 424 |
+
/// efficient scanning: some fragments may be accessed more quickly than others (e.g.
|
| 425 |
+
/// may be cached in RAM or just happen to get scheduled earlier by the I/O)
|
| 426 |
+
///
|
| 427 |
+
/// To make up for the out-of-order iteration each batch is further tagged with
|
| 428 |
+
/// positional information.
|
| 429 |
+
virtual Result<EnumeratedRecordBatchIterator> ScanBatchesUnordered() = 0;
|
| 430 |
+
virtual Result<EnumeratedRecordBatchGenerator> ScanBatchesUnorderedAsync() = 0;
|
| 431 |
+
virtual Result<EnumeratedRecordBatchGenerator> ScanBatchesUnorderedAsync(
|
| 432 |
+
::arrow::internal::Executor* cpu_thread_pool) = 0;
|
| 433 |
+
/// \brief A convenience to synchronously load the given rows by index.
|
| 434 |
+
///
|
| 435 |
+
/// Will only consume as many batches as needed from ScanBatches().
|
| 436 |
+
virtual Result<std::shared_ptr<Table>> TakeRows(const Array& indices) = 0;
|
| 437 |
+
/// \brief Get the first N rows.
|
| 438 |
+
virtual Result<std::shared_ptr<Table>> Head(int64_t num_rows) = 0;
|
| 439 |
+
/// \brief Count rows matching a predicate.
|
| 440 |
+
///
|
| 441 |
+
/// This method will push down the predicate and compute the result based on fragment
|
| 442 |
+
/// metadata if possible.
|
| 443 |
+
virtual Result<int64_t> CountRows() = 0;
|
| 444 |
+
virtual Future<int64_t> CountRowsAsync() = 0;
|
| 445 |
+
/// \brief Convert the Scanner to a RecordBatchReader so it can be
|
| 446 |
+
/// easily used with APIs that expect a reader.
|
| 447 |
+
virtual Result<std::shared_ptr<RecordBatchReader>> ToRecordBatchReader() = 0;
|
| 448 |
+
|
| 449 |
+
/// \brief Get the options for this scan.
|
| 450 |
+
const std::shared_ptr<ScanOptions>& options() const { return scan_options_; }
|
| 451 |
+
/// \brief Get the dataset that this scanner will scan
|
| 452 |
+
virtual const std::shared_ptr<Dataset>& dataset() const = 0;
|
| 453 |
+
|
| 454 |
+
protected:
|
| 455 |
+
explicit Scanner(std::shared_ptr<ScanOptions> scan_options)
|
| 456 |
+
: scan_options_(std::move(scan_options)) {}
|
| 457 |
+
|
| 458 |
+
Result<EnumeratedRecordBatchIterator> AddPositioningToInOrderScan(
|
| 459 |
+
TaggedRecordBatchIterator scan);
|
| 460 |
+
|
| 461 |
+
const std::shared_ptr<ScanOptions> scan_options_;
|
| 462 |
+
};
|
| 463 |
+
|
| 464 |
+
/// \brief ScannerBuilder is a factory class to construct a Scanner. It is used
|
| 465 |
+
/// to pass information, notably a potential filter expression and a subset of
|
| 466 |
+
/// columns to materialize.
|
| 467 |
+
class ARROW_DS_EXPORT ScannerBuilder {
|
| 468 |
+
public:
|
| 469 |
+
explicit ScannerBuilder(std::shared_ptr<Dataset> dataset);
|
| 470 |
+
|
| 471 |
+
ScannerBuilder(std::shared_ptr<Dataset> dataset,
|
| 472 |
+
std::shared_ptr<ScanOptions> scan_options);
|
| 473 |
+
|
| 474 |
+
ScannerBuilder(std::shared_ptr<Schema> schema, std::shared_ptr<Fragment> fragment,
|
| 475 |
+
std::shared_ptr<ScanOptions> scan_options);
|
| 476 |
+
|
| 477 |
+
/// \brief Make a scanner from a record batch reader.
|
| 478 |
+
///
|
| 479 |
+
/// The resulting scanner can be scanned only once. This is intended
|
| 480 |
+
/// to support writing data from streaming sources or other sources
|
| 481 |
+
/// that can be iterated only once.
|
| 482 |
+
static std::shared_ptr<ScannerBuilder> FromRecordBatchReader(
|
| 483 |
+
std::shared_ptr<RecordBatchReader> reader);
|
| 484 |
+
|
| 485 |
+
/// \brief Set the subset of columns to materialize.
|
| 486 |
+
///
|
| 487 |
+
/// Columns which are not referenced may not be read from fragments.
|
| 488 |
+
///
|
| 489 |
+
/// \param[in] columns list of columns to project. Order and duplicates will
|
| 490 |
+
/// be preserved.
|
| 491 |
+
///
|
| 492 |
+
/// \return Failure if any column name does not exists in the dataset's
|
| 493 |
+
/// Schema.
|
| 494 |
+
Status Project(std::vector<std::string> columns);
|
| 495 |
+
|
| 496 |
+
/// \brief Set expressions which will be evaluated to produce the materialized
|
| 497 |
+
/// columns.
|
| 498 |
+
///
|
| 499 |
+
/// Columns which are not referenced may not be read from fragments.
|
| 500 |
+
///
|
| 501 |
+
/// \param[in] exprs expressions to evaluate to produce columns.
|
| 502 |
+
/// \param[in] names list of names for the resulting columns.
|
| 503 |
+
///
|
| 504 |
+
/// \return Failure if any referenced column does not exists in the dataset's
|
| 505 |
+
/// Schema.
|
| 506 |
+
Status Project(std::vector<compute::Expression> exprs, std::vector<std::string> names);
|
| 507 |
+
|
| 508 |
+
/// \brief Set the filter expression to return only rows matching the filter.
|
| 509 |
+
///
|
| 510 |
+
/// The predicate will be passed down to Sources and corresponding
|
| 511 |
+
/// Fragments to exploit predicate pushdown if possible using
|
| 512 |
+
/// partition information or Fragment internal metadata, e.g. Parquet statistics.
|
| 513 |
+
/// Columns which are not referenced may not be read from fragments.
|
| 514 |
+
///
|
| 515 |
+
/// \param[in] filter expression to filter rows with.
|
| 516 |
+
///
|
| 517 |
+
/// \return Failure if any referenced columns does not exist in the dataset's
|
| 518 |
+
/// Schema.
|
| 519 |
+
Status Filter(const compute::Expression& filter);
|
| 520 |
+
|
| 521 |
+
/// \brief Indicate if the Scanner should make use of the available
|
| 522 |
+
/// ThreadPool found in ScanOptions;
|
| 523 |
+
Status UseThreads(bool use_threads = true);
|
| 524 |
+
|
| 525 |
+
/// \brief Indicate if metadata should be cached when scanning
|
| 526 |
+
///
|
| 527 |
+
/// Fragments may typically cache metadata to speed up repeated accesses.
|
| 528 |
+
/// However, in use cases where a single scan is done, or if memory use
|
| 529 |
+
/// is more critical than CPU time, setting this option to false can
|
| 530 |
+
/// lessen memory use.
|
| 531 |
+
Status CacheMetadata(bool cache_metadata = true);
|
| 532 |
+
|
| 533 |
+
/// \brief Set the maximum number of rows per RecordBatch.
|
| 534 |
+
///
|
| 535 |
+
/// \param[in] batch_size the maximum number of rows.
|
| 536 |
+
/// \returns An error if the number for batch is not greater than 0.
|
| 537 |
+
///
|
| 538 |
+
/// This option provides a control limiting the memory owned by any RecordBatch.
|
| 539 |
+
Status BatchSize(int64_t batch_size);
|
| 540 |
+
|
| 541 |
+
/// \brief Set the number of batches to read ahead within a fragment.
|
| 542 |
+
///
|
| 543 |
+
/// \param[in] batch_readahead How many batches to read ahead within a fragment
|
| 544 |
+
/// \returns an error if this number is less than 0.
|
| 545 |
+
///
|
| 546 |
+
/// This option provides a control on the RAM vs I/O tradeoff.
|
| 547 |
+
/// It might not be supported by all file formats, in which case it will
|
| 548 |
+
/// simply be ignored.
|
| 549 |
+
Status BatchReadahead(int32_t batch_readahead);
|
| 550 |
+
|
| 551 |
+
/// \brief Set the number of fragments to read ahead
|
| 552 |
+
///
|
| 553 |
+
/// \param[in] fragment_readahead How many fragments to read ahead
|
| 554 |
+
/// \returns an error if this number is less than 0.
|
| 555 |
+
///
|
| 556 |
+
/// This option provides a control on the RAM vs I/O tradeoff.
|
| 557 |
+
Status FragmentReadahead(int32_t fragment_readahead);
|
| 558 |
+
|
| 559 |
+
/// \brief Set the pool from which materialized and scanned arrays will be allocated.
|
| 560 |
+
Status Pool(MemoryPool* pool);
|
| 561 |
+
|
| 562 |
+
/// \brief Set fragment-specific scan options.
|
| 563 |
+
Status FragmentScanOptions(std::shared_ptr<FragmentScanOptions> fragment_scan_options);
|
| 564 |
+
|
| 565 |
+
/// \brief Override default backpressure configuration
|
| 566 |
+
Status Backpressure(acero::BackpressureOptions backpressure);
|
| 567 |
+
|
| 568 |
+
/// \brief Return the current scan options for the builder.
|
| 569 |
+
Result<std::shared_ptr<ScanOptions>> GetScanOptions();
|
| 570 |
+
|
| 571 |
+
/// \brief Return the constructed now-immutable Scanner object
|
| 572 |
+
Result<std::shared_ptr<Scanner>> Finish();
|
| 573 |
+
|
| 574 |
+
const std::shared_ptr<Schema>& schema() const;
|
| 575 |
+
const std::shared_ptr<Schema>& projected_schema() const;
|
| 576 |
+
|
| 577 |
+
private:
|
| 578 |
+
std::shared_ptr<Dataset> dataset_;
|
| 579 |
+
std::shared_ptr<ScanOptions> scan_options_ = std::make_shared<ScanOptions>();
|
| 580 |
+
};
|
| 581 |
+
|
| 582 |
+
/// \brief Construct a source ExecNode which yields batches from a dataset scan.
|
| 583 |
+
///
|
| 584 |
+
/// Does not construct associated filter or project nodes.
|
| 585 |
+
///
|
| 586 |
+
/// Batches are yielded sequentially, like single-threaded,
|
| 587 |
+
/// when require_sequenced_output=true.
|
| 588 |
+
///
|
| 589 |
+
/// Yielded batches will be augmented with fragment/batch indices when
|
| 590 |
+
/// implicit_ordering=true to enable stable ordering for simple ExecPlans.
|
| 591 |
+
class ARROW_DS_EXPORT ScanNodeOptions : public acero::ExecNodeOptions {
|
| 592 |
+
public:
|
| 593 |
+
explicit ScanNodeOptions(std::shared_ptr<Dataset> dataset,
|
| 594 |
+
std::shared_ptr<ScanOptions> scan_options,
|
| 595 |
+
bool require_sequenced_output = false,
|
| 596 |
+
bool implicit_ordering = false)
|
| 597 |
+
: dataset(std::move(dataset)),
|
| 598 |
+
scan_options(std::move(scan_options)),
|
| 599 |
+
require_sequenced_output(require_sequenced_output),
|
| 600 |
+
implicit_ordering(implicit_ordering) {}
|
| 601 |
+
|
| 602 |
+
std::shared_ptr<Dataset> dataset;
|
| 603 |
+
std::shared_ptr<ScanOptions> scan_options;
|
| 604 |
+
bool require_sequenced_output;
|
| 605 |
+
bool implicit_ordering;
|
| 606 |
+
};
|
| 607 |
+
|
| 608 |
+
/// @}
|
| 609 |
+
|
| 610 |
+
namespace internal {
|
| 611 |
+
ARROW_DS_EXPORT void InitializeScanner(arrow::acero::ExecFactoryRegistry* registry);
|
| 612 |
+
ARROW_DS_EXPORT void InitializeScannerV2(arrow::acero::ExecFactoryRegistry* registry);
|
| 613 |
+
} // namespace internal
|
| 614 |
+
} // namespace dataset
|
| 615 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/dataset/type_fwd.h
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// This API is EXPERIMENTAL.
|
| 19 |
+
|
| 20 |
+
#pragma once
|
| 21 |
+
|
| 22 |
+
#include <memory>
|
| 23 |
+
#include <vector>
|
| 24 |
+
|
| 25 |
+
#include "arrow/compute/type_fwd.h" // IWYU pragma: export
|
| 26 |
+
#include "arrow/dataset/visibility.h"
|
| 27 |
+
#include "arrow/filesystem/type_fwd.h" // IWYU pragma: export
|
| 28 |
+
#include "arrow/type_fwd.h" // IWYU pragma: export
|
| 29 |
+
|
| 30 |
+
namespace arrow {
|
| 31 |
+
namespace dataset {
|
| 32 |
+
|
| 33 |
+
class Dataset;
|
| 34 |
+
class DatasetFactory;
|
| 35 |
+
using DatasetVector = std::vector<std::shared_ptr<Dataset>>;
|
| 36 |
+
|
| 37 |
+
class UnionDataset;
|
| 38 |
+
class UnionDatasetFactory;
|
| 39 |
+
|
| 40 |
+
class Fragment;
|
| 41 |
+
using FragmentIterator = Iterator<std::shared_ptr<Fragment>>;
|
| 42 |
+
using FragmentVector = std::vector<std::shared_ptr<Fragment>>;
|
| 43 |
+
|
| 44 |
+
class FragmentScanOptions;
|
| 45 |
+
|
| 46 |
+
class FileSource;
|
| 47 |
+
class FileFormat;
|
| 48 |
+
class FileFragment;
|
| 49 |
+
class FileWriter;
|
| 50 |
+
class FileWriteOptions;
|
| 51 |
+
class FileSystemDataset;
|
| 52 |
+
class FileSystemDatasetFactory;
|
| 53 |
+
struct FileSystemDatasetWriteOptions;
|
| 54 |
+
class WriteNodeOptions;
|
| 55 |
+
|
| 56 |
+
/// \brief Controls what happens if files exist in an output directory during a dataset
|
| 57 |
+
/// write
|
| 58 |
+
enum class ExistingDataBehavior : int8_t {
|
| 59 |
+
/// Deletes all files in a directory the first time that directory is encountered
|
| 60 |
+
kDeleteMatchingPartitions,
|
| 61 |
+
/// Ignores existing files, overwriting any that happen to have the same name as an
|
| 62 |
+
/// output file
|
| 63 |
+
kOverwriteOrIgnore,
|
| 64 |
+
/// Returns an error if there are any files or subdirectories in the output directory
|
| 65 |
+
kError,
|
| 66 |
+
};
|
| 67 |
+
|
| 68 |
+
class InMemoryDataset;
|
| 69 |
+
|
| 70 |
+
class CsvFileFormat;
|
| 71 |
+
class CsvFileWriter;
|
| 72 |
+
class CsvFileWriteOptions;
|
| 73 |
+
struct CsvFragmentScanOptions;
|
| 74 |
+
|
| 75 |
+
class JsonFileFormat;
|
| 76 |
+
class JsonFileWriter;
|
| 77 |
+
class JsonFileWriteOptions;
|
| 78 |
+
struct JsonFragmentScanOptions;
|
| 79 |
+
|
| 80 |
+
class IpcFileFormat;
|
| 81 |
+
class IpcFileWriter;
|
| 82 |
+
class IpcFileWriteOptions;
|
| 83 |
+
class IpcFragmentScanOptions;
|
| 84 |
+
|
| 85 |
+
class ParquetFileFormat;
|
| 86 |
+
class ParquetFileFragment;
|
| 87 |
+
class ParquetFragmentScanOptions;
|
| 88 |
+
class ParquetFileWriter;
|
| 89 |
+
class ParquetFileWriteOptions;
|
| 90 |
+
|
| 91 |
+
class Partitioning;
|
| 92 |
+
class PartitioningFactory;
|
| 93 |
+
class PartitioningOrFactory;
|
| 94 |
+
struct KeyValuePartitioningOptions;
|
| 95 |
+
class DirectoryPartitioning;
|
| 96 |
+
class HivePartitioning;
|
| 97 |
+
struct HivePartitioningOptions;
|
| 98 |
+
class FilenamePartitioning;
|
| 99 |
+
struct FilenamePartitioningOptions;
|
| 100 |
+
|
| 101 |
+
class ScanNodeOptions;
|
| 102 |
+
struct ScanOptions;
|
| 103 |
+
|
| 104 |
+
class Scanner;
|
| 105 |
+
|
| 106 |
+
class ScannerBuilder;
|
| 107 |
+
|
| 108 |
+
class ScanTask;
|
| 109 |
+
using ScanTaskVector = std::vector<std::shared_ptr<ScanTask>>;
|
| 110 |
+
using ScanTaskIterator = Iterator<std::shared_ptr<ScanTask>>;
|
| 111 |
+
|
| 112 |
+
} // namespace dataset
|
| 113 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/dataset/visibility.h
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// This API is EXPERIMENTAL.
|
| 19 |
+
|
| 20 |
+
#pragma once
|
| 21 |
+
|
| 22 |
+
#if defined(_WIN32) || defined(__CYGWIN__)
|
| 23 |
+
# if defined(_MSC_VER)
|
| 24 |
+
# pragma warning(push)
|
| 25 |
+
# pragma warning(disable : 4251)
|
| 26 |
+
# else
|
| 27 |
+
# pragma GCC diagnostic ignored "-Wattributes"
|
| 28 |
+
# endif
|
| 29 |
+
|
| 30 |
+
# ifdef ARROW_DS_STATIC
|
| 31 |
+
# define ARROW_DS_EXPORT
|
| 32 |
+
# elif defined(ARROW_DS_EXPORTING)
|
| 33 |
+
# define ARROW_DS_EXPORT __declspec(dllexport)
|
| 34 |
+
# else
|
| 35 |
+
# define ARROW_DS_EXPORT __declspec(dllimport)
|
| 36 |
+
# endif
|
| 37 |
+
|
| 38 |
+
# define ARROW_DS_NO_EXPORT
|
| 39 |
+
#else // Not Windows
|
| 40 |
+
# ifndef ARROW_DS_EXPORT
|
| 41 |
+
# define ARROW_DS_EXPORT __attribute__((visibility("default")))
|
| 42 |
+
# endif
|
| 43 |
+
# ifndef ARROW_DS_NO_EXPORT
|
| 44 |
+
# define ARROW_DS_NO_EXPORT __attribute__((visibility("hidden")))
|
| 45 |
+
# endif
|
| 46 |
+
#endif // Non-Windows
|
| 47 |
+
|
| 48 |
+
#if defined(_MSC_VER)
|
| 49 |
+
# pragma warning(pop)
|
| 50 |
+
#endif
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/engine/substrait/options.h
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// This API is EXPERIMENTAL.
|
| 19 |
+
|
| 20 |
+
#pragma once
|
| 21 |
+
|
| 22 |
+
#include <functional>
|
| 23 |
+
#include <string>
|
| 24 |
+
#include <vector>
|
| 25 |
+
|
| 26 |
+
#include "arrow/acero/exec_plan.h"
|
| 27 |
+
#include "arrow/acero/options.h"
|
| 28 |
+
#include "arrow/compute/type_fwd.h"
|
| 29 |
+
#include "arrow/engine/substrait/type_fwd.h"
|
| 30 |
+
#include "arrow/engine/substrait/visibility.h"
|
| 31 |
+
#include "arrow/type_fwd.h"
|
| 32 |
+
|
| 33 |
+
namespace arrow {
|
| 34 |
+
namespace engine {
|
| 35 |
+
|
| 36 |
+
/// How strictly to adhere to the input structure when converting between Substrait and
|
| 37 |
+
/// Acero representations of a plan. This allows the user to trade conversion accuracy
|
| 38 |
+
/// for performance and lenience.
|
| 39 |
+
enum class ARROW_ENGINE_EXPORT ConversionStrictness {
|
| 40 |
+
/// When a primitive is used at the input that doesn't have an exact match at the
|
| 41 |
+
/// output, reject the conversion. This effectively asserts that there is no (known)
|
| 42 |
+
/// information loss in the conversion, and that plans should either round-trip back and
|
| 43 |
+
/// forth exactly or not at all. This option is primarily intended for testing and
|
| 44 |
+
/// debugging.
|
| 45 |
+
EXACT_ROUNDTRIP,
|
| 46 |
+
|
| 47 |
+
/// When a primitive is used at the input that doesn't have an exact match at the
|
| 48 |
+
/// output, attempt to model it with some collection of primitives at the output. This
|
| 49 |
+
/// means that even if the incoming plan is completely optimal by some metric, the
|
| 50 |
+
/// returned plan is fairly likely to not be optimal anymore, and round-trips back and
|
| 51 |
+
/// forth may make the plan increasingly suboptimal. However, every primitive at the
|
| 52 |
+
/// output can be (manually) traced back to exactly one primitive at the input, which
|
| 53 |
+
/// may be useful when debugging.
|
| 54 |
+
PRESERVE_STRUCTURE,
|
| 55 |
+
|
| 56 |
+
/// Behaves like PRESERVE_STRUCTURE, but prefers performance over structural accuracy.
|
| 57 |
+
/// Basic optimizations *may* be applied, in order to attempt to not regress in terms of
|
| 58 |
+
/// plan performance: if the incoming plan was already aggressively optimized, the goal
|
| 59 |
+
/// is for the output plan to not be less performant. In practical use cases, this is
|
| 60 |
+
/// probably the option you want.
|
| 61 |
+
///
|
| 62 |
+
/// Note that no guarantees are made on top of PRESERVE_STRUCTURE. Past and future
|
| 63 |
+
/// versions of Arrow may even ignore this option entirely and treat it exactly like
|
| 64 |
+
/// PRESERVE_STRUCTURE.
|
| 65 |
+
BEST_EFFORT,
|
| 66 |
+
};
|
| 67 |
+
|
| 68 |
+
using NamedTableProvider = std::function<Result<acero::Declaration>(
|
| 69 |
+
const std::vector<std::string>&, const Schema&)>;
|
| 70 |
+
static NamedTableProvider kDefaultNamedTableProvider;
|
| 71 |
+
|
| 72 |
+
using NamedTapProvider = std::function<Result<acero::Declaration>(
|
| 73 |
+
const std::string&, std::vector<acero::Declaration::Input>, const std::string&,
|
| 74 |
+
std::shared_ptr<Schema>)>;
|
| 75 |
+
|
| 76 |
+
class ARROW_ENGINE_EXPORT ExtensionDetails {
|
| 77 |
+
public:
|
| 78 |
+
virtual ~ExtensionDetails() = default;
|
| 79 |
+
};
|
| 80 |
+
|
| 81 |
+
class ARROW_ENGINE_EXPORT ExtensionProvider {
|
| 82 |
+
public:
|
| 83 |
+
virtual ~ExtensionProvider() = default;
|
| 84 |
+
virtual Result<DeclarationInfo> MakeRel(const ConversionOptions& conv_opts,
|
| 85 |
+
const std::vector<DeclarationInfo>& inputs,
|
| 86 |
+
const ExtensionDetails& ext_details,
|
| 87 |
+
const ExtensionSet& ext_set) = 0;
|
| 88 |
+
};
|
| 89 |
+
|
| 90 |
+
/// \brief Get the default extension provider
|
| 91 |
+
ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionProvider> default_extension_provider();
|
| 92 |
+
/// \brief Set the default extension provider
|
| 93 |
+
///
|
| 94 |
+
/// \param[in] provider the new provider to be set as default
|
| 95 |
+
ARROW_ENGINE_EXPORT void set_default_extension_provider(
|
| 96 |
+
const std::shared_ptr<ExtensionProvider>& provider);
|
| 97 |
+
|
| 98 |
+
ARROW_ENGINE_EXPORT NamedTapProvider default_named_tap_provider();
|
| 99 |
+
|
| 100 |
+
ARROW_ENGINE_EXPORT void set_default_named_tap_provider(NamedTapProvider provider);
|
| 101 |
+
|
| 102 |
+
/// Options that control the conversion between Substrait and Acero representations of a
|
| 103 |
+
/// plan.
|
| 104 |
+
struct ARROW_ENGINE_EXPORT ConversionOptions {
|
| 105 |
+
ConversionOptions()
|
| 106 |
+
: strictness(ConversionStrictness::BEST_EFFORT),
|
| 107 |
+
named_table_provider(kDefaultNamedTableProvider),
|
| 108 |
+
named_tap_provider(default_named_tap_provider()),
|
| 109 |
+
extension_provider(default_extension_provider()),
|
| 110 |
+
allow_arrow_extensions(false) {}
|
| 111 |
+
|
| 112 |
+
/// \brief How strictly the converter should adhere to the structure of the input.
|
| 113 |
+
ConversionStrictness strictness;
|
| 114 |
+
/// \brief A custom strategy to be used for providing named tables
|
| 115 |
+
///
|
| 116 |
+
/// The default behavior will return an invalid status if the plan has any
|
| 117 |
+
/// named table relations.
|
| 118 |
+
NamedTableProvider named_table_provider;
|
| 119 |
+
/// \brief A custom strategy to be used for obtaining a tap declaration
|
| 120 |
+
///
|
| 121 |
+
/// The default provider returns an error
|
| 122 |
+
NamedTapProvider named_tap_provider;
|
| 123 |
+
/// \brief A custom strategy to be used for providing relation infos.
|
| 124 |
+
///
|
| 125 |
+
/// The default behavior will provide for relations known to Arrow.
|
| 126 |
+
std::shared_ptr<ExtensionProvider> extension_provider;
|
| 127 |
+
/// \brief If true then Arrow-specific types and functions will be allowed
|
| 128 |
+
///
|
| 129 |
+
/// Set to false to create plans that are more likely to be compatible with non-Arrow
|
| 130 |
+
/// engines
|
| 131 |
+
bool allow_arrow_extensions;
|
| 132 |
+
};
|
| 133 |
+
|
| 134 |
+
} // namespace engine
|
| 135 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/engine/substrait/relation.h
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 <memory>
|
| 21 |
+
|
| 22 |
+
#include "arrow/acero/exec_plan.h"
|
| 23 |
+
#include "arrow/compute/api_aggregate.h"
|
| 24 |
+
#include "arrow/engine/substrait/visibility.h"
|
| 25 |
+
#include "arrow/type_fwd.h"
|
| 26 |
+
|
| 27 |
+
namespace arrow {
|
| 28 |
+
namespace engine {
|
| 29 |
+
|
| 30 |
+
/// Execution information resulting from converting a Substrait relation.
|
| 31 |
+
struct ARROW_ENGINE_EXPORT DeclarationInfo {
|
| 32 |
+
/// The compute declaration produced thus far.
|
| 33 |
+
acero::Declaration declaration;
|
| 34 |
+
|
| 35 |
+
std::shared_ptr<Schema> output_schema;
|
| 36 |
+
};
|
| 37 |
+
|
| 38 |
+
/// Information resulting from converting a Substrait plan
|
| 39 |
+
struct ARROW_ENGINE_EXPORT PlanInfo {
|
| 40 |
+
/// The root declaration.
|
| 41 |
+
///
|
| 42 |
+
/// Only plans containing a single top-level relation are supported and so this will
|
| 43 |
+
/// represent that relation.
|
| 44 |
+
///
|
| 45 |
+
/// This should technically be a RelRoot but some producers use a simple Rel here and so
|
| 46 |
+
/// Acero currently supports that case.
|
| 47 |
+
DeclarationInfo root;
|
| 48 |
+
/// The names of the output fields
|
| 49 |
+
///
|
| 50 |
+
/// If `root` was created from a simple Rel then this will be empty
|
| 51 |
+
std::vector<std::string> names;
|
| 52 |
+
};
|
| 53 |
+
|
| 54 |
+
/// An expression whose output has a name
|
| 55 |
+
struct ARROW_ENGINE_EXPORT NamedExpression {
|
| 56 |
+
/// An expression
|
| 57 |
+
compute::Expression expression;
|
| 58 |
+
// An optional name to assign to the output, may be the empty string
|
| 59 |
+
std::string name;
|
| 60 |
+
};
|
| 61 |
+
|
| 62 |
+
/// A collection of expressions bound to a common schema
|
| 63 |
+
struct ARROW_ENGINE_EXPORT BoundExpressions {
|
| 64 |
+
/// The expressions
|
| 65 |
+
std::vector<NamedExpression> named_expressions;
|
| 66 |
+
/// The schema that all the expressions are bound to
|
| 67 |
+
std::shared_ptr<Schema> schema;
|
| 68 |
+
};
|
| 69 |
+
|
| 70 |
+
} // namespace engine
|
| 71 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/engine/substrait/serde.h
ADDED
|
@@ -0,0 +1,331 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// This API is EXPERIMENTAL.
|
| 19 |
+
|
| 20 |
+
#pragma once
|
| 21 |
+
|
| 22 |
+
#include <functional>
|
| 23 |
+
#include <memory>
|
| 24 |
+
#include <string>
|
| 25 |
+
#include <string_view>
|
| 26 |
+
#include <vector>
|
| 27 |
+
|
| 28 |
+
#include "arrow/compute/type_fwd.h"
|
| 29 |
+
#include "arrow/dataset/type_fwd.h"
|
| 30 |
+
#include "arrow/engine/substrait/options.h"
|
| 31 |
+
#include "arrow/engine/substrait/relation.h"
|
| 32 |
+
#include "arrow/engine/substrait/type_fwd.h"
|
| 33 |
+
#include "arrow/engine/substrait/visibility.h"
|
| 34 |
+
#include "arrow/result.h"
|
| 35 |
+
#include "arrow/status.h"
|
| 36 |
+
#include "arrow/type_fwd.h"
|
| 37 |
+
#include "arrow/util/macros.h"
|
| 38 |
+
|
| 39 |
+
namespace arrow {
|
| 40 |
+
namespace engine {
|
| 41 |
+
|
| 42 |
+
/// \brief Serialize an Acero Plan to a binary protobuf Substrait message
|
| 43 |
+
///
|
| 44 |
+
/// \param[in] declaration the Acero declaration to serialize.
|
| 45 |
+
/// This declaration is the sink relation of the Acero plan.
|
| 46 |
+
/// \param[in,out] ext_set the extension mapping to use; may be updated to add
|
| 47 |
+
/// \param[in] conversion_options options to control how the conversion is done
|
| 48 |
+
///
|
| 49 |
+
/// \return a buffer containing the protobuf serialization of the Acero relation
|
| 50 |
+
ARROW_ENGINE_EXPORT
|
| 51 |
+
Result<std::shared_ptr<Buffer>> SerializePlan(
|
| 52 |
+
const acero::Declaration& declaration, ExtensionSet* ext_set,
|
| 53 |
+
const ConversionOptions& conversion_options = {});
|
| 54 |
+
|
| 55 |
+
/// \brief Serialize expressions to a Substrait message
|
| 56 |
+
///
|
| 57 |
+
/// \param[in] bound_expressions the expressions to serialize.
|
| 58 |
+
/// \param[in] conversion_options options to control how the conversion is done
|
| 59 |
+
/// \param[in,out] ext_set the extension mapping to use, optional, only needed
|
| 60 |
+
/// if you want to control the value of function anchors
|
| 61 |
+
/// to mirror a previous serialization / deserialization.
|
| 62 |
+
/// Will be updated if new functions are encountered
|
| 63 |
+
ARROW_ENGINE_EXPORT
|
| 64 |
+
Result<std::shared_ptr<Buffer>> SerializeExpressions(
|
| 65 |
+
const BoundExpressions& bound_expressions,
|
| 66 |
+
const ConversionOptions& conversion_options = {}, ExtensionSet* ext_set = NULLPTR);
|
| 67 |
+
|
| 68 |
+
/// Factory function type for generating the node that consumes the batches produced by
|
| 69 |
+
/// each toplevel Substrait relation when deserializing a Substrait Plan.
|
| 70 |
+
using ConsumerFactory = std::function<std::shared_ptr<acero::SinkNodeConsumer>()>;
|
| 71 |
+
|
| 72 |
+
/// \brief Deserializes a Substrait Plan message to a list of ExecNode declarations
|
| 73 |
+
///
|
| 74 |
+
/// The output of each top-level Substrait relation will be sent to a caller supplied
|
| 75 |
+
/// consumer function provided by consumer_factory
|
| 76 |
+
///
|
| 77 |
+
/// \param[in] buf a buffer containing the protobuf serialization of a Substrait Plan
|
| 78 |
+
/// message
|
| 79 |
+
/// \param[in] consumer_factory factory function for generating the node that consumes
|
| 80 |
+
/// the batches produced by each toplevel Substrait relation
|
| 81 |
+
/// \param[in] registry an extension-id-registry to use, or null for the default one.
|
| 82 |
+
/// \param[out] ext_set_out if non-null, the extension mapping used by the Substrait
|
| 83 |
+
/// Plan is returned here.
|
| 84 |
+
/// \param[in] conversion_options options to control how the conversion is to be done.
|
| 85 |
+
/// \return a vector of ExecNode declarations, one for each toplevel relation in the
|
| 86 |
+
/// Substrait Plan
|
| 87 |
+
ARROW_ENGINE_EXPORT Result<std::vector<acero::Declaration>> DeserializePlans(
|
| 88 |
+
const Buffer& buf, const ConsumerFactory& consumer_factory,
|
| 89 |
+
const ExtensionIdRegistry* registry = NULLPTR, ExtensionSet* ext_set_out = NULLPTR,
|
| 90 |
+
const ConversionOptions& conversion_options = {});
|
| 91 |
+
|
| 92 |
+
/// \brief Deserializes a single-relation Substrait Plan message to an execution plan
|
| 93 |
+
///
|
| 94 |
+
/// The output of each top-level Substrait relation will be sent to a caller supplied
|
| 95 |
+
/// consumer function provided by consumer_factory
|
| 96 |
+
///
|
| 97 |
+
/// \param[in] buf a buffer containing the protobuf serialization of a Substrait Plan
|
| 98 |
+
/// message
|
| 99 |
+
/// \param[in] consumer node that consumes the batches produced by each toplevel Substrait
|
| 100 |
+
/// relation
|
| 101 |
+
/// \param[in] registry an extension-id-registry to use, or null for the default one.
|
| 102 |
+
/// \param[out] ext_set_out if non-null, the extension mapping used by the Substrait
|
| 103 |
+
/// \param[in] conversion_options options to control how the conversion is to be done.
|
| 104 |
+
/// Plan is returned here.
|
| 105 |
+
/// \return an ExecPlan for the Substrait Plan
|
| 106 |
+
ARROW_ENGINE_EXPORT Result<std::shared_ptr<acero::ExecPlan>> DeserializePlan(
|
| 107 |
+
const Buffer& buf, const std::shared_ptr<acero::SinkNodeConsumer>& consumer,
|
| 108 |
+
const ExtensionIdRegistry* registry = NULLPTR, ExtensionSet* ext_set_out = NULLPTR,
|
| 109 |
+
const ConversionOptions& conversion_options = {});
|
| 110 |
+
|
| 111 |
+
/// Factory function type for generating the write options of a node consuming the batches
|
| 112 |
+
/// produced by each toplevel Substrait relation when deserializing a Substrait Plan.
|
| 113 |
+
using WriteOptionsFactory = std::function<std::shared_ptr<dataset::WriteNodeOptions>()>;
|
| 114 |
+
|
| 115 |
+
/// \brief Deserializes a Substrait Plan message to a list of ExecNode declarations
|
| 116 |
+
///
|
| 117 |
+
/// The output of each top-level Substrait relation will be written to a filesystem.
|
| 118 |
+
/// `write_options_factory` can be used to control write behavior.
|
| 119 |
+
///
|
| 120 |
+
/// \param[in] buf a buffer containing the protobuf serialization of a Substrait Plan
|
| 121 |
+
/// message
|
| 122 |
+
/// \param[in] write_options_factory factory function for generating the write options of
|
| 123 |
+
/// a node consuming the batches produced by each toplevel Substrait relation
|
| 124 |
+
/// \param[in] registry an extension-id-registry to use, or null for the default one.
|
| 125 |
+
/// \param[out] ext_set_out if non-null, the extension mapping used by the Substrait
|
| 126 |
+
/// Plan is returned here.
|
| 127 |
+
/// \param[in] conversion_options options to control how the conversion is to be done.
|
| 128 |
+
/// \return a vector of ExecNode declarations, one for each toplevel relation in the
|
| 129 |
+
/// Substrait Plan
|
| 130 |
+
ARROW_ENGINE_EXPORT Result<std::vector<acero::Declaration>> DeserializePlans(
|
| 131 |
+
const Buffer& buf, const WriteOptionsFactory& write_options_factory,
|
| 132 |
+
const ExtensionIdRegistry* registry = NULLPTR, ExtensionSet* ext_set_out = NULLPTR,
|
| 133 |
+
const ConversionOptions& conversion_options = {});
|
| 134 |
+
|
| 135 |
+
/// \brief Deserializes a single-relation Substrait Plan message to an execution plan
|
| 136 |
+
///
|
| 137 |
+
/// The output of the single Substrait relation will be written to a filesystem.
|
| 138 |
+
/// `write_options_factory` can be used to control write behavior.
|
| 139 |
+
///
|
| 140 |
+
/// \param[in] buf a buffer containing the protobuf serialization of a Substrait Plan
|
| 141 |
+
/// message
|
| 142 |
+
/// \param[in] write_options write options of a node consuming the batches produced by
|
| 143 |
+
/// each toplevel Substrait relation
|
| 144 |
+
/// \param[in] registry an extension-id-registry to use, or null for the default one.
|
| 145 |
+
/// \param[out] ext_set_out if non-null, the extension mapping used by the Substrait
|
| 146 |
+
/// Plan is returned here.
|
| 147 |
+
/// \param[in] conversion_options options to control how the conversion is to be done.
|
| 148 |
+
/// \return an ExecPlan for the Substrait Plan
|
| 149 |
+
ARROW_ENGINE_EXPORT Result<std::shared_ptr<acero::ExecPlan>> DeserializePlan(
|
| 150 |
+
const Buffer& buf, const std::shared_ptr<dataset::WriteNodeOptions>& write_options,
|
| 151 |
+
const ExtensionIdRegistry* registry = NULLPTR, ExtensionSet* ext_set_out = NULLPTR,
|
| 152 |
+
const ConversionOptions& conversion_options = {});
|
| 153 |
+
|
| 154 |
+
/// \brief Deserializes a Substrait Plan message to a Declaration
|
| 155 |
+
///
|
| 156 |
+
/// The plan will not contain any sink nodes and will be suitable for use in any
|
| 157 |
+
/// of the arrow::compute::DeclarationToXyz methods.
|
| 158 |
+
///
|
| 159 |
+
/// \param[in] buf a buffer containing the protobuf serialization of a Substrait Plan
|
| 160 |
+
/// message
|
| 161 |
+
/// \param[in] registry an extension-id-registry to use, or null for the default one.
|
| 162 |
+
/// \param[out] ext_set_out if non-null, the extension mapping used by the Substrait
|
| 163 |
+
/// Plan is returned here.
|
| 164 |
+
/// \param[in] conversion_options options to control how the conversion is to be done.
|
| 165 |
+
/// \return A declaration representing the Substrait plan
|
| 166 |
+
ARROW_ENGINE_EXPORT Result<PlanInfo> DeserializePlan(
|
| 167 |
+
const Buffer& buf, const ExtensionIdRegistry* registry = NULLPTR,
|
| 168 |
+
ExtensionSet* ext_set_out = NULLPTR,
|
| 169 |
+
const ConversionOptions& conversion_options = {});
|
| 170 |
+
|
| 171 |
+
/// \brief Deserialize a Substrait ExtendedExpression message to the corresponding Arrow
|
| 172 |
+
/// type
|
| 173 |
+
///
|
| 174 |
+
/// \param[in] buf a buffer containing the protobuf serialization of a collection of bound
|
| 175 |
+
/// expressions
|
| 176 |
+
/// \param[in] registry an extension-id-registry to use, or null for the default one
|
| 177 |
+
/// \param[in] conversion_options options to control how the conversion is done
|
| 178 |
+
/// \param[out] ext_set_out if non-null, the extension mapping used by the Substrait
|
| 179 |
+
/// message is returned here.
|
| 180 |
+
/// \return A collection of expressions and a common input schema they are bound to
|
| 181 |
+
ARROW_ENGINE_EXPORT Result<BoundExpressions> DeserializeExpressions(
|
| 182 |
+
const Buffer& buf, const ExtensionIdRegistry* registry = NULLPTR,
|
| 183 |
+
const ConversionOptions& conversion_options = {},
|
| 184 |
+
ExtensionSet* ext_set_out = NULLPTR);
|
| 185 |
+
|
| 186 |
+
/// \brief Deserializes a Substrait Type message to the corresponding Arrow type
|
| 187 |
+
///
|
| 188 |
+
/// \param[in] buf a buffer containing the protobuf serialization of a Substrait Type
|
| 189 |
+
/// message
|
| 190 |
+
/// \param[in] ext_set the extension mapping to use, normally provided by the
|
| 191 |
+
/// surrounding Plan message
|
| 192 |
+
/// \param[in] conversion_options options to control how the conversion is to be done.
|
| 193 |
+
/// \return the corresponding Arrow data type
|
| 194 |
+
ARROW_ENGINE_EXPORT
|
| 195 |
+
Result<std::shared_ptr<DataType>> DeserializeType(
|
| 196 |
+
const Buffer& buf, const ExtensionSet& ext_set,
|
| 197 |
+
const ConversionOptions& conversion_options = {});
|
| 198 |
+
|
| 199 |
+
/// \brief Serializes an Arrow type to a Substrait Type message
|
| 200 |
+
///
|
| 201 |
+
/// \param[in] type the Arrow data type to serialize
|
| 202 |
+
/// \param[in,out] ext_set the extension mapping to use; may be updated to add a
|
| 203 |
+
/// mapping for the given type
|
| 204 |
+
/// \param[in] conversion_options options to control how the conversion is to be done.
|
| 205 |
+
/// \return a buffer containing the protobuf serialization of the corresponding Substrait
|
| 206 |
+
/// Type message
|
| 207 |
+
ARROW_ENGINE_EXPORT
|
| 208 |
+
Result<std::shared_ptr<Buffer>> SerializeType(
|
| 209 |
+
const DataType& type, ExtensionSet* ext_set,
|
| 210 |
+
const ConversionOptions& conversion_options = {});
|
| 211 |
+
|
| 212 |
+
/// \brief Deserializes a Substrait NamedStruct message to an Arrow schema
|
| 213 |
+
///
|
| 214 |
+
/// \param[in] buf a buffer containing the protobuf serialization of a Substrait
|
| 215 |
+
/// NamedStruct message
|
| 216 |
+
/// \param[in] ext_set the extension mapping to use, normally provided by the
|
| 217 |
+
/// surrounding Plan message
|
| 218 |
+
/// \param[in] conversion_options options to control how the conversion is to be done.
|
| 219 |
+
/// \return the corresponding Arrow schema
|
| 220 |
+
ARROW_ENGINE_EXPORT
|
| 221 |
+
Result<std::shared_ptr<Schema>> DeserializeSchema(
|
| 222 |
+
const Buffer& buf, const ExtensionSet& ext_set,
|
| 223 |
+
const ConversionOptions& conversion_options = {});
|
| 224 |
+
|
| 225 |
+
/// \brief Serializes an Arrow schema to a Substrait NamedStruct message
|
| 226 |
+
///
|
| 227 |
+
/// \param[in] schema the Arrow schema to serialize
|
| 228 |
+
/// \param[in,out] ext_set the extension mapping to use; may be updated to add
|
| 229 |
+
/// mappings for the types used in the schema
|
| 230 |
+
/// \param[in] conversion_options options to control how the conversion is to be done.
|
| 231 |
+
/// \return a buffer containing the protobuf serialization of the corresponding Substrait
|
| 232 |
+
/// NamedStruct message
|
| 233 |
+
ARROW_ENGINE_EXPORT
|
| 234 |
+
Result<std::shared_ptr<Buffer>> SerializeSchema(
|
| 235 |
+
const Schema& schema, ExtensionSet* ext_set,
|
| 236 |
+
const ConversionOptions& conversion_options = {});
|
| 237 |
+
|
| 238 |
+
/// \brief Deserializes a Substrait Expression message to a compute expression
|
| 239 |
+
///
|
| 240 |
+
/// \param[in] buf a buffer containing the protobuf serialization of a Substrait
|
| 241 |
+
/// Expression message
|
| 242 |
+
/// \param[in] ext_set the extension mapping to use, normally provided by the
|
| 243 |
+
/// surrounding Plan message
|
| 244 |
+
/// \param[in] conversion_options options to control how the conversion is to be done.
|
| 245 |
+
/// \return the corresponding Arrow compute expression
|
| 246 |
+
ARROW_ENGINE_EXPORT
|
| 247 |
+
Result<compute::Expression> DeserializeExpression(
|
| 248 |
+
const Buffer& buf, const ExtensionSet& ext_set,
|
| 249 |
+
const ConversionOptions& conversion_options = {});
|
| 250 |
+
|
| 251 |
+
/// \brief Serializes an Arrow compute expression to a Substrait Expression message
|
| 252 |
+
///
|
| 253 |
+
/// \param[in] expr the Arrow compute expression to serialize
|
| 254 |
+
/// \param[in,out] ext_set the extension mapping to use; may be updated to add
|
| 255 |
+
/// mappings for the types used in the expression
|
| 256 |
+
/// \param[in] conversion_options options to control how the conversion is to be done.
|
| 257 |
+
/// \return a buffer containing the protobuf serialization of the corresponding Substrait
|
| 258 |
+
/// Expression message
|
| 259 |
+
ARROW_ENGINE_EXPORT
|
| 260 |
+
Result<std::shared_ptr<Buffer>> SerializeExpression(
|
| 261 |
+
const compute::Expression& expr, ExtensionSet* ext_set,
|
| 262 |
+
const ConversionOptions& conversion_options = {});
|
| 263 |
+
|
| 264 |
+
/// \brief Serialize an Acero Declaration to a binary protobuf Substrait message
|
| 265 |
+
///
|
| 266 |
+
/// \param[in] declaration the Acero declaration to serialize
|
| 267 |
+
/// \param[in,out] ext_set the extension mapping to use; may be updated to add
|
| 268 |
+
/// \param[in] conversion_options options to control how the conversion is done
|
| 269 |
+
///
|
| 270 |
+
/// \return a buffer containing the protobuf serialization of the Acero relation
|
| 271 |
+
ARROW_ENGINE_EXPORT Result<std::shared_ptr<Buffer>> SerializeRelation(
|
| 272 |
+
const acero::Declaration& declaration, ExtensionSet* ext_set,
|
| 273 |
+
const ConversionOptions& conversion_options = {});
|
| 274 |
+
|
| 275 |
+
/// \brief Deserializes a Substrait Rel (relation) message to an ExecNode declaration
|
| 276 |
+
///
|
| 277 |
+
/// \param[in] buf a buffer containing the protobuf serialization of a Substrait
|
| 278 |
+
/// Rel message
|
| 279 |
+
/// \param[in] ext_set the extension mapping to use, normally provided by the
|
| 280 |
+
/// surrounding Plan message
|
| 281 |
+
/// \param[in] conversion_options options to control how the conversion is to be done.
|
| 282 |
+
/// \return the corresponding ExecNode declaration
|
| 283 |
+
ARROW_ENGINE_EXPORT Result<acero::Declaration> DeserializeRelation(
|
| 284 |
+
const Buffer& buf, const ExtensionSet& ext_set,
|
| 285 |
+
const ConversionOptions& conversion_options = {});
|
| 286 |
+
|
| 287 |
+
namespace internal {
|
| 288 |
+
|
| 289 |
+
/// \brief Checks whether two protobuf serializations of a particular Substrait message
|
| 290 |
+
/// type are equivalent
|
| 291 |
+
///
|
| 292 |
+
/// Note that a binary comparison of the two buffers is insufficient. One reason for this
|
| 293 |
+
/// is that the fields of a message can be specified in any order in the serialization.
|
| 294 |
+
///
|
| 295 |
+
/// \param[in] message_name the name of the Substrait message type to check
|
| 296 |
+
/// \param[in] l_buf buffer containing the first protobuf serialization to compare
|
| 297 |
+
/// \param[in] r_buf buffer containing the second protobuf serialization to compare
|
| 298 |
+
/// \return success if equivalent, failure if not
|
| 299 |
+
ARROW_ENGINE_EXPORT
|
| 300 |
+
Status CheckMessagesEquivalent(std::string_view message_name, const Buffer& l_buf,
|
| 301 |
+
const Buffer& r_buf);
|
| 302 |
+
|
| 303 |
+
/// \brief Utility function to convert a JSON serialization of a Substrait message to
|
| 304 |
+
/// its binary serialization
|
| 305 |
+
///
|
| 306 |
+
/// \param[in] type_name the name of the Substrait message type to convert
|
| 307 |
+
/// \param[in] json the JSON string to convert
|
| 308 |
+
/// \param[in] ignore_unknown_fields if true then unknown fields will be ignored and
|
| 309 |
+
/// will not cause an error
|
| 310 |
+
///
|
| 311 |
+
/// This should generally be true to allow consumption of plans from newer
|
| 312 |
+
/// producers but setting to false can be useful if you are testing
|
| 313 |
+
/// conformance to a specific Substrait version
|
| 314 |
+
/// \return a buffer filled with the binary protobuf serialization of message
|
| 315 |
+
ARROW_ENGINE_EXPORT
|
| 316 |
+
Result<std::shared_ptr<Buffer>> SubstraitFromJSON(std::string_view type_name,
|
| 317 |
+
std::string_view json,
|
| 318 |
+
bool ignore_unknown_fields = true);
|
| 319 |
+
|
| 320 |
+
/// \brief Utility function to convert a binary protobuf serialization of a Substrait
|
| 321 |
+
/// message to JSON
|
| 322 |
+
///
|
| 323 |
+
/// \param[in] type_name the name of the Substrait message type to convert
|
| 324 |
+
/// \param[in] buf the buffer containing the binary protobuf serialization of the message
|
| 325 |
+
/// \return a JSON string representing the message
|
| 326 |
+
ARROW_ENGINE_EXPORT
|
| 327 |
+
Result<std::string> SubstraitToJSON(std::string_view type_name, const Buffer& buf);
|
| 328 |
+
|
| 329 |
+
} // namespace internal
|
| 330 |
+
} // namespace engine
|
| 331 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/engine/substrait/test_plan_builder.h
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// These utilities are for internal / unit test use only.
|
| 19 |
+
// They allow for the construction of simple Substrait plans
|
| 20 |
+
// programmatically without first requiring the construction
|
| 21 |
+
// of an ExecPlan
|
| 22 |
+
|
| 23 |
+
// These utilities have to be here, and not in a test_util.cc
|
| 24 |
+
// file (or in a unit test) because only one .so is allowed
|
| 25 |
+
// to include each .pb.h file or else protobuf will encounter
|
| 26 |
+
// global namespace conflicts.
|
| 27 |
+
|
| 28 |
+
#include <memory>
|
| 29 |
+
#include <string>
|
| 30 |
+
#include <unordered_map>
|
| 31 |
+
#include <vector>
|
| 32 |
+
|
| 33 |
+
#include "arrow/engine/substrait/visibility.h"
|
| 34 |
+
#include "arrow/result.h"
|
| 35 |
+
#include "arrow/type_fwd.h"
|
| 36 |
+
|
| 37 |
+
namespace arrow {
|
| 38 |
+
namespace engine {
|
| 39 |
+
|
| 40 |
+
struct Id;
|
| 41 |
+
|
| 42 |
+
namespace internal {
|
| 43 |
+
|
| 44 |
+
/// \brief Create a scan->project->sink plan for tests
|
| 45 |
+
///
|
| 46 |
+
/// The plan will project one additional column using the function
|
| 47 |
+
/// defined by `function_id`, `arguments`, and data_types. `arguments`
|
| 48 |
+
/// and `data_types` should have the same length but only one of each
|
| 49 |
+
/// should be defined at each index.
|
| 50 |
+
///
|
| 51 |
+
/// If `data_types` is defined at an index then the plan will create a
|
| 52 |
+
/// direct reference (starting at index 0 and increasing by 1 for each
|
| 53 |
+
/// argument of this type).
|
| 54 |
+
///
|
| 55 |
+
/// If `arguments` is defined at an index then the plan will create an
|
| 56 |
+
/// enum argument with that value.
|
| 57 |
+
ARROW_ENGINE_EXPORT Result<std::shared_ptr<Buffer>> CreateScanProjectSubstrait(
|
| 58 |
+
Id function_id, const std::shared_ptr<Table>& input_table,
|
| 59 |
+
const std::vector<std::string>& arguments,
|
| 60 |
+
const std::unordered_map<std::string, std::vector<std::string>>& options,
|
| 61 |
+
const std::vector<std::shared_ptr<DataType>>& data_types,
|
| 62 |
+
const DataType& output_type);
|
| 63 |
+
|
| 64 |
+
/// \brief Create a scan->aggregate->sink plan for tests
|
| 65 |
+
///
|
| 66 |
+
/// The plan will create an aggregate with one grouping set (defined by
|
| 67 |
+
/// key_idxs) and one measure. The measure will be a function
|
| 68 |
+
/// defined by `function_id` and direct references to `arg_idxs`.
|
| 69 |
+
ARROW_ENGINE_EXPORT Result<std::shared_ptr<Buffer>> CreateScanAggSubstrait(
|
| 70 |
+
Id function_id, const std::shared_ptr<Table>& input_table,
|
| 71 |
+
const std::vector<int>& key_idxs, const std::vector<int>& arg_idxs,
|
| 72 |
+
const DataType& output_type);
|
| 73 |
+
|
| 74 |
+
} // namespace internal
|
| 75 |
+
} // namespace engine
|
| 76 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/engine/substrait/test_util.h
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 "arrow/testing/gtest_util.h"
|
| 21 |
+
#include "arrow/util/vector.h"
|
| 22 |
+
|
| 23 |
+
#include <functional>
|
| 24 |
+
#include <random>
|
| 25 |
+
#include <string>
|
| 26 |
+
#include <string_view>
|
| 27 |
+
#include <vector>
|
| 28 |
+
|
| 29 |
+
#include "arrow/acero/exec_plan.h"
|
| 30 |
+
#include "arrow/compute/exec.h"
|
| 31 |
+
#include "arrow/compute/kernel.h"
|
| 32 |
+
#include "arrow/testing/visibility.h"
|
| 33 |
+
#include "arrow/util/async_generator.h"
|
| 34 |
+
#include "arrow/util/pcg_random.h"
|
| 35 |
+
|
| 36 |
+
namespace arrow {
|
| 37 |
+
namespace engine {
|
| 38 |
+
|
| 39 |
+
Result<std::shared_ptr<Table>> SortTableOnAllFields(const std::shared_ptr<Table>& tab);
|
| 40 |
+
|
| 41 |
+
void AssertTablesEqualIgnoringOrder(const std::shared_ptr<Table>& exp,
|
| 42 |
+
const std::shared_ptr<Table>& act);
|
| 43 |
+
|
| 44 |
+
} // namespace engine
|
| 45 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/engine/substrait/type_fwd.h
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// This API is EXPERIMENTAL.
|
| 19 |
+
|
| 20 |
+
#pragma once
|
| 21 |
+
|
| 22 |
+
namespace arrow {
|
| 23 |
+
namespace engine {
|
| 24 |
+
|
| 25 |
+
class ExtensionIdRegistry;
|
| 26 |
+
class ExtensionSet;
|
| 27 |
+
|
| 28 |
+
struct ConversionOptions;
|
| 29 |
+
struct DeclarationInfo;
|
| 30 |
+
|
| 31 |
+
} // namespace engine
|
| 32 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/engine/substrait/util.h
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 <functional>
|
| 21 |
+
#include <memory>
|
| 22 |
+
#include <string>
|
| 23 |
+
#include <vector>
|
| 24 |
+
|
| 25 |
+
#include "arrow/compute/type_fwd.h"
|
| 26 |
+
#include "arrow/engine/substrait/options.h"
|
| 27 |
+
#include "arrow/engine/substrait/type_fwd.h"
|
| 28 |
+
#include "arrow/engine/substrait/visibility.h"
|
| 29 |
+
#include "arrow/result.h"
|
| 30 |
+
#include "arrow/type_fwd.h"
|
| 31 |
+
#include "arrow/util/iterator.h"
|
| 32 |
+
#include "arrow/util/macros.h"
|
| 33 |
+
|
| 34 |
+
namespace arrow {
|
| 35 |
+
|
| 36 |
+
namespace engine {
|
| 37 |
+
|
| 38 |
+
using PythonTableProvider =
|
| 39 |
+
std::function<Result<std::shared_ptr<Table>>(const std::vector<std::string>&)>;
|
| 40 |
+
|
| 41 |
+
/// \brief Utility method to run a Substrait plan
|
| 42 |
+
/// \param substrait_buffer The plan to run, must be in binary protobuf format
|
| 43 |
+
/// \param registry A registry of extension functions to make available to the plan
|
| 44 |
+
/// If null then the default registry will be used.
|
| 45 |
+
/// \param memory_pool The memory pool the plan should use to make allocations.
|
| 46 |
+
/// \param func_registry A registry of functions used for execution expressions.
|
| 47 |
+
/// `registry` maps from Substrait function IDs to "names". These
|
| 48 |
+
/// names will be provided to `func_registry` to get the actual
|
| 49 |
+
/// kernel.
|
| 50 |
+
/// \param conversion_options Options to control plan deserialization
|
| 51 |
+
/// \param use_threads If True then the CPU thread pool will be used for CPU work. If
|
| 52 |
+
/// False then all work will be done on the calling thread.
|
| 53 |
+
/// \return A record batch reader that will read out the results
|
| 54 |
+
ARROW_ENGINE_EXPORT Result<std::shared_ptr<RecordBatchReader>> ExecuteSerializedPlan(
|
| 55 |
+
const Buffer& substrait_buffer, const ExtensionIdRegistry* registry = NULLPTR,
|
| 56 |
+
compute::FunctionRegistry* func_registry = NULLPTR,
|
| 57 |
+
const ConversionOptions& conversion_options = {}, bool use_threads = true,
|
| 58 |
+
MemoryPool* memory_pool = default_memory_pool());
|
| 59 |
+
|
| 60 |
+
/// \brief Get a Serialized Plan from a Substrait JSON plan.
|
| 61 |
+
/// This is a helper method for Python tests.
|
| 62 |
+
ARROW_ENGINE_EXPORT Result<std::shared_ptr<Buffer>> SerializeJsonPlan(
|
| 63 |
+
const std::string& substrait_json);
|
| 64 |
+
|
| 65 |
+
/// \brief Make a nested registry with the default registry as parent.
|
| 66 |
+
/// See arrow::engine::nested_extension_id_registry for details.
|
| 67 |
+
ARROW_ENGINE_EXPORT std::shared_ptr<ExtensionIdRegistry> MakeExtensionIdRegistry();
|
| 68 |
+
|
| 69 |
+
ARROW_ENGINE_EXPORT const std::string& default_extension_types_uri();
|
| 70 |
+
|
| 71 |
+
// TODO(ARROW-18145) Populate these from cmake files
|
| 72 |
+
constexpr uint32_t kSubstraitMajorVersion = 0;
|
| 73 |
+
constexpr uint32_t kSubstraitMinorVersion = 44;
|
| 74 |
+
constexpr uint32_t kSubstraitPatchVersion = 0;
|
| 75 |
+
|
| 76 |
+
constexpr uint32_t kSubstraitMinimumMajorVersion = 0;
|
| 77 |
+
constexpr uint32_t kSubstraitMinimumMinorVersion = 20;
|
| 78 |
+
|
| 79 |
+
Status CheckVersion(uint32_t major_version, uint32_t minor_version);
|
| 80 |
+
|
| 81 |
+
} // namespace engine
|
| 82 |
+
|
| 83 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/engine/substrait/visibility.h
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// TODO(westonpace): Once we have a proper engine module this file
|
| 19 |
+
// should be renamed arrow/engine/visibility.h
|
| 20 |
+
// This API is EXPERIMENTAL.
|
| 21 |
+
|
| 22 |
+
#pragma once
|
| 23 |
+
|
| 24 |
+
#if defined(_WIN32) || defined(__CYGWIN__)
|
| 25 |
+
# if defined(_MSC_VER)
|
| 26 |
+
# pragma warning(push)
|
| 27 |
+
# pragma warning(disable : 4251)
|
| 28 |
+
# else
|
| 29 |
+
# pragma GCC diagnostic ignored "-Wattributes"
|
| 30 |
+
# endif
|
| 31 |
+
|
| 32 |
+
# ifdef ARROW_ENGINE_STATIC
|
| 33 |
+
# define ARROW_ENGINE_EXPORT
|
| 34 |
+
# elif defined(ARROW_ENGINE_EXPORTING)
|
| 35 |
+
# define ARROW_ENGINE_EXPORT __declspec(dllexport)
|
| 36 |
+
# else
|
| 37 |
+
# define ARROW_ENGINE_EXPORT __declspec(dllimport)
|
| 38 |
+
# endif
|
| 39 |
+
|
| 40 |
+
# define ARROW_ENGINE_NO_EXPORT
|
| 41 |
+
#else // Not Windows
|
| 42 |
+
# ifndef ARROW_ENGINE_EXPORT
|
| 43 |
+
# define ARROW_ENGINE_EXPORT __attribute__((visibility("default")))
|
| 44 |
+
# endif
|
| 45 |
+
# ifndef ARROW_ENGINE_NO_EXPORT
|
| 46 |
+
# define ARROW_ENGINE_NO_EXPORT __attribute__((visibility("hidden")))
|
| 47 |
+
# endif
|
| 48 |
+
#endif // Non-Windows
|
| 49 |
+
|
| 50 |
+
#if defined(_MSC_VER)
|
| 51 |
+
# pragma warning(pop)
|
| 52 |
+
#endif
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/extension/fixed_shape_tensor.h
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 "arrow/extension_type.h"
|
| 21 |
+
|
| 22 |
+
namespace arrow {
|
| 23 |
+
namespace extension {
|
| 24 |
+
|
| 25 |
+
class ARROW_EXPORT FixedShapeTensorArray : public ExtensionArray {
|
| 26 |
+
public:
|
| 27 |
+
using ExtensionArray::ExtensionArray;
|
| 28 |
+
|
| 29 |
+
/// \brief Create a FixedShapeTensorArray from a Tensor
|
| 30 |
+
///
|
| 31 |
+
/// This method will create a FixedShapeTensorArray from a Tensor, taking its first
|
| 32 |
+
/// dimension as the number of elements in the resulting array and the remaining
|
| 33 |
+
/// dimensions as the shape of the individual tensors. If Tensor provides strides,
|
| 34 |
+
/// they will be used to determine dimension permutation. Otherwise, row-major layout
|
| 35 |
+
/// (i.e. no permutation) will be assumed.
|
| 36 |
+
///
|
| 37 |
+
/// \param[in] tensor The Tensor to convert to a FixedShapeTensorArray
|
| 38 |
+
static Result<std::shared_ptr<FixedShapeTensorArray>> FromTensor(
|
| 39 |
+
const std::shared_ptr<Tensor>& tensor);
|
| 40 |
+
|
| 41 |
+
/// \brief Create a Tensor from FixedShapeTensorArray
|
| 42 |
+
///
|
| 43 |
+
/// This method will create a Tensor from a FixedShapeTensorArray, setting its first
|
| 44 |
+
/// dimension as length equal to the FixedShapeTensorArray's length and the remaining
|
| 45 |
+
/// dimensions as the FixedShapeTensorType's shape. Shape and dim_names will be
|
| 46 |
+
/// permuted according to permutation stored in the FixedShapeTensorType metadata.
|
| 47 |
+
const Result<std::shared_ptr<Tensor>> ToTensor() const;
|
| 48 |
+
};
|
| 49 |
+
|
| 50 |
+
/// \brief Concrete type class for constant-size Tensor data.
|
| 51 |
+
/// This is a canonical arrow extension type.
|
| 52 |
+
/// See: https://arrow.apache.org/docs/format/CanonicalExtensions.html
|
| 53 |
+
class ARROW_EXPORT FixedShapeTensorType : public ExtensionType {
|
| 54 |
+
public:
|
| 55 |
+
FixedShapeTensorType(const std::shared_ptr<DataType>& value_type, const int32_t& size,
|
| 56 |
+
const std::vector<int64_t>& shape,
|
| 57 |
+
const std::vector<int64_t>& permutation = {},
|
| 58 |
+
const std::vector<std::string>& dim_names = {})
|
| 59 |
+
: ExtensionType(fixed_size_list(value_type, size)),
|
| 60 |
+
value_type_(value_type),
|
| 61 |
+
shape_(shape),
|
| 62 |
+
permutation_(permutation),
|
| 63 |
+
dim_names_(dim_names) {}
|
| 64 |
+
|
| 65 |
+
std::string extension_name() const override { return "arrow.fixed_shape_tensor"; }
|
| 66 |
+
std::string ToString(bool show_metadata = false) const override;
|
| 67 |
+
|
| 68 |
+
/// Number of dimensions of tensor elements
|
| 69 |
+
size_t ndim() const { return shape_.size(); }
|
| 70 |
+
|
| 71 |
+
/// Shape of tensor elements
|
| 72 |
+
const std::vector<int64_t>& shape() const { return shape_; }
|
| 73 |
+
|
| 74 |
+
/// Value type of tensor elements
|
| 75 |
+
const std::shared_ptr<DataType>& value_type() const { return value_type_; }
|
| 76 |
+
|
| 77 |
+
/// Strides of tensor elements. Strides state offset in bytes between adjacent
|
| 78 |
+
/// elements along each dimension. In case permutation is non-empty strides are
|
| 79 |
+
/// computed from permuted tensor element's shape.
|
| 80 |
+
const std::vector<int64_t>& strides();
|
| 81 |
+
|
| 82 |
+
/// Permutation mapping from logical to physical memory layout of tensor elements
|
| 83 |
+
const std::vector<int64_t>& permutation() const { return permutation_; }
|
| 84 |
+
|
| 85 |
+
/// Dimension names of tensor elements. Dimensions are ordered physically.
|
| 86 |
+
const std::vector<std::string>& dim_names() const { return dim_names_; }
|
| 87 |
+
|
| 88 |
+
bool ExtensionEquals(const ExtensionType& other) const override;
|
| 89 |
+
|
| 90 |
+
std::string Serialize() const override;
|
| 91 |
+
|
| 92 |
+
Result<std::shared_ptr<DataType>> Deserialize(
|
| 93 |
+
std::shared_ptr<DataType> storage_type,
|
| 94 |
+
const std::string& serialized_data) const override;
|
| 95 |
+
|
| 96 |
+
/// Create a FixedShapeTensorArray from ArrayData
|
| 97 |
+
std::shared_ptr<Array> MakeArray(std::shared_ptr<ArrayData> data) const override;
|
| 98 |
+
|
| 99 |
+
/// \brief Create a Tensor from an ExtensionScalar from a FixedShapeTensorArray
|
| 100 |
+
///
|
| 101 |
+
/// This method will return a Tensor from ExtensionScalar with strides
|
| 102 |
+
/// derived from shape and permutation of FixedShapeTensorType. Shape and
|
| 103 |
+
/// dim_names will be permuted according to permutation stored in the
|
| 104 |
+
/// FixedShapeTensorType metadata.
|
| 105 |
+
static Result<std::shared_ptr<Tensor>> MakeTensor(
|
| 106 |
+
const std::shared_ptr<ExtensionScalar>& scalar);
|
| 107 |
+
|
| 108 |
+
/// \brief Create a FixedShapeTensorType instance
|
| 109 |
+
static Result<std::shared_ptr<DataType>> Make(
|
| 110 |
+
const std::shared_ptr<DataType>& value_type, const std::vector<int64_t>& shape,
|
| 111 |
+
const std::vector<int64_t>& permutation = {},
|
| 112 |
+
const std::vector<std::string>& dim_names = {});
|
| 113 |
+
|
| 114 |
+
private:
|
| 115 |
+
std::shared_ptr<DataType> storage_type_;
|
| 116 |
+
std::shared_ptr<DataType> value_type_;
|
| 117 |
+
std::vector<int64_t> shape_;
|
| 118 |
+
std::vector<int64_t> strides_;
|
| 119 |
+
std::vector<int64_t> permutation_;
|
| 120 |
+
std::vector<std::string> dim_names_;
|
| 121 |
+
};
|
| 122 |
+
|
| 123 |
+
/// \brief Return a FixedShapeTensorType instance.
|
| 124 |
+
ARROW_EXPORT std::shared_ptr<DataType> fixed_shape_tensor(
|
| 125 |
+
const std::shared_ptr<DataType>& storage_type, const std::vector<int64_t>& shape,
|
| 126 |
+
const std::vector<int64_t>& permutation = {},
|
| 127 |
+
const std::vector<std::string>& dim_names = {});
|
| 128 |
+
|
| 129 |
+
} // namespace extension
|
| 130 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/extension/json.h
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 <stdexcept>
|
| 21 |
+
#include <string>
|
| 22 |
+
|
| 23 |
+
#include "arrow/extension_type.h"
|
| 24 |
+
#include "arrow/result.h"
|
| 25 |
+
#include "arrow/type_fwd.h"
|
| 26 |
+
#include "arrow/util/visibility.h"
|
| 27 |
+
|
| 28 |
+
namespace arrow::extension {
|
| 29 |
+
|
| 30 |
+
/// \brief Concrete type class for variable-size JSON data, utf8-encoded.
|
| 31 |
+
class ARROW_EXPORT JsonExtensionType : public ExtensionType {
|
| 32 |
+
public:
|
| 33 |
+
explicit JsonExtensionType(const std::shared_ptr<DataType>& storage_type)
|
| 34 |
+
: ExtensionType(storage_type) {}
|
| 35 |
+
|
| 36 |
+
std::string extension_name() const override { return "arrow.json"; }
|
| 37 |
+
|
| 38 |
+
bool ExtensionEquals(const ExtensionType& other) const override;
|
| 39 |
+
|
| 40 |
+
Result<std::shared_ptr<DataType>> Deserialize(
|
| 41 |
+
std::shared_ptr<DataType> storage_type,
|
| 42 |
+
const std::string& serialized_data) const override;
|
| 43 |
+
|
| 44 |
+
std::string Serialize() const override;
|
| 45 |
+
|
| 46 |
+
std::shared_ptr<Array> MakeArray(std::shared_ptr<ArrayData> data) const override;
|
| 47 |
+
|
| 48 |
+
static Result<std::shared_ptr<DataType>> Make(std::shared_ptr<DataType> storage_type);
|
| 49 |
+
|
| 50 |
+
static bool IsSupportedStorageType(Type::type type_id);
|
| 51 |
+
};
|
| 52 |
+
|
| 53 |
+
/// \brief Return a JsonExtensionType instance.
|
| 54 |
+
ARROW_EXPORT std::shared_ptr<DataType> json(
|
| 55 |
+
std::shared_ptr<DataType> storage_type = utf8());
|
| 56 |
+
|
| 57 |
+
} // namespace arrow::extension
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/extension/opaque.h
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 "arrow/extension_type.h"
|
| 21 |
+
#include "arrow/type.h"
|
| 22 |
+
|
| 23 |
+
namespace arrow::extension {
|
| 24 |
+
|
| 25 |
+
/// \brief Opaque is a placeholder for a type from an external (usually
|
| 26 |
+
/// non-Arrow) system that could not be interpreted.
|
| 27 |
+
class ARROW_EXPORT OpaqueType : public ExtensionType {
|
| 28 |
+
public:
|
| 29 |
+
/// \brief Construct an OpaqueType.
|
| 30 |
+
///
|
| 31 |
+
/// \param[in] storage_type The underlying storage type. Should be
|
| 32 |
+
/// arrow::null if there is no data.
|
| 33 |
+
/// \param[in] type_name The name of the type in the external system.
|
| 34 |
+
/// \param[in] vendor_name The name of the external system.
|
| 35 |
+
explicit OpaqueType(std::shared_ptr<DataType> storage_type, std::string type_name,
|
| 36 |
+
std::string vendor_name)
|
| 37 |
+
: ExtensionType(std::move(storage_type)),
|
| 38 |
+
type_name_(std::move(type_name)),
|
| 39 |
+
vendor_name_(std::move(vendor_name)) {}
|
| 40 |
+
|
| 41 |
+
std::string extension_name() const override { return "arrow.opaque"; }
|
| 42 |
+
std::string ToString(bool show_metadata) const override;
|
| 43 |
+
bool ExtensionEquals(const ExtensionType& other) const override;
|
| 44 |
+
std::string Serialize() const override;
|
| 45 |
+
Result<std::shared_ptr<DataType>> Deserialize(
|
| 46 |
+
std::shared_ptr<DataType> storage_type,
|
| 47 |
+
const std::string& serialized_data) const override;
|
| 48 |
+
/// Create an OpaqueArray from ArrayData
|
| 49 |
+
std::shared_ptr<Array> MakeArray(std::shared_ptr<ArrayData> data) const override;
|
| 50 |
+
|
| 51 |
+
std::string_view type_name() const { return type_name_; }
|
| 52 |
+
std::string_view vendor_name() const { return vendor_name_; }
|
| 53 |
+
|
| 54 |
+
private:
|
| 55 |
+
std::string type_name_;
|
| 56 |
+
std::string vendor_name_;
|
| 57 |
+
};
|
| 58 |
+
|
| 59 |
+
/// \brief Opaque is a wrapper for (usually binary) data from an external
|
| 60 |
+
/// (often non-Arrow) system that could not be interpreted.
|
| 61 |
+
class ARROW_EXPORT OpaqueArray : public ExtensionArray {
|
| 62 |
+
public:
|
| 63 |
+
using ExtensionArray::ExtensionArray;
|
| 64 |
+
};
|
| 65 |
+
|
| 66 |
+
/// \brief Return an OpaqueType instance.
|
| 67 |
+
ARROW_EXPORT std::shared_ptr<DataType> opaque(std::shared_ptr<DataType> storage_type,
|
| 68 |
+
std::string type_name,
|
| 69 |
+
std::string vendor_name);
|
| 70 |
+
|
| 71 |
+
} // namespace arrow::extension
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/extension/uuid.h
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 "arrow/extension_type.h"
|
| 21 |
+
|
| 22 |
+
namespace arrow::extension {
|
| 23 |
+
|
| 24 |
+
/// \brief UuidArray stores array of UUIDs. Underlying storage type is
|
| 25 |
+
/// FixedSizeBinary(16).
|
| 26 |
+
class ARROW_EXPORT UuidArray : public ExtensionArray {
|
| 27 |
+
public:
|
| 28 |
+
using ExtensionArray::ExtensionArray;
|
| 29 |
+
};
|
| 30 |
+
|
| 31 |
+
/// \brief UuidType is a canonical arrow extension type for UUIDs.
|
| 32 |
+
/// UUIDs are stored as FixedSizeBinary(16) with big-endian notation and this
|
| 33 |
+
/// does not interpret the bytes in any way. Specific UUID version is not
|
| 34 |
+
/// required or guaranteed.
|
| 35 |
+
class ARROW_EXPORT UuidType : public ExtensionType {
|
| 36 |
+
public:
|
| 37 |
+
/// \brief Construct a UuidType.
|
| 38 |
+
UuidType() : ExtensionType(fixed_size_binary(16)) {}
|
| 39 |
+
|
| 40 |
+
std::string extension_name() const override { return "arrow.uuid"; }
|
| 41 |
+
std::string ToString(bool show_metadata = false) const override;
|
| 42 |
+
|
| 43 |
+
bool ExtensionEquals(const ExtensionType& other) const override;
|
| 44 |
+
|
| 45 |
+
/// Create a UuidArray from ArrayData
|
| 46 |
+
std::shared_ptr<Array> MakeArray(std::shared_ptr<ArrayData> data) const override;
|
| 47 |
+
|
| 48 |
+
Result<std::shared_ptr<DataType>> Deserialize(
|
| 49 |
+
std::shared_ptr<DataType> storage_type,
|
| 50 |
+
const std::string& serialized) const override;
|
| 51 |
+
|
| 52 |
+
std::string Serialize() const override { return ""; }
|
| 53 |
+
|
| 54 |
+
/// \brief Create a UuidType instance
|
| 55 |
+
static Result<std::shared_ptr<DataType>> Make() { return std::make_shared<UuidType>(); }
|
| 56 |
+
|
| 57 |
+
static bool IsSupportedStorageType(const std::shared_ptr<DataType>& storage_type);
|
| 58 |
+
};
|
| 59 |
+
|
| 60 |
+
/// \brief Return a UuidType instance.
|
| 61 |
+
ARROW_EXPORT std::shared_ptr<DataType> uuid();
|
| 62 |
+
|
| 63 |
+
} // namespace arrow::extension
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/filesystem/api.h
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 "arrow/util/config.h" // IWYU pragma: export
|
| 21 |
+
|
| 22 |
+
#include "arrow/filesystem/filesystem.h" // IWYU pragma: export
|
| 23 |
+
#ifdef ARROW_AZURE
|
| 24 |
+
# include "arrow/filesystem/azurefs.h" // IWYU pragma: export
|
| 25 |
+
#endif
|
| 26 |
+
#ifdef ARROW_GCS
|
| 27 |
+
# include "arrow/filesystem/gcsfs.h" // IWYU pragma: export
|
| 28 |
+
#endif
|
| 29 |
+
#include "arrow/filesystem/hdfs.h" // IWYU pragma: export
|
| 30 |
+
#include "arrow/filesystem/localfs.h" // IWYU pragma: export
|
| 31 |
+
#include "arrow/filesystem/mockfs.h" // IWYU pragma: export
|
| 32 |
+
#ifdef ARROW_S3
|
| 33 |
+
# include "arrow/filesystem/s3fs.h" // IWYU pragma: export
|
| 34 |
+
#endif
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/filesystem/azurefs.h
ADDED
|
@@ -0,0 +1,373 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 <memory>
|
| 21 |
+
#include <string>
|
| 22 |
+
#include <vector>
|
| 23 |
+
|
| 24 |
+
#include "arrow/filesystem/filesystem.h"
|
| 25 |
+
#include "arrow/util/macros.h"
|
| 26 |
+
#include "arrow/util/uri.h"
|
| 27 |
+
|
| 28 |
+
namespace Azure::Core::Credentials {
|
| 29 |
+
class TokenCredential;
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
namespace Azure::Storage {
|
| 33 |
+
class StorageSharedKeyCredential;
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
namespace Azure::Storage::Blobs {
|
| 37 |
+
class BlobServiceClient;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
namespace Azure::Storage::Files::DataLake {
|
| 41 |
+
class DataLakeFileSystemClient;
|
| 42 |
+
class DataLakeServiceClient;
|
| 43 |
+
} // namespace Azure::Storage::Files::DataLake
|
| 44 |
+
|
| 45 |
+
namespace arrow::fs {
|
| 46 |
+
|
| 47 |
+
class TestAzureFileSystem;
|
| 48 |
+
class TestAzureOptions;
|
| 49 |
+
|
| 50 |
+
/// Options for the AzureFileSystem implementation.
|
| 51 |
+
///
|
| 52 |
+
/// By default, authentication is handled by the Azure SDK's credential chain
|
| 53 |
+
/// which may read from multiple environment variables, such as:
|
| 54 |
+
/// - `AZURE_TENANT_ID`
|
| 55 |
+
/// - `AZURE_CLIENT_ID`
|
| 56 |
+
/// - `AZURE_CLIENT_SECRET`
|
| 57 |
+
/// - `AZURE_AUTHORITY_HOST`
|
| 58 |
+
/// - `AZURE_CLIENT_CERTIFICATE_PATH`
|
| 59 |
+
/// - `AZURE_FEDERATED_TOKEN_FILE`
|
| 60 |
+
///
|
| 61 |
+
/// Functions are provided for explicit configuration of credentials if that is preferred.
|
| 62 |
+
struct ARROW_EXPORT AzureOptions {
|
| 63 |
+
friend class TestAzureOptions;
|
| 64 |
+
|
| 65 |
+
/// \brief The name of the Azure Storage Account being accessed.
|
| 66 |
+
///
|
| 67 |
+
/// All service URLs will be constructed using this storage account name.
|
| 68 |
+
/// `ConfigureAccountKeyCredential` assumes the user wants to authenticate
|
| 69 |
+
/// this account.
|
| 70 |
+
std::string account_name;
|
| 71 |
+
|
| 72 |
+
/// \brief hostname[:port] of the Azure Blob Storage Service.
|
| 73 |
+
///
|
| 74 |
+
/// If the hostname is a relative domain name (one that starts with a '.'), then storage
|
| 75 |
+
/// account URLs will be constructed by prepending the account name to the hostname.
|
| 76 |
+
/// If the hostname is a fully qualified domain name, then the hostname will be used
|
| 77 |
+
/// as-is and the account name will follow the hostname in the URL path.
|
| 78 |
+
///
|
| 79 |
+
/// Default: ".blob.core.windows.net"
|
| 80 |
+
std::string blob_storage_authority = ".blob.core.windows.net";
|
| 81 |
+
|
| 82 |
+
/// \brief hostname[:port] of the Azure Data Lake Storage Gen 2 Service.
|
| 83 |
+
///
|
| 84 |
+
/// If the hostname is a relative domain name (one that starts with a '.'), then storage
|
| 85 |
+
/// account URLs will be constructed by prepending the account name to the hostname.
|
| 86 |
+
/// If the hostname is a fully qualified domain name, then the hostname will be used
|
| 87 |
+
/// as-is and the account name will follow the hostname in the URL path.
|
| 88 |
+
///
|
| 89 |
+
/// Default: ".dfs.core.windows.net"
|
| 90 |
+
std::string dfs_storage_authority = ".dfs.core.windows.net";
|
| 91 |
+
|
| 92 |
+
/// \brief Azure Blob Storage connection transport.
|
| 93 |
+
///
|
| 94 |
+
/// Default: "https"
|
| 95 |
+
std::string blob_storage_scheme = "https";
|
| 96 |
+
|
| 97 |
+
/// \brief Azure Data Lake Storage Gen 2 connection transport.
|
| 98 |
+
///
|
| 99 |
+
/// Default: "https"
|
| 100 |
+
std::string dfs_storage_scheme = "https";
|
| 101 |
+
|
| 102 |
+
// TODO(GH-38598): Add support for more auth methods.
|
| 103 |
+
// std::string connection_string;
|
| 104 |
+
// std::string sas_token;
|
| 105 |
+
|
| 106 |
+
/// \brief Default metadata for OpenOutputStream.
|
| 107 |
+
///
|
| 108 |
+
/// This will be ignored if non-empty metadata is passed to OpenOutputStream.
|
| 109 |
+
std::shared_ptr<const KeyValueMetadata> default_metadata;
|
| 110 |
+
|
| 111 |
+
/// Whether OutputStream writes will be issued in the background, without blocking.
|
| 112 |
+
bool background_writes = true;
|
| 113 |
+
|
| 114 |
+
private:
|
| 115 |
+
enum class CredentialKind {
|
| 116 |
+
kDefault,
|
| 117 |
+
kAnonymous,
|
| 118 |
+
kStorageSharedKey,
|
| 119 |
+
kSASToken,
|
| 120 |
+
kClientSecret,
|
| 121 |
+
kManagedIdentity,
|
| 122 |
+
kCLI,
|
| 123 |
+
kWorkloadIdentity,
|
| 124 |
+
kEnvironment,
|
| 125 |
+
} credential_kind_ = CredentialKind::kDefault;
|
| 126 |
+
|
| 127 |
+
std::shared_ptr<Azure::Storage::StorageSharedKeyCredential>
|
| 128 |
+
storage_shared_key_credential_;
|
| 129 |
+
std::string sas_token_;
|
| 130 |
+
mutable std::shared_ptr<Azure::Core::Credentials::TokenCredential> token_credential_;
|
| 131 |
+
|
| 132 |
+
public:
|
| 133 |
+
AzureOptions();
|
| 134 |
+
~AzureOptions();
|
| 135 |
+
|
| 136 |
+
private:
|
| 137 |
+
void ExtractFromUriSchemeAndHierPart(const Uri& uri, std::string* out_path);
|
| 138 |
+
Status ExtractFromUriQuery(const Uri& uri);
|
| 139 |
+
|
| 140 |
+
public:
|
| 141 |
+
/// \brief Construct a new AzureOptions from an URI.
|
| 142 |
+
///
|
| 143 |
+
/// Supported formats:
|
| 144 |
+
///
|
| 145 |
+
/// 1. abfs[s]://\<account\>.blob.core.windows.net[/\<container\>[/\<path\>]]
|
| 146 |
+
/// 2. abfs[s]://\<container\>\@\<account\>.dfs.core.windows.net[/path]
|
| 147 |
+
/// 3. abfs[s]://[\<account@]\<host[.domain]\>[\<:port\>][/\<container\>[/path]]
|
| 148 |
+
/// 4. abfs[s]://[\<account@]\<container\>[/path]
|
| 149 |
+
///
|
| 150 |
+
/// (1) and (2) are compatible with the Azure Data Lake Storage Gen2 URIs
|
| 151 |
+
/// [1], (3) is for Azure Blob Storage compatible service including Azurite,
|
| 152 |
+
/// and (4) is a shorter version of (1) and (2).
|
| 153 |
+
///
|
| 154 |
+
/// Note that there is no difference between abfs and abfss. HTTPS is
|
| 155 |
+
/// used with abfs by default. You can force to use HTTP by specifying
|
| 156 |
+
/// "enable_tls=false" query.
|
| 157 |
+
///
|
| 158 |
+
/// Supported query parameters:
|
| 159 |
+
///
|
| 160 |
+
/// * blob_storage_authority: Set AzureOptions::blob_storage_authority
|
| 161 |
+
/// * dfs_storage_authority: Set AzureOptions::dfs_storage_authority
|
| 162 |
+
/// * enable_tls: If it's "false" or "0", HTTP not HTTPS is used.
|
| 163 |
+
/// * credential_kind: One of "default", "anonymous", "workload_identity",
|
| 164 |
+
/// "environment" or "cli". If "default" is specified, it's
|
| 165 |
+
/// just ignored. If "anonymous" is specified,
|
| 166 |
+
/// AzureOptions::ConfigureAnonymousCredential() is called. If
|
| 167 |
+
/// "workload_identity" is specified,
|
| 168 |
+
/// AzureOptions::ConfigureWorkloadIdentityCredential() is called. If
|
| 169 |
+
/// "environment" is specified,
|
| 170 |
+
/// AzureOptions::ConfigureEnvironmentCredential() is called. If "cli" is
|
| 171 |
+
/// specified, AzureOptions::ConfigureCLICredential() is called.
|
| 172 |
+
/// * tenant_id: You must specify "client_id" and "client_secret"
|
| 173 |
+
/// too. AzureOptions::ConfigureClientSecretCredential() is called.
|
| 174 |
+
/// * client_id: If you don't specify "tenant_id" and
|
| 175 |
+
/// "client_secret",
|
| 176 |
+
/// AzureOptions::ConfigureManagedIdentityCredential() is
|
| 177 |
+
/// called. If you specify "tenant_id" and "client_secret" too,
|
| 178 |
+
/// AzureOptions::ConfigureClientSecretCredential() is called.
|
| 179 |
+
/// * client_secret: You must specify "tenant_id" and "client_id"
|
| 180 |
+
/// too. AzureOptions::ConfigureClientSecretCredential() is called.
|
| 181 |
+
/// * A SAS token is made up of several query parameters. Appending a SAS
|
| 182 |
+
/// token to the URI configures SAS token auth by calling
|
| 183 |
+
/// AzureOptions::ConfigureSASCredential().
|
| 184 |
+
///
|
| 185 |
+
/// [1]:
|
| 186 |
+
/// https://learn.microsoft.com/en-us/azure/storage/blobs/data-lake-storage-introduction-abfs-uri
|
| 187 |
+
static Result<AzureOptions> FromUri(const Uri& uri, std::string* out_path);
|
| 188 |
+
static Result<AzureOptions> FromUri(const std::string& uri, std::string* out_path);
|
| 189 |
+
|
| 190 |
+
Status ConfigureDefaultCredential();
|
| 191 |
+
Status ConfigureAnonymousCredential();
|
| 192 |
+
Status ConfigureAccountKeyCredential(const std::string& account_key);
|
| 193 |
+
Status ConfigureSASCredential(const std::string& sas_token);
|
| 194 |
+
Status ConfigureClientSecretCredential(const std::string& tenant_id,
|
| 195 |
+
const std::string& client_id,
|
| 196 |
+
const std::string& client_secret);
|
| 197 |
+
Status ConfigureManagedIdentityCredential(const std::string& client_id = std::string());
|
| 198 |
+
Status ConfigureCLICredential();
|
| 199 |
+
Status ConfigureWorkloadIdentityCredential();
|
| 200 |
+
Status ConfigureEnvironmentCredential();
|
| 201 |
+
|
| 202 |
+
bool Equals(const AzureOptions& other) const;
|
| 203 |
+
|
| 204 |
+
std::string AccountBlobUrl(const std::string& account_name) const;
|
| 205 |
+
std::string AccountDfsUrl(const std::string& account_name) const;
|
| 206 |
+
|
| 207 |
+
Result<std::unique_ptr<Azure::Storage::Blobs::BlobServiceClient>>
|
| 208 |
+
MakeBlobServiceClient() const;
|
| 209 |
+
|
| 210 |
+
Result<std::unique_ptr<Azure::Storage::Files::DataLake::DataLakeServiceClient>>
|
| 211 |
+
MakeDataLakeServiceClient() const;
|
| 212 |
+
};
|
| 213 |
+
|
| 214 |
+
/// \brief FileSystem implementation backed by Azure Blob Storage (ABS) [1] and
|
| 215 |
+
/// Azure Data Lake Storage Gen2 (ADLS Gen2) [2].
|
| 216 |
+
///
|
| 217 |
+
/// ADLS Gen2 isn't a dedicated service or account type. It's a set of capabilities that
|
| 218 |
+
/// support high throughput analytic workloads, built on Azure Blob Storage. All the data
|
| 219 |
+
/// ingested via the ADLS Gen2 APIs is persisted as blobs in the storage account.
|
| 220 |
+
/// ADLS Gen2 provides filesystem semantics, file-level security, and Hadoop
|
| 221 |
+
/// compatibility. ADLS Gen1 exists as a separate object that will retired on 2024-02-29
|
| 222 |
+
/// and new ADLS accounts use Gen2 instead.
|
| 223 |
+
///
|
| 224 |
+
/// ADLS Gen2 and Blob APIs can operate on the same data, but there are
|
| 225 |
+
/// some limitations [3]. The ones that are relevant to this
|
| 226 |
+
/// implementation are listed here:
|
| 227 |
+
///
|
| 228 |
+
/// - You can't use Blob APIs, and ADLS APIs to write to the same instance of a file. If
|
| 229 |
+
/// you write to a file by using ADLS APIs then that file's blocks won't be visible
|
| 230 |
+
/// to calls to the GetBlockList Blob API. The only exception is when you're
|
| 231 |
+
/// overwriting.
|
| 232 |
+
/// - When you use the ListBlobs operation without specifying a delimiter, the results
|
| 233 |
+
/// include both directories and blobs. If you choose to use a delimiter, use only a
|
| 234 |
+
/// forward slash (/) \--- the only supported delimiter.
|
| 235 |
+
/// - If you use the DeleteBlob API to delete a directory, that directory is deleted only
|
| 236 |
+
/// if it's empty. This means that you can't use the Blob API delete directories
|
| 237 |
+
/// recursively.
|
| 238 |
+
///
|
| 239 |
+
/// [1]: https://azure.microsoft.com/en-us/products/storage/blobs
|
| 240 |
+
/// [2]: https://azure.microsoft.com/en-us/products/storage/data-lake-storage
|
| 241 |
+
/// [3]:
|
| 242 |
+
/// https://learn.microsoft.com/en-us/azure/storage/blobs/data-lake-storage-known-issues
|
| 243 |
+
class ARROW_EXPORT AzureFileSystem : public FileSystem {
|
| 244 |
+
private:
|
| 245 |
+
class Impl;
|
| 246 |
+
std::unique_ptr<Impl> impl_;
|
| 247 |
+
|
| 248 |
+
explicit AzureFileSystem(std::unique_ptr<Impl>&& impl);
|
| 249 |
+
|
| 250 |
+
friend class TestAzureFileSystem;
|
| 251 |
+
void ForceCachedHierarchicalNamespaceSupport(int hns_support);
|
| 252 |
+
|
| 253 |
+
public:
|
| 254 |
+
~AzureFileSystem() override = default;
|
| 255 |
+
|
| 256 |
+
static Result<std::shared_ptr<AzureFileSystem>> Make(
|
| 257 |
+
const AzureOptions& options, const io::IOContext& = io::default_io_context());
|
| 258 |
+
|
| 259 |
+
std::string type_name() const override { return "abfs"; }
|
| 260 |
+
|
| 261 |
+
/// Return the original Azure options when constructing the filesystem
|
| 262 |
+
const AzureOptions& options() const;
|
| 263 |
+
|
| 264 |
+
bool Equals(const FileSystem& other) const override;
|
| 265 |
+
|
| 266 |
+
/// \cond FALSE
|
| 267 |
+
using FileSystem::CreateDir;
|
| 268 |
+
using FileSystem::DeleteDirContents;
|
| 269 |
+
using FileSystem::GetFileInfo;
|
| 270 |
+
using FileSystem::OpenAppendStream;
|
| 271 |
+
using FileSystem::OpenOutputStream;
|
| 272 |
+
/// \endcond
|
| 273 |
+
|
| 274 |
+
Result<FileInfo> GetFileInfo(const std::string& path) override;
|
| 275 |
+
|
| 276 |
+
Result<FileInfoVector> GetFileInfo(const FileSelector& select) override;
|
| 277 |
+
|
| 278 |
+
Status CreateDir(const std::string& path, bool recursive) override;
|
| 279 |
+
|
| 280 |
+
/// \brief Delete a directory and its contents recursively.
|
| 281 |
+
///
|
| 282 |
+
/// Atomicity is guaranteed only on Hierarchical Namespace Storage accounts.
|
| 283 |
+
Status DeleteDir(const std::string& path) override;
|
| 284 |
+
|
| 285 |
+
/// \brief Non-atomically deletes the contents of a directory.
|
| 286 |
+
///
|
| 287 |
+
/// This function can return a bad Status after only partially deleting the
|
| 288 |
+
/// contents of the directory.
|
| 289 |
+
Status DeleteDirContents(const std::string& path, bool missing_dir_ok) override;
|
| 290 |
+
|
| 291 |
+
/// \brief Deletion of all the containers in the storage account (not
|
| 292 |
+
/// implemented for safety reasons).
|
| 293 |
+
///
|
| 294 |
+
/// \return Status::NotImplemented
|
| 295 |
+
Status DeleteRootDirContents() override;
|
| 296 |
+
|
| 297 |
+
/// \brief Deletes a file.
|
| 298 |
+
///
|
| 299 |
+
/// Supported on both flat namespace and Hierarchical Namespace storage
|
| 300 |
+
/// accounts. A check is made to guarantee the parent directory doesn't
|
| 301 |
+
/// disappear after the blob is deleted and while this operation is running,
|
| 302 |
+
/// no other client can delete the parent directory due to the use of leases.
|
| 303 |
+
///
|
| 304 |
+
/// This means applications can safely retry this operation without coordination to
|
| 305 |
+
/// guarantee only one client/process is trying to delete the same file.
|
| 306 |
+
Status DeleteFile(const std::string& path) override;
|
| 307 |
+
|
| 308 |
+
/// \brief Move/rename a file or directory.
|
| 309 |
+
///
|
| 310 |
+
/// There are no files immediately at the root directory, so paths like
|
| 311 |
+
/// "/segment" always refer to a container of the storage account and are
|
| 312 |
+
/// treated as directories.
|
| 313 |
+
///
|
| 314 |
+
/// If `dest` exists but the operation fails for some reason, `Move`
|
| 315 |
+
/// guarantees `dest` is not lost.
|
| 316 |
+
///
|
| 317 |
+
/// Conditions for a successful move:
|
| 318 |
+
///
|
| 319 |
+
/// 1. `src` must exist.
|
| 320 |
+
/// 2. `dest` can't contain a strict path prefix of `src`. More generally,
|
| 321 |
+
/// a directory can't be made a subdirectory of itself.
|
| 322 |
+
/// 3. If `dest` already exists and it's a file, `src` must also be a file.
|
| 323 |
+
/// `dest` is then replaced by `src`.
|
| 324 |
+
/// 4. All components of `dest` must exist, except for the last.
|
| 325 |
+
/// 5. If `dest` already exists and it's a directory, `src` must also be a
|
| 326 |
+
/// directory and `dest` must be empty. `dest` is then replaced by `src`
|
| 327 |
+
/// and its contents.
|
| 328 |
+
///
|
| 329 |
+
/// Leases are used to guarantee the pre-condition checks and the rename
|
| 330 |
+
/// operation are atomic: other clients can't invalidate the pre-condition in
|
| 331 |
+
/// the time between the checks and the actual rename operation.
|
| 332 |
+
///
|
| 333 |
+
/// This is possible because Move() is only support on storage accounts with
|
| 334 |
+
/// Hierarchical Namespace Support enabled.
|
| 335 |
+
///
|
| 336 |
+
/// ## Limitations
|
| 337 |
+
///
|
| 338 |
+
/// - Moves are not supported on storage accounts without
|
| 339 |
+
/// Hierarchical Namespace support enabled
|
| 340 |
+
/// - Moves across different containers are not supported
|
| 341 |
+
/// - Moving a path of the form `/container` is not supported as it would
|
| 342 |
+
/// require moving all the files in a container to another container.
|
| 343 |
+
/// The only exception is a `Move("/container_a", "/container_b")` where
|
| 344 |
+
/// both containers are empty or `container_b` doesn't even exist.
|
| 345 |
+
/// The atomicity of the emptiness checks followed by the renaming operation
|
| 346 |
+
/// is guaranteed by the use of leases.
|
| 347 |
+
Status Move(const std::string& src, const std::string& dest) override;
|
| 348 |
+
|
| 349 |
+
Status CopyFile(const std::string& src, const std::string& dest) override;
|
| 350 |
+
|
| 351 |
+
Result<std::shared_ptr<io::InputStream>> OpenInputStream(
|
| 352 |
+
const std::string& path) override;
|
| 353 |
+
|
| 354 |
+
Result<std::shared_ptr<io::InputStream>> OpenInputStream(const FileInfo& info) override;
|
| 355 |
+
|
| 356 |
+
Result<std::shared_ptr<io::RandomAccessFile>> OpenInputFile(
|
| 357 |
+
const std::string& path) override;
|
| 358 |
+
|
| 359 |
+
Result<std::shared_ptr<io::RandomAccessFile>> OpenInputFile(
|
| 360 |
+
const FileInfo& info) override;
|
| 361 |
+
|
| 362 |
+
Result<std::shared_ptr<io::OutputStream>> OpenOutputStream(
|
| 363 |
+
const std::string& path,
|
| 364 |
+
const std::shared_ptr<const KeyValueMetadata>& metadata) override;
|
| 365 |
+
|
| 366 |
+
Result<std::shared_ptr<io::OutputStream>> OpenAppendStream(
|
| 367 |
+
const std::string& path,
|
| 368 |
+
const std::shared_ptr<const KeyValueMetadata>& metadata) override;
|
| 369 |
+
|
| 370 |
+
Result<std::string> PathFromUri(const std::string& uri_string) const override;
|
| 371 |
+
};
|
| 372 |
+
|
| 373 |
+
} // namespace arrow::fs
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/filesystem/filesystem.h
ADDED
|
@@ -0,0 +1,723 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 <chrono>
|
| 21 |
+
#include <cstdint>
|
| 22 |
+
#include <functional>
|
| 23 |
+
#include <iosfwd>
|
| 24 |
+
#include <memory>
|
| 25 |
+
#include <string>
|
| 26 |
+
#include <utility>
|
| 27 |
+
#include <vector>
|
| 28 |
+
|
| 29 |
+
#include "arrow/filesystem/type_fwd.h"
|
| 30 |
+
#include "arrow/io/interfaces.h"
|
| 31 |
+
#include "arrow/type_fwd.h"
|
| 32 |
+
#include "arrow/util/compare.h"
|
| 33 |
+
#include "arrow/util/macros.h"
|
| 34 |
+
#include "arrow/util/type_fwd.h"
|
| 35 |
+
#include "arrow/util/visibility.h"
|
| 36 |
+
#include "arrow/util/windows_fixup.h"
|
| 37 |
+
|
| 38 |
+
namespace arrow {
|
| 39 |
+
namespace fs {
|
| 40 |
+
|
| 41 |
+
using arrow::util::Uri;
|
| 42 |
+
|
| 43 |
+
// A system clock time point expressed as a 64-bit (or more) number of
|
| 44 |
+
// nanoseconds since the epoch.
|
| 45 |
+
using TimePoint =
|
| 46 |
+
std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds>;
|
| 47 |
+
|
| 48 |
+
ARROW_EXPORT std::string ToString(FileType);
|
| 49 |
+
|
| 50 |
+
ARROW_EXPORT std::ostream& operator<<(std::ostream& os, FileType);
|
| 51 |
+
|
| 52 |
+
static const int64_t kNoSize = -1;
|
| 53 |
+
static const TimePoint kNoTime = TimePoint(TimePoint::duration(-1));
|
| 54 |
+
|
| 55 |
+
/// \brief FileSystem entry info
|
| 56 |
+
struct ARROW_EXPORT FileInfo : public util::EqualityComparable<FileInfo> {
|
| 57 |
+
FileInfo() = default;
|
| 58 |
+
FileInfo(FileInfo&&) = default;
|
| 59 |
+
FileInfo& operator=(FileInfo&&) = default;
|
| 60 |
+
FileInfo(const FileInfo&) = default;
|
| 61 |
+
FileInfo& operator=(const FileInfo&) = default;
|
| 62 |
+
|
| 63 |
+
explicit FileInfo(std::string path, FileType type = FileType::Unknown)
|
| 64 |
+
: path_(std::move(path)), type_(type) {}
|
| 65 |
+
|
| 66 |
+
/// The file type
|
| 67 |
+
FileType type() const { return type_; }
|
| 68 |
+
void set_type(FileType type) { type_ = type; }
|
| 69 |
+
|
| 70 |
+
/// The full file path in the filesystem
|
| 71 |
+
const std::string& path() const { return path_; }
|
| 72 |
+
void set_path(std::string path) { path_ = std::move(path); }
|
| 73 |
+
|
| 74 |
+
/// The file base name (component after the last directory separator)
|
| 75 |
+
std::string base_name() const;
|
| 76 |
+
|
| 77 |
+
// The directory base name (component before the file base name).
|
| 78 |
+
std::string dir_name() const;
|
| 79 |
+
|
| 80 |
+
/// The size in bytes, if available
|
| 81 |
+
///
|
| 82 |
+
/// Only regular files are guaranteed to have a size.
|
| 83 |
+
int64_t size() const { return size_; }
|
| 84 |
+
void set_size(int64_t size) { size_ = size; }
|
| 85 |
+
|
| 86 |
+
/// The file extension (excluding the dot)
|
| 87 |
+
std::string extension() const;
|
| 88 |
+
|
| 89 |
+
/// The time of last modification, if available
|
| 90 |
+
TimePoint mtime() const { return mtime_; }
|
| 91 |
+
void set_mtime(TimePoint mtime) { mtime_ = mtime; }
|
| 92 |
+
|
| 93 |
+
bool IsFile() const { return type_ == FileType::File; }
|
| 94 |
+
bool IsDirectory() const { return type_ == FileType::Directory; }
|
| 95 |
+
|
| 96 |
+
bool Equals(const FileInfo& other) const {
|
| 97 |
+
return type() == other.type() && path() == other.path() && size() == other.size() &&
|
| 98 |
+
mtime() == other.mtime();
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
std::string ToString() const;
|
| 102 |
+
|
| 103 |
+
/// Function object implementing less-than comparison and hashing by
|
| 104 |
+
/// path, to support sorting infos, using them as keys, and other
|
| 105 |
+
/// interactions with the STL.
|
| 106 |
+
struct ByPath {
|
| 107 |
+
bool operator()(const FileInfo& l, const FileInfo& r) const {
|
| 108 |
+
return l.path() < r.path();
|
| 109 |
+
}
|
| 110 |
+
|
| 111 |
+
size_t operator()(const FileInfo& i) const {
|
| 112 |
+
return std::hash<std::string>{}(i.path());
|
| 113 |
+
}
|
| 114 |
+
};
|
| 115 |
+
|
| 116 |
+
protected:
|
| 117 |
+
std::string path_;
|
| 118 |
+
FileType type_ = FileType::Unknown;
|
| 119 |
+
int64_t size_ = kNoSize;
|
| 120 |
+
TimePoint mtime_ = kNoTime;
|
| 121 |
+
};
|
| 122 |
+
|
| 123 |
+
ARROW_EXPORT std::ostream& operator<<(std::ostream& os, const FileInfo&);
|
| 124 |
+
|
| 125 |
+
/// \brief File selector for filesystem APIs
|
| 126 |
+
struct ARROW_EXPORT FileSelector {
|
| 127 |
+
/// The directory in which to select files.
|
| 128 |
+
/// If the path exists but doesn't point to a directory, this should be an error.
|
| 129 |
+
std::string base_dir;
|
| 130 |
+
/// The behavior if `base_dir` isn't found in the filesystem. If false,
|
| 131 |
+
/// an error is returned. If true, an empty selection is returned.
|
| 132 |
+
bool allow_not_found;
|
| 133 |
+
/// Whether to recurse into subdirectories.
|
| 134 |
+
bool recursive;
|
| 135 |
+
/// The maximum number of subdirectories to recurse into.
|
| 136 |
+
int32_t max_recursion;
|
| 137 |
+
|
| 138 |
+
FileSelector() : allow_not_found(false), recursive(false), max_recursion(INT32_MAX) {}
|
| 139 |
+
};
|
| 140 |
+
|
| 141 |
+
/// \brief FileSystem, path pair
|
| 142 |
+
struct ARROW_EXPORT FileLocator {
|
| 143 |
+
std::shared_ptr<FileSystem> filesystem;
|
| 144 |
+
std::string path;
|
| 145 |
+
};
|
| 146 |
+
|
| 147 |
+
using FileInfoVector = std::vector<FileInfo>;
|
| 148 |
+
using FileInfoGenerator = std::function<Future<FileInfoVector>()>;
|
| 149 |
+
|
| 150 |
+
} // namespace fs
|
| 151 |
+
|
| 152 |
+
template <>
|
| 153 |
+
struct IterationTraits<fs::FileInfoVector> {
|
| 154 |
+
static fs::FileInfoVector End() { return {}; }
|
| 155 |
+
static bool IsEnd(const fs::FileInfoVector& val) { return val.empty(); }
|
| 156 |
+
};
|
| 157 |
+
|
| 158 |
+
namespace fs {
|
| 159 |
+
|
| 160 |
+
/// \brief Abstract file system API
|
| 161 |
+
class ARROW_EXPORT FileSystem
|
| 162 |
+
/// \cond false
|
| 163 |
+
: public std::enable_shared_from_this<FileSystem>
|
| 164 |
+
/// \endcond
|
| 165 |
+
{ // NOLINT
|
| 166 |
+
public:
|
| 167 |
+
virtual ~FileSystem();
|
| 168 |
+
|
| 169 |
+
virtual std::string type_name() const = 0;
|
| 170 |
+
|
| 171 |
+
/// EXPERIMENTAL: The IOContext associated with this filesystem.
|
| 172 |
+
const io::IOContext& io_context() const { return io_context_; }
|
| 173 |
+
|
| 174 |
+
/// Normalize path for the given filesystem
|
| 175 |
+
///
|
| 176 |
+
/// The default implementation of this method is a no-op, but subclasses
|
| 177 |
+
/// may allow normalizing irregular path forms (such as Windows local paths).
|
| 178 |
+
virtual Result<std::string> NormalizePath(std::string path);
|
| 179 |
+
|
| 180 |
+
/// \brief Ensure a URI (or path) is compatible with the given filesystem and return the
|
| 181 |
+
/// path
|
| 182 |
+
///
|
| 183 |
+
/// \param uri_string A URI representing a resource in the given filesystem.
|
| 184 |
+
///
|
| 185 |
+
/// This method will check to ensure the given filesystem is compatible with the
|
| 186 |
+
/// URI. This can be useful when the user provides both a URI and a filesystem or
|
| 187 |
+
/// when a user provides multiple URIs that should be compatible with the same
|
| 188 |
+
/// filesystem.
|
| 189 |
+
///
|
| 190 |
+
/// uri_string can be an absolute path instead of a URI. In that case it will ensure
|
| 191 |
+
/// the filesystem (if supplied) is the local filesystem (or some custom filesystem that
|
| 192 |
+
/// is capable of reading local paths) and will normalize the path's file separators.
|
| 193 |
+
///
|
| 194 |
+
/// Note, this method only checks to ensure the URI scheme is valid. It will not detect
|
| 195 |
+
/// inconsistencies like a mismatching region or endpoint override.
|
| 196 |
+
///
|
| 197 |
+
/// \return The path inside the filesystem that is indicated by the URI.
|
| 198 |
+
virtual Result<std::string> PathFromUri(const std::string& uri_string) const;
|
| 199 |
+
|
| 200 |
+
/// \brief Make a URI from which FileSystemFromUri produces an equivalent filesystem
|
| 201 |
+
/// \param path The path component to use in the resulting URI. Must be absolute.
|
| 202 |
+
/// \return A URI string, or an error if an equivalent URI cannot be produced
|
| 203 |
+
virtual Result<std::string> MakeUri(std::string path) const;
|
| 204 |
+
|
| 205 |
+
virtual bool Equals(const FileSystem& other) const = 0;
|
| 206 |
+
|
| 207 |
+
virtual bool Equals(const std::shared_ptr<FileSystem>& other) const {
|
| 208 |
+
return Equals(*other);
|
| 209 |
+
}
|
| 210 |
+
|
| 211 |
+
/// Get info for the given target.
|
| 212 |
+
///
|
| 213 |
+
/// Any symlink is automatically dereferenced, recursively.
|
| 214 |
+
/// A nonexistent or unreachable file returns an Ok status and
|
| 215 |
+
/// has a FileType of value NotFound. An error status indicates
|
| 216 |
+
/// a truly exceptional condition (low-level I/O error, etc.).
|
| 217 |
+
virtual Result<FileInfo> GetFileInfo(const std::string& path) = 0;
|
| 218 |
+
/// Same, for many targets at once.
|
| 219 |
+
virtual Result<FileInfoVector> GetFileInfo(const std::vector<std::string>& paths);
|
| 220 |
+
/// Same, according to a selector.
|
| 221 |
+
///
|
| 222 |
+
/// The selector's base directory will not be part of the results, even if
|
| 223 |
+
/// it exists.
|
| 224 |
+
/// If it doesn't exist, see `FileSelector::allow_not_found`.
|
| 225 |
+
virtual Result<FileInfoVector> GetFileInfo(const FileSelector& select) = 0;
|
| 226 |
+
|
| 227 |
+
/// Async version of GetFileInfo
|
| 228 |
+
virtual Future<FileInfoVector> GetFileInfoAsync(const std::vector<std::string>& paths);
|
| 229 |
+
|
| 230 |
+
/// Streaming async version of GetFileInfo
|
| 231 |
+
///
|
| 232 |
+
/// The returned generator is not async-reentrant, i.e. you need to wait for
|
| 233 |
+
/// the returned future to complete before calling the generator again.
|
| 234 |
+
virtual FileInfoGenerator GetFileInfoGenerator(const FileSelector& select);
|
| 235 |
+
|
| 236 |
+
/// Create a directory and subdirectories.
|
| 237 |
+
///
|
| 238 |
+
/// This function succeeds if the directory already exists.
|
| 239 |
+
virtual Status CreateDir(const std::string& path, bool recursive) = 0;
|
| 240 |
+
Status CreateDir(const std::string& path) { return CreateDir(path, true); }
|
| 241 |
+
|
| 242 |
+
/// Delete a directory and its contents, recursively.
|
| 243 |
+
virtual Status DeleteDir(const std::string& path) = 0;
|
| 244 |
+
|
| 245 |
+
/// Delete a directory's contents, recursively.
|
| 246 |
+
///
|
| 247 |
+
/// Like DeleteDir, but doesn't delete the directory itself.
|
| 248 |
+
/// Passing an empty path ("" or "/") is disallowed, see DeleteRootDirContents.
|
| 249 |
+
virtual Status DeleteDirContents(const std::string& path, bool missing_dir_ok) = 0;
|
| 250 |
+
Status DeleteDirContents(const std::string& path) {
|
| 251 |
+
return DeleteDirContents(path, false);
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
/// Async version of DeleteDirContents.
|
| 255 |
+
virtual Future<> DeleteDirContentsAsync(const std::string& path, bool missing_dir_ok);
|
| 256 |
+
|
| 257 |
+
/// Async version of DeleteDirContents.
|
| 258 |
+
///
|
| 259 |
+
/// This overload allows missing directories.
|
| 260 |
+
Future<> DeleteDirContentsAsync(const std::string& path);
|
| 261 |
+
|
| 262 |
+
/// EXPERIMENTAL: Delete the root directory's contents, recursively.
|
| 263 |
+
///
|
| 264 |
+
/// Implementations may decide to raise an error if this operation is
|
| 265 |
+
/// too dangerous.
|
| 266 |
+
// NOTE: may decide to remove this if it's deemed not useful
|
| 267 |
+
virtual Status DeleteRootDirContents() = 0;
|
| 268 |
+
|
| 269 |
+
/// Delete a file.
|
| 270 |
+
virtual Status DeleteFile(const std::string& path) = 0;
|
| 271 |
+
/// Delete many files.
|
| 272 |
+
///
|
| 273 |
+
/// The default implementation issues individual delete operations in sequence.
|
| 274 |
+
virtual Status DeleteFiles(const std::vector<std::string>& paths);
|
| 275 |
+
|
| 276 |
+
/// Move / rename a file or directory.
|
| 277 |
+
///
|
| 278 |
+
/// If the destination exists:
|
| 279 |
+
/// - if it is a non-empty directory, an error is returned
|
| 280 |
+
/// - otherwise, if it has the same type as the source, it is replaced
|
| 281 |
+
/// - otherwise, behavior is unspecified (implementation-dependent).
|
| 282 |
+
virtual Status Move(const std::string& src, const std::string& dest) = 0;
|
| 283 |
+
|
| 284 |
+
/// Copy a file.
|
| 285 |
+
///
|
| 286 |
+
/// If the destination exists and is a directory, an error is returned.
|
| 287 |
+
/// Otherwise, it is replaced.
|
| 288 |
+
virtual Status CopyFile(const std::string& src, const std::string& dest) = 0;
|
| 289 |
+
|
| 290 |
+
/// Open an input stream for sequential reading.
|
| 291 |
+
virtual Result<std::shared_ptr<io::InputStream>> OpenInputStream(
|
| 292 |
+
const std::string& path) = 0;
|
| 293 |
+
|
| 294 |
+
/// Open an input stream for sequential reading.
|
| 295 |
+
///
|
| 296 |
+
/// This override assumes the given FileInfo validly represents the file's
|
| 297 |
+
/// characteristics, and may optimize access depending on them (for example
|
| 298 |
+
/// avoid querying the file size or its existence).
|
| 299 |
+
virtual Result<std::shared_ptr<io::InputStream>> OpenInputStream(const FileInfo& info);
|
| 300 |
+
|
| 301 |
+
/// Open an input file for random access reading.
|
| 302 |
+
virtual Result<std::shared_ptr<io::RandomAccessFile>> OpenInputFile(
|
| 303 |
+
const std::string& path) = 0;
|
| 304 |
+
|
| 305 |
+
/// Open an input file for random access reading.
|
| 306 |
+
///
|
| 307 |
+
/// This override assumes the given FileInfo validly represents the file's
|
| 308 |
+
/// characteristics, and may optimize access depending on them (for example
|
| 309 |
+
/// avoid querying the file size or its existence).
|
| 310 |
+
virtual Result<std::shared_ptr<io::RandomAccessFile>> OpenInputFile(
|
| 311 |
+
const FileInfo& info);
|
| 312 |
+
|
| 313 |
+
/// Async version of OpenInputStream
|
| 314 |
+
virtual Future<std::shared_ptr<io::InputStream>> OpenInputStreamAsync(
|
| 315 |
+
const std::string& path);
|
| 316 |
+
|
| 317 |
+
/// Async version of OpenInputStream
|
| 318 |
+
virtual Future<std::shared_ptr<io::InputStream>> OpenInputStreamAsync(
|
| 319 |
+
const FileInfo& info);
|
| 320 |
+
|
| 321 |
+
/// Async version of OpenInputFile
|
| 322 |
+
virtual Future<std::shared_ptr<io::RandomAccessFile>> OpenInputFileAsync(
|
| 323 |
+
const std::string& path);
|
| 324 |
+
|
| 325 |
+
/// Async version of OpenInputFile
|
| 326 |
+
virtual Future<std::shared_ptr<io::RandomAccessFile>> OpenInputFileAsync(
|
| 327 |
+
const FileInfo& info);
|
| 328 |
+
|
| 329 |
+
/// Open an output stream for sequential writing.
|
| 330 |
+
///
|
| 331 |
+
/// If the target already exists, existing data is truncated.
|
| 332 |
+
virtual Result<std::shared_ptr<io::OutputStream>> OpenOutputStream(
|
| 333 |
+
const std::string& path,
|
| 334 |
+
const std::shared_ptr<const KeyValueMetadata>& metadata) = 0;
|
| 335 |
+
Result<std::shared_ptr<io::OutputStream>> OpenOutputStream(const std::string& path);
|
| 336 |
+
|
| 337 |
+
/// Open an output stream for appending.
|
| 338 |
+
///
|
| 339 |
+
/// If the target doesn't exist, a new empty file is created.
|
| 340 |
+
///
|
| 341 |
+
/// Note: some filesystem implementations do not support efficient appending
|
| 342 |
+
/// to an existing file, in which case this method will return NotImplemented.
|
| 343 |
+
/// Consider writing to multiple files (using e.g. the dataset layer) instead.
|
| 344 |
+
virtual Result<std::shared_ptr<io::OutputStream>> OpenAppendStream(
|
| 345 |
+
const std::string& path,
|
| 346 |
+
const std::shared_ptr<const KeyValueMetadata>& metadata) = 0;
|
| 347 |
+
Result<std::shared_ptr<io::OutputStream>> OpenAppendStream(const std::string& path);
|
| 348 |
+
|
| 349 |
+
protected:
|
| 350 |
+
explicit FileSystem(io::IOContext io_context = io::default_io_context())
|
| 351 |
+
: io_context_(std::move(io_context)) {}
|
| 352 |
+
|
| 353 |
+
io::IOContext io_context_;
|
| 354 |
+
// Whether metadata operations (such as GetFileInfo or OpenInputStream)
|
| 355 |
+
// are cheap enough that the default async variants don't bother with
|
| 356 |
+
// a thread pool.
|
| 357 |
+
bool default_async_is_sync_ = true;
|
| 358 |
+
};
|
| 359 |
+
|
| 360 |
+
struct FileSystemFactory {
|
| 361 |
+
std::function<Result<std::shared_ptr<FileSystem>>(
|
| 362 |
+
const Uri& uri, const io::IOContext& io_context, std::string* out_path)>
|
| 363 |
+
function;
|
| 364 |
+
std::string_view file;
|
| 365 |
+
int line;
|
| 366 |
+
|
| 367 |
+
bool operator==(const FileSystemFactory& other) const {
|
| 368 |
+
// In the case where libarrow is linked statically both to the executable and to a
|
| 369 |
+
// dynamically loaded filesystem implementation library, the library contains a
|
| 370 |
+
// duplicate definition of the registry and duplicate definitions of any
|
| 371 |
+
// FileSystemRegistrars which are statically linked to libarrow. When retrieving
|
| 372 |
+
// factories from the filesystem implementation library, we use the file and line
|
| 373 |
+
// of the registrar's definition to determine equivalence of the duplicate factories.
|
| 374 |
+
return file == other.file && line == other.line;
|
| 375 |
+
}
|
| 376 |
+
};
|
| 377 |
+
|
| 378 |
+
/// \brief A FileSystem implementation that delegates to another
|
| 379 |
+
/// implementation after prepending a fixed base path.
|
| 380 |
+
///
|
| 381 |
+
/// This is useful to expose a logical view of a subtree of a filesystem,
|
| 382 |
+
/// for example a directory in a LocalFileSystem.
|
| 383 |
+
/// This works on abstract paths, i.e. paths using forward slashes and
|
| 384 |
+
/// and a single root "/". Windows paths are not guaranteed to work.
|
| 385 |
+
/// This makes no security guarantee. For example, symlinks may allow to
|
| 386 |
+
/// "escape" the subtree and access other parts of the underlying filesystem.
|
| 387 |
+
class ARROW_EXPORT SubTreeFileSystem : public FileSystem {
|
| 388 |
+
public:
|
| 389 |
+
// This constructor may abort if base_path is invalid.
|
| 390 |
+
explicit SubTreeFileSystem(const std::string& base_path,
|
| 391 |
+
std::shared_ptr<FileSystem> base_fs);
|
| 392 |
+
~SubTreeFileSystem() override;
|
| 393 |
+
|
| 394 |
+
std::string type_name() const override { return "subtree"; }
|
| 395 |
+
std::string base_path() const { return base_path_; }
|
| 396 |
+
std::shared_ptr<FileSystem> base_fs() const { return base_fs_; }
|
| 397 |
+
|
| 398 |
+
Result<std::string> NormalizePath(std::string path) override;
|
| 399 |
+
Result<std::string> PathFromUri(const std::string& uri_string) const override;
|
| 400 |
+
|
| 401 |
+
bool Equals(const FileSystem& other) const override;
|
| 402 |
+
|
| 403 |
+
/// \cond FALSE
|
| 404 |
+
using FileSystem::CreateDir;
|
| 405 |
+
using FileSystem::DeleteDirContents;
|
| 406 |
+
using FileSystem::GetFileInfo;
|
| 407 |
+
using FileSystem::OpenAppendStream;
|
| 408 |
+
using FileSystem::OpenOutputStream;
|
| 409 |
+
/// \endcond
|
| 410 |
+
|
| 411 |
+
Result<FileInfo> GetFileInfo(const std::string& path) override;
|
| 412 |
+
Result<FileInfoVector> GetFileInfo(const FileSelector& select) override;
|
| 413 |
+
|
| 414 |
+
FileInfoGenerator GetFileInfoGenerator(const FileSelector& select) override;
|
| 415 |
+
|
| 416 |
+
Status CreateDir(const std::string& path, bool recursive) override;
|
| 417 |
+
|
| 418 |
+
Status DeleteDir(const std::string& path) override;
|
| 419 |
+
Status DeleteDirContents(const std::string& path, bool missing_dir_ok) override;
|
| 420 |
+
Status DeleteRootDirContents() override;
|
| 421 |
+
|
| 422 |
+
Status DeleteFile(const std::string& path) override;
|
| 423 |
+
|
| 424 |
+
Status Move(const std::string& src, const std::string& dest) override;
|
| 425 |
+
|
| 426 |
+
Status CopyFile(const std::string& src, const std::string& dest) override;
|
| 427 |
+
|
| 428 |
+
Result<std::shared_ptr<io::InputStream>> OpenInputStream(
|
| 429 |
+
const std::string& path) override;
|
| 430 |
+
Result<std::shared_ptr<io::InputStream>> OpenInputStream(const FileInfo& info) override;
|
| 431 |
+
Result<std::shared_ptr<io::RandomAccessFile>> OpenInputFile(
|
| 432 |
+
const std::string& path) override;
|
| 433 |
+
Result<std::shared_ptr<io::RandomAccessFile>> OpenInputFile(
|
| 434 |
+
const FileInfo& info) override;
|
| 435 |
+
|
| 436 |
+
Future<std::shared_ptr<io::InputStream>> OpenInputStreamAsync(
|
| 437 |
+
const std::string& path) override;
|
| 438 |
+
Future<std::shared_ptr<io::InputStream>> OpenInputStreamAsync(
|
| 439 |
+
const FileInfo& info) override;
|
| 440 |
+
Future<std::shared_ptr<io::RandomAccessFile>> OpenInputFileAsync(
|
| 441 |
+
const std::string& path) override;
|
| 442 |
+
Future<std::shared_ptr<io::RandomAccessFile>> OpenInputFileAsync(
|
| 443 |
+
const FileInfo& info) override;
|
| 444 |
+
|
| 445 |
+
Result<std::shared_ptr<io::OutputStream>> OpenOutputStream(
|
| 446 |
+
const std::string& path,
|
| 447 |
+
const std::shared_ptr<const KeyValueMetadata>& metadata) override;
|
| 448 |
+
Result<std::shared_ptr<io::OutputStream>> OpenAppendStream(
|
| 449 |
+
const std::string& path,
|
| 450 |
+
const std::shared_ptr<const KeyValueMetadata>& metadata) override;
|
| 451 |
+
|
| 452 |
+
protected:
|
| 453 |
+
SubTreeFileSystem() = default;
|
| 454 |
+
|
| 455 |
+
const std::string base_path_;
|
| 456 |
+
std::shared_ptr<FileSystem> base_fs_;
|
| 457 |
+
|
| 458 |
+
Result<std::string> PrependBase(const std::string& s) const;
|
| 459 |
+
Result<std::string> PrependBaseNonEmpty(const std::string& s) const;
|
| 460 |
+
Result<std::string> StripBase(const std::string& s) const;
|
| 461 |
+
Status FixInfo(FileInfo* info) const;
|
| 462 |
+
|
| 463 |
+
static Result<std::string> NormalizeBasePath(
|
| 464 |
+
std::string base_path, const std::shared_ptr<FileSystem>& base_fs);
|
| 465 |
+
};
|
| 466 |
+
|
| 467 |
+
/// \brief A FileSystem implementation that delegates to another
|
| 468 |
+
/// implementation but inserts latencies at various points.
|
| 469 |
+
class ARROW_EXPORT SlowFileSystem : public FileSystem {
|
| 470 |
+
public:
|
| 471 |
+
SlowFileSystem(std::shared_ptr<FileSystem> base_fs,
|
| 472 |
+
std::shared_ptr<io::LatencyGenerator> latencies);
|
| 473 |
+
SlowFileSystem(std::shared_ptr<FileSystem> base_fs, double average_latency);
|
| 474 |
+
SlowFileSystem(std::shared_ptr<FileSystem> base_fs, double average_latency,
|
| 475 |
+
int32_t seed);
|
| 476 |
+
|
| 477 |
+
std::string type_name() const override { return "slow"; }
|
| 478 |
+
bool Equals(const FileSystem& other) const override;
|
| 479 |
+
Result<std::string> PathFromUri(const std::string& uri_string) const override;
|
| 480 |
+
|
| 481 |
+
/// \cond FALSE
|
| 482 |
+
using FileSystem::CreateDir;
|
| 483 |
+
using FileSystem::DeleteDirContents;
|
| 484 |
+
using FileSystem::GetFileInfo;
|
| 485 |
+
using FileSystem::OpenAppendStream;
|
| 486 |
+
using FileSystem::OpenOutputStream;
|
| 487 |
+
/// \endcond
|
| 488 |
+
|
| 489 |
+
Result<FileInfo> GetFileInfo(const std::string& path) override;
|
| 490 |
+
Result<FileInfoVector> GetFileInfo(const FileSelector& select) override;
|
| 491 |
+
|
| 492 |
+
Status CreateDir(const std::string& path, bool recursive) override;
|
| 493 |
+
|
| 494 |
+
Status DeleteDir(const std::string& path) override;
|
| 495 |
+
Status DeleteDirContents(const std::string& path, bool missing_dir_ok) override;
|
| 496 |
+
Status DeleteRootDirContents() override;
|
| 497 |
+
|
| 498 |
+
Status DeleteFile(const std::string& path) override;
|
| 499 |
+
|
| 500 |
+
Status Move(const std::string& src, const std::string& dest) override;
|
| 501 |
+
|
| 502 |
+
Status CopyFile(const std::string& src, const std::string& dest) override;
|
| 503 |
+
|
| 504 |
+
Result<std::shared_ptr<io::InputStream>> OpenInputStream(
|
| 505 |
+
const std::string& path) override;
|
| 506 |
+
Result<std::shared_ptr<io::InputStream>> OpenInputStream(const FileInfo& info) override;
|
| 507 |
+
Result<std::shared_ptr<io::RandomAccessFile>> OpenInputFile(
|
| 508 |
+
const std::string& path) override;
|
| 509 |
+
Result<std::shared_ptr<io::RandomAccessFile>> OpenInputFile(
|
| 510 |
+
const FileInfo& info) override;
|
| 511 |
+
Result<std::shared_ptr<io::OutputStream>> OpenOutputStream(
|
| 512 |
+
const std::string& path,
|
| 513 |
+
const std::shared_ptr<const KeyValueMetadata>& metadata) override;
|
| 514 |
+
Result<std::shared_ptr<io::OutputStream>> OpenAppendStream(
|
| 515 |
+
const std::string& path,
|
| 516 |
+
const std::shared_ptr<const KeyValueMetadata>& metadata) override;
|
| 517 |
+
|
| 518 |
+
protected:
|
| 519 |
+
std::shared_ptr<FileSystem> base_fs_;
|
| 520 |
+
std::shared_ptr<io::LatencyGenerator> latencies_;
|
| 521 |
+
};
|
| 522 |
+
|
| 523 |
+
/// \brief Ensure all registered filesystem implementations are finalized.
|
| 524 |
+
///
|
| 525 |
+
/// Individual finalizers may wait for concurrent calls to finish so as to avoid
|
| 526 |
+
/// race conditions. After this function has been called, all filesystem APIs
|
| 527 |
+
/// will fail with an error.
|
| 528 |
+
///
|
| 529 |
+
/// The user is responsible for synchronization of calls to this function.
|
| 530 |
+
void EnsureFinalized();
|
| 531 |
+
|
| 532 |
+
/// \defgroup filesystem-factories Functions for creating FileSystem instances
|
| 533 |
+
///
|
| 534 |
+
/// @{
|
| 535 |
+
|
| 536 |
+
/// \brief Create a new FileSystem by URI
|
| 537 |
+
///
|
| 538 |
+
/// Recognized schemes are "file", "mock", "hdfs", "viewfs", "s3",
|
| 539 |
+
/// "gs" and "gcs".
|
| 540 |
+
///
|
| 541 |
+
/// Support for other schemes can be added using RegisterFileSystemFactory.
|
| 542 |
+
///
|
| 543 |
+
/// \param[in] uri a URI-based path, ex: file:///some/local/path
|
| 544 |
+
/// \param[out] out_path (optional) Path inside the filesystem.
|
| 545 |
+
/// \return out_fs FileSystem instance.
|
| 546 |
+
ARROW_EXPORT
|
| 547 |
+
Result<std::shared_ptr<FileSystem>> FileSystemFromUri(const std::string& uri,
|
| 548 |
+
std::string* out_path = NULLPTR);
|
| 549 |
+
|
| 550 |
+
/// \brief Create a new FileSystem by URI with a custom IO context
|
| 551 |
+
///
|
| 552 |
+
/// Recognized schemes are "file", "mock", "hdfs", "viewfs", "s3",
|
| 553 |
+
/// "gs" and "gcs".
|
| 554 |
+
///
|
| 555 |
+
/// Support for other schemes can be added using RegisterFileSystemFactory.
|
| 556 |
+
///
|
| 557 |
+
/// \param[in] uri a URI-based path, ex: file:///some/local/path
|
| 558 |
+
/// \param[in] io_context an IOContext which will be associated with the filesystem
|
| 559 |
+
/// \param[out] out_path (optional) Path inside the filesystem.
|
| 560 |
+
/// \return out_fs FileSystem instance.
|
| 561 |
+
ARROW_EXPORT
|
| 562 |
+
Result<std::shared_ptr<FileSystem>> FileSystemFromUri(const std::string& uri,
|
| 563 |
+
const io::IOContext& io_context,
|
| 564 |
+
std::string* out_path = NULLPTR);
|
| 565 |
+
|
| 566 |
+
/// \brief Create a new FileSystem by URI
|
| 567 |
+
///
|
| 568 |
+
/// Support for other schemes can be added using RegisterFileSystemFactory.
|
| 569 |
+
///
|
| 570 |
+
/// Same as FileSystemFromUri, but in addition also recognize non-URIs
|
| 571 |
+
/// and treat them as local filesystem paths. Only absolute local filesystem
|
| 572 |
+
/// paths are allowed.
|
| 573 |
+
ARROW_EXPORT
|
| 574 |
+
Result<std::shared_ptr<FileSystem>> FileSystemFromUriOrPath(
|
| 575 |
+
const std::string& uri, std::string* out_path = NULLPTR);
|
| 576 |
+
|
| 577 |
+
/// \brief Create a new FileSystem by URI with a custom IO context
|
| 578 |
+
///
|
| 579 |
+
/// Support for other schemes can be added using RegisterFileSystemFactory.
|
| 580 |
+
///
|
| 581 |
+
/// Same as FileSystemFromUri, but in addition also recognize non-URIs
|
| 582 |
+
/// and treat them as local filesystem paths. Only absolute local filesystem
|
| 583 |
+
/// paths are allowed.
|
| 584 |
+
ARROW_EXPORT
|
| 585 |
+
Result<std::shared_ptr<FileSystem>> FileSystemFromUriOrPath(
|
| 586 |
+
const std::string& uri, const io::IOContext& io_context,
|
| 587 |
+
std::string* out_path = NULLPTR);
|
| 588 |
+
|
| 589 |
+
/// @}
|
| 590 |
+
|
| 591 |
+
/// \defgroup filesystem-factory-registration Helpers for FileSystem registration
|
| 592 |
+
///
|
| 593 |
+
/// @{
|
| 594 |
+
|
| 595 |
+
/// \brief Register a FileSystem factory
|
| 596 |
+
///
|
| 597 |
+
/// Support for custom URI schemes can be added by registering a factory
|
| 598 |
+
/// for the corresponding FileSystem.
|
| 599 |
+
///
|
| 600 |
+
/// \param[in] scheme a Uri scheme which the factory will handle.
|
| 601 |
+
/// If a factory has already been registered for a scheme,
|
| 602 |
+
/// the new factory will be ignored.
|
| 603 |
+
/// \param[in] factory a function which can produce a FileSystem for Uris which match
|
| 604 |
+
/// scheme.
|
| 605 |
+
/// \param[in] finalizer a function which must be called to finalize the factory before
|
| 606 |
+
/// the process exits, or nullptr if no finalization is necessary.
|
| 607 |
+
/// \return raises KeyError if a name collision occurs.
|
| 608 |
+
ARROW_EXPORT Status RegisterFileSystemFactory(std::string scheme,
|
| 609 |
+
FileSystemFactory factory,
|
| 610 |
+
std::function<void()> finalizer = {});
|
| 611 |
+
|
| 612 |
+
/// \brief Register FileSystem factories from a shared library
|
| 613 |
+
///
|
| 614 |
+
/// FileSystem implementations may be housed in separate shared libraries and only
|
| 615 |
+
/// registered when the shared library is explicitly loaded. FileSystemRegistrar is
|
| 616 |
+
/// provided to simplify definition of such libraries: each instance at namespace scope
|
| 617 |
+
/// in the library will register a factory for a scheme. Any library which uses
|
| 618 |
+
/// FileSystemRegistrars and which must be dynamically loaded should be loaded using
|
| 619 |
+
/// LoadFileSystemFactories(), which will additionally merge registries are if necessary
|
| 620 |
+
/// (static linkage to arrow can produce isolated registries).
|
| 621 |
+
ARROW_EXPORT Status LoadFileSystemFactories(const char* libpath);
|
| 622 |
+
|
| 623 |
+
struct ARROW_EXPORT FileSystemRegistrar {
|
| 624 |
+
/// \brief Register a FileSystem factory at load time
|
| 625 |
+
///
|
| 626 |
+
/// Support for custom URI schemes can be added by registering a factory for the
|
| 627 |
+
/// corresponding FileSystem. An instance of this helper can be defined at namespace
|
| 628 |
+
/// scope to cause the factory to be registered at load time.
|
| 629 |
+
///
|
| 630 |
+
/// Global constructors will finish execution before main() starts if the registrar is
|
| 631 |
+
/// linked into the same binary as main(), or before dlopen()/LoadLibrary() returns if
|
| 632 |
+
/// the library in which the registrar is defined is dynamically loaded.
|
| 633 |
+
///
|
| 634 |
+
/// \code
|
| 635 |
+
/// FileSystemRegistrar kSlowFileSystemModule{
|
| 636 |
+
/// "slowfile",
|
| 637 |
+
/// [](const Uri& uri, const io::IOContext& io_context, std::string* out_path)
|
| 638 |
+
/// ->Result<std::shared_ptr<FileSystem>> {
|
| 639 |
+
/// auto local_uri = "file" + uri.ToString().substr(uri.scheme().size());
|
| 640 |
+
/// ARROW_ASSIGN_OR_RAISE(auto base_fs,
|
| 641 |
+
/// FileSystemFromUri(local_uri, io_context, out_path));
|
| 642 |
+
/// double average_latency = 1;
|
| 643 |
+
/// int32_t seed = 0xDEADBEEF;
|
| 644 |
+
/// ARROW_ASSIGN_OR_RAISE(auto params, uri.query_item());
|
| 645 |
+
/// for (const auto& [key, value] : params) {
|
| 646 |
+
/// if (key == "average_latency") {
|
| 647 |
+
/// average_latency = std::stod(value);
|
| 648 |
+
/// }
|
| 649 |
+
/// if (key == "seed") {
|
| 650 |
+
/// seed = std::stoi(value, nullptr, /*base=*/16);
|
| 651 |
+
/// }
|
| 652 |
+
/// }
|
| 653 |
+
/// return std::make_shared<SlowFileSystem>(base_fs, average_latency, seed);
|
| 654 |
+
/// }));
|
| 655 |
+
/// \endcode
|
| 656 |
+
///
|
| 657 |
+
/// \param[in] scheme a Uri scheme which the factory will handle.
|
| 658 |
+
/// If a factory has already been registered for a scheme, the
|
| 659 |
+
/// new factory will be ignored.
|
| 660 |
+
/// \param[in] factory a function which can produce a FileSystem for Uris which match
|
| 661 |
+
/// scheme.
|
| 662 |
+
/// \param[in] finalizer a function which must be called to finalize the factory before
|
| 663 |
+
/// the process exits, or nullptr if no finalization is necessary.
|
| 664 |
+
FileSystemRegistrar(std::string scheme, FileSystemFactory factory,
|
| 665 |
+
std::function<void()> finalizer = {});
|
| 666 |
+
};
|
| 667 |
+
|
| 668 |
+
#define ARROW_REGISTER_FILESYSTEM(scheme, factory_function, finalizer) \
|
| 669 |
+
::arrow::fs::FileSystemRegistrar { \
|
| 670 |
+
scheme, ::arrow::fs::FileSystemFactory{factory_function, __FILE__, __LINE__}, \
|
| 671 |
+
finalizer \
|
| 672 |
+
}
|
| 673 |
+
|
| 674 |
+
/// @}
|
| 675 |
+
|
| 676 |
+
namespace internal {
|
| 677 |
+
ARROW_EXPORT void* GetFileSystemRegistry();
|
| 678 |
+
} // namespace internal
|
| 679 |
+
|
| 680 |
+
/// \brief Copy files, including from one FileSystem to another
|
| 681 |
+
///
|
| 682 |
+
/// If a source and destination are resident in the same FileSystem FileSystem::CopyFile
|
| 683 |
+
/// will be used, otherwise the file will be opened as a stream in both FileSystems and
|
| 684 |
+
/// chunks copied from the source to the destination. No directories will be created.
|
| 685 |
+
ARROW_EXPORT
|
| 686 |
+
Status CopyFiles(const std::vector<FileLocator>& sources,
|
| 687 |
+
const std::vector<FileLocator>& destinations,
|
| 688 |
+
const io::IOContext& io_context = io::default_io_context(),
|
| 689 |
+
int64_t chunk_size = 1024 * 1024, bool use_threads = true);
|
| 690 |
+
|
| 691 |
+
/// \brief Copy selected files, including from one FileSystem to another
|
| 692 |
+
///
|
| 693 |
+
/// Directories will be created under the destination base directory as needed.
|
| 694 |
+
ARROW_EXPORT
|
| 695 |
+
Status CopyFiles(const std::shared_ptr<FileSystem>& source_fs,
|
| 696 |
+
const FileSelector& source_sel,
|
| 697 |
+
const std::shared_ptr<FileSystem>& destination_fs,
|
| 698 |
+
const std::string& destination_base_dir,
|
| 699 |
+
const io::IOContext& io_context = io::default_io_context(),
|
| 700 |
+
int64_t chunk_size = 1024 * 1024, bool use_threads = true);
|
| 701 |
+
|
| 702 |
+
struct FileSystemGlobalOptions {
|
| 703 |
+
/// Path to a single PEM file holding all TLS CA certificates
|
| 704 |
+
///
|
| 705 |
+
/// If empty, the underlying TLS library's defaults will be used.
|
| 706 |
+
std::string tls_ca_file_path;
|
| 707 |
+
|
| 708 |
+
/// Path to a directory holding TLS CA certificates in individual PEM files
|
| 709 |
+
/// named along the OpenSSL "hashed" format.
|
| 710 |
+
///
|
| 711 |
+
/// If empty, the underlying TLS library's defaults will be used.
|
| 712 |
+
std::string tls_ca_dir_path;
|
| 713 |
+
};
|
| 714 |
+
|
| 715 |
+
/// EXPERIMENTAL: optional global initialization routine
|
| 716 |
+
///
|
| 717 |
+
/// This is for environments (such as manylinux) where the path
|
| 718 |
+
/// to TLS CA certificates needs to be configured at runtime.
|
| 719 |
+
ARROW_EXPORT
|
| 720 |
+
Status Initialize(const FileSystemGlobalOptions& options);
|
| 721 |
+
|
| 722 |
+
} // namespace fs
|
| 723 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/filesystem/filesystem_library.h
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 "arrow/filesystem/filesystem.h"
|
| 21 |
+
|
| 22 |
+
namespace arrow::fs {
|
| 23 |
+
extern "C" {
|
| 24 |
+
|
| 25 |
+
// ARROW_FORCE_EXPORT ensures this function's visibility is
|
| 26 |
+
// _declspec(dllexport)/[[gnu::visibility("default")]] even when
|
| 27 |
+
// this header is #included by a non-arrow source, as in a third
|
| 28 |
+
// party filesystem implementation.
|
| 29 |
+
ARROW_FORCE_EXPORT void* arrow_filesystem_get_registry() {
|
| 30 |
+
// In the case where libarrow is linked statically both to the executable and to a
|
| 31 |
+
// dynamically loaded filesystem implementation library, the library contains a
|
| 32 |
+
// duplicate definition of the registry into which the library's instances of
|
| 33 |
+
// FileSystemRegistrar insert their factories. This function is made accessible to
|
| 34 |
+
// dlsym/GetProcAddress to enable detection of such duplicate registries and merging
|
| 35 |
+
// into the registry accessible to the executable.
|
| 36 |
+
return internal::GetFileSystemRegistry();
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
} // namespace arrow::fs
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/filesystem/gcsfs.h
ADDED
|
@@ -0,0 +1,242 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 <memory>
|
| 21 |
+
#include <optional>
|
| 22 |
+
#include <string>
|
| 23 |
+
#include <vector>
|
| 24 |
+
|
| 25 |
+
#include "arrow/filesystem/filesystem.h"
|
| 26 |
+
#include "arrow/util/uri.h"
|
| 27 |
+
|
| 28 |
+
namespace arrow {
|
| 29 |
+
namespace fs {
|
| 30 |
+
namespace internal {
|
| 31 |
+
|
| 32 |
+
// Opaque wrapper for GCS's library credentials to avoid exposing in Arrow headers.
|
| 33 |
+
struct GcsCredentialsHolder;
|
| 34 |
+
|
| 35 |
+
} // namespace internal
|
| 36 |
+
|
| 37 |
+
class GcsFileSystem;
|
| 38 |
+
|
| 39 |
+
/// \brief Container for GCS Credentials and information necessary to recreate them.
|
| 40 |
+
class ARROW_EXPORT GcsCredentials {
|
| 41 |
+
public:
|
| 42 |
+
bool Equals(const GcsCredentials& other) const;
|
| 43 |
+
bool anonymous() const { return anonymous_; }
|
| 44 |
+
const std::string& access_token() const { return access_token_; }
|
| 45 |
+
TimePoint expiration() const { return expiration_; }
|
| 46 |
+
const std::string& target_service_account() const { return target_service_account_; }
|
| 47 |
+
const std::string& json_credentials() const { return json_credentials_; }
|
| 48 |
+
const std::shared_ptr<internal::GcsCredentialsHolder>& holder() const {
|
| 49 |
+
return holder_;
|
| 50 |
+
}
|
| 51 |
+
|
| 52 |
+
private:
|
| 53 |
+
GcsCredentials() = default;
|
| 54 |
+
bool anonymous_ = false;
|
| 55 |
+
std::string access_token_;
|
| 56 |
+
TimePoint expiration_;
|
| 57 |
+
std::string target_service_account_;
|
| 58 |
+
std::string json_credentials_;
|
| 59 |
+
std::shared_ptr<internal::GcsCredentialsHolder> holder_;
|
| 60 |
+
friend class GcsFileSystem;
|
| 61 |
+
friend struct GcsOptions;
|
| 62 |
+
};
|
| 63 |
+
|
| 64 |
+
/// Options for the GcsFileSystem implementation.
|
| 65 |
+
struct ARROW_EXPORT GcsOptions {
|
| 66 |
+
/// \brief Equivalent to GcsOptions::Defaults().
|
| 67 |
+
GcsOptions();
|
| 68 |
+
GcsCredentials credentials;
|
| 69 |
+
|
| 70 |
+
std::string endpoint_override;
|
| 71 |
+
std::string scheme;
|
| 72 |
+
/// \brief Location to use for creating buckets.
|
| 73 |
+
std::string default_bucket_location;
|
| 74 |
+
|
| 75 |
+
/// \brief If set used to control total time allowed for retrying underlying
|
| 76 |
+
/// errors.
|
| 77 |
+
///
|
| 78 |
+
/// The default policy is to retry for up to 15 minutes.
|
| 79 |
+
std::optional<double> retry_limit_seconds;
|
| 80 |
+
|
| 81 |
+
/// \brief Default metadata for OpenOutputStream.
|
| 82 |
+
///
|
| 83 |
+
/// This will be ignored if non-empty metadata is passed to OpenOutputStream.
|
| 84 |
+
std::shared_ptr<const KeyValueMetadata> default_metadata;
|
| 85 |
+
|
| 86 |
+
/// \brief The project to use for creating buckets.
|
| 87 |
+
///
|
| 88 |
+
/// If not set, the library uses the GOOGLE_CLOUD_PROJECT environment
|
| 89 |
+
/// variable. Most I/O operations do not need a project id, only applications
|
| 90 |
+
/// that create new buckets need a project id.
|
| 91 |
+
std::optional<std::string> project_id;
|
| 92 |
+
|
| 93 |
+
bool Equals(const GcsOptions& other) const;
|
| 94 |
+
|
| 95 |
+
/// \brief Initialize with Google Default Credentials
|
| 96 |
+
///
|
| 97 |
+
/// Create options configured to use [Application Default Credentials][aip/4110]. The
|
| 98 |
+
/// details of this mechanism are too involved to describe here, but suffice is to say
|
| 99 |
+
/// that applications can override any defaults using an environment variable
|
| 100 |
+
/// (`GOOGLE_APPLICATION_CREDENTIALS`), and that the defaults work with most Google
|
| 101 |
+
/// Cloud Platform deployment environments (GCE, GKE, Cloud Run, etc.), and that have
|
| 102 |
+
/// the same behavior as the `gcloud` CLI tool on your workstation.
|
| 103 |
+
///
|
| 104 |
+
/// \see https://cloud.google.com/docs/authentication
|
| 105 |
+
///
|
| 106 |
+
/// [aip/4110]: https://google.aip.dev/auth/4110
|
| 107 |
+
static GcsOptions Defaults();
|
| 108 |
+
|
| 109 |
+
/// \brief Initialize with anonymous credentials
|
| 110 |
+
static GcsOptions Anonymous();
|
| 111 |
+
|
| 112 |
+
/// \brief Initialize with access token
|
| 113 |
+
///
|
| 114 |
+
/// These credentials are useful when using an out-of-band mechanism to fetch access
|
| 115 |
+
/// tokens. Note that access tokens are time limited, you will need to manually refresh
|
| 116 |
+
/// the tokens created by the out-of-band mechanism.
|
| 117 |
+
static GcsOptions FromAccessToken(const std::string& access_token,
|
| 118 |
+
TimePoint expiration);
|
| 119 |
+
|
| 120 |
+
/// \brief Initialize with service account impersonation
|
| 121 |
+
///
|
| 122 |
+
/// Service account impersonation allows one principal (a user or service account) to
|
| 123 |
+
/// impersonate a service account. It requires that the calling principal has the
|
| 124 |
+
/// necessary permissions *on* the service account.
|
| 125 |
+
static GcsOptions FromImpersonatedServiceAccount(
|
| 126 |
+
const GcsCredentials& base_credentials, const std::string& target_service_account);
|
| 127 |
+
|
| 128 |
+
/// Creates service account credentials from a JSON object in string form.
|
| 129 |
+
///
|
| 130 |
+
/// The @p json_object is expected to be in the format described by [aip/4112]. Such an
|
| 131 |
+
/// object contains the identity of a service account, as well as a private key that can
|
| 132 |
+
/// be used to sign tokens, showing the caller was holding the private key.
|
| 133 |
+
///
|
| 134 |
+
/// In GCP one can create several "keys" for each service account, and these keys are
|
| 135 |
+
/// downloaded as a JSON "key file". The contents of such a file are in the format
|
| 136 |
+
/// required by this function. Remember that key files and their contents should be
|
| 137 |
+
/// treated as any other secret with security implications, think of them as passwords
|
| 138 |
+
/// (because they are!), don't store them or output them where unauthorized persons may
|
| 139 |
+
/// read them.
|
| 140 |
+
///
|
| 141 |
+
/// Most applications should probably use default credentials, maybe pointing them to a
|
| 142 |
+
/// file with these contents. Using this function may be useful when the json object is
|
| 143 |
+
/// obtained from a Cloud Secret Manager or a similar service.
|
| 144 |
+
///
|
| 145 |
+
/// [aip/4112]: https://google.aip.dev/auth/4112
|
| 146 |
+
static GcsOptions FromServiceAccountCredentials(const std::string& json_object);
|
| 147 |
+
|
| 148 |
+
/// Initialize from URIs such as "gs://bucket/object".
|
| 149 |
+
static Result<GcsOptions> FromUri(const arrow::util::Uri& uri, std::string* out_path);
|
| 150 |
+
static Result<GcsOptions> FromUri(const std::string& uri, std::string* out_path);
|
| 151 |
+
};
|
| 152 |
+
|
| 153 |
+
/// \brief GCS-backed FileSystem implementation.
|
| 154 |
+
///
|
| 155 |
+
/// GCS (Google Cloud Storage - https://cloud.google.com/storage) is a scalable object
|
| 156 |
+
/// storage system for any amount of data. The main abstractions in GCS are buckets and
|
| 157 |
+
/// objects. A bucket is a namespace for objects, buckets can store any number of objects,
|
| 158 |
+
/// tens of millions and even billions is not uncommon. Each object contains a single
|
| 159 |
+
/// blob of data, up to 5TiB in size. Buckets are typically configured to keep a single
|
| 160 |
+
/// version of each object, but versioning can be enabled. Versioning is important because
|
| 161 |
+
/// objects are immutable, once created one cannot append data to the object or modify the
|
| 162 |
+
/// object data in any way.
|
| 163 |
+
///
|
| 164 |
+
/// GCS buckets are in a global namespace, if a Google Cloud customer creates a bucket
|
| 165 |
+
/// named `foo` no other customer can create a bucket with the same name. Note that a
|
| 166 |
+
/// principal (a user or service account) may only list the buckets they are entitled to,
|
| 167 |
+
/// and then only within a project. It is not possible to list "all" the buckets.
|
| 168 |
+
///
|
| 169 |
+
/// Within each bucket objects are in flat namespace. GCS does not have folders or
|
| 170 |
+
/// directories. However, following some conventions it is possible to emulate
|
| 171 |
+
/// directories. To this end, this class:
|
| 172 |
+
///
|
| 173 |
+
/// - All buckets are treated as directories at the "root"
|
| 174 |
+
/// - Creating a root directory results in a new bucket being created, this may be slower
|
| 175 |
+
/// than most GCS operations.
|
| 176 |
+
/// - The class creates marker objects for a directory, using a metadata attribute to
|
| 177 |
+
/// annotate the file.
|
| 178 |
+
/// - GCS can list all the objects with a given prefix, this is used to emulate listing
|
| 179 |
+
/// of directories.
|
| 180 |
+
/// - In object lists GCS can summarize all the objects with a common prefix as a single
|
| 181 |
+
/// entry, this is used to emulate non-recursive lists. Note that GCS list time is
|
| 182 |
+
/// proportional to the number of objects in the prefix. Listing recursively takes
|
| 183 |
+
/// almost the same time as non-recursive lists.
|
| 184 |
+
///
|
| 185 |
+
class ARROW_EXPORT GcsFileSystem : public FileSystem {
|
| 186 |
+
public:
|
| 187 |
+
~GcsFileSystem() override = default;
|
| 188 |
+
|
| 189 |
+
std::string type_name() const override;
|
| 190 |
+
const GcsOptions& options() const;
|
| 191 |
+
|
| 192 |
+
bool Equals(const FileSystem& other) const override;
|
| 193 |
+
Result<std::string> PathFromUri(const std::string& uri_string) const override;
|
| 194 |
+
|
| 195 |
+
Result<FileInfo> GetFileInfo(const std::string& path) override;
|
| 196 |
+
Result<FileInfoVector> GetFileInfo(const FileSelector& select) override;
|
| 197 |
+
|
| 198 |
+
Status CreateDir(const std::string& path, bool recursive) override;
|
| 199 |
+
|
| 200 |
+
Status DeleteDir(const std::string& path) override;
|
| 201 |
+
|
| 202 |
+
Status DeleteDirContents(const std::string& path, bool missing_dir_ok = false) override;
|
| 203 |
+
|
| 204 |
+
/// This is not implemented in GcsFileSystem, as it would be too dangerous.
|
| 205 |
+
Status DeleteRootDirContents() override;
|
| 206 |
+
|
| 207 |
+
Status DeleteFile(const std::string& path) override;
|
| 208 |
+
|
| 209 |
+
Status Move(const std::string& src, const std::string& dest) override;
|
| 210 |
+
|
| 211 |
+
Status CopyFile(const std::string& src, const std::string& dest) override;
|
| 212 |
+
|
| 213 |
+
Result<std::shared_ptr<io::InputStream>> OpenInputStream(
|
| 214 |
+
const std::string& path) override;
|
| 215 |
+
Result<std::shared_ptr<io::InputStream>> OpenInputStream(const FileInfo& info) override;
|
| 216 |
+
|
| 217 |
+
Result<std::shared_ptr<io::RandomAccessFile>> OpenInputFile(
|
| 218 |
+
const std::string& path) override;
|
| 219 |
+
Result<std::shared_ptr<io::RandomAccessFile>> OpenInputFile(
|
| 220 |
+
const FileInfo& info) override;
|
| 221 |
+
|
| 222 |
+
Result<std::shared_ptr<io::OutputStream>> OpenOutputStream(
|
| 223 |
+
const std::string& path,
|
| 224 |
+
const std::shared_ptr<const KeyValueMetadata>& metadata) override;
|
| 225 |
+
|
| 226 |
+
Result<std::shared_ptr<io::OutputStream>> OpenAppendStream(
|
| 227 |
+
const std::string& path,
|
| 228 |
+
const std::shared_ptr<const KeyValueMetadata>& metadata) override;
|
| 229 |
+
|
| 230 |
+
/// Create a GcsFileSystem instance from the given options.
|
| 231 |
+
static Result<std::shared_ptr<GcsFileSystem>> Make(
|
| 232 |
+
const GcsOptions& options, const io::IOContext& = io::default_io_context());
|
| 233 |
+
|
| 234 |
+
private:
|
| 235 |
+
explicit GcsFileSystem(const GcsOptions& options, const io::IOContext& io_context);
|
| 236 |
+
|
| 237 |
+
class Impl;
|
| 238 |
+
std::shared_ptr<Impl> impl_;
|
| 239 |
+
};
|
| 240 |
+
|
| 241 |
+
} // namespace fs
|
| 242 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/filesystem/hdfs.h
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 <memory>
|
| 21 |
+
#include <string>
|
| 22 |
+
#include <vector>
|
| 23 |
+
|
| 24 |
+
#include "arrow/filesystem/filesystem.h"
|
| 25 |
+
#include "arrow/io/hdfs.h"
|
| 26 |
+
#include "arrow/util/uri.h"
|
| 27 |
+
|
| 28 |
+
namespace arrow::fs {
|
| 29 |
+
|
| 30 |
+
/// Options for the HDFS implementation.
|
| 31 |
+
struct ARROW_EXPORT HdfsOptions {
|
| 32 |
+
HdfsOptions() = default;
|
| 33 |
+
~HdfsOptions() = default;
|
| 34 |
+
|
| 35 |
+
/// Hdfs configuration options, contains host, port, driver
|
| 36 |
+
io::HdfsConnectionConfig connection_config;
|
| 37 |
+
|
| 38 |
+
/// Used by Hdfs OpenWritable Interface.
|
| 39 |
+
int32_t buffer_size = 0;
|
| 40 |
+
int16_t replication = 3;
|
| 41 |
+
int64_t default_block_size = 0;
|
| 42 |
+
|
| 43 |
+
void ConfigureEndPoint(std::string host, int port);
|
| 44 |
+
void ConfigureReplication(int16_t replication);
|
| 45 |
+
void ConfigureUser(std::string user_name);
|
| 46 |
+
void ConfigureBufferSize(int32_t buffer_size);
|
| 47 |
+
void ConfigureBlockSize(int64_t default_block_size);
|
| 48 |
+
void ConfigureKerberosTicketCachePath(std::string path);
|
| 49 |
+
void ConfigureExtraConf(std::string key, std::string val);
|
| 50 |
+
|
| 51 |
+
bool Equals(const HdfsOptions& other) const;
|
| 52 |
+
|
| 53 |
+
static Result<HdfsOptions> FromUri(const ::arrow::util::Uri& uri);
|
| 54 |
+
static Result<HdfsOptions> FromUri(const std::string& uri);
|
| 55 |
+
};
|
| 56 |
+
|
| 57 |
+
/// HDFS-backed FileSystem implementation.
|
| 58 |
+
///
|
| 59 |
+
/// implementation notes:
|
| 60 |
+
/// - This is a wrapper of arrow/io/hdfs, so we can use FileSystem API to handle hdfs.
|
| 61 |
+
class ARROW_EXPORT HadoopFileSystem : public FileSystem {
|
| 62 |
+
public:
|
| 63 |
+
~HadoopFileSystem() override;
|
| 64 |
+
|
| 65 |
+
std::string type_name() const override { return "hdfs"; }
|
| 66 |
+
HdfsOptions options() const;
|
| 67 |
+
bool Equals(const FileSystem& other) const override;
|
| 68 |
+
Result<std::string> PathFromUri(const std::string& uri_string) const override;
|
| 69 |
+
|
| 70 |
+
/// \cond FALSE
|
| 71 |
+
using FileSystem::CreateDir;
|
| 72 |
+
using FileSystem::DeleteDirContents;
|
| 73 |
+
using FileSystem::GetFileInfo;
|
| 74 |
+
using FileSystem::OpenAppendStream;
|
| 75 |
+
using FileSystem::OpenOutputStream;
|
| 76 |
+
/// \endcond
|
| 77 |
+
|
| 78 |
+
Result<FileInfo> GetFileInfo(const std::string& path) override;
|
| 79 |
+
Result<std::vector<FileInfo>> GetFileInfo(const FileSelector& select) override;
|
| 80 |
+
|
| 81 |
+
Status CreateDir(const std::string& path, bool recursive) override;
|
| 82 |
+
|
| 83 |
+
Status DeleteDir(const std::string& path) override;
|
| 84 |
+
|
| 85 |
+
Status DeleteDirContents(const std::string& path, bool missing_dir_ok) override;
|
| 86 |
+
|
| 87 |
+
Status DeleteRootDirContents() override;
|
| 88 |
+
|
| 89 |
+
Status DeleteFile(const std::string& path) override;
|
| 90 |
+
|
| 91 |
+
Status Move(const std::string& src, const std::string& dest) override;
|
| 92 |
+
|
| 93 |
+
Status CopyFile(const std::string& src, const std::string& dest) override;
|
| 94 |
+
|
| 95 |
+
Result<std::shared_ptr<io::InputStream>> OpenInputStream(
|
| 96 |
+
const std::string& path) override;
|
| 97 |
+
Result<std::shared_ptr<io::RandomAccessFile>> OpenInputFile(
|
| 98 |
+
const std::string& path) override;
|
| 99 |
+
Result<std::shared_ptr<io::OutputStream>> OpenOutputStream(
|
| 100 |
+
const std::string& path,
|
| 101 |
+
const std::shared_ptr<const KeyValueMetadata>& metadata) override;
|
| 102 |
+
Result<std::shared_ptr<io::OutputStream>> OpenAppendStream(
|
| 103 |
+
const std::string& path,
|
| 104 |
+
const std::shared_ptr<const KeyValueMetadata>& metadata) override;
|
| 105 |
+
|
| 106 |
+
/// Create a HdfsFileSystem instance from the given options.
|
| 107 |
+
static Result<std::shared_ptr<HadoopFileSystem>> Make(
|
| 108 |
+
const HdfsOptions& options, const io::IOContext& = io::default_io_context());
|
| 109 |
+
|
| 110 |
+
protected:
|
| 111 |
+
HadoopFileSystem(const HdfsOptions& options, const io::IOContext&);
|
| 112 |
+
|
| 113 |
+
class Impl;
|
| 114 |
+
std::unique_ptr<Impl> impl_;
|
| 115 |
+
};
|
| 116 |
+
|
| 117 |
+
} // namespace arrow::fs
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/filesystem/localfs.h
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 <memory>
|
| 21 |
+
#include <string>
|
| 22 |
+
#include <vector>
|
| 23 |
+
|
| 24 |
+
#include "arrow/filesystem/filesystem.h"
|
| 25 |
+
|
| 26 |
+
namespace arrow {
|
| 27 |
+
namespace internal {
|
| 28 |
+
|
| 29 |
+
class Uri;
|
| 30 |
+
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
namespace fs {
|
| 34 |
+
|
| 35 |
+
/// Options for the LocalFileSystem implementation.
|
| 36 |
+
struct ARROW_EXPORT LocalFileSystemOptions {
|
| 37 |
+
static constexpr int32_t kDefaultDirectoryReadahead = 16;
|
| 38 |
+
static constexpr int32_t kDefaultFileInfoBatchSize = 1000;
|
| 39 |
+
|
| 40 |
+
/// Whether OpenInputStream and OpenInputFile return a mmap'ed file,
|
| 41 |
+
/// or a regular one.
|
| 42 |
+
bool use_mmap = false;
|
| 43 |
+
|
| 44 |
+
/// Options related to `GetFileInfoGenerator` interface.
|
| 45 |
+
|
| 46 |
+
/// EXPERIMENTAL: The maximum number of directories processed in parallel
|
| 47 |
+
/// by `GetFileInfoGenerator`.
|
| 48 |
+
int32_t directory_readahead = kDefaultDirectoryReadahead;
|
| 49 |
+
|
| 50 |
+
/// EXPERIMENTAL: The maximum number of entries aggregated into each
|
| 51 |
+
/// FileInfoVector chunk by `GetFileInfoGenerator`.
|
| 52 |
+
///
|
| 53 |
+
/// Since each FileInfo entry needs a separate `stat` system call, a
|
| 54 |
+
/// directory with a very large number of files may take a lot of time to
|
| 55 |
+
/// process entirely. By generating a FileInfoVector after this chunk
|
| 56 |
+
/// size is reached, we ensure FileInfo entries can start being consumed
|
| 57 |
+
/// from the FileInfoGenerator with less initial latency.
|
| 58 |
+
int32_t file_info_batch_size = kDefaultFileInfoBatchSize;
|
| 59 |
+
|
| 60 |
+
/// \brief Initialize with defaults
|
| 61 |
+
static LocalFileSystemOptions Defaults();
|
| 62 |
+
|
| 63 |
+
bool Equals(const LocalFileSystemOptions& other) const;
|
| 64 |
+
|
| 65 |
+
static Result<LocalFileSystemOptions> FromUri(const ::arrow::util::Uri& uri,
|
| 66 |
+
std::string* out_path);
|
| 67 |
+
};
|
| 68 |
+
|
| 69 |
+
/// \brief A FileSystem implementation accessing files on the local machine.
|
| 70 |
+
///
|
| 71 |
+
/// This class handles only `/`-separated paths. If desired, conversion
|
| 72 |
+
/// from Windows backslash-separated paths should be done by the caller.
|
| 73 |
+
/// Details such as symlinks are abstracted away (symlinks are always
|
| 74 |
+
/// followed, except when deleting an entry).
|
| 75 |
+
class ARROW_EXPORT LocalFileSystem : public FileSystem {
|
| 76 |
+
public:
|
| 77 |
+
explicit LocalFileSystem(const io::IOContext& = io::default_io_context());
|
| 78 |
+
explicit LocalFileSystem(const LocalFileSystemOptions&,
|
| 79 |
+
const io::IOContext& = io::default_io_context());
|
| 80 |
+
~LocalFileSystem() override;
|
| 81 |
+
|
| 82 |
+
std::string type_name() const override { return "local"; }
|
| 83 |
+
|
| 84 |
+
Result<std::string> NormalizePath(std::string path) override;
|
| 85 |
+
Result<std::string> PathFromUri(const std::string& uri_string) const override;
|
| 86 |
+
Result<std::string> MakeUri(std::string path) const override;
|
| 87 |
+
|
| 88 |
+
bool Equals(const FileSystem& other) const override;
|
| 89 |
+
|
| 90 |
+
LocalFileSystemOptions options() const { return options_; }
|
| 91 |
+
|
| 92 |
+
/// \cond FALSE
|
| 93 |
+
using FileSystem::CreateDir;
|
| 94 |
+
using FileSystem::DeleteDirContents;
|
| 95 |
+
using FileSystem::GetFileInfo;
|
| 96 |
+
using FileSystem::OpenAppendStream;
|
| 97 |
+
using FileSystem::OpenOutputStream;
|
| 98 |
+
/// \endcond
|
| 99 |
+
|
| 100 |
+
Result<FileInfo> GetFileInfo(const std::string& path) override;
|
| 101 |
+
Result<std::vector<FileInfo>> GetFileInfo(const FileSelector& select) override;
|
| 102 |
+
FileInfoGenerator GetFileInfoGenerator(const FileSelector& select) override;
|
| 103 |
+
|
| 104 |
+
Status CreateDir(const std::string& path, bool recursive) override;
|
| 105 |
+
|
| 106 |
+
Status DeleteDir(const std::string& path) override;
|
| 107 |
+
Status DeleteDirContents(const std::string& path, bool missing_dir_ok) override;
|
| 108 |
+
Status DeleteRootDirContents() override;
|
| 109 |
+
|
| 110 |
+
Status DeleteFile(const std::string& path) override;
|
| 111 |
+
|
| 112 |
+
Status Move(const std::string& src, const std::string& dest) override;
|
| 113 |
+
|
| 114 |
+
Status CopyFile(const std::string& src, const std::string& dest) override;
|
| 115 |
+
|
| 116 |
+
Result<std::shared_ptr<io::InputStream>> OpenInputStream(
|
| 117 |
+
const std::string& path) override;
|
| 118 |
+
Result<std::shared_ptr<io::RandomAccessFile>> OpenInputFile(
|
| 119 |
+
const std::string& path) override;
|
| 120 |
+
Result<std::shared_ptr<io::OutputStream>> OpenOutputStream(
|
| 121 |
+
const std::string& path,
|
| 122 |
+
const std::shared_ptr<const KeyValueMetadata>& metadata) override;
|
| 123 |
+
Result<std::shared_ptr<io::OutputStream>> OpenAppendStream(
|
| 124 |
+
const std::string& path,
|
| 125 |
+
const std::shared_ptr<const KeyValueMetadata>& metadata) override;
|
| 126 |
+
|
| 127 |
+
protected:
|
| 128 |
+
LocalFileSystemOptions options_;
|
| 129 |
+
};
|
| 130 |
+
|
| 131 |
+
} // namespace fs
|
| 132 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/filesystem/mockfs.h
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 <iosfwd>
|
| 21 |
+
#include <memory>
|
| 22 |
+
#include <string>
|
| 23 |
+
#include <string_view>
|
| 24 |
+
#include <vector>
|
| 25 |
+
|
| 26 |
+
#include "arrow/filesystem/filesystem.h"
|
| 27 |
+
#include "arrow/util/windows_fixup.h"
|
| 28 |
+
|
| 29 |
+
namespace arrow::fs::internal {
|
| 30 |
+
|
| 31 |
+
struct MockDirInfo {
|
| 32 |
+
std::string full_path;
|
| 33 |
+
TimePoint mtime;
|
| 34 |
+
|
| 35 |
+
bool operator==(const MockDirInfo& other) const {
|
| 36 |
+
return mtime == other.mtime && full_path == other.full_path;
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
ARROW_FRIEND_EXPORT friend std::ostream& operator<<(std::ostream&, const MockDirInfo&);
|
| 40 |
+
};
|
| 41 |
+
|
| 42 |
+
struct MockFileInfo {
|
| 43 |
+
std::string full_path;
|
| 44 |
+
TimePoint mtime;
|
| 45 |
+
std::string_view data;
|
| 46 |
+
|
| 47 |
+
bool operator==(const MockFileInfo& other) const {
|
| 48 |
+
return mtime == other.mtime && full_path == other.full_path && data == other.data;
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
ARROW_FRIEND_EXPORT friend std::ostream& operator<<(std::ostream&, const MockFileInfo&);
|
| 52 |
+
};
|
| 53 |
+
|
| 54 |
+
/// A mock FileSystem implementation that holds its contents in memory.
|
| 55 |
+
///
|
| 56 |
+
/// Useful for validating the FileSystem API, writing conformance suite,
|
| 57 |
+
/// and bootstrapping FileSystem-based APIs.
|
| 58 |
+
class ARROW_EXPORT MockFileSystem : public FileSystem {
|
| 59 |
+
public:
|
| 60 |
+
explicit MockFileSystem(TimePoint current_time,
|
| 61 |
+
const io::IOContext& = io::default_io_context());
|
| 62 |
+
~MockFileSystem() override;
|
| 63 |
+
|
| 64 |
+
std::string type_name() const override { return "mock"; }
|
| 65 |
+
|
| 66 |
+
bool Equals(const FileSystem& other) const override;
|
| 67 |
+
Result<std::string> PathFromUri(const std::string& uri_string) const override;
|
| 68 |
+
|
| 69 |
+
/// \cond FALSE
|
| 70 |
+
using FileSystem::CreateDir;
|
| 71 |
+
using FileSystem::DeleteDirContents;
|
| 72 |
+
using FileSystem::GetFileInfo;
|
| 73 |
+
using FileSystem::OpenAppendStream;
|
| 74 |
+
using FileSystem::OpenOutputStream;
|
| 75 |
+
/// \endcond
|
| 76 |
+
|
| 77 |
+
Result<FileInfo> GetFileInfo(const std::string& path) override;
|
| 78 |
+
Result<std::vector<FileInfo>> GetFileInfo(const FileSelector& select) override;
|
| 79 |
+
|
| 80 |
+
Status CreateDir(const std::string& path, bool recursive) override;
|
| 81 |
+
|
| 82 |
+
Status DeleteDir(const std::string& path) override;
|
| 83 |
+
Status DeleteDirContents(const std::string& path, bool missing_dir_ok) override;
|
| 84 |
+
Status DeleteRootDirContents() override;
|
| 85 |
+
|
| 86 |
+
Status DeleteFile(const std::string& path) override;
|
| 87 |
+
|
| 88 |
+
Status Move(const std::string& src, const std::string& dest) override;
|
| 89 |
+
|
| 90 |
+
Status CopyFile(const std::string& src, const std::string& dest) override;
|
| 91 |
+
|
| 92 |
+
Result<std::shared_ptr<io::InputStream>> OpenInputStream(
|
| 93 |
+
const std::string& path) override;
|
| 94 |
+
Result<std::shared_ptr<io::RandomAccessFile>> OpenInputFile(
|
| 95 |
+
const std::string& path) override;
|
| 96 |
+
Result<std::shared_ptr<io::OutputStream>> OpenOutputStream(
|
| 97 |
+
const std::string& path,
|
| 98 |
+
const std::shared_ptr<const KeyValueMetadata>& metadata) override;
|
| 99 |
+
Result<std::shared_ptr<io::OutputStream>> OpenAppendStream(
|
| 100 |
+
const std::string& path,
|
| 101 |
+
const std::shared_ptr<const KeyValueMetadata>& metadata) override;
|
| 102 |
+
|
| 103 |
+
// Contents-dumping helpers to ease testing.
|
| 104 |
+
// Output is lexicographically-ordered by full path.
|
| 105 |
+
std::vector<MockDirInfo> AllDirs();
|
| 106 |
+
std::vector<MockFileInfo> AllFiles();
|
| 107 |
+
|
| 108 |
+
// Create a File with a content from a string.
|
| 109 |
+
Status CreateFile(const std::string& path, std::string_view content,
|
| 110 |
+
bool recursive = true);
|
| 111 |
+
|
| 112 |
+
// Create a MockFileSystem out of (empty) FileInfo. The content of every
|
| 113 |
+
// file is empty and of size 0. All directories will be created recursively.
|
| 114 |
+
static Result<std::shared_ptr<FileSystem>> Make(TimePoint current_time,
|
| 115 |
+
const std::vector<FileInfo>& infos);
|
| 116 |
+
|
| 117 |
+
class Impl;
|
| 118 |
+
|
| 119 |
+
protected:
|
| 120 |
+
std::unique_ptr<Impl> impl_;
|
| 121 |
+
};
|
| 122 |
+
|
| 123 |
+
class ARROW_EXPORT MockAsyncFileSystem : public MockFileSystem {
|
| 124 |
+
public:
|
| 125 |
+
explicit MockAsyncFileSystem(TimePoint current_time,
|
| 126 |
+
const io::IOContext& io_context = io::default_io_context())
|
| 127 |
+
: MockFileSystem(current_time, io_context) {
|
| 128 |
+
default_async_is_sync_ = false;
|
| 129 |
+
}
|
| 130 |
+
|
| 131 |
+
FileInfoGenerator GetFileInfoGenerator(const FileSelector& select) override;
|
| 132 |
+
};
|
| 133 |
+
|
| 134 |
+
} // namespace arrow::fs::internal
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/filesystem/path_util.h
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 <optional>
|
| 21 |
+
#include <string>
|
| 22 |
+
#include <string_view>
|
| 23 |
+
#include <utility>
|
| 24 |
+
#include <vector>
|
| 25 |
+
|
| 26 |
+
#include "arrow/type_fwd.h"
|
| 27 |
+
|
| 28 |
+
namespace arrow {
|
| 29 |
+
namespace fs {
|
| 30 |
+
namespace internal {
|
| 31 |
+
|
| 32 |
+
constexpr char kSep = '/';
|
| 33 |
+
|
| 34 |
+
// Computations on abstract paths (not local paths with system-dependent behaviour).
|
| 35 |
+
// Abstract paths are typically used in URIs.
|
| 36 |
+
|
| 37 |
+
// Split an abstract path into its individual components.
|
| 38 |
+
ARROW_EXPORT
|
| 39 |
+
std::vector<std::string> SplitAbstractPath(const std::string& path, char sep = kSep);
|
| 40 |
+
|
| 41 |
+
// Slice the individual components of an abstract path and combine them
|
| 42 |
+
//
|
| 43 |
+
// If offset or length are negative then an empty string is returned
|
| 44 |
+
// If offset is >= the number of components then an empty string is returned
|
| 45 |
+
// If offset + length is >= the number of components then length is truncated
|
| 46 |
+
ARROW_EXPORT
|
| 47 |
+
std::string SliceAbstractPath(const std::string& path, int offset, int length,
|
| 48 |
+
char sep = kSep);
|
| 49 |
+
|
| 50 |
+
// Return the extension of the file
|
| 51 |
+
ARROW_EXPORT std::string GetAbstractPathExtension(const std::string& s);
|
| 52 |
+
|
| 53 |
+
// Return the depth (number of components) of an abstract path
|
| 54 |
+
//
|
| 55 |
+
// Trailing slashes do not count towards depth
|
| 56 |
+
// Leading slashes do not count towards depth
|
| 57 |
+
//
|
| 58 |
+
// The root path ("/") has depth 0
|
| 59 |
+
ARROW_EXPORT int GetAbstractPathDepth(std::string_view path);
|
| 60 |
+
|
| 61 |
+
// Return the parent directory and basename of an abstract path. Both values may be
|
| 62 |
+
// empty.
|
| 63 |
+
ARROW_EXPORT
|
| 64 |
+
std::pair<std::string, std::string> GetAbstractPathParent(const std::string& s);
|
| 65 |
+
|
| 66 |
+
// Validate an abstract path.
|
| 67 |
+
ARROW_EXPORT
|
| 68 |
+
Status ValidateAbstractPath(std::string_view path);
|
| 69 |
+
|
| 70 |
+
// Validate the components of an abstract path.
|
| 71 |
+
ARROW_EXPORT
|
| 72 |
+
Status ValidateAbstractPathParts(const std::vector<std::string>& parts);
|
| 73 |
+
|
| 74 |
+
// Append a non-empty stem to an abstract path.
|
| 75 |
+
ARROW_EXPORT
|
| 76 |
+
std::string ConcatAbstractPath(std::string_view base, std::string_view stem);
|
| 77 |
+
|
| 78 |
+
// Make path relative to base, if it starts with base. Otherwise error out.
|
| 79 |
+
ARROW_EXPORT
|
| 80 |
+
Result<std::string> MakeAbstractPathRelative(const std::string& base,
|
| 81 |
+
const std::string& path);
|
| 82 |
+
|
| 83 |
+
ARROW_EXPORT
|
| 84 |
+
std::string EnsureLeadingSlash(std::string_view s);
|
| 85 |
+
|
| 86 |
+
ARROW_EXPORT
|
| 87 |
+
std::string_view RemoveLeadingSlash(std::string_view s);
|
| 88 |
+
|
| 89 |
+
ARROW_EXPORT
|
| 90 |
+
std::string EnsureTrailingSlash(std::string_view s);
|
| 91 |
+
|
| 92 |
+
/// \brief remove the forward slash (if any) from the given path
|
| 93 |
+
/// \param s the input path
|
| 94 |
+
/// \param preserve_root if true, allow a path of just "/" to remain unchanged
|
| 95 |
+
ARROW_EXPORT
|
| 96 |
+
std::string_view RemoveTrailingSlash(std::string_view s, bool preserve_root = false);
|
| 97 |
+
|
| 98 |
+
ARROW_EXPORT
|
| 99 |
+
Status AssertNoTrailingSlash(std::string_view s);
|
| 100 |
+
|
| 101 |
+
inline bool HasTrailingSlash(std::string_view s) {
|
| 102 |
+
return !s.empty() && s.back() == kSep;
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
inline bool HasLeadingSlash(std::string_view s) {
|
| 106 |
+
return !s.empty() && s.front() == kSep;
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
ARROW_EXPORT
|
| 110 |
+
bool IsAncestorOf(std::string_view ancestor, std::string_view descendant);
|
| 111 |
+
|
| 112 |
+
ARROW_EXPORT
|
| 113 |
+
std::optional<std::string_view> RemoveAncestor(std::string_view ancestor,
|
| 114 |
+
std::string_view descendant);
|
| 115 |
+
|
| 116 |
+
/// Return a vector of ancestors between a base path and a descendant.
|
| 117 |
+
/// For example,
|
| 118 |
+
///
|
| 119 |
+
/// AncestorsFromBasePath("a/b", "a/b/c/d/e") -> ["a/b/c", "a/b/c/d"]
|
| 120 |
+
ARROW_EXPORT
|
| 121 |
+
std::vector<std::string> AncestorsFromBasePath(std::string_view base_path,
|
| 122 |
+
std::string_view descendant);
|
| 123 |
+
|
| 124 |
+
/// Given a vector of paths of directories which must be created, produce a the minimal
|
| 125 |
+
/// subset for passing to CreateDir(recursive=true) by removing redundant parent
|
| 126 |
+
/// directories
|
| 127 |
+
ARROW_EXPORT
|
| 128 |
+
std::vector<std::string> MinimalCreateDirSet(std::vector<std::string> dirs);
|
| 129 |
+
|
| 130 |
+
// Join the components of an abstract path.
|
| 131 |
+
template <class StringIt>
|
| 132 |
+
std::string JoinAbstractPath(StringIt it, StringIt end, char sep = kSep) {
|
| 133 |
+
std::string path;
|
| 134 |
+
for (; it != end; ++it) {
|
| 135 |
+
if (it->empty()) continue;
|
| 136 |
+
|
| 137 |
+
if (!path.empty()) {
|
| 138 |
+
path += sep;
|
| 139 |
+
}
|
| 140 |
+
path += *it;
|
| 141 |
+
}
|
| 142 |
+
return path;
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
template <class StringRange>
|
| 146 |
+
std::string JoinAbstractPath(const StringRange& range, char sep = kSep) {
|
| 147 |
+
return JoinAbstractPath(range.begin(), range.end(), sep);
|
| 148 |
+
}
|
| 149 |
+
|
| 150 |
+
/// Convert slashes to backslashes, on all platforms. Mostly useful for testing.
|
| 151 |
+
ARROW_EXPORT
|
| 152 |
+
std::string ToBackslashes(std::string_view s);
|
| 153 |
+
|
| 154 |
+
/// Ensure a local path is abstract, by converting backslashes to regular slashes
|
| 155 |
+
/// on Windows. Return the path unchanged on other systems.
|
| 156 |
+
ARROW_EXPORT
|
| 157 |
+
std::string ToSlashes(std::string_view s);
|
| 158 |
+
|
| 159 |
+
ARROW_EXPORT
|
| 160 |
+
bool IsEmptyPath(std::string_view s);
|
| 161 |
+
|
| 162 |
+
ARROW_EXPORT
|
| 163 |
+
bool IsLikelyUri(std::string_view s);
|
| 164 |
+
|
| 165 |
+
class ARROW_EXPORT Globber {
|
| 166 |
+
public:
|
| 167 |
+
~Globber();
|
| 168 |
+
explicit Globber(std::string pattern);
|
| 169 |
+
bool Matches(const std::string& path);
|
| 170 |
+
|
| 171 |
+
protected:
|
| 172 |
+
struct Impl;
|
| 173 |
+
std::unique_ptr<Impl> impl_;
|
| 174 |
+
};
|
| 175 |
+
|
| 176 |
+
} // namespace internal
|
| 177 |
+
} // namespace fs
|
| 178 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/filesystem/s3_test_util.h
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 <memory>
|
| 21 |
+
#include <string>
|
| 22 |
+
#include <utility>
|
| 23 |
+
|
| 24 |
+
#include <gtest/gtest.h>
|
| 25 |
+
|
| 26 |
+
#include "arrow/filesystem/s3fs.h"
|
| 27 |
+
#include "arrow/status.h"
|
| 28 |
+
#include "arrow/testing/gtest_util.h"
|
| 29 |
+
#include "arrow/testing/util.h"
|
| 30 |
+
#include "arrow/util/checked_cast.h"
|
| 31 |
+
#include "arrow/util/macros.h"
|
| 32 |
+
|
| 33 |
+
namespace arrow {
|
| 34 |
+
namespace fs {
|
| 35 |
+
|
| 36 |
+
// A minio test server, managed as a child process
|
| 37 |
+
|
| 38 |
+
class MinioTestServer {
|
| 39 |
+
public:
|
| 40 |
+
MinioTestServer();
|
| 41 |
+
~MinioTestServer();
|
| 42 |
+
|
| 43 |
+
Status Start(bool enable_tls = false);
|
| 44 |
+
|
| 45 |
+
Status Stop();
|
| 46 |
+
|
| 47 |
+
std::string connect_string() const;
|
| 48 |
+
|
| 49 |
+
std::string access_key() const;
|
| 50 |
+
|
| 51 |
+
std::string secret_key() const;
|
| 52 |
+
|
| 53 |
+
std::string ca_dir_path() const;
|
| 54 |
+
|
| 55 |
+
std::string ca_file_path() const;
|
| 56 |
+
|
| 57 |
+
std::string scheme() const;
|
| 58 |
+
|
| 59 |
+
private:
|
| 60 |
+
Status GenerateCertificateFile();
|
| 61 |
+
struct Impl;
|
| 62 |
+
std::unique_ptr<Impl> impl_;
|
| 63 |
+
};
|
| 64 |
+
|
| 65 |
+
// A Minio "environment" that spawns Minio processes in advances, such as
|
| 66 |
+
// to hide process launch latencies during testing.
|
| 67 |
+
|
| 68 |
+
class MinioTestEnvironment : public ::testing::Environment {
|
| 69 |
+
public:
|
| 70 |
+
explicit MinioTestEnvironment(bool enable_tls = false);
|
| 71 |
+
~MinioTestEnvironment();
|
| 72 |
+
|
| 73 |
+
void SetUp() override;
|
| 74 |
+
|
| 75 |
+
Result<std::shared_ptr<MinioTestServer>> GetOneServer();
|
| 76 |
+
|
| 77 |
+
protected:
|
| 78 |
+
struct Impl;
|
| 79 |
+
std::unique_ptr<Impl> impl_;
|
| 80 |
+
};
|
| 81 |
+
|
| 82 |
+
// A global test "environment", to ensure that the S3 API is initialized before
|
| 83 |
+
// running unit tests.
|
| 84 |
+
|
| 85 |
+
class S3Environment : public ::testing::Environment {
|
| 86 |
+
public:
|
| 87 |
+
// We set this environment variable to speed up tests by ensuring
|
| 88 |
+
// DefaultAWSCredentialsProviderChain does not query (inaccessible)
|
| 89 |
+
// EC2 metadata endpoint.
|
| 90 |
+
// This must be done before spawning any Minio child process to avoid any race
|
| 91 |
+
// condition accessing environment variables.
|
| 92 |
+
S3Environment() : ec2_metadata_disabled_guard_("AWS_EC2_METADATA_DISABLED", "true") {}
|
| 93 |
+
|
| 94 |
+
void SetUp() override {
|
| 95 |
+
// Change this to increase logging during tests
|
| 96 |
+
S3GlobalOptions options;
|
| 97 |
+
options.log_level = S3LogLevel::Fatal;
|
| 98 |
+
ASSERT_OK(InitializeS3(options));
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
+
void TearDown() override { ASSERT_OK(FinalizeS3()); }
|
| 102 |
+
|
| 103 |
+
private:
|
| 104 |
+
EnvVarGuard ec2_metadata_disabled_guard_;
|
| 105 |
+
};
|
| 106 |
+
|
| 107 |
+
} // namespace fs
|
| 108 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/filesystem/s3fs.h
ADDED
|
@@ -0,0 +1,467 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 <memory>
|
| 21 |
+
#include <string>
|
| 22 |
+
#include <vector>
|
| 23 |
+
|
| 24 |
+
#include "arrow/filesystem/filesystem.h"
|
| 25 |
+
#include "arrow/util/macros.h"
|
| 26 |
+
#include "arrow/util/uri.h"
|
| 27 |
+
|
| 28 |
+
namespace Aws::Auth {
|
| 29 |
+
class AWSCredentialsProvider;
|
| 30 |
+
class STSAssumeRoleCredentialsProvider;
|
| 31 |
+
} // namespace Aws::Auth
|
| 32 |
+
|
| 33 |
+
namespace Aws::STS {
|
| 34 |
+
class STSClient;
|
| 35 |
+
} // namespace Aws::STS
|
| 36 |
+
|
| 37 |
+
namespace arrow::fs {
|
| 38 |
+
|
| 39 |
+
/// Options for using a proxy for S3
|
| 40 |
+
struct ARROW_EXPORT S3ProxyOptions {
|
| 41 |
+
std::string scheme;
|
| 42 |
+
std::string host;
|
| 43 |
+
int port = -1;
|
| 44 |
+
std::string username;
|
| 45 |
+
std::string password;
|
| 46 |
+
|
| 47 |
+
/// Initialize from URI such as http://username:password@host:port
|
| 48 |
+
/// or http://host:port
|
| 49 |
+
static Result<S3ProxyOptions> FromUri(const std::string& uri);
|
| 50 |
+
static Result<S3ProxyOptions> FromUri(const ::arrow::util::Uri& uri);
|
| 51 |
+
|
| 52 |
+
bool Equals(const S3ProxyOptions& other) const;
|
| 53 |
+
};
|
| 54 |
+
|
| 55 |
+
enum class S3CredentialsKind : int8_t {
|
| 56 |
+
/// Anonymous access (no credentials used)
|
| 57 |
+
Anonymous,
|
| 58 |
+
/// Use default AWS credentials, configured through environment variables
|
| 59 |
+
Default,
|
| 60 |
+
/// Use explicitly-provided access key pair
|
| 61 |
+
Explicit,
|
| 62 |
+
/// Assume role through a role ARN
|
| 63 |
+
Role,
|
| 64 |
+
/// Use web identity token to assume role, configured through environment variables
|
| 65 |
+
WebIdentity
|
| 66 |
+
};
|
| 67 |
+
|
| 68 |
+
/// Pure virtual class for describing custom S3 retry strategies
|
| 69 |
+
class ARROW_EXPORT S3RetryStrategy {
|
| 70 |
+
public:
|
| 71 |
+
virtual ~S3RetryStrategy() = default;
|
| 72 |
+
|
| 73 |
+
/// Simple struct where each field corresponds to a field in Aws::Client::AWSError
|
| 74 |
+
struct AWSErrorDetail {
|
| 75 |
+
/// Corresponds to AWSError::GetErrorType()
|
| 76 |
+
int error_type;
|
| 77 |
+
/// Corresponds to AWSError::GetMessage()
|
| 78 |
+
std::string message;
|
| 79 |
+
/// Corresponds to AWSError::GetExceptionName()
|
| 80 |
+
std::string exception_name;
|
| 81 |
+
/// Corresponds to AWSError::ShouldRetry()
|
| 82 |
+
bool should_retry;
|
| 83 |
+
};
|
| 84 |
+
/// Returns true if the S3 request resulting in the provided error should be retried.
|
| 85 |
+
virtual bool ShouldRetry(const AWSErrorDetail& error, int64_t attempted_retries) = 0;
|
| 86 |
+
/// Returns the time in milliseconds the S3 client should sleep for until retrying.
|
| 87 |
+
virtual int64_t CalculateDelayBeforeNextRetry(const AWSErrorDetail& error,
|
| 88 |
+
int64_t attempted_retries) = 0;
|
| 89 |
+
/// Returns a stock AWS Default retry strategy.
|
| 90 |
+
static std::shared_ptr<S3RetryStrategy> GetAwsDefaultRetryStrategy(
|
| 91 |
+
int64_t max_attempts);
|
| 92 |
+
/// Returns a stock AWS Standard retry strategy.
|
| 93 |
+
static std::shared_ptr<S3RetryStrategy> GetAwsStandardRetryStrategy(
|
| 94 |
+
int64_t max_attempts);
|
| 95 |
+
};
|
| 96 |
+
|
| 97 |
+
/// Options for the S3FileSystem implementation.
|
| 98 |
+
struct ARROW_EXPORT S3Options {
|
| 99 |
+
/// \brief Smart defaults for option values
|
| 100 |
+
///
|
| 101 |
+
/// The possible values for this setting are explained in the AWS docs:
|
| 102 |
+
/// https://docs.aws.amazon.com/sdkref/latest/guide/feature-smart-config-defaults.html
|
| 103 |
+
std::string smart_defaults = "standard";
|
| 104 |
+
|
| 105 |
+
/// \brief AWS region to connect to.
|
| 106 |
+
///
|
| 107 |
+
/// If unset, the AWS SDK will choose a default value. The exact algorithm
|
| 108 |
+
/// depends on the SDK version. Before 1.8, the default is hardcoded
|
| 109 |
+
/// to "us-east-1". Since 1.8, several heuristics are used to determine
|
| 110 |
+
/// the region (environment variables, configuration profile, EC2 metadata
|
| 111 |
+
/// server).
|
| 112 |
+
std::string region;
|
| 113 |
+
|
| 114 |
+
/// \brief Socket connection timeout, in seconds
|
| 115 |
+
///
|
| 116 |
+
/// If negative, the AWS SDK default value is used (typically 1 second).
|
| 117 |
+
double connect_timeout = -1;
|
| 118 |
+
|
| 119 |
+
/// \brief Socket read timeout on Windows and macOS, in seconds
|
| 120 |
+
///
|
| 121 |
+
/// If negative, the AWS SDK default value is used (typically 3 seconds).
|
| 122 |
+
/// This option is ignored on non-Windows, non-macOS systems.
|
| 123 |
+
double request_timeout = -1;
|
| 124 |
+
|
| 125 |
+
/// If non-empty, override region with a connect string such as "localhost:9000"
|
| 126 |
+
// XXX perhaps instead take a URL like "http://localhost:9000"?
|
| 127 |
+
std::string endpoint_override;
|
| 128 |
+
/// S3 connection transport, default "https"
|
| 129 |
+
std::string scheme = "https";
|
| 130 |
+
|
| 131 |
+
/// ARN of role to assume
|
| 132 |
+
std::string role_arn;
|
| 133 |
+
/// Optional identifier for an assumed role session.
|
| 134 |
+
std::string session_name;
|
| 135 |
+
/// Optional external identifier to pass to STS when assuming a role
|
| 136 |
+
std::string external_id;
|
| 137 |
+
/// Frequency (in seconds) to refresh temporary credentials from assumed role
|
| 138 |
+
int load_frequency = 900;
|
| 139 |
+
|
| 140 |
+
/// If connection is through a proxy, set options here
|
| 141 |
+
S3ProxyOptions proxy_options;
|
| 142 |
+
|
| 143 |
+
/// AWS credentials provider
|
| 144 |
+
std::shared_ptr<Aws::Auth::AWSCredentialsProvider> credentials_provider;
|
| 145 |
+
|
| 146 |
+
/// Type of credentials being used. Set along with credentials_provider.
|
| 147 |
+
S3CredentialsKind credentials_kind = S3CredentialsKind::Default;
|
| 148 |
+
|
| 149 |
+
/// Whether to use virtual addressing of buckets
|
| 150 |
+
///
|
| 151 |
+
/// If true, then virtual addressing is always enabled.
|
| 152 |
+
/// If false, then virtual addressing is only enabled if `endpoint_override` is empty.
|
| 153 |
+
///
|
| 154 |
+
/// This can be used for non-AWS backends that only support virtual hosted-style access.
|
| 155 |
+
bool force_virtual_addressing = false;
|
| 156 |
+
|
| 157 |
+
/// Whether OutputStream writes will be issued in the background, without blocking.
|
| 158 |
+
bool background_writes = true;
|
| 159 |
+
|
| 160 |
+
/// Whether to allow creation of buckets
|
| 161 |
+
///
|
| 162 |
+
/// When S3FileSystem creates new buckets, it does not pass any non-default settings.
|
| 163 |
+
/// In AWS S3, the bucket and all objects will be not publicly visible, and there
|
| 164 |
+
/// will be no bucket policies and no resource tags. To have more control over how
|
| 165 |
+
/// buckets are created, use a different API to create them.
|
| 166 |
+
bool allow_bucket_creation = false;
|
| 167 |
+
|
| 168 |
+
/// Whether to allow deletion of buckets
|
| 169 |
+
bool allow_bucket_deletion = false;
|
| 170 |
+
|
| 171 |
+
/// Whether to allow pessimistic directory creation in CreateDir function
|
| 172 |
+
///
|
| 173 |
+
/// By default, CreateDir function will try to create the directory without checking its
|
| 174 |
+
/// existence. It's an optimization to try directory creation and catch the error,
|
| 175 |
+
/// rather than issue two dependent I/O calls.
|
| 176 |
+
/// Though for key/value storage like Google Cloud Storage, too many creation calls will
|
| 177 |
+
/// breach the rate limit for object mutation operations and cause serious consequences.
|
| 178 |
+
/// It's also possible you don't have creation access for the parent directory. Set it
|
| 179 |
+
/// to be true to address these scenarios.
|
| 180 |
+
bool check_directory_existence_before_creation = false;
|
| 181 |
+
|
| 182 |
+
/// Whether to allow file-open methods to return before the actual open.
|
| 183 |
+
///
|
| 184 |
+
/// Enabling this may reduce the latency of `OpenInputStream`, `OpenOutputStream`,
|
| 185 |
+
/// and similar methods, by reducing the number of roundtrips necessary. It may also
|
| 186 |
+
/// allow usage of more efficient S3 APIs for small files.
|
| 187 |
+
/// The downside is that failure conditions such as attempting to open a file in a
|
| 188 |
+
/// non-existing bucket will only be reported when actual I/O is done (at worse,
|
| 189 |
+
/// when attempting to close the file).
|
| 190 |
+
bool allow_delayed_open = false;
|
| 191 |
+
|
| 192 |
+
/// \brief Default metadata for OpenOutputStream.
|
| 193 |
+
///
|
| 194 |
+
/// This will be ignored if non-empty metadata is passed to OpenOutputStream.
|
| 195 |
+
std::shared_ptr<const KeyValueMetadata> default_metadata;
|
| 196 |
+
|
| 197 |
+
/// Optional retry strategy to determine which error types should be retried, and the
|
| 198 |
+
/// delay between retries.
|
| 199 |
+
std::shared_ptr<S3RetryStrategy> retry_strategy;
|
| 200 |
+
|
| 201 |
+
/// Optional customer-provided key for server-side encryption (SSE-C).
|
| 202 |
+
///
|
| 203 |
+
/// This should be the 32-byte AES-256 key, unencoded.
|
| 204 |
+
std::string sse_customer_key;
|
| 205 |
+
|
| 206 |
+
/// Optional path to a single PEM file holding all TLS CA certificates
|
| 207 |
+
///
|
| 208 |
+
/// If empty, global filesystem options will be used (see FileSystemGlobalOptions);
|
| 209 |
+
/// if the corresponding global filesystem option is also empty, the underlying
|
| 210 |
+
/// TLS library's defaults will be used.
|
| 211 |
+
///
|
| 212 |
+
/// Note this option may be ignored on some systems (Windows, macOS).
|
| 213 |
+
std::string tls_ca_file_path;
|
| 214 |
+
|
| 215 |
+
/// Optional path to a directory holding TLS CA
|
| 216 |
+
///
|
| 217 |
+
/// The given directory should contain CA certificates as individual PEM files
|
| 218 |
+
/// named along the OpenSSL "hashed" format.
|
| 219 |
+
///
|
| 220 |
+
/// If empty, global filesystem options will be used (see FileSystemGlobalOptions);
|
| 221 |
+
/// if the corresponding global filesystem option is also empty, the underlying
|
| 222 |
+
/// TLS library's defaults will be used.
|
| 223 |
+
///
|
| 224 |
+
/// Note this option may be ignored on some systems (Windows, macOS).
|
| 225 |
+
std::string tls_ca_dir_path;
|
| 226 |
+
|
| 227 |
+
/// Whether to verify the S3 endpoint's TLS certificate
|
| 228 |
+
///
|
| 229 |
+
/// This option applies if the scheme is "https".
|
| 230 |
+
bool tls_verify_certificates = true;
|
| 231 |
+
|
| 232 |
+
S3Options();
|
| 233 |
+
|
| 234 |
+
/// Configure with the default AWS credentials provider chain.
|
| 235 |
+
void ConfigureDefaultCredentials();
|
| 236 |
+
|
| 237 |
+
/// Configure with anonymous credentials. This will only let you access public buckets.
|
| 238 |
+
void ConfigureAnonymousCredentials();
|
| 239 |
+
|
| 240 |
+
/// Configure with explicit access and secret key.
|
| 241 |
+
void ConfigureAccessKey(const std::string& access_key, const std::string& secret_key,
|
| 242 |
+
const std::string& session_token = "");
|
| 243 |
+
|
| 244 |
+
/// Configure with credentials from an assumed role.
|
| 245 |
+
void ConfigureAssumeRoleCredentials(
|
| 246 |
+
const std::string& role_arn, const std::string& session_name = "",
|
| 247 |
+
const std::string& external_id = "", int load_frequency = 900,
|
| 248 |
+
const std::shared_ptr<Aws::STS::STSClient>& stsClient = NULLPTR);
|
| 249 |
+
|
| 250 |
+
/// Configure with credentials from role assumed using a web identity token
|
| 251 |
+
void ConfigureAssumeRoleWithWebIdentityCredentials();
|
| 252 |
+
|
| 253 |
+
std::string GetAccessKey() const;
|
| 254 |
+
std::string GetSecretKey() const;
|
| 255 |
+
std::string GetSessionToken() const;
|
| 256 |
+
|
| 257 |
+
bool Equals(const S3Options& other) const;
|
| 258 |
+
|
| 259 |
+
/// \brief Initialize with default credentials provider chain
|
| 260 |
+
///
|
| 261 |
+
/// This is recommended if you use the standard AWS environment variables
|
| 262 |
+
/// and/or configuration file.
|
| 263 |
+
static S3Options Defaults();
|
| 264 |
+
|
| 265 |
+
/// \brief Initialize with anonymous credentials.
|
| 266 |
+
///
|
| 267 |
+
/// This will only let you access public buckets.
|
| 268 |
+
static S3Options Anonymous();
|
| 269 |
+
|
| 270 |
+
/// \brief Initialize with explicit access and secret key.
|
| 271 |
+
///
|
| 272 |
+
/// Optionally, a session token may also be provided for temporary credentials
|
| 273 |
+
/// (from STS).
|
| 274 |
+
static S3Options FromAccessKey(const std::string& access_key,
|
| 275 |
+
const std::string& secret_key,
|
| 276 |
+
const std::string& session_token = "");
|
| 277 |
+
|
| 278 |
+
/// \brief Initialize from an assumed role.
|
| 279 |
+
static S3Options FromAssumeRole(
|
| 280 |
+
const std::string& role_arn, const std::string& session_name = "",
|
| 281 |
+
const std::string& external_id = "", int load_frequency = 900,
|
| 282 |
+
const std::shared_ptr<Aws::STS::STSClient>& stsClient = NULLPTR);
|
| 283 |
+
|
| 284 |
+
/// \brief Initialize from an assumed role with web-identity.
|
| 285 |
+
/// Uses the AWS SDK which uses environment variables to
|
| 286 |
+
/// generate temporary credentials.
|
| 287 |
+
static S3Options FromAssumeRoleWithWebIdentity();
|
| 288 |
+
|
| 289 |
+
static Result<S3Options> FromUri(const ::arrow::util::Uri& uri,
|
| 290 |
+
std::string* out_path = NULLPTR);
|
| 291 |
+
static Result<S3Options> FromUri(const std::string& uri,
|
| 292 |
+
std::string* out_path = NULLPTR);
|
| 293 |
+
};
|
| 294 |
+
|
| 295 |
+
/// S3-backed FileSystem implementation.
|
| 296 |
+
///
|
| 297 |
+
/// Some implementation notes:
|
| 298 |
+
/// - buckets are special and the operations available on them may be limited
|
| 299 |
+
/// or more expensive than desired.
|
| 300 |
+
class ARROW_EXPORT S3FileSystem : public FileSystem {
|
| 301 |
+
public:
|
| 302 |
+
~S3FileSystem() override;
|
| 303 |
+
|
| 304 |
+
std::string type_name() const override { return "s3"; }
|
| 305 |
+
|
| 306 |
+
/// Return the original S3 options when constructing the filesystem
|
| 307 |
+
S3Options options() const;
|
| 308 |
+
/// Return the actual region this filesystem connects to
|
| 309 |
+
std::string region() const;
|
| 310 |
+
|
| 311 |
+
bool Equals(const FileSystem& other) const override;
|
| 312 |
+
Result<std::string> PathFromUri(const std::string& uri_string) const override;
|
| 313 |
+
Result<std::string> MakeUri(std::string path) const override;
|
| 314 |
+
|
| 315 |
+
/// \cond FALSE
|
| 316 |
+
using FileSystem::CreateDir;
|
| 317 |
+
using FileSystem::DeleteDirContents;
|
| 318 |
+
using FileSystem::DeleteDirContentsAsync;
|
| 319 |
+
using FileSystem::GetFileInfo;
|
| 320 |
+
using FileSystem::OpenAppendStream;
|
| 321 |
+
using FileSystem::OpenOutputStream;
|
| 322 |
+
/// \endcond
|
| 323 |
+
|
| 324 |
+
Result<FileInfo> GetFileInfo(const std::string& path) override;
|
| 325 |
+
Result<std::vector<FileInfo>> GetFileInfo(const FileSelector& select) override;
|
| 326 |
+
|
| 327 |
+
FileInfoGenerator GetFileInfoGenerator(const FileSelector& select) override;
|
| 328 |
+
|
| 329 |
+
Status CreateDir(const std::string& path, bool recursive) override;
|
| 330 |
+
|
| 331 |
+
Status DeleteDir(const std::string& path) override;
|
| 332 |
+
Status DeleteDirContents(const std::string& path, bool missing_dir_ok) override;
|
| 333 |
+
Future<> DeleteDirContentsAsync(const std::string& path, bool missing_dir_ok) override;
|
| 334 |
+
Status DeleteRootDirContents() override;
|
| 335 |
+
|
| 336 |
+
Status DeleteFile(const std::string& path) override;
|
| 337 |
+
|
| 338 |
+
Status Move(const std::string& src, const std::string& dest) override;
|
| 339 |
+
|
| 340 |
+
Status CopyFile(const std::string& src, const std::string& dest) override;
|
| 341 |
+
|
| 342 |
+
/// Create a sequential input stream for reading from a S3 object.
|
| 343 |
+
///
|
| 344 |
+
/// NOTE: Reads from the stream will be synchronous and unbuffered.
|
| 345 |
+
/// You way want to wrap the stream in a BufferedInputStream or use
|
| 346 |
+
/// a custom readahead strategy to avoid idle waits.
|
| 347 |
+
Result<std::shared_ptr<io::InputStream>> OpenInputStream(
|
| 348 |
+
const std::string& path) override;
|
| 349 |
+
/// Create a sequential input stream for reading from a S3 object.
|
| 350 |
+
///
|
| 351 |
+
/// This override avoids a HEAD request by assuming the FileInfo
|
| 352 |
+
/// contains correct information.
|
| 353 |
+
Result<std::shared_ptr<io::InputStream>> OpenInputStream(const FileInfo& info) override;
|
| 354 |
+
|
| 355 |
+
/// Create a random access file for reading from a S3 object.
|
| 356 |
+
///
|
| 357 |
+
/// See OpenInputStream for performance notes.
|
| 358 |
+
Result<std::shared_ptr<io::RandomAccessFile>> OpenInputFile(
|
| 359 |
+
const std::string& path) override;
|
| 360 |
+
/// Create a random access file for reading from a S3 object.
|
| 361 |
+
///
|
| 362 |
+
/// This override avoids a HEAD request by assuming the FileInfo
|
| 363 |
+
/// contains correct information.
|
| 364 |
+
Result<std::shared_ptr<io::RandomAccessFile>> OpenInputFile(
|
| 365 |
+
const FileInfo& info) override;
|
| 366 |
+
|
| 367 |
+
/// Create a sequential output stream for writing to a S3 object.
|
| 368 |
+
///
|
| 369 |
+
/// NOTE: Writes to the stream will be buffered. Depending on
|
| 370 |
+
/// S3Options.background_writes, they can be synchronous or not.
|
| 371 |
+
/// It is recommended to enable background_writes unless you prefer
|
| 372 |
+
/// implementing your own background execution strategy.
|
| 373 |
+
Result<std::shared_ptr<io::OutputStream>> OpenOutputStream(
|
| 374 |
+
const std::string& path,
|
| 375 |
+
const std::shared_ptr<const KeyValueMetadata>& metadata) override;
|
| 376 |
+
|
| 377 |
+
Result<std::shared_ptr<io::OutputStream>> OpenAppendStream(
|
| 378 |
+
const std::string& path,
|
| 379 |
+
const std::shared_ptr<const KeyValueMetadata>& metadata) override;
|
| 380 |
+
|
| 381 |
+
/// Create a S3FileSystem instance from the given options.
|
| 382 |
+
static Result<std::shared_ptr<S3FileSystem>> Make(
|
| 383 |
+
const S3Options& options, const io::IOContext& = io::default_io_context());
|
| 384 |
+
|
| 385 |
+
protected:
|
| 386 |
+
explicit S3FileSystem(const S3Options& options, const io::IOContext&);
|
| 387 |
+
|
| 388 |
+
class Impl;
|
| 389 |
+
std::shared_ptr<Impl> impl_;
|
| 390 |
+
};
|
| 391 |
+
|
| 392 |
+
enum class S3LogLevel : int8_t { Off, Fatal, Error, Warn, Info, Debug, Trace };
|
| 393 |
+
|
| 394 |
+
struct ARROW_EXPORT S3GlobalOptions {
|
| 395 |
+
/// The log level for S3-originating messages.
|
| 396 |
+
S3LogLevel log_level;
|
| 397 |
+
|
| 398 |
+
/// The number of threads to configure when creating AWS' I/O event loop
|
| 399 |
+
///
|
| 400 |
+
/// Defaults to 1 as recommended by AWS' doc when the # of connections is
|
| 401 |
+
/// expected to be, at most, in the hundreds
|
| 402 |
+
///
|
| 403 |
+
/// For more details see Aws::Crt::Io::EventLoopGroup
|
| 404 |
+
int num_event_loop_threads = 1;
|
| 405 |
+
|
| 406 |
+
/// Whether to install a process-wide SIGPIPE handler
|
| 407 |
+
///
|
| 408 |
+
/// The AWS SDK may sometimes emit SIGPIPE signals for certain errors;
|
| 409 |
+
/// by default, they would abort the current process.
|
| 410 |
+
/// This option, if enabled, will install a process-wide signal handler
|
| 411 |
+
/// that logs and otherwise ignore incoming SIGPIPE signals.
|
| 412 |
+
///
|
| 413 |
+
/// This option has no effect on Windows.
|
| 414 |
+
bool install_sigpipe_handler = false;
|
| 415 |
+
|
| 416 |
+
/// \brief Initialize with default options
|
| 417 |
+
///
|
| 418 |
+
/// For log_level, this method first tries to extract a suitable value from the
|
| 419 |
+
/// environment variable ARROW_S3_LOG_LEVEL.
|
| 420 |
+
static S3GlobalOptions Defaults();
|
| 421 |
+
};
|
| 422 |
+
|
| 423 |
+
/// \brief Initialize the S3 APIs with the specified set of options.
|
| 424 |
+
///
|
| 425 |
+
/// It is required to call this function at least once before using S3FileSystem.
|
| 426 |
+
///
|
| 427 |
+
/// Once this function is called you MUST call FinalizeS3 before the end of the
|
| 428 |
+
/// application in order to avoid a segmentation fault at shutdown.
|
| 429 |
+
ARROW_EXPORT
|
| 430 |
+
Status InitializeS3(const S3GlobalOptions& options);
|
| 431 |
+
|
| 432 |
+
/// \brief Ensure the S3 APIs are initialized, but only if not already done.
|
| 433 |
+
///
|
| 434 |
+
/// If necessary, this will call InitializeS3() with some default options.
|
| 435 |
+
ARROW_EXPORT
|
| 436 |
+
Status EnsureS3Initialized();
|
| 437 |
+
|
| 438 |
+
/// Whether S3 was initialized, and not finalized.
|
| 439 |
+
ARROW_EXPORT
|
| 440 |
+
bool IsS3Initialized();
|
| 441 |
+
|
| 442 |
+
/// Whether S3 was finalized.
|
| 443 |
+
ARROW_EXPORT
|
| 444 |
+
bool IsS3Finalized();
|
| 445 |
+
|
| 446 |
+
/// \brief Shutdown the S3 APIs.
|
| 447 |
+
///
|
| 448 |
+
/// This can wait for some S3 concurrent calls to finish so as to avoid
|
| 449 |
+
/// race conditions.
|
| 450 |
+
/// After this function has been called, all S3 calls will fail with an error.
|
| 451 |
+
///
|
| 452 |
+
/// Calls to InitializeS3() and FinalizeS3() should be serialized by the
|
| 453 |
+
/// application (this also applies to EnsureS3Initialized() and
|
| 454 |
+
/// EnsureS3Finalized()).
|
| 455 |
+
ARROW_EXPORT
|
| 456 |
+
Status FinalizeS3();
|
| 457 |
+
|
| 458 |
+
/// \brief Ensure the S3 APIs are shutdown, but only if not already done.
|
| 459 |
+
///
|
| 460 |
+
/// If necessary, this will call FinalizeS3().
|
| 461 |
+
ARROW_EXPORT
|
| 462 |
+
Status EnsureS3Finalized();
|
| 463 |
+
|
| 464 |
+
ARROW_EXPORT
|
| 465 |
+
Result<std::string> ResolveS3BucketRegion(const std::string& bucket);
|
| 466 |
+
|
| 467 |
+
} // namespace arrow::fs
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/filesystem/test_util.h
ADDED
|
@@ -0,0 +1,264 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 <chrono>
|
| 21 |
+
#include <memory>
|
| 22 |
+
#include <string>
|
| 23 |
+
#include <vector>
|
| 24 |
+
|
| 25 |
+
#include "arrow/filesystem/filesystem.h"
|
| 26 |
+
#include "arrow/filesystem/mockfs.h"
|
| 27 |
+
#include "arrow/testing/visibility.h"
|
| 28 |
+
#include "arrow/util/counting_semaphore_internal.h"
|
| 29 |
+
|
| 30 |
+
namespace arrow {
|
| 31 |
+
namespace fs {
|
| 32 |
+
|
| 33 |
+
static constexpr double kTimeSlack = 2.0; // In seconds
|
| 34 |
+
|
| 35 |
+
static inline FileInfo File(std::string path) {
|
| 36 |
+
return FileInfo(std::move(path), FileType::File);
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
static inline FileInfo Dir(std::string path) {
|
| 40 |
+
return FileInfo(std::move(path), FileType::Directory);
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
// A subclass of MockFileSystem that blocks operations until an unlock method is
|
| 44 |
+
// called.
|
| 45 |
+
//
|
| 46 |
+
// This is intended for testing fine-grained ordering of filesystem operations.
|
| 47 |
+
//
|
| 48 |
+
// N.B. Only OpenOutputStream supports gating at the moment but this is simply because
|
| 49 |
+
// it is all that has been needed so far. Feel free to add support for more methods
|
| 50 |
+
// as required.
|
| 51 |
+
class ARROW_TESTING_EXPORT GatedMockFilesystem : public internal::MockFileSystem {
|
| 52 |
+
public:
|
| 53 |
+
GatedMockFilesystem(TimePoint current_time,
|
| 54 |
+
const io::IOContext& = io::default_io_context());
|
| 55 |
+
~GatedMockFilesystem() override;
|
| 56 |
+
|
| 57 |
+
Result<std::shared_ptr<io::OutputStream>> OpenOutputStream(
|
| 58 |
+
const std::string& path,
|
| 59 |
+
const std::shared_ptr<const KeyValueMetadata>& metadata = {}) override;
|
| 60 |
+
|
| 61 |
+
// Wait until at least num_waiters are waiting on OpenOutputStream
|
| 62 |
+
Status WaitForOpenOutputStream(uint32_t num_waiters);
|
| 63 |
+
// Unlock `num_waiters` individual calls to OpenOutputStream
|
| 64 |
+
Status UnlockOpenOutputStream(uint32_t num_waiters);
|
| 65 |
+
|
| 66 |
+
private:
|
| 67 |
+
util::CountingSemaphore open_output_sem_;
|
| 68 |
+
};
|
| 69 |
+
|
| 70 |
+
ARROW_TESTING_EXPORT
|
| 71 |
+
void CreateFile(FileSystem* fs, const std::string& path, const std::string& data);
|
| 72 |
+
|
| 73 |
+
// Sort a vector of FileInfo by lexicographic path order
|
| 74 |
+
ARROW_TESTING_EXPORT
|
| 75 |
+
void SortInfos(FileInfoVector* infos);
|
| 76 |
+
|
| 77 |
+
// Create a copy of a FileInfo vector sorted by lexicographic path order
|
| 78 |
+
ARROW_TESTING_EXPORT
|
| 79 |
+
FileInfoVector SortedInfos(const FileInfoVector& infos);
|
| 80 |
+
|
| 81 |
+
ARROW_TESTING_EXPORT
|
| 82 |
+
void CollectFileInfoGenerator(FileInfoGenerator gen, FileInfoVector* out_infos);
|
| 83 |
+
|
| 84 |
+
ARROW_TESTING_EXPORT
|
| 85 |
+
void AssertFileInfo(const FileInfo& info, const std::string& path, FileType type);
|
| 86 |
+
|
| 87 |
+
ARROW_TESTING_EXPORT
|
| 88 |
+
void AssertFileInfo(const FileInfo& info, const std::string& path, FileType type,
|
| 89 |
+
TimePoint mtime);
|
| 90 |
+
|
| 91 |
+
ARROW_TESTING_EXPORT
|
| 92 |
+
void AssertFileInfo(const FileInfo& info, const std::string& path, FileType type,
|
| 93 |
+
TimePoint mtime, int64_t size);
|
| 94 |
+
|
| 95 |
+
ARROW_TESTING_EXPORT
|
| 96 |
+
void AssertFileInfo(const FileInfo& info, const std::string& path, FileType type,
|
| 97 |
+
int64_t size);
|
| 98 |
+
|
| 99 |
+
ARROW_TESTING_EXPORT
|
| 100 |
+
void AssertFileInfo(FileSystem* fs, const std::string& path, FileType type);
|
| 101 |
+
|
| 102 |
+
ARROW_TESTING_EXPORT
|
| 103 |
+
void AssertFileInfo(FileSystem* fs, const std::string& path, FileType type,
|
| 104 |
+
TimePoint mtime);
|
| 105 |
+
|
| 106 |
+
ARROW_TESTING_EXPORT
|
| 107 |
+
void AssertFileInfo(FileSystem* fs, const std::string& path, FileType type,
|
| 108 |
+
TimePoint mtime, int64_t size);
|
| 109 |
+
|
| 110 |
+
ARROW_TESTING_EXPORT
|
| 111 |
+
void AssertFileInfo(FileSystem* fs, const std::string& path, FileType type, int64_t size);
|
| 112 |
+
|
| 113 |
+
ARROW_TESTING_EXPORT
|
| 114 |
+
void AssertFileContents(FileSystem* fs, const std::string& path,
|
| 115 |
+
const std::string& expected_data);
|
| 116 |
+
|
| 117 |
+
template <typename Duration>
|
| 118 |
+
void AssertDurationBetween(Duration d, double min_secs, double max_secs) {
|
| 119 |
+
auto seconds = std::chrono::duration_cast<std::chrono::duration<double>>(d);
|
| 120 |
+
ASSERT_GE(seconds.count(), min_secs);
|
| 121 |
+
ASSERT_LE(seconds.count(), max_secs);
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
// Generic tests for FileSystem implementations.
|
| 125 |
+
// To use this class, subclass both from it and ::testing::Test,
|
| 126 |
+
// implement GetEmptyFileSystem(), and use GENERIC_FS_TEST_FUNCTIONS()
|
| 127 |
+
// to define the various tests.
|
| 128 |
+
class ARROW_TESTING_EXPORT GenericFileSystemTest {
|
| 129 |
+
public:
|
| 130 |
+
virtual ~GenericFileSystemTest();
|
| 131 |
+
|
| 132 |
+
void TestEmpty();
|
| 133 |
+
void TestNormalizePath();
|
| 134 |
+
void TestCreateDir();
|
| 135 |
+
void TestDeleteDir();
|
| 136 |
+
void TestDeleteDirContents();
|
| 137 |
+
void TestDeleteRootDirContents();
|
| 138 |
+
void TestDeleteFile();
|
| 139 |
+
void TestDeleteFiles();
|
| 140 |
+
void TestMoveFile();
|
| 141 |
+
void TestMoveDir();
|
| 142 |
+
void TestCopyFile();
|
| 143 |
+
void TestCopyFiles();
|
| 144 |
+
void TestGetFileInfo();
|
| 145 |
+
void TestGetFileInfoVector();
|
| 146 |
+
void TestGetFileInfoSelector();
|
| 147 |
+
void TestGetFileInfoSelectorWithRecursion();
|
| 148 |
+
void TestGetFileInfoAsync();
|
| 149 |
+
void TestGetFileInfoGenerator();
|
| 150 |
+
void TestOpenOutputStream();
|
| 151 |
+
void TestOpenAppendStream();
|
| 152 |
+
void TestOpenInputStream();
|
| 153 |
+
void TestOpenInputStreamWithFileInfo();
|
| 154 |
+
void TestOpenInputStreamAsync();
|
| 155 |
+
void TestOpenInputFile();
|
| 156 |
+
void TestOpenInputFileWithFileInfo();
|
| 157 |
+
void TestOpenInputFileAsync();
|
| 158 |
+
void TestSpecialChars();
|
| 159 |
+
|
| 160 |
+
protected:
|
| 161 |
+
// This function should return the filesystem under test.
|
| 162 |
+
virtual std::shared_ptr<FileSystem> GetEmptyFileSystem() = 0;
|
| 163 |
+
|
| 164 |
+
// Override the following functions to specify deviations from expected
|
| 165 |
+
// filesystem semantics.
|
| 166 |
+
// - Whether the filesystem may "implicitly" create intermediate directories
|
| 167 |
+
virtual bool have_implicit_directories() const { return false; }
|
| 168 |
+
// - Whether the filesystem may allow writing a file "over" a directory
|
| 169 |
+
virtual bool allow_write_file_over_dir() const { return false; }
|
| 170 |
+
// - Whether the filesystem may allow writing a directory "over" a file,
|
| 171 |
+
// for example copying file "A" to "B/C" while "B" exists and is a file.
|
| 172 |
+
virtual bool allow_write_implicit_dir_over_file() const { return false; }
|
| 173 |
+
// - Whether the filesystem allows reading a directory
|
| 174 |
+
virtual bool allow_read_dir_as_file() const { return false; }
|
| 175 |
+
// - Whether the filesystem allows moving a file
|
| 176 |
+
virtual bool allow_move_file() const { return true; }
|
| 177 |
+
// - Whether the filesystem allows moving a directory
|
| 178 |
+
virtual bool allow_move_dir() const { return true; }
|
| 179 |
+
// - Whether the filesystem allows moving a directory "over" a non-empty destination
|
| 180 |
+
virtual bool allow_move_dir_over_non_empty_dir() const { return false; }
|
| 181 |
+
// - Whether the filesystem allows appending to a file
|
| 182 |
+
virtual bool allow_append_to_file() const { return true; }
|
| 183 |
+
// - Whether the filesystem allows appending to a nonexistent file
|
| 184 |
+
virtual bool allow_append_to_new_file() const { return true; }
|
| 185 |
+
// - Whether the filesystem supports directory modification times
|
| 186 |
+
virtual bool have_directory_mtimes() const { return true; }
|
| 187 |
+
// - Whether some directory tree deletion tests may fail randomly
|
| 188 |
+
virtual bool have_flaky_directory_tree_deletion() const { return false; }
|
| 189 |
+
// - Whether the filesystem stores some metadata alongside files
|
| 190 |
+
virtual bool have_file_metadata() const { return false; }
|
| 191 |
+
// - Whether the filesystem has a false positive memory leak with generator
|
| 192 |
+
virtual bool have_false_positive_memory_leak_with_generator() const { return false; }
|
| 193 |
+
// - Whether the filesystem has a false positive memory leak in async close
|
| 194 |
+
virtual bool have_false_positive_memory_leak_with_async_close() const { return false; }
|
| 195 |
+
|
| 196 |
+
void TestEmpty(FileSystem* fs);
|
| 197 |
+
void TestNormalizePath(FileSystem* fs);
|
| 198 |
+
void TestCreateDir(FileSystem* fs);
|
| 199 |
+
void TestDeleteDir(FileSystem* fs);
|
| 200 |
+
void TestDeleteDirContents(FileSystem* fs);
|
| 201 |
+
void TestDeleteRootDirContents(FileSystem* fs);
|
| 202 |
+
void TestDeleteFile(FileSystem* fs);
|
| 203 |
+
void TestDeleteFiles(FileSystem* fs);
|
| 204 |
+
void TestMoveFile(FileSystem* fs);
|
| 205 |
+
void TestMoveDir(FileSystem* fs);
|
| 206 |
+
void TestCopyFile(FileSystem* fs);
|
| 207 |
+
void TestCopyFiles(FileSystem* fs);
|
| 208 |
+
void TestGetFileInfo(FileSystem* fs);
|
| 209 |
+
void TestGetFileInfoVector(FileSystem* fs);
|
| 210 |
+
void TestGetFileInfoSelector(FileSystem* fs);
|
| 211 |
+
void TestGetFileInfoSelectorWithRecursion(FileSystem* fs);
|
| 212 |
+
void TestGetFileInfoAsync(FileSystem* fs);
|
| 213 |
+
void TestGetFileInfoGenerator(FileSystem* fs);
|
| 214 |
+
void TestOpenOutputStream(FileSystem* fs);
|
| 215 |
+
void TestOpenAppendStream(FileSystem* fs);
|
| 216 |
+
void TestOpenInputStream(FileSystem* fs);
|
| 217 |
+
void TestOpenInputStreamWithFileInfo(FileSystem* fs);
|
| 218 |
+
void TestOpenInputStreamAsync(FileSystem* fs);
|
| 219 |
+
void TestOpenInputFile(FileSystem* fs);
|
| 220 |
+
void TestOpenInputFileWithFileInfo(FileSystem* fs);
|
| 221 |
+
void TestOpenInputFileAsync(FileSystem* fs);
|
| 222 |
+
void TestSpecialChars(FileSystem* fs);
|
| 223 |
+
};
|
| 224 |
+
|
| 225 |
+
#define GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, NAME) \
|
| 226 |
+
TEST_MACRO(TEST_CLASS, NAME) { this->Test##NAME(); }
|
| 227 |
+
|
| 228 |
+
#define GENERIC_FS_TEST_FUNCTIONS_MACROS(TEST_MACRO, TEST_CLASS) \
|
| 229 |
+
GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, Empty) \
|
| 230 |
+
GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, NormalizePath) \
|
| 231 |
+
GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, CreateDir) \
|
| 232 |
+
GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, DeleteDir) \
|
| 233 |
+
GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, DeleteDirContents) \
|
| 234 |
+
GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, DeleteRootDirContents) \
|
| 235 |
+
GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, DeleteFile) \
|
| 236 |
+
GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, DeleteFiles) \
|
| 237 |
+
GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, MoveFile) \
|
| 238 |
+
GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, MoveDir) \
|
| 239 |
+
GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, CopyFile) \
|
| 240 |
+
GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, CopyFiles) \
|
| 241 |
+
GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, GetFileInfo) \
|
| 242 |
+
GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, GetFileInfoVector) \
|
| 243 |
+
GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, GetFileInfoSelector) \
|
| 244 |
+
GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, GetFileInfoSelectorWithRecursion) \
|
| 245 |
+
GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, GetFileInfoAsync) \
|
| 246 |
+
GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, GetFileInfoGenerator) \
|
| 247 |
+
GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, OpenOutputStream) \
|
| 248 |
+
GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, OpenAppendStream) \
|
| 249 |
+
GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, OpenInputStream) \
|
| 250 |
+
GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, OpenInputStreamWithFileInfo) \
|
| 251 |
+
GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, OpenInputStreamAsync) \
|
| 252 |
+
GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, OpenInputFile) \
|
| 253 |
+
GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, OpenInputFileWithFileInfo) \
|
| 254 |
+
GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, OpenInputFileAsync) \
|
| 255 |
+
GENERIC_FS_TEST_FUNCTION(TEST_MACRO, TEST_CLASS, SpecialChars)
|
| 256 |
+
|
| 257 |
+
#define GENERIC_FS_TEST_FUNCTIONS(TEST_CLASS) \
|
| 258 |
+
GENERIC_FS_TEST_FUNCTIONS_MACROS(TEST_F, TEST_CLASS)
|
| 259 |
+
|
| 260 |
+
#define GENERIC_FS_TYPED_TEST_FUNCTIONS(TEST_CLASS) \
|
| 261 |
+
GENERIC_FS_TEST_FUNCTIONS_MACROS(TYPED_TEST, TEST_CLASS)
|
| 262 |
+
|
| 263 |
+
} // namespace fs
|
| 264 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/filesystem/type_fwd.h
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 <cstdint>
|
| 21 |
+
|
| 22 |
+
namespace arrow {
|
| 23 |
+
namespace fs {
|
| 24 |
+
|
| 25 |
+
/// \brief FileSystem entry type
|
| 26 |
+
enum class FileType : int8_t {
|
| 27 |
+
/// Entry is not found
|
| 28 |
+
NotFound,
|
| 29 |
+
/// Entry exists but its type is unknown
|
| 30 |
+
///
|
| 31 |
+
/// This can designate a special file such as a Unix socket or character
|
| 32 |
+
/// device, or Windows NUL / CON / ...
|
| 33 |
+
Unknown,
|
| 34 |
+
/// Entry is a regular file
|
| 35 |
+
File,
|
| 36 |
+
/// Entry is a directory
|
| 37 |
+
Directory
|
| 38 |
+
};
|
| 39 |
+
|
| 40 |
+
struct FileInfo;
|
| 41 |
+
|
| 42 |
+
struct FileSelector;
|
| 43 |
+
|
| 44 |
+
class FileSystem;
|
| 45 |
+
class AzureFileSystem;
|
| 46 |
+
class GcsFileSystem;
|
| 47 |
+
class LocalFileSystem;
|
| 48 |
+
class S3FileSystem;
|
| 49 |
+
class SlowFileSystem;
|
| 50 |
+
class SubTreeFileSystem;
|
| 51 |
+
|
| 52 |
+
} // namespace fs
|
| 53 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/api.h
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 "arrow/flight/client.h"
|
| 21 |
+
#include "arrow/flight/client_auth.h"
|
| 22 |
+
#include "arrow/flight/client_middleware.h"
|
| 23 |
+
#include "arrow/flight/client_tracing_middleware.h"
|
| 24 |
+
#include "arrow/flight/middleware.h"
|
| 25 |
+
#include "arrow/flight/server.h"
|
| 26 |
+
#include "arrow/flight/server_auth.h"
|
| 27 |
+
#include "arrow/flight/server_middleware.h"
|
| 28 |
+
#include "arrow/flight/server_tracing_middleware.h"
|
| 29 |
+
#include "arrow/flight/types.h"
|
| 30 |
+
#include "arrow/flight/types_async.h"
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/client.h
ADDED
|
@@ -0,0 +1,430 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
/// \brief Implementation of Flight RPC client.
|
| 19 |
+
|
| 20 |
+
#pragma once
|
| 21 |
+
|
| 22 |
+
#include <chrono>
|
| 23 |
+
#include <memory>
|
| 24 |
+
#include <string>
|
| 25 |
+
#include <utility>
|
| 26 |
+
#include <variant>
|
| 27 |
+
#include <vector>
|
| 28 |
+
|
| 29 |
+
#include "arrow/ipc/options.h"
|
| 30 |
+
#include "arrow/ipc/reader.h"
|
| 31 |
+
#include "arrow/ipc/writer.h"
|
| 32 |
+
#include "arrow/result.h"
|
| 33 |
+
#include "arrow/status.h"
|
| 34 |
+
#include "arrow/util/cancel.h"
|
| 35 |
+
|
| 36 |
+
#include "arrow/flight/type_fwd.h"
|
| 37 |
+
#include "arrow/flight/types.h" // IWYU pragma: keep
|
| 38 |
+
#include "arrow/flight/visibility.h"
|
| 39 |
+
|
| 40 |
+
namespace arrow {
|
| 41 |
+
|
| 42 |
+
class RecordBatch;
|
| 43 |
+
class Schema;
|
| 44 |
+
|
| 45 |
+
namespace flight {
|
| 46 |
+
|
| 47 |
+
/// \brief A duration type for Flight call timeouts.
|
| 48 |
+
typedef std::chrono::duration<double, std::chrono::seconds::period> TimeoutDuration;
|
| 49 |
+
|
| 50 |
+
/// \brief Hints to the underlying RPC layer for Arrow Flight calls.
|
| 51 |
+
class ARROW_FLIGHT_EXPORT FlightCallOptions {
|
| 52 |
+
public:
|
| 53 |
+
/// Create a default set of call options.
|
| 54 |
+
FlightCallOptions();
|
| 55 |
+
|
| 56 |
+
/// \brief An optional timeout for this call. Negative durations
|
| 57 |
+
/// mean an implementation-defined default behavior will be used
|
| 58 |
+
/// instead. This is the default value.
|
| 59 |
+
TimeoutDuration timeout;
|
| 60 |
+
|
| 61 |
+
/// \brief IPC reader options, if applicable for the call.
|
| 62 |
+
ipc::IpcReadOptions read_options;
|
| 63 |
+
|
| 64 |
+
/// \brief IPC writer options, if applicable for the call.
|
| 65 |
+
ipc::IpcWriteOptions write_options;
|
| 66 |
+
|
| 67 |
+
/// \brief Headers for client to add to context.
|
| 68 |
+
std::vector<std::pair<std::string, std::string>> headers;
|
| 69 |
+
|
| 70 |
+
/// \brief A token to enable interactive user cancellation of long-running requests.
|
| 71 |
+
StopToken stop_token;
|
| 72 |
+
|
| 73 |
+
/// \brief An optional memory manager to control where to allocate incoming data.
|
| 74 |
+
std::shared_ptr<MemoryManager> memory_manager;
|
| 75 |
+
};
|
| 76 |
+
|
| 77 |
+
/// \brief Indicate that the client attempted to write a message
|
| 78 |
+
/// larger than the soft limit set via write_size_limit_bytes.
|
| 79 |
+
class ARROW_FLIGHT_EXPORT FlightWriteSizeStatusDetail : public arrow::StatusDetail {
|
| 80 |
+
public:
|
| 81 |
+
explicit FlightWriteSizeStatusDetail(int64_t limit, int64_t actual)
|
| 82 |
+
: limit_(limit), actual_(actual) {}
|
| 83 |
+
const char* type_id() const override;
|
| 84 |
+
std::string ToString() const override;
|
| 85 |
+
int64_t limit() const { return limit_; }
|
| 86 |
+
int64_t actual() const { return actual_; }
|
| 87 |
+
|
| 88 |
+
/// \brief Extract this status detail from a status, or return
|
| 89 |
+
/// nullptr if the status doesn't contain this status detail.
|
| 90 |
+
static std::shared_ptr<FlightWriteSizeStatusDetail> UnwrapStatus(
|
| 91 |
+
const arrow::Status& status);
|
| 92 |
+
|
| 93 |
+
private:
|
| 94 |
+
int64_t limit_;
|
| 95 |
+
int64_t actual_;
|
| 96 |
+
};
|
| 97 |
+
|
| 98 |
+
struct ARROW_FLIGHT_EXPORT FlightClientOptions {
|
| 99 |
+
/// \brief Root certificates to use for validating server
|
| 100 |
+
/// certificates.
|
| 101 |
+
std::string tls_root_certs;
|
| 102 |
+
/// \brief Override the hostname checked by TLS. Use with caution.
|
| 103 |
+
std::string override_hostname;
|
| 104 |
+
/// \brief The client certificate to use if using Mutual TLS
|
| 105 |
+
std::string cert_chain;
|
| 106 |
+
/// \brief The private key associated with the client certificate for Mutual TLS
|
| 107 |
+
std::string private_key;
|
| 108 |
+
/// \brief A list of client middleware to apply.
|
| 109 |
+
std::vector<std::shared_ptr<ClientMiddlewareFactory>> middleware;
|
| 110 |
+
/// \brief A soft limit on the number of bytes to write in a single
|
| 111 |
+
/// batch when sending Arrow data to a server.
|
| 112 |
+
///
|
| 113 |
+
/// Used to help limit server memory consumption. Only enabled if
|
| 114 |
+
/// positive. When enabled, FlightStreamWriter.Write* may yield a
|
| 115 |
+
/// IOError with error detail FlightWriteSizeStatusDetail.
|
| 116 |
+
int64_t write_size_limit_bytes = 0;
|
| 117 |
+
|
| 118 |
+
/// \brief Generic connection options, passed to the underlying
|
| 119 |
+
/// transport; interpretation is implementation-dependent.
|
| 120 |
+
std::vector<std::pair<std::string, std::variant<int, std::string>>> generic_options;
|
| 121 |
+
|
| 122 |
+
/// \brief Use TLS without validating the server certificate. Use with caution.
|
| 123 |
+
bool disable_server_verification = false;
|
| 124 |
+
|
| 125 |
+
/// \brief Get default options.
|
| 126 |
+
static FlightClientOptions Defaults();
|
| 127 |
+
};
|
| 128 |
+
|
| 129 |
+
/// \brief A RecordBatchReader exposing Flight metadata and cancel
|
| 130 |
+
/// operations.
|
| 131 |
+
class ARROW_FLIGHT_EXPORT FlightStreamReader : public MetadataRecordBatchReader {
|
| 132 |
+
public:
|
| 133 |
+
/// \brief Try to cancel the call.
|
| 134 |
+
virtual void Cancel() = 0;
|
| 135 |
+
|
| 136 |
+
using MetadataRecordBatchReader::ToRecordBatches;
|
| 137 |
+
/// \brief Consume entire stream as a vector of record batches
|
| 138 |
+
virtual arrow::Result<std::vector<std::shared_ptr<RecordBatch>>> ToRecordBatches(
|
| 139 |
+
const StopToken& stop_token) = 0;
|
| 140 |
+
|
| 141 |
+
using MetadataRecordBatchReader::ToTable;
|
| 142 |
+
/// \brief Consume entire stream as a Table
|
| 143 |
+
arrow::Result<std::shared_ptr<Table>> ToTable(const StopToken& stop_token);
|
| 144 |
+
};
|
| 145 |
+
|
| 146 |
+
// Silence warning
|
| 147 |
+
// "non dll-interface class RecordBatchReader used as base for dll-interface class"
|
| 148 |
+
#ifdef _MSC_VER
|
| 149 |
+
# pragma warning(push)
|
| 150 |
+
# pragma warning(disable : 4275)
|
| 151 |
+
#endif
|
| 152 |
+
|
| 153 |
+
/// \brief A RecordBatchWriter that also allows sending
|
| 154 |
+
/// application-defined metadata via the Flight protocol.
|
| 155 |
+
class ARROW_FLIGHT_EXPORT FlightStreamWriter : public MetadataRecordBatchWriter {
|
| 156 |
+
public:
|
| 157 |
+
/// \brief Indicate that the application is done writing to this stream.
|
| 158 |
+
///
|
| 159 |
+
/// The application may not write to this stream after calling
|
| 160 |
+
/// this. This differs from closing the stream because this writer
|
| 161 |
+
/// may represent only one half of a readable and writable stream.
|
| 162 |
+
virtual Status DoneWriting() = 0;
|
| 163 |
+
};
|
| 164 |
+
|
| 165 |
+
#ifdef _MSC_VER
|
| 166 |
+
# pragma warning(pop)
|
| 167 |
+
#endif
|
| 168 |
+
|
| 169 |
+
/// \brief A reader for application-specific metadata sent back to the
|
| 170 |
+
/// client during an upload.
|
| 171 |
+
class ARROW_FLIGHT_EXPORT FlightMetadataReader {
|
| 172 |
+
public:
|
| 173 |
+
virtual ~FlightMetadataReader();
|
| 174 |
+
/// \brief Read a message from the server.
|
| 175 |
+
virtual Status ReadMetadata(std::shared_ptr<Buffer>* out) = 0;
|
| 176 |
+
};
|
| 177 |
+
|
| 178 |
+
/// \brief Client class for Arrow Flight RPC services.
|
| 179 |
+
class ARROW_FLIGHT_EXPORT FlightClient {
|
| 180 |
+
public:
|
| 181 |
+
~FlightClient();
|
| 182 |
+
|
| 183 |
+
/// \brief Connect to an unauthenticated flight service
|
| 184 |
+
/// \param[in] location the URI
|
| 185 |
+
/// \return Arrow result with the created FlightClient, OK status may not indicate that
|
| 186 |
+
/// the connection was successful
|
| 187 |
+
static arrow::Result<std::unique_ptr<FlightClient>> Connect(const Location& location);
|
| 188 |
+
|
| 189 |
+
/// \brief Connect to an unauthenticated flight service
|
| 190 |
+
/// \param[in] location the URI
|
| 191 |
+
/// \param[in] options Other options for setting up the client
|
| 192 |
+
/// \return Arrow result with the created FlightClient, OK status may not indicate that
|
| 193 |
+
/// the connection was successful
|
| 194 |
+
static arrow::Result<std::unique_ptr<FlightClient>> Connect(
|
| 195 |
+
const Location& location, const FlightClientOptions& options);
|
| 196 |
+
|
| 197 |
+
/// \brief Authenticate to the server using the given handler.
|
| 198 |
+
/// \param[in] options Per-RPC options
|
| 199 |
+
/// \param[in] auth_handler The authentication mechanism to use
|
| 200 |
+
/// \return Status OK if the client authenticated successfully
|
| 201 |
+
Status Authenticate(const FlightCallOptions& options,
|
| 202 |
+
std::unique_ptr<ClientAuthHandler> auth_handler);
|
| 203 |
+
|
| 204 |
+
/// \brief Authenticate to the server using basic HTTP style authentication.
|
| 205 |
+
/// \param[in] options Per-RPC options
|
| 206 |
+
/// \param[in] username Username to use
|
| 207 |
+
/// \param[in] password Password to use
|
| 208 |
+
/// \return Arrow result with bearer token and status OK if client authenticated
|
| 209 |
+
/// successfully
|
| 210 |
+
arrow::Result<std::pair<std::string, std::string>> AuthenticateBasicToken(
|
| 211 |
+
const FlightCallOptions& options, const std::string& username,
|
| 212 |
+
const std::string& password);
|
| 213 |
+
|
| 214 |
+
/// \brief Perform the indicated action, returning an iterator to the stream
|
| 215 |
+
/// of results, if any
|
| 216 |
+
/// \param[in] options Per-RPC options
|
| 217 |
+
/// \param[in] action the action to be performed
|
| 218 |
+
/// \return Arrow result with an iterator object for reading the returned results
|
| 219 |
+
arrow::Result<std::unique_ptr<ResultStream>> DoAction(const FlightCallOptions& options,
|
| 220 |
+
const Action& action);
|
| 221 |
+
arrow::Result<std::unique_ptr<ResultStream>> DoAction(const Action& action) {
|
| 222 |
+
return DoAction({}, action);
|
| 223 |
+
}
|
| 224 |
+
|
| 225 |
+
/// \brief Perform the CancelFlightInfo action, returning a
|
| 226 |
+
/// CancelFlightInfoResult
|
| 227 |
+
///
|
| 228 |
+
/// \param[in] options Per-RPC options
|
| 229 |
+
/// \param[in] request The CancelFlightInfoRequest
|
| 230 |
+
/// \return Arrow result with a CancelFlightInfoResult
|
| 231 |
+
arrow::Result<CancelFlightInfoResult> CancelFlightInfo(
|
| 232 |
+
const FlightCallOptions& options, const CancelFlightInfoRequest& request);
|
| 233 |
+
arrow::Result<CancelFlightInfoResult> CancelFlightInfo(
|
| 234 |
+
const CancelFlightInfoRequest& request) {
|
| 235 |
+
return CancelFlightInfo({}, request);
|
| 236 |
+
}
|
| 237 |
+
|
| 238 |
+
/// \brief Perform the RenewFlightEndpoint action, returning a renewed
|
| 239 |
+
/// FlightEndpoint
|
| 240 |
+
///
|
| 241 |
+
/// \param[in] options Per-RPC options
|
| 242 |
+
/// \param[in] request The RenewFlightEndpointRequest
|
| 243 |
+
/// \return Arrow result with a renewed FlightEndpoint
|
| 244 |
+
arrow::Result<FlightEndpoint> RenewFlightEndpoint(
|
| 245 |
+
const FlightCallOptions& options, const RenewFlightEndpointRequest& request);
|
| 246 |
+
arrow::Result<FlightEndpoint> RenewFlightEndpoint(
|
| 247 |
+
const RenewFlightEndpointRequest& request) {
|
| 248 |
+
return RenewFlightEndpoint({}, request);
|
| 249 |
+
}
|
| 250 |
+
|
| 251 |
+
/// \brief Retrieve a list of available Action types
|
| 252 |
+
/// \param[in] options Per-RPC options
|
| 253 |
+
/// \return Arrow result with the available actions
|
| 254 |
+
arrow::Result<std::vector<ActionType>> ListActions(const FlightCallOptions& options);
|
| 255 |
+
arrow::Result<std::vector<ActionType>> ListActions() {
|
| 256 |
+
return ListActions(FlightCallOptions());
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
/// \brief Request access plan for a single flight, which may be an existing
|
| 260 |
+
/// dataset or a command to be executed
|
| 261 |
+
/// \param[in] options Per-RPC options
|
| 262 |
+
/// \param[in] descriptor the dataset request, whether a named dataset or
|
| 263 |
+
/// command
|
| 264 |
+
/// \return Arrow result with the FlightInfo describing where to access the dataset
|
| 265 |
+
arrow::Result<std::unique_ptr<FlightInfo>> GetFlightInfo(
|
| 266 |
+
const FlightCallOptions& options, const FlightDescriptor& descriptor);
|
| 267 |
+
arrow::Result<std::unique_ptr<FlightInfo>> GetFlightInfo(
|
| 268 |
+
const FlightDescriptor& descriptor) {
|
| 269 |
+
return GetFlightInfo({}, descriptor);
|
| 270 |
+
}
|
| 271 |
+
|
| 272 |
+
/// \brief Asynchronous GetFlightInfo.
|
| 273 |
+
/// \param[in] options Per-RPC options
|
| 274 |
+
/// \param[in] descriptor the dataset request
|
| 275 |
+
/// \param[in] listener Callbacks for response and RPC completion
|
| 276 |
+
void GetFlightInfoAsync(const FlightCallOptions& options,
|
| 277 |
+
const FlightDescriptor& descriptor,
|
| 278 |
+
std::shared_ptr<AsyncListener<FlightInfo>> listener);
|
| 279 |
+
void GetFlightInfoAsync(const FlightDescriptor& descriptor,
|
| 280 |
+
std::shared_ptr<AsyncListener<FlightInfo>> listener) {
|
| 281 |
+
return GetFlightInfoAsync({}, descriptor, std::move(listener));
|
| 282 |
+
}
|
| 283 |
+
|
| 284 |
+
/// \brief Asynchronous GetFlightInfo returning a Future.
|
| 285 |
+
/// \param[in] options Per-RPC options
|
| 286 |
+
/// \param[in] descriptor the dataset request
|
| 287 |
+
arrow::Future<FlightInfo> GetFlightInfoAsync(const FlightCallOptions& options,
|
| 288 |
+
const FlightDescriptor& descriptor);
|
| 289 |
+
arrow::Future<FlightInfo> GetFlightInfoAsync(const FlightDescriptor& descriptor) {
|
| 290 |
+
return GetFlightInfoAsync({}, descriptor);
|
| 291 |
+
}
|
| 292 |
+
|
| 293 |
+
/// \brief Request and poll a long running query
|
| 294 |
+
/// \param[in] options Per-RPC options
|
| 295 |
+
/// \param[in] descriptor the dataset request or a descriptor returned by a
|
| 296 |
+
/// prior PollFlightInfo call
|
| 297 |
+
/// \return Arrow result with the PollInfo describing the status of
|
| 298 |
+
/// the requested query
|
| 299 |
+
arrow::Result<std::unique_ptr<PollInfo>> PollFlightInfo(
|
| 300 |
+
const FlightCallOptions& options, const FlightDescriptor& descriptor);
|
| 301 |
+
arrow::Result<std::unique_ptr<PollInfo>> PollFlightInfo(
|
| 302 |
+
const FlightDescriptor& descriptor) {
|
| 303 |
+
return PollFlightInfo({}, descriptor);
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
/// \brief Request schema for a single flight, which may be an existing
|
| 307 |
+
/// dataset or a command to be executed
|
| 308 |
+
/// \param[in] options Per-RPC options
|
| 309 |
+
/// \param[in] descriptor the dataset request, whether a named dataset or
|
| 310 |
+
/// command
|
| 311 |
+
/// \return Arrow result with the SchemaResult describing the dataset schema
|
| 312 |
+
arrow::Result<std::unique_ptr<SchemaResult>> GetSchema(
|
| 313 |
+
const FlightCallOptions& options, const FlightDescriptor& descriptor);
|
| 314 |
+
|
| 315 |
+
arrow::Result<std::unique_ptr<SchemaResult>> GetSchema(
|
| 316 |
+
const FlightDescriptor& descriptor) {
|
| 317 |
+
return GetSchema({}, descriptor);
|
| 318 |
+
}
|
| 319 |
+
|
| 320 |
+
/// \brief List all available flights known to the server
|
| 321 |
+
/// \return Arrow result with an iterator that returns a FlightInfo for each flight
|
| 322 |
+
arrow::Result<std::unique_ptr<FlightListing>> ListFlights();
|
| 323 |
+
|
| 324 |
+
/// \brief List available flights given indicated filter criteria
|
| 325 |
+
/// \param[in] options Per-RPC options
|
| 326 |
+
/// \param[in] criteria the filter criteria (opaque)
|
| 327 |
+
/// \return Arrow result with an iterator that returns a FlightInfo for each flight
|
| 328 |
+
arrow::Result<std::unique_ptr<FlightListing>> ListFlights(
|
| 329 |
+
const FlightCallOptions& options, const Criteria& criteria);
|
| 330 |
+
|
| 331 |
+
/// \brief Given a flight ticket and schema, request to be sent the
|
| 332 |
+
/// stream. Returns record batch stream reader
|
| 333 |
+
/// \param[in] options Per-RPC options
|
| 334 |
+
/// \param[in] ticket The flight ticket to use
|
| 335 |
+
/// \return Arrow result with the returned RecordBatchReader
|
| 336 |
+
arrow::Result<std::unique_ptr<FlightStreamReader>> DoGet(
|
| 337 |
+
const FlightCallOptions& options, const Ticket& ticket);
|
| 338 |
+
arrow::Result<std::unique_ptr<FlightStreamReader>> DoGet(const Ticket& ticket) {
|
| 339 |
+
return DoGet({}, ticket);
|
| 340 |
+
}
|
| 341 |
+
|
| 342 |
+
/// \brief DoPut return value
|
| 343 |
+
struct DoPutResult {
|
| 344 |
+
/// \brief a writer to write record batches to
|
| 345 |
+
std::unique_ptr<FlightStreamWriter> writer;
|
| 346 |
+
/// \brief a reader for application metadata from the server
|
| 347 |
+
std::unique_ptr<FlightMetadataReader> reader;
|
| 348 |
+
};
|
| 349 |
+
/// \brief Upload data to a Flight described by the given
|
| 350 |
+
/// descriptor. The caller must call Close() on the returned stream
|
| 351 |
+
/// once they are done writing.
|
| 352 |
+
///
|
| 353 |
+
/// The reader and writer are linked; closing the writer will also
|
| 354 |
+
/// close the reader. Use \a DoneWriting to only close the write
|
| 355 |
+
/// side of the channel.
|
| 356 |
+
///
|
| 357 |
+
/// \param[in] options Per-RPC options
|
| 358 |
+
/// \param[in] descriptor the descriptor of the stream
|
| 359 |
+
/// \param[in] schema the schema for the data to upload
|
| 360 |
+
/// \return Arrow result with a DoPutResult struct holding a reader and a writer
|
| 361 |
+
arrow::Result<DoPutResult> DoPut(const FlightCallOptions& options,
|
| 362 |
+
const FlightDescriptor& descriptor,
|
| 363 |
+
const std::shared_ptr<Schema>& schema);
|
| 364 |
+
|
| 365 |
+
arrow::Result<DoPutResult> DoPut(const FlightDescriptor& descriptor,
|
| 366 |
+
const std::shared_ptr<Schema>& schema) {
|
| 367 |
+
return DoPut({}, descriptor, schema);
|
| 368 |
+
}
|
| 369 |
+
|
| 370 |
+
struct DoExchangeResult {
|
| 371 |
+
std::unique_ptr<FlightStreamWriter> writer;
|
| 372 |
+
std::unique_ptr<FlightStreamReader> reader;
|
| 373 |
+
};
|
| 374 |
+
arrow::Result<DoExchangeResult> DoExchange(const FlightCallOptions& options,
|
| 375 |
+
const FlightDescriptor& descriptor);
|
| 376 |
+
arrow::Result<DoExchangeResult> DoExchange(const FlightDescriptor& descriptor) {
|
| 377 |
+
return DoExchange({}, descriptor);
|
| 378 |
+
}
|
| 379 |
+
|
| 380 |
+
/// \brief Set server session option(s) by name/value. Sessions are generally
|
| 381 |
+
/// persisted via HTTP cookies.
|
| 382 |
+
/// \param[in] options Per-RPC options
|
| 383 |
+
/// \param[in] request The server session options to set
|
| 384 |
+
::arrow::Result<SetSessionOptionsResult> SetSessionOptions(
|
| 385 |
+
const FlightCallOptions& options, const SetSessionOptionsRequest& request);
|
| 386 |
+
|
| 387 |
+
/// \brief Get the current server session options. The session is generally
|
| 388 |
+
/// accessed via an HTTP cookie.
|
| 389 |
+
/// \param[in] options Per-RPC options
|
| 390 |
+
/// \param[in] request The (empty) GetSessionOptions request object.
|
| 391 |
+
::arrow::Result<GetSessionOptionsResult> GetSessionOptions(
|
| 392 |
+
const FlightCallOptions& options, const GetSessionOptionsRequest& request);
|
| 393 |
+
|
| 394 |
+
/// \brief Close/invalidate the current server session. The session is generally
|
| 395 |
+
/// accessed via an HTTP cookie.
|
| 396 |
+
/// \param[in] options Per-RPC options
|
| 397 |
+
/// \param[in] request The (empty) CloseSession request object.
|
| 398 |
+
::arrow::Result<CloseSessionResult> CloseSession(const FlightCallOptions& options,
|
| 399 |
+
const CloseSessionRequest& request);
|
| 400 |
+
|
| 401 |
+
/// \brief Explicitly shut down and clean up the client.
|
| 402 |
+
///
|
| 403 |
+
/// For backwards compatibility, this will be implicitly called by
|
| 404 |
+
/// the destructor if not already called, but this gives the
|
| 405 |
+
/// application no chance to handle errors, so it is recommended to
|
| 406 |
+
/// explicitly close the client.
|
| 407 |
+
///
|
| 408 |
+
/// \since 8.0.0
|
| 409 |
+
Status Close();
|
| 410 |
+
|
| 411 |
+
/// \brief Whether this client supports asynchronous methods.
|
| 412 |
+
bool supports_async() const;
|
| 413 |
+
|
| 414 |
+
/// \brief Check whether this client supports asynchronous methods.
|
| 415 |
+
///
|
| 416 |
+
/// This is like supports_async(), except that a detailed error message
|
| 417 |
+
/// is returned if async support is not available. If async support is
|
| 418 |
+
/// available, this function returns successfully.
|
| 419 |
+
Status CheckAsyncSupport() const;
|
| 420 |
+
|
| 421 |
+
private:
|
| 422 |
+
FlightClient();
|
| 423 |
+
Status CheckOpen() const;
|
| 424 |
+
std::unique_ptr<internal::ClientTransport> transport_;
|
| 425 |
+
bool closed_;
|
| 426 |
+
int64_t write_size_limit_bytes_;
|
| 427 |
+
};
|
| 428 |
+
|
| 429 |
+
} // namespace flight
|
| 430 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/client_auth.h
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 <string>
|
| 21 |
+
|
| 22 |
+
#include "arrow/flight/visibility.h"
|
| 23 |
+
#include "arrow/status.h"
|
| 24 |
+
|
| 25 |
+
namespace arrow {
|
| 26 |
+
|
| 27 |
+
namespace flight {
|
| 28 |
+
|
| 29 |
+
/// \brief A reader for messages from the server during an
|
| 30 |
+
/// authentication handshake.
|
| 31 |
+
class ARROW_FLIGHT_EXPORT ClientAuthReader {
|
| 32 |
+
public:
|
| 33 |
+
virtual ~ClientAuthReader() = default;
|
| 34 |
+
virtual Status Read(std::string* response) = 0;
|
| 35 |
+
};
|
| 36 |
+
|
| 37 |
+
/// \brief A writer for messages to the server during an
|
| 38 |
+
/// authentication handshake.
|
| 39 |
+
class ARROW_FLIGHT_EXPORT ClientAuthSender {
|
| 40 |
+
public:
|
| 41 |
+
virtual ~ClientAuthSender() = default;
|
| 42 |
+
virtual Status Write(const std::string& token) = 0;
|
| 43 |
+
};
|
| 44 |
+
|
| 45 |
+
/// \brief An authentication implementation for a Flight service.
|
| 46 |
+
/// Authentication includes both an initial negotiation and a per-call
|
| 47 |
+
/// token validation. Implementations may choose to use either or both
|
| 48 |
+
/// mechanisms.
|
| 49 |
+
class ARROW_FLIGHT_EXPORT ClientAuthHandler {
|
| 50 |
+
public:
|
| 51 |
+
virtual ~ClientAuthHandler() = default;
|
| 52 |
+
/// \brief Authenticate the client on initial connection. The client
|
| 53 |
+
/// can send messages to/read responses from the server at any time.
|
| 54 |
+
/// \return Status OK if authenticated successfully
|
| 55 |
+
virtual Status Authenticate(ClientAuthSender* outgoing, ClientAuthReader* incoming) = 0;
|
| 56 |
+
/// \brief Get a per-call token.
|
| 57 |
+
/// \param[out] token The token to send to the server.
|
| 58 |
+
virtual Status GetToken(std::string* token) = 0;
|
| 59 |
+
};
|
| 60 |
+
|
| 61 |
+
} // namespace flight
|
| 62 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/client_cookie_middleware.h
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// Middleware implementation for sending and receiving HTTP cookies.
|
| 19 |
+
|
| 20 |
+
#pragma once
|
| 21 |
+
|
| 22 |
+
#include <memory>
|
| 23 |
+
|
| 24 |
+
#include "arrow/flight/client_middleware.h"
|
| 25 |
+
|
| 26 |
+
namespace arrow {
|
| 27 |
+
namespace flight {
|
| 28 |
+
|
| 29 |
+
/// \brief Returns a ClientMiddlewareFactory that handles sending and receiving cookies.
|
| 30 |
+
ARROW_FLIGHT_EXPORT std::shared_ptr<ClientMiddlewareFactory> GetCookieFactory();
|
| 31 |
+
|
| 32 |
+
} // namespace flight
|
| 33 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/client_middleware.h
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// Interfaces for defining middleware for Flight clients. Currently
|
| 19 |
+
// experimental.
|
| 20 |
+
|
| 21 |
+
#pragma once
|
| 22 |
+
|
| 23 |
+
#include <memory>
|
| 24 |
+
|
| 25 |
+
#include "arrow/flight/middleware.h"
|
| 26 |
+
#include "arrow/flight/visibility.h" // IWYU pragma: keep
|
| 27 |
+
#include "arrow/status.h"
|
| 28 |
+
|
| 29 |
+
namespace arrow {
|
| 30 |
+
namespace flight {
|
| 31 |
+
|
| 32 |
+
/// \brief Client-side middleware for a call, instantiated per RPC.
|
| 33 |
+
///
|
| 34 |
+
/// Middleware should be fast and must be infallible: there is no way
|
| 35 |
+
/// to reject the call or report errors from the middleware instance.
|
| 36 |
+
class ARROW_FLIGHT_EXPORT ClientMiddleware {
|
| 37 |
+
public:
|
| 38 |
+
virtual ~ClientMiddleware() = default;
|
| 39 |
+
|
| 40 |
+
/// \brief A callback before headers are sent. Extra headers can be
|
| 41 |
+
/// added, but existing ones cannot be read.
|
| 42 |
+
virtual void SendingHeaders(AddCallHeaders* outgoing_headers) = 0;
|
| 43 |
+
|
| 44 |
+
/// \brief A callback when headers are received from the server.
|
| 45 |
+
///
|
| 46 |
+
/// This may be called more than once, since servers send both
|
| 47 |
+
/// headers and trailers. Some implementations (e.g. gRPC-Java, and
|
| 48 |
+
/// hence Arrow Flight in Java) may consolidate headers into
|
| 49 |
+
/// trailers if the RPC errored.
|
| 50 |
+
virtual void ReceivedHeaders(const CallHeaders& incoming_headers) = 0;
|
| 51 |
+
|
| 52 |
+
/// \brief A callback after the call has completed.
|
| 53 |
+
virtual void CallCompleted(const Status& status) = 0;
|
| 54 |
+
};
|
| 55 |
+
|
| 56 |
+
/// \brief A factory for new middleware instances.
|
| 57 |
+
///
|
| 58 |
+
/// If added to a client, this will be called for each RPC (including
|
| 59 |
+
/// Handshake) to give the opportunity to intercept the call.
|
| 60 |
+
///
|
| 61 |
+
/// It is guaranteed that all client middleware methods are called
|
| 62 |
+
/// from the same thread that calls the RPC method implementation.
|
| 63 |
+
class ARROW_FLIGHT_EXPORT ClientMiddlewareFactory {
|
| 64 |
+
public:
|
| 65 |
+
virtual ~ClientMiddlewareFactory() = default;
|
| 66 |
+
|
| 67 |
+
/// \brief A callback for the start of a new call.
|
| 68 |
+
///
|
| 69 |
+
/// \param info Information about the call.
|
| 70 |
+
/// \param[out] middleware The middleware instance for this call. If
|
| 71 |
+
/// unset, will not add middleware to this call instance from
|
| 72 |
+
/// this factory.
|
| 73 |
+
virtual void StartCall(const CallInfo& info,
|
| 74 |
+
std::unique_ptr<ClientMiddleware>* middleware) = 0;
|
| 75 |
+
};
|
| 76 |
+
|
| 77 |
+
} // namespace flight
|
| 78 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/client_tracing_middleware.h
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// Middleware implementation for propagating OpenTelemetry spans.
|
| 19 |
+
|
| 20 |
+
#pragma once
|
| 21 |
+
|
| 22 |
+
#include <memory>
|
| 23 |
+
|
| 24 |
+
#include "arrow/flight/client_middleware.h"
|
| 25 |
+
|
| 26 |
+
namespace arrow {
|
| 27 |
+
namespace flight {
|
| 28 |
+
|
| 29 |
+
/// \brief Returns a ClientMiddlewareFactory that handles sending OpenTelemetry spans.
|
| 30 |
+
ARROW_FLIGHT_EXPORT std::shared_ptr<ClientMiddlewareFactory>
|
| 31 |
+
MakeTracingClientMiddlewareFactory();
|
| 32 |
+
|
| 33 |
+
} // namespace flight
|
| 34 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/middleware.h
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// Interfaces for defining middleware for Flight clients and
|
| 19 |
+
// servers.
|
| 20 |
+
|
| 21 |
+
#pragma once
|
| 22 |
+
|
| 23 |
+
#include <memory>
|
| 24 |
+
#include <string>
|
| 25 |
+
#include <string_view>
|
| 26 |
+
#include <utility>
|
| 27 |
+
|
| 28 |
+
#include "arrow/flight/types.h"
|
| 29 |
+
#include "arrow/status.h"
|
| 30 |
+
|
| 31 |
+
namespace arrow {
|
| 32 |
+
namespace flight {
|
| 33 |
+
|
| 34 |
+
/// \brief A write-only wrapper around headers for an RPC call.
|
| 35 |
+
class ARROW_FLIGHT_EXPORT AddCallHeaders {
|
| 36 |
+
public:
|
| 37 |
+
virtual ~AddCallHeaders() = default;
|
| 38 |
+
|
| 39 |
+
/// \brief Add a header to be sent to the client.
|
| 40 |
+
///
|
| 41 |
+
/// \param[in] key The header name. Must be lowercase ASCII; some
|
| 42 |
+
/// transports may reject invalid header names.
|
| 43 |
+
/// \param[in] value The header value. Some transports may only
|
| 44 |
+
/// accept binary header values if the header name ends in "-bin".
|
| 45 |
+
virtual void AddHeader(const std::string& key, const std::string& value) = 0;
|
| 46 |
+
};
|
| 47 |
+
|
| 48 |
+
/// \brief An enumeration of the RPC methods Flight implements.
|
| 49 |
+
enum class FlightMethod : char {
|
| 50 |
+
Invalid = 0,
|
| 51 |
+
Handshake = 1,
|
| 52 |
+
ListFlights = 2,
|
| 53 |
+
GetFlightInfo = 3,
|
| 54 |
+
GetSchema = 4,
|
| 55 |
+
DoGet = 5,
|
| 56 |
+
DoPut = 6,
|
| 57 |
+
DoAction = 7,
|
| 58 |
+
ListActions = 8,
|
| 59 |
+
DoExchange = 9,
|
| 60 |
+
PollFlightInfo = 10,
|
| 61 |
+
};
|
| 62 |
+
|
| 63 |
+
/// \brief Get a human-readable name for a Flight method.
|
| 64 |
+
ARROW_FLIGHT_EXPORT
|
| 65 |
+
std::string ToString(FlightMethod method);
|
| 66 |
+
|
| 67 |
+
/// \brief Information about an instance of a Flight RPC.
|
| 68 |
+
struct ARROW_FLIGHT_EXPORT CallInfo {
|
| 69 |
+
public:
|
| 70 |
+
/// \brief The RPC method of this call.
|
| 71 |
+
FlightMethod method;
|
| 72 |
+
};
|
| 73 |
+
|
| 74 |
+
} // namespace flight
|
| 75 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/otel_logging.h
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 "arrow/util/config.h"
|
| 21 |
+
|
| 22 |
+
#ifdef ARROW_WITH_OPENTELEMETRY
|
| 23 |
+
# include "arrow/status.h"
|
| 24 |
+
# include "arrow/telemetry/logging.h"
|
| 25 |
+
# include "arrow/util/macros.h"
|
| 26 |
+
|
| 27 |
+
namespace arrow::flight {
|
| 28 |
+
|
| 29 |
+
ARROW_EXPORT Status
|
| 30 |
+
RegisterFlightOtelLoggers(const telemetry::OtelLoggingOptions& options);
|
| 31 |
+
|
| 32 |
+
} // namespace arrow::flight
|
| 33 |
+
#endif
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/platform.h
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// Internal header. Platform-specific definitions for Flight.
|
| 19 |
+
|
| 20 |
+
#pragma once
|
| 21 |
+
|
| 22 |
+
#ifdef _MSC_VER
|
| 23 |
+
|
| 24 |
+
// The protobuf documentation says that C4251 warnings when using the
|
| 25 |
+
// library are spurious and suppressed when the build the library and
|
| 26 |
+
// compiler, but must be also suppressed in downstream projects
|
| 27 |
+
# pragma warning(disable : 4251)
|
| 28 |
+
|
| 29 |
+
#endif // _MSC_VER
|
| 30 |
+
|
| 31 |
+
#include "arrow/util/config.h" // IWYU pragma: keep
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/server.h
ADDED
|
@@ -0,0 +1,327 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// Interfaces to use for defining Flight RPC servers.
|
| 19 |
+
|
| 20 |
+
#pragma once
|
| 21 |
+
|
| 22 |
+
#include <chrono>
|
| 23 |
+
#include <functional>
|
| 24 |
+
#include <memory>
|
| 25 |
+
#include <string>
|
| 26 |
+
#include <utility>
|
| 27 |
+
#include <vector>
|
| 28 |
+
|
| 29 |
+
#include "arrow/flight/server_auth.h"
|
| 30 |
+
#include "arrow/flight/type_fwd.h"
|
| 31 |
+
#include "arrow/flight/types.h" // IWYU pragma: keep
|
| 32 |
+
#include "arrow/flight/visibility.h" // IWYU pragma: keep
|
| 33 |
+
#include "arrow/ipc/dictionary.h"
|
| 34 |
+
#include "arrow/ipc/options.h"
|
| 35 |
+
#include "arrow/record_batch.h"
|
| 36 |
+
|
| 37 |
+
namespace arrow {
|
| 38 |
+
|
| 39 |
+
class Schema;
|
| 40 |
+
class Status;
|
| 41 |
+
|
| 42 |
+
namespace flight {
|
| 43 |
+
|
| 44 |
+
/// \brief Interface that produces a sequence of IPC payloads to be sent in
|
| 45 |
+
/// FlightData protobuf messages
|
| 46 |
+
class ARROW_FLIGHT_EXPORT FlightDataStream {
|
| 47 |
+
public:
|
| 48 |
+
virtual ~FlightDataStream();
|
| 49 |
+
|
| 50 |
+
virtual std::shared_ptr<Schema> schema() = 0;
|
| 51 |
+
|
| 52 |
+
/// \brief Compute FlightPayload containing serialized RecordBatch schema
|
| 53 |
+
virtual arrow::Result<FlightPayload> GetSchemaPayload() = 0;
|
| 54 |
+
|
| 55 |
+
// When the stream is completed, the last payload written will have null
|
| 56 |
+
// metadata
|
| 57 |
+
virtual arrow::Result<FlightPayload> Next() = 0;
|
| 58 |
+
|
| 59 |
+
virtual Status Close();
|
| 60 |
+
};
|
| 61 |
+
|
| 62 |
+
/// \brief A basic implementation of FlightDataStream that will provide
|
| 63 |
+
/// a sequence of FlightData messages to be written to a stream
|
| 64 |
+
class ARROW_FLIGHT_EXPORT RecordBatchStream : public FlightDataStream {
|
| 65 |
+
public:
|
| 66 |
+
/// \param[in] reader produces a sequence of record batches
|
| 67 |
+
/// \param[in] options IPC options for writing
|
| 68 |
+
explicit RecordBatchStream(
|
| 69 |
+
const std::shared_ptr<RecordBatchReader>& reader,
|
| 70 |
+
const ipc::IpcWriteOptions& options = ipc::IpcWriteOptions::Defaults());
|
| 71 |
+
~RecordBatchStream() override;
|
| 72 |
+
|
| 73 |
+
// inherit deprecated API
|
| 74 |
+
using FlightDataStream::GetSchemaPayload;
|
| 75 |
+
using FlightDataStream::Next;
|
| 76 |
+
|
| 77 |
+
std::shared_ptr<Schema> schema() override;
|
| 78 |
+
arrow::Result<FlightPayload> GetSchemaPayload() override;
|
| 79 |
+
|
| 80 |
+
arrow::Result<FlightPayload> Next() override;
|
| 81 |
+
Status Close() override;
|
| 82 |
+
|
| 83 |
+
private:
|
| 84 |
+
class RecordBatchStreamImpl;
|
| 85 |
+
std::unique_ptr<RecordBatchStreamImpl> impl_;
|
| 86 |
+
};
|
| 87 |
+
|
| 88 |
+
/// \brief A reader for IPC payloads uploaded by a client. Also allows
|
| 89 |
+
/// reading application-defined metadata via the Flight protocol.
|
| 90 |
+
class ARROW_FLIGHT_EXPORT FlightMessageReader : public MetadataRecordBatchReader {
|
| 91 |
+
public:
|
| 92 |
+
/// \brief Get the descriptor for this upload.
|
| 93 |
+
virtual const FlightDescriptor& descriptor() const = 0;
|
| 94 |
+
};
|
| 95 |
+
|
| 96 |
+
/// \brief A writer for application-specific metadata sent back to the
|
| 97 |
+
/// client during an upload.
|
| 98 |
+
class ARROW_FLIGHT_EXPORT FlightMetadataWriter {
|
| 99 |
+
public:
|
| 100 |
+
virtual ~FlightMetadataWriter();
|
| 101 |
+
/// \brief Send a message to the client.
|
| 102 |
+
virtual Status WriteMetadata(const Buffer& app_metadata) = 0;
|
| 103 |
+
};
|
| 104 |
+
|
| 105 |
+
/// \brief A writer for IPC payloads to a client. Also allows sending
|
| 106 |
+
/// application-defined metadata via the Flight protocol.
|
| 107 |
+
///
|
| 108 |
+
/// This class offers more control compared to FlightDataStream,
|
| 109 |
+
/// including the option to write metadata without data and the
|
| 110 |
+
/// ability to interleave reading and writing.
|
| 111 |
+
class ARROW_FLIGHT_EXPORT FlightMessageWriter : public MetadataRecordBatchWriter {
|
| 112 |
+
public:
|
| 113 |
+
virtual ~FlightMessageWriter() = default;
|
| 114 |
+
};
|
| 115 |
+
|
| 116 |
+
/// \brief Call state/contextual data.
|
| 117 |
+
class ARROW_FLIGHT_EXPORT ServerCallContext {
|
| 118 |
+
public:
|
| 119 |
+
virtual ~ServerCallContext() = default;
|
| 120 |
+
/// \brief The name of the authenticated peer (may be the empty string)
|
| 121 |
+
virtual const std::string& peer_identity() const = 0;
|
| 122 |
+
/// \brief The peer address (not validated)
|
| 123 |
+
virtual const std::string& peer() const = 0;
|
| 124 |
+
/// \brief Add a response header. This is only valid before the server
|
| 125 |
+
/// starts sending the response; generally this isn't an issue unless you
|
| 126 |
+
/// are implementing FlightDataStream, ResultStream, or similar interfaces
|
| 127 |
+
/// yourself, or during a DoExchange or DoPut.
|
| 128 |
+
virtual void AddHeader(const std::string& key, const std::string& value) const = 0;
|
| 129 |
+
/// \brief Add a response trailer. This is only valid before the server
|
| 130 |
+
/// sends the final status; generally this isn't an issue unless your RPC
|
| 131 |
+
/// handler launches a thread or similar.
|
| 132 |
+
virtual void AddTrailer(const std::string& key, const std::string& value) const = 0;
|
| 133 |
+
/// \brief Look up a middleware by key. Do not maintain a reference
|
| 134 |
+
/// to the object beyond the request body.
|
| 135 |
+
/// \return The middleware, or nullptr if not found.
|
| 136 |
+
virtual ServerMiddleware* GetMiddleware(const std::string& key) const = 0;
|
| 137 |
+
/// \brief Check if the current RPC has been cancelled (by the client, by
|
| 138 |
+
/// a network error, etc.).
|
| 139 |
+
virtual bool is_cancelled() const = 0;
|
| 140 |
+
/// \brief The headers sent by the client for this call.
|
| 141 |
+
virtual const CallHeaders& incoming_headers() const = 0;
|
| 142 |
+
};
|
| 143 |
+
|
| 144 |
+
class ARROW_FLIGHT_EXPORT FlightServerOptions {
|
| 145 |
+
public:
|
| 146 |
+
explicit FlightServerOptions(const Location& location_);
|
| 147 |
+
|
| 148 |
+
~FlightServerOptions();
|
| 149 |
+
|
| 150 |
+
/// \brief The host & port (or domain socket path) to listen on.
|
| 151 |
+
/// Use port 0 to bind to an available port.
|
| 152 |
+
Location location;
|
| 153 |
+
/// \brief The authentication handler to use.
|
| 154 |
+
std::shared_ptr<ServerAuthHandler> auth_handler;
|
| 155 |
+
/// \brief A list of TLS certificate+key pairs to use.
|
| 156 |
+
std::vector<CertKeyPair> tls_certificates;
|
| 157 |
+
/// \brief Enable mTLS and require that the client present a certificate.
|
| 158 |
+
bool verify_client;
|
| 159 |
+
/// \brief If using mTLS, the PEM-encoded root certificate to use.
|
| 160 |
+
std::string root_certificates;
|
| 161 |
+
/// \brief A list of server middleware to apply, along with a key to
|
| 162 |
+
/// identify them by.
|
| 163 |
+
///
|
| 164 |
+
/// Middleware are always applied in the order provided. Duplicate
|
| 165 |
+
/// keys are an error.
|
| 166 |
+
std::vector<std::pair<std::string, std::shared_ptr<ServerMiddlewareFactory>>>
|
| 167 |
+
middleware;
|
| 168 |
+
|
| 169 |
+
/// \brief An optional memory manager to control where to allocate incoming data.
|
| 170 |
+
std::shared_ptr<MemoryManager> memory_manager;
|
| 171 |
+
|
| 172 |
+
/// \brief A Flight implementation-specific callback to customize
|
| 173 |
+
/// transport-specific options.
|
| 174 |
+
///
|
| 175 |
+
/// Not guaranteed to be called. The type of the parameter is
|
| 176 |
+
/// specific to the Flight implementation. Users should take care to
|
| 177 |
+
/// link to the same transport implementation as Flight to avoid
|
| 178 |
+
/// runtime problems. See "Using Arrow C++ in your own project" in
|
| 179 |
+
/// the documentation for more details.
|
| 180 |
+
std::function<void(void*)> builder_hook;
|
| 181 |
+
};
|
| 182 |
+
|
| 183 |
+
/// \brief Skeleton RPC server implementation which can be used to create
|
| 184 |
+
/// custom servers by implementing its abstract methods
|
| 185 |
+
class ARROW_FLIGHT_EXPORT FlightServerBase {
|
| 186 |
+
public:
|
| 187 |
+
FlightServerBase();
|
| 188 |
+
virtual ~FlightServerBase();
|
| 189 |
+
|
| 190 |
+
// Lifecycle methods.
|
| 191 |
+
|
| 192 |
+
/// \brief Initialize a Flight server listening at the given location.
|
| 193 |
+
/// This method must be called before any other method.
|
| 194 |
+
/// \param[in] options The configuration for this server.
|
| 195 |
+
Status Init(const FlightServerOptions& options);
|
| 196 |
+
|
| 197 |
+
/// \brief Get the port that the Flight server is listening on.
|
| 198 |
+
/// This method must only be called after Init(). Will return a
|
| 199 |
+
/// non-positive value if no port exists (e.g. when listening on a
|
| 200 |
+
/// domain socket).
|
| 201 |
+
int port() const;
|
| 202 |
+
|
| 203 |
+
/// \brief Get the address that the Flight server is listening on.
|
| 204 |
+
/// This method must only be called after Init().
|
| 205 |
+
Location location() const;
|
| 206 |
+
|
| 207 |
+
/// \brief Set the server to stop when receiving any of the given signal
|
| 208 |
+
/// numbers.
|
| 209 |
+
/// This method must be called before Serve().
|
| 210 |
+
Status SetShutdownOnSignals(const std::vector<int> sigs);
|
| 211 |
+
|
| 212 |
+
/// \brief Start serving.
|
| 213 |
+
/// This method blocks until the server shuts down.
|
| 214 |
+
///
|
| 215 |
+
/// The server will start to shut down when either Shutdown() is called
|
| 216 |
+
/// or one of the signals registered in SetShutdownOnSignals() is received.
|
| 217 |
+
Status Serve();
|
| 218 |
+
|
| 219 |
+
/// \brief Query whether Serve() was interrupted by a signal.
|
| 220 |
+
/// This method must be called after Serve() has returned.
|
| 221 |
+
///
|
| 222 |
+
/// \return int the signal number that interrupted Serve(), if any, otherwise 0
|
| 223 |
+
int GotSignal() const;
|
| 224 |
+
|
| 225 |
+
/// \brief Shut down the server, blocking until current requests finish.
|
| 226 |
+
///
|
| 227 |
+
/// Can be called from a signal handler or another thread while Serve()
|
| 228 |
+
/// blocks. Optionally a deadline can be set. Once the deadline expires
|
| 229 |
+
/// server will wait until remaining running calls complete.
|
| 230 |
+
///
|
| 231 |
+
/// Should only be called once.
|
| 232 |
+
Status Shutdown(const std::chrono::system_clock::time_point* deadline = NULLPTR);
|
| 233 |
+
|
| 234 |
+
/// \brief Block until server shuts down with Shutdown.
|
| 235 |
+
///
|
| 236 |
+
/// Does not respond to signals like Serve().
|
| 237 |
+
Status Wait();
|
| 238 |
+
|
| 239 |
+
// Implement these methods to create your own server. The default
|
| 240 |
+
// implementations will return a not-implemented result to the client
|
| 241 |
+
|
| 242 |
+
/// \brief Retrieve a list of available fields given an optional opaque
|
| 243 |
+
/// criteria
|
| 244 |
+
/// \param[in] context The call context.
|
| 245 |
+
/// \param[in] criteria may be null
|
| 246 |
+
/// \param[out] listings the returned listings iterator
|
| 247 |
+
/// \return Status
|
| 248 |
+
virtual Status ListFlights(const ServerCallContext& context, const Criteria* criteria,
|
| 249 |
+
std::unique_ptr<FlightListing>* listings);
|
| 250 |
+
|
| 251 |
+
/// \brief Retrieve the schema and an access plan for the indicated
|
| 252 |
+
/// descriptor
|
| 253 |
+
/// \param[in] context The call context.
|
| 254 |
+
/// \param[in] request the dataset request, whether a named dataset or command
|
| 255 |
+
/// \param[out] info the returned flight info provider
|
| 256 |
+
/// \return Status
|
| 257 |
+
virtual Status GetFlightInfo(const ServerCallContext& context,
|
| 258 |
+
const FlightDescriptor& request,
|
| 259 |
+
std::unique_ptr<FlightInfo>* info);
|
| 260 |
+
|
| 261 |
+
/// \brief Retrieve the current status of the target query
|
| 262 |
+
/// \param[in] context The call context.
|
| 263 |
+
/// \param[in] request the dataset request or a descriptor returned by a
|
| 264 |
+
/// prior PollFlightInfo call
|
| 265 |
+
/// \param[out] info the returned retry info provider
|
| 266 |
+
/// \return Status
|
| 267 |
+
virtual Status PollFlightInfo(const ServerCallContext& context,
|
| 268 |
+
const FlightDescriptor& request,
|
| 269 |
+
std::unique_ptr<PollInfo>* info);
|
| 270 |
+
|
| 271 |
+
/// \brief Retrieve the schema for the indicated descriptor
|
| 272 |
+
/// \param[in] context The call context.
|
| 273 |
+
/// \param[in] request the dataset request, whether a named dataset or command
|
| 274 |
+
/// \param[out] schema the returned flight schema provider
|
| 275 |
+
/// \return Status
|
| 276 |
+
virtual Status GetSchema(const ServerCallContext& context,
|
| 277 |
+
const FlightDescriptor& request,
|
| 278 |
+
std::unique_ptr<SchemaResult>* schema);
|
| 279 |
+
|
| 280 |
+
/// \brief Get a stream of IPC payloads to put on the wire
|
| 281 |
+
/// \param[in] context The call context.
|
| 282 |
+
/// \param[in] request an opaque ticket
|
| 283 |
+
/// \param[out] stream the returned stream provider
|
| 284 |
+
/// \return Status
|
| 285 |
+
virtual Status DoGet(const ServerCallContext& context, const Ticket& request,
|
| 286 |
+
std::unique_ptr<FlightDataStream>* stream);
|
| 287 |
+
|
| 288 |
+
/// \brief Process a stream of IPC payloads sent from a client
|
| 289 |
+
/// \param[in] context The call context.
|
| 290 |
+
/// \param[in] reader a sequence of uploaded record batches
|
| 291 |
+
/// \param[in] writer send metadata back to the client
|
| 292 |
+
/// \return Status
|
| 293 |
+
virtual Status DoPut(const ServerCallContext& context,
|
| 294 |
+
std::unique_ptr<FlightMessageReader> reader,
|
| 295 |
+
std::unique_ptr<FlightMetadataWriter> writer);
|
| 296 |
+
|
| 297 |
+
/// \brief Process a bidirectional stream of IPC payloads
|
| 298 |
+
/// \param[in] context The call context.
|
| 299 |
+
/// \param[in] reader a sequence of uploaded record batches
|
| 300 |
+
/// \param[in] writer send data back to the client
|
| 301 |
+
/// \return Status
|
| 302 |
+
virtual Status DoExchange(const ServerCallContext& context,
|
| 303 |
+
std::unique_ptr<FlightMessageReader> reader,
|
| 304 |
+
std::unique_ptr<FlightMessageWriter> writer);
|
| 305 |
+
|
| 306 |
+
/// \brief Execute an action, return stream of zero or more results
|
| 307 |
+
/// \param[in] context The call context.
|
| 308 |
+
/// \param[in] action the action to execute, with type and body
|
| 309 |
+
/// \param[out] result the result iterator
|
| 310 |
+
/// \return Status
|
| 311 |
+
virtual Status DoAction(const ServerCallContext& context, const Action& action,
|
| 312 |
+
std::unique_ptr<ResultStream>* result);
|
| 313 |
+
|
| 314 |
+
/// \brief Retrieve the list of available actions
|
| 315 |
+
/// \param[in] context The call context.
|
| 316 |
+
/// \param[out] actions a vector of available action types
|
| 317 |
+
/// \return Status
|
| 318 |
+
virtual Status ListActions(const ServerCallContext& context,
|
| 319 |
+
std::vector<ActionType>* actions);
|
| 320 |
+
|
| 321 |
+
private:
|
| 322 |
+
struct Impl;
|
| 323 |
+
std::unique_ptr<Impl> impl_;
|
| 324 |
+
};
|
| 325 |
+
|
| 326 |
+
} // namespace flight
|
| 327 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/server_auth.h
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
/// \brief Server-side APIs to implement authentication for Flight.
|
| 19 |
+
|
| 20 |
+
#pragma once
|
| 21 |
+
|
| 22 |
+
#include <string>
|
| 23 |
+
|
| 24 |
+
#include "arrow/flight/type_fwd.h"
|
| 25 |
+
#include "arrow/flight/visibility.h"
|
| 26 |
+
#include "arrow/status.h"
|
| 27 |
+
|
| 28 |
+
namespace arrow {
|
| 29 |
+
|
| 30 |
+
namespace flight {
|
| 31 |
+
|
| 32 |
+
/// \brief A reader for messages from the client during an
|
| 33 |
+
/// authentication handshake.
|
| 34 |
+
class ARROW_FLIGHT_EXPORT ServerAuthReader {
|
| 35 |
+
public:
|
| 36 |
+
virtual ~ServerAuthReader() = default;
|
| 37 |
+
virtual Status Read(std::string* token) = 0;
|
| 38 |
+
};
|
| 39 |
+
|
| 40 |
+
/// \brief A writer for messages to the client during an
|
| 41 |
+
/// authentication handshake.
|
| 42 |
+
class ARROW_FLIGHT_EXPORT ServerAuthSender {
|
| 43 |
+
public:
|
| 44 |
+
virtual ~ServerAuthSender() = default;
|
| 45 |
+
virtual Status Write(const std::string& message) = 0;
|
| 46 |
+
};
|
| 47 |
+
|
| 48 |
+
/// \brief An authentication implementation for a Flight service.
|
| 49 |
+
/// Authentication includes both an initial negotiation and a per-call
|
| 50 |
+
/// token validation. Implementations may choose to use either or both
|
| 51 |
+
/// mechanisms.
|
| 52 |
+
/// An implementation may need to track some state, e.g. a mapping of
|
| 53 |
+
/// client tokens to authenticated identities.
|
| 54 |
+
class ARROW_FLIGHT_EXPORT ServerAuthHandler {
|
| 55 |
+
public:
|
| 56 |
+
virtual ~ServerAuthHandler();
|
| 57 |
+
/// \brief Authenticate the client on initial connection. The server
|
| 58 |
+
/// can send and read responses from the client at any time.
|
| 59 |
+
/// \param[in] context The call context.
|
| 60 |
+
/// \param[in] outgoing The writer for messages to the client.
|
| 61 |
+
/// \param[in] incoming The reader for messages from the client.
|
| 62 |
+
/// \return Status OK if this authentication is succeeded.
|
| 63 |
+
virtual Status Authenticate(const ServerCallContext& context,
|
| 64 |
+
ServerAuthSender* outgoing, ServerAuthReader* incoming) = 0;
|
| 65 |
+
/// \brief Validate a per-call client token.
|
| 66 |
+
/// \param[in] context The call context.
|
| 67 |
+
/// \param[in] token The client token. May be the empty string if
|
| 68 |
+
/// the client does not provide a token.
|
| 69 |
+
/// \param[out] peer_identity The identity of the peer, if this
|
| 70 |
+
/// authentication method supports it.
|
| 71 |
+
/// \return Status OK if the token is valid, any other status if
|
| 72 |
+
/// validation failed
|
| 73 |
+
virtual Status IsValid(const ServerCallContext& context, const std::string& token,
|
| 74 |
+
std::string* peer_identity) {
|
| 75 |
+
// TODO: We can make this pure virtual function when we remove
|
| 76 |
+
// the deprecated version.
|
| 77 |
+
ARROW_SUPPRESS_DEPRECATION_WARNING
|
| 78 |
+
return IsValid(token, peer_identity);
|
| 79 |
+
ARROW_UNSUPPRESS_DEPRECATION_WARNING
|
| 80 |
+
}
|
| 81 |
+
/// \brief Validate a per-call client token.
|
| 82 |
+
/// \param[in] token The client token. May be the empty string if
|
| 83 |
+
/// the client does not provide a token.
|
| 84 |
+
/// \param[out] peer_identity The identity of the peer, if this
|
| 85 |
+
/// authentication method supports it.
|
| 86 |
+
/// \return Status OK if the token is valid, any other status if
|
| 87 |
+
/// validation failed
|
| 88 |
+
/// \deprecated Deprecated in 13.0.0. Implement the IsValid()
|
| 89 |
+
/// with ServerCallContext version instead.
|
| 90 |
+
ARROW_DEPRECATED("Deprecated in 13.0.0. Use ServerCallContext overload instead.")
|
| 91 |
+
virtual Status IsValid(const std::string& token, std::string* peer_identity) {
|
| 92 |
+
return Status::NotImplemented(typeid(this).name(), "::IsValid() isn't implemented");
|
| 93 |
+
}
|
| 94 |
+
};
|
| 95 |
+
|
| 96 |
+
/// \brief An authentication mechanism that does nothing.
|
| 97 |
+
class ARROW_FLIGHT_EXPORT NoOpAuthHandler : public ServerAuthHandler {
|
| 98 |
+
public:
|
| 99 |
+
~NoOpAuthHandler() override;
|
| 100 |
+
Status Authenticate(const ServerCallContext& context, ServerAuthSender* outgoing,
|
| 101 |
+
ServerAuthReader* incoming) override;
|
| 102 |
+
Status IsValid(const ServerCallContext& context, const std::string& token,
|
| 103 |
+
std::string* peer_identity) override;
|
| 104 |
+
};
|
| 105 |
+
|
| 106 |
+
} // namespace flight
|
| 107 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/server_middleware.h
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// Interfaces for defining middleware for Flight servers.
|
| 19 |
+
|
| 20 |
+
#pragma once
|
| 21 |
+
|
| 22 |
+
#include <memory>
|
| 23 |
+
#include <string>
|
| 24 |
+
|
| 25 |
+
#include "arrow/flight/middleware.h"
|
| 26 |
+
#include "arrow/flight/type_fwd.h"
|
| 27 |
+
#include "arrow/flight/visibility.h" // IWYU pragma: keep
|
| 28 |
+
#include "arrow/status.h"
|
| 29 |
+
|
| 30 |
+
namespace arrow {
|
| 31 |
+
namespace flight {
|
| 32 |
+
|
| 33 |
+
/// \brief Server-side middleware for a call, instantiated per RPC.
|
| 34 |
+
///
|
| 35 |
+
/// Middleware should be fast and must be infallible: there is no way
|
| 36 |
+
/// to reject the call or report errors from the middleware instance.
|
| 37 |
+
class ARROW_FLIGHT_EXPORT ServerMiddleware {
|
| 38 |
+
public:
|
| 39 |
+
virtual ~ServerMiddleware() = default;
|
| 40 |
+
|
| 41 |
+
/// \brief Unique name of middleware, used as alternative to RTTI
|
| 42 |
+
/// \return the string name of the middleware
|
| 43 |
+
virtual std::string name() const = 0;
|
| 44 |
+
|
| 45 |
+
/// \brief A callback before headers are sent. Extra headers can be
|
| 46 |
+
/// added, but existing ones cannot be read.
|
| 47 |
+
virtual void SendingHeaders(AddCallHeaders* outgoing_headers) = 0;
|
| 48 |
+
|
| 49 |
+
/// \brief A callback after the call has completed.
|
| 50 |
+
virtual void CallCompleted(const Status& status) = 0;
|
| 51 |
+
};
|
| 52 |
+
|
| 53 |
+
/// \brief A factory for new middleware instances.
|
| 54 |
+
///
|
| 55 |
+
/// If added to a server, this will be called for each RPC (including
|
| 56 |
+
/// Handshake) to give the opportunity to intercept the call.
|
| 57 |
+
///
|
| 58 |
+
/// It is guaranteed that all server middleware methods are called
|
| 59 |
+
/// from the same thread that calls the RPC method implementation.
|
| 60 |
+
class ARROW_FLIGHT_EXPORT ServerMiddlewareFactory {
|
| 61 |
+
public:
|
| 62 |
+
virtual ~ServerMiddlewareFactory() = default;
|
| 63 |
+
|
| 64 |
+
/// \brief A callback for the start of a new call.
|
| 65 |
+
///
|
| 66 |
+
/// Return a non-OK status to reject the call with the given status.
|
| 67 |
+
///
|
| 68 |
+
/// \param[in] info Information about the call.
|
| 69 |
+
/// \param[in] context The call context.
|
| 70 |
+
/// \param[out] middleware The middleware instance for this call. If
|
| 71 |
+
/// null, no middleware will be added to this call instance from
|
| 72 |
+
/// this factory.
|
| 73 |
+
/// \return Status A non-OK status will reject the call with the
|
| 74 |
+
/// given status. Middleware previously in the chain will have
|
| 75 |
+
/// their CallCompleted callback called. Other middleware
|
| 76 |
+
/// factories will not be called.
|
| 77 |
+
virtual Status StartCall(const CallInfo& info, const ServerCallContext& context,
|
| 78 |
+
std::shared_ptr<ServerMiddleware>* middleware) = 0;
|
| 79 |
+
};
|
| 80 |
+
|
| 81 |
+
} // namespace flight
|
| 82 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/server_tracing_middleware.h
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// Middleware implementation for propagating OpenTelemetry spans.
|
| 19 |
+
|
| 20 |
+
#pragma once
|
| 21 |
+
|
| 22 |
+
#include <memory>
|
| 23 |
+
#include <string>
|
| 24 |
+
#include <vector>
|
| 25 |
+
|
| 26 |
+
#include "arrow/flight/server_middleware.h"
|
| 27 |
+
#include "arrow/flight/visibility.h"
|
| 28 |
+
#include "arrow/status.h"
|
| 29 |
+
|
| 30 |
+
namespace arrow {
|
| 31 |
+
namespace flight {
|
| 32 |
+
|
| 33 |
+
/// \brief Returns a ServerMiddlewareFactory that handles receiving OpenTelemetry spans.
|
| 34 |
+
ARROW_FLIGHT_EXPORT std::shared_ptr<ServerMiddlewareFactory>
|
| 35 |
+
MakeTracingServerMiddlewareFactory();
|
| 36 |
+
|
| 37 |
+
/// \brief A server middleware that provides access to the
|
| 38 |
+
/// OpenTelemetry context, if present.
|
| 39 |
+
///
|
| 40 |
+
/// Used to make the OpenTelemetry span available in Python.
|
| 41 |
+
class ARROW_FLIGHT_EXPORT TracingServerMiddleware : public ServerMiddleware {
|
| 42 |
+
public:
|
| 43 |
+
~TracingServerMiddleware();
|
| 44 |
+
|
| 45 |
+
static constexpr char const kMiddlewareName[] =
|
| 46 |
+
"arrow::flight::TracingServerMiddleware";
|
| 47 |
+
|
| 48 |
+
std::string name() const override { return kMiddlewareName; }
|
| 49 |
+
void SendingHeaders(AddCallHeaders*) override;
|
| 50 |
+
void CallCompleted(const Status&) override;
|
| 51 |
+
|
| 52 |
+
struct TraceKey {
|
| 53 |
+
std::string key;
|
| 54 |
+
std::string value;
|
| 55 |
+
};
|
| 56 |
+
/// \brief Get the trace context.
|
| 57 |
+
std::vector<TraceKey> GetTraceContext() const;
|
| 58 |
+
|
| 59 |
+
private:
|
| 60 |
+
class Impl;
|
| 61 |
+
friend class TracingServerMiddlewareFactory;
|
| 62 |
+
|
| 63 |
+
explicit TracingServerMiddleware(std::unique_ptr<Impl> impl);
|
| 64 |
+
std::unique_ptr<Impl> impl_;
|
| 65 |
+
};
|
| 66 |
+
|
| 67 |
+
} // namespace flight
|
| 68 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/test_auth_handlers.h
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 <string>
|
| 21 |
+
|
| 22 |
+
#include "arrow/flight/client_auth.h"
|
| 23 |
+
#include "arrow/flight/server.h"
|
| 24 |
+
#include "arrow/flight/server_auth.h"
|
| 25 |
+
#include "arrow/flight/types.h"
|
| 26 |
+
#include "arrow/flight/visibility.h"
|
| 27 |
+
#include "arrow/status.h"
|
| 28 |
+
|
| 29 |
+
// A pair of authentication handlers that check for a predefined password
|
| 30 |
+
// and set the peer identity to a predefined username.
|
| 31 |
+
|
| 32 |
+
namespace arrow::flight {
|
| 33 |
+
|
| 34 |
+
class ARROW_FLIGHT_EXPORT TestServerAuthHandler : public ServerAuthHandler {
|
| 35 |
+
public:
|
| 36 |
+
explicit TestServerAuthHandler(const std::string& username,
|
| 37 |
+
const std::string& password);
|
| 38 |
+
~TestServerAuthHandler() override;
|
| 39 |
+
Status Authenticate(const ServerCallContext& context, ServerAuthSender* outgoing,
|
| 40 |
+
ServerAuthReader* incoming) override;
|
| 41 |
+
Status IsValid(const ServerCallContext& context, const std::string& token,
|
| 42 |
+
std::string* peer_identity) override;
|
| 43 |
+
|
| 44 |
+
private:
|
| 45 |
+
std::string username_;
|
| 46 |
+
std::string password_;
|
| 47 |
+
};
|
| 48 |
+
|
| 49 |
+
class ARROW_FLIGHT_EXPORT TestServerBasicAuthHandler : public ServerAuthHandler {
|
| 50 |
+
public:
|
| 51 |
+
explicit TestServerBasicAuthHandler(const std::string& username,
|
| 52 |
+
const std::string& password);
|
| 53 |
+
~TestServerBasicAuthHandler() override;
|
| 54 |
+
Status Authenticate(const ServerCallContext& context, ServerAuthSender* outgoing,
|
| 55 |
+
ServerAuthReader* incoming) override;
|
| 56 |
+
Status IsValid(const ServerCallContext& context, const std::string& token,
|
| 57 |
+
std::string* peer_identity) override;
|
| 58 |
+
|
| 59 |
+
private:
|
| 60 |
+
BasicAuth basic_auth_;
|
| 61 |
+
};
|
| 62 |
+
|
| 63 |
+
class ARROW_FLIGHT_EXPORT TestClientAuthHandler : public ClientAuthHandler {
|
| 64 |
+
public:
|
| 65 |
+
explicit TestClientAuthHandler(const std::string& username,
|
| 66 |
+
const std::string& password);
|
| 67 |
+
~TestClientAuthHandler() override;
|
| 68 |
+
Status Authenticate(ClientAuthSender* outgoing, ClientAuthReader* incoming) override;
|
| 69 |
+
Status GetToken(std::string* token) override;
|
| 70 |
+
|
| 71 |
+
private:
|
| 72 |
+
std::string username_;
|
| 73 |
+
std::string password_;
|
| 74 |
+
};
|
| 75 |
+
|
| 76 |
+
class ARROW_FLIGHT_EXPORT TestClientBasicAuthHandler : public ClientAuthHandler {
|
| 77 |
+
public:
|
| 78 |
+
explicit TestClientBasicAuthHandler(const std::string& username,
|
| 79 |
+
const std::string& password);
|
| 80 |
+
~TestClientBasicAuthHandler() override;
|
| 81 |
+
Status Authenticate(ClientAuthSender* outgoing, ClientAuthReader* incoming) override;
|
| 82 |
+
Status GetToken(std::string* token) override;
|
| 83 |
+
|
| 84 |
+
private:
|
| 85 |
+
BasicAuth basic_auth_;
|
| 86 |
+
std::string token_;
|
| 87 |
+
};
|
| 88 |
+
|
| 89 |
+
} // namespace arrow::flight
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/test_definitions.h
ADDED
|
@@ -0,0 +1,318 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
// Common test definitions for Flight. Individual transport
|
| 19 |
+
// implementations can instantiate these tests.
|
| 20 |
+
//
|
| 21 |
+
// While Googletest's value-parameterized tests would be a more
|
| 22 |
+
// natural way to do this, they cause runtime issues on MinGW/MSVC
|
| 23 |
+
// (Googletest thinks the test suite has been defined twice).
|
| 24 |
+
|
| 25 |
+
#pragma once
|
| 26 |
+
|
| 27 |
+
#include <functional>
|
| 28 |
+
#include <memory>
|
| 29 |
+
#include <string>
|
| 30 |
+
#include <type_traits>
|
| 31 |
+
#include <vector>
|
| 32 |
+
|
| 33 |
+
#include "arrow/flight/server.h"
|
| 34 |
+
#include "arrow/flight/types.h"
|
| 35 |
+
#include "arrow/util/macros.h"
|
| 36 |
+
|
| 37 |
+
namespace arrow {
|
| 38 |
+
namespace flight {
|
| 39 |
+
|
| 40 |
+
class ARROW_FLIGHT_EXPORT FlightTest {
|
| 41 |
+
protected:
|
| 42 |
+
virtual std::string transport() const = 0;
|
| 43 |
+
virtual bool supports_async() const { return false; }
|
| 44 |
+
virtual void SetUpTest() {}
|
| 45 |
+
virtual void TearDownTest() {}
|
| 46 |
+
};
|
| 47 |
+
|
| 48 |
+
/// Common tests of startup/shutdown
|
| 49 |
+
class ARROW_FLIGHT_EXPORT ConnectivityTest : public FlightTest {
|
| 50 |
+
public:
|
| 51 |
+
// Test methods
|
| 52 |
+
void TestGetPort();
|
| 53 |
+
void TestBuilderHook();
|
| 54 |
+
void TestShutdown();
|
| 55 |
+
void TestShutdownWithDeadline();
|
| 56 |
+
void TestBrokenConnection();
|
| 57 |
+
};
|
| 58 |
+
|
| 59 |
+
#define ARROW_FLIGHT_TEST_CONNECTIVITY(FIXTURE) \
|
| 60 |
+
static_assert(std::is_base_of<ConnectivityTest, FIXTURE>::value, \
|
| 61 |
+
ARROW_STRINGIFY(FIXTURE) " must inherit from ConnectivityTest"); \
|
| 62 |
+
TEST_F(FIXTURE, GetPort) { TestGetPort(); } \
|
| 63 |
+
TEST_F(FIXTURE, BuilderHook) { TestBuilderHook(); } \
|
| 64 |
+
TEST_F(FIXTURE, Shutdown) { TestShutdown(); } \
|
| 65 |
+
TEST_F(FIXTURE, ShutdownWithDeadline) { TestShutdownWithDeadline(); } \
|
| 66 |
+
TEST_F(FIXTURE, BrokenConnection) { TestBrokenConnection(); }
|
| 67 |
+
|
| 68 |
+
/// Common tests of data plane methods
|
| 69 |
+
class ARROW_FLIGHT_EXPORT DataTest : public FlightTest {
|
| 70 |
+
public:
|
| 71 |
+
void SetUpTest() override;
|
| 72 |
+
void TearDownTest() override;
|
| 73 |
+
Status ConnectClient();
|
| 74 |
+
|
| 75 |
+
// Test methods
|
| 76 |
+
void TestDoGetInts();
|
| 77 |
+
void TestDoGetFloats();
|
| 78 |
+
void TestDoGetDicts();
|
| 79 |
+
void TestDoGetLargeBatch();
|
| 80 |
+
void TestFlightDataStreamError();
|
| 81 |
+
void TestOverflowServerBatch();
|
| 82 |
+
void TestOverflowClientBatch();
|
| 83 |
+
void TestDoExchange();
|
| 84 |
+
void TestDoExchangeNoData();
|
| 85 |
+
void TestDoExchangeWriteOnlySchema();
|
| 86 |
+
void TestDoExchangeGet();
|
| 87 |
+
void TestDoExchangePut();
|
| 88 |
+
void TestDoExchangeEcho();
|
| 89 |
+
void TestDoExchangeTotal();
|
| 90 |
+
void TestDoExchangeError();
|
| 91 |
+
void TestDoExchangeConcurrency();
|
| 92 |
+
void TestDoExchangeUndrained();
|
| 93 |
+
void TestIssue5095();
|
| 94 |
+
|
| 95 |
+
private:
|
| 96 |
+
void CheckDoGet(
|
| 97 |
+
const FlightDescriptor& descr, const RecordBatchVector& expected_batches,
|
| 98 |
+
std::function<void(const std::vector<FlightEndpoint>&)> check_endpoints);
|
| 99 |
+
void CheckDoGet(const Ticket& ticket, const RecordBatchVector& expected_batches);
|
| 100 |
+
|
| 101 |
+
std::unique_ptr<FlightClient> client_;
|
| 102 |
+
std::unique_ptr<FlightServerBase> server_;
|
| 103 |
+
};
|
| 104 |
+
|
| 105 |
+
#define ARROW_FLIGHT_TEST_DATA(FIXTURE) \
|
| 106 |
+
static_assert(std::is_base_of<DataTest, FIXTURE>::value, \
|
| 107 |
+
ARROW_STRINGIFY(FIXTURE) " must inherit from DataTest"); \
|
| 108 |
+
TEST_F(FIXTURE, TestDoGetInts) { TestDoGetInts(); } \
|
| 109 |
+
TEST_F(FIXTURE, TestDoGetFloats) { TestDoGetFloats(); } \
|
| 110 |
+
TEST_F(FIXTURE, TestDoGetDicts) { TestDoGetDicts(); } \
|
| 111 |
+
TEST_F(FIXTURE, TestDoGetLargeBatch) { TestDoGetLargeBatch(); } \
|
| 112 |
+
TEST_F(FIXTURE, TestFlightDataStreamError) { TestFlightDataStreamError(); } \
|
| 113 |
+
TEST_F(FIXTURE, TestOverflowServerBatch) { TestOverflowServerBatch(); } \
|
| 114 |
+
TEST_F(FIXTURE, TestOverflowClientBatch) { TestOverflowClientBatch(); } \
|
| 115 |
+
TEST_F(FIXTURE, TestDoExchange) { TestDoExchange(); } \
|
| 116 |
+
TEST_F(FIXTURE, TestDoExchangeNoData) { TestDoExchangeNoData(); } \
|
| 117 |
+
TEST_F(FIXTURE, TestDoExchangeWriteOnlySchema) { TestDoExchangeWriteOnlySchema(); } \
|
| 118 |
+
TEST_F(FIXTURE, TestDoExchangeGet) { TestDoExchangeGet(); } \
|
| 119 |
+
TEST_F(FIXTURE, TestDoExchangePut) { TestDoExchangePut(); } \
|
| 120 |
+
TEST_F(FIXTURE, TestDoExchangeEcho) { TestDoExchangeEcho(); } \
|
| 121 |
+
TEST_F(FIXTURE, TestDoExchangeTotal) { TestDoExchangeTotal(); } \
|
| 122 |
+
TEST_F(FIXTURE, TestDoExchangeError) { TestDoExchangeError(); } \
|
| 123 |
+
TEST_F(FIXTURE, TestDoExchangeConcurrency) { TestDoExchangeConcurrency(); } \
|
| 124 |
+
TEST_F(FIXTURE, TestDoExchangeUndrained) { TestDoExchangeUndrained(); } \
|
| 125 |
+
TEST_F(FIXTURE, TestIssue5095) { TestIssue5095(); }
|
| 126 |
+
|
| 127 |
+
/// \brief Specific tests of DoPut.
|
| 128 |
+
class ARROW_FLIGHT_EXPORT DoPutTest : public FlightTest {
|
| 129 |
+
public:
|
| 130 |
+
void SetUpTest() override;
|
| 131 |
+
void TearDownTest() override;
|
| 132 |
+
void CheckBatches(const FlightDescriptor& expected_descriptor,
|
| 133 |
+
const RecordBatchVector& expected_batches);
|
| 134 |
+
void CheckDoPut(const FlightDescriptor& descr, const std::shared_ptr<Schema>& schema,
|
| 135 |
+
const RecordBatchVector& batches);
|
| 136 |
+
|
| 137 |
+
// Test methods
|
| 138 |
+
void TestInts();
|
| 139 |
+
void TestFloats();
|
| 140 |
+
void TestEmptyBatch();
|
| 141 |
+
void TestDicts();
|
| 142 |
+
void TestLargeBatch();
|
| 143 |
+
void TestSizeLimit();
|
| 144 |
+
void TestUndrained();
|
| 145 |
+
|
| 146 |
+
private:
|
| 147 |
+
std::unique_ptr<FlightClient> client_;
|
| 148 |
+
std::unique_ptr<FlightServerBase> server_;
|
| 149 |
+
};
|
| 150 |
+
|
| 151 |
+
#define ARROW_FLIGHT_TEST_DO_PUT(FIXTURE) \
|
| 152 |
+
static_assert(std::is_base_of<DoPutTest, FIXTURE>::value, \
|
| 153 |
+
ARROW_STRINGIFY(FIXTURE) " must inherit from DoPutTest"); \
|
| 154 |
+
TEST_F(FIXTURE, TestInts) { TestInts(); } \
|
| 155 |
+
TEST_F(FIXTURE, TestFloats) { TestFloats(); } \
|
| 156 |
+
TEST_F(FIXTURE, TestEmptyBatch) { TestEmptyBatch(); } \
|
| 157 |
+
TEST_F(FIXTURE, TestDicts) { TestDicts(); } \
|
| 158 |
+
TEST_F(FIXTURE, TestLargeBatch) { TestLargeBatch(); } \
|
| 159 |
+
TEST_F(FIXTURE, TestSizeLimit) { TestSizeLimit(); } \
|
| 160 |
+
TEST_F(FIXTURE, TestUndrained) { TestUndrained(); }
|
| 161 |
+
|
| 162 |
+
class ARROW_FLIGHT_EXPORT AppMetadataTestServer : public FlightServerBase {
|
| 163 |
+
public:
|
| 164 |
+
virtual ~AppMetadataTestServer() = default;
|
| 165 |
+
|
| 166 |
+
Status DoGet(const ServerCallContext& context, const Ticket& request,
|
| 167 |
+
std::unique_ptr<FlightDataStream>* data_stream) override;
|
| 168 |
+
|
| 169 |
+
Status DoPut(const ServerCallContext& context,
|
| 170 |
+
std::unique_ptr<FlightMessageReader> reader,
|
| 171 |
+
std::unique_ptr<FlightMetadataWriter> writer) override;
|
| 172 |
+
};
|
| 173 |
+
|
| 174 |
+
/// \brief Tests of app_metadata in data plane methods.
|
| 175 |
+
class ARROW_FLIGHT_EXPORT AppMetadataTest : public FlightTest {
|
| 176 |
+
public:
|
| 177 |
+
void SetUpTest() override;
|
| 178 |
+
void TearDownTest() override;
|
| 179 |
+
|
| 180 |
+
// Test methods
|
| 181 |
+
void TestDoGet();
|
| 182 |
+
void TestDoGetDictionaries();
|
| 183 |
+
void TestDoPut();
|
| 184 |
+
void TestDoPutDictionaries();
|
| 185 |
+
void TestDoPutReadMetadata();
|
| 186 |
+
|
| 187 |
+
private:
|
| 188 |
+
std::unique_ptr<FlightClient> client_;
|
| 189 |
+
std::unique_ptr<FlightServerBase> server_;
|
| 190 |
+
};
|
| 191 |
+
|
| 192 |
+
#define ARROW_FLIGHT_TEST_APP_METADATA(FIXTURE) \
|
| 193 |
+
static_assert(std::is_base_of<AppMetadataTest, FIXTURE>::value, \
|
| 194 |
+
ARROW_STRINGIFY(FIXTURE) " must inherit from AppMetadataTest"); \
|
| 195 |
+
TEST_F(FIXTURE, TestDoGet) { TestDoGet(); } \
|
| 196 |
+
TEST_F(FIXTURE, TestDoGetDictionaries) { TestDoGetDictionaries(); } \
|
| 197 |
+
TEST_F(FIXTURE, TestDoPut) { TestDoPut(); } \
|
| 198 |
+
TEST_F(FIXTURE, TestDoPutDictionaries) { TestDoPutDictionaries(); } \
|
| 199 |
+
TEST_F(FIXTURE, TestDoPutReadMetadata) { TestDoPutReadMetadata(); }
|
| 200 |
+
|
| 201 |
+
/// \brief Tests of IPC options in data plane methods.
|
| 202 |
+
class ARROW_FLIGHT_EXPORT IpcOptionsTest : public FlightTest {
|
| 203 |
+
public:
|
| 204 |
+
void SetUpTest() override;
|
| 205 |
+
void TearDownTest() override;
|
| 206 |
+
|
| 207 |
+
// Test methods
|
| 208 |
+
void TestDoGetReadOptions();
|
| 209 |
+
void TestDoPutWriteOptions();
|
| 210 |
+
void TestDoExchangeClientWriteOptions();
|
| 211 |
+
void TestDoExchangeClientWriteOptionsBegin();
|
| 212 |
+
void TestDoExchangeServerWriteOptions();
|
| 213 |
+
|
| 214 |
+
private:
|
| 215 |
+
std::unique_ptr<FlightClient> client_;
|
| 216 |
+
std::unique_ptr<FlightServerBase> server_;
|
| 217 |
+
};
|
| 218 |
+
|
| 219 |
+
#define ARROW_FLIGHT_TEST_IPC_OPTIONS(FIXTURE) \
|
| 220 |
+
static_assert(std::is_base_of<IpcOptionsTest, FIXTURE>::value, \
|
| 221 |
+
ARROW_STRINGIFY(FIXTURE) " must inherit from IpcOptionsTest"); \
|
| 222 |
+
TEST_F(FIXTURE, TestDoGetReadOptions) { TestDoGetReadOptions(); } \
|
| 223 |
+
TEST_F(FIXTURE, TestDoPutWriteOptions) { TestDoPutWriteOptions(); } \
|
| 224 |
+
TEST_F(FIXTURE, TestDoExchangeClientWriteOptions) { \
|
| 225 |
+
TestDoExchangeClientWriteOptions(); \
|
| 226 |
+
} \
|
| 227 |
+
TEST_F(FIXTURE, TestDoExchangeClientWriteOptionsBegin) { \
|
| 228 |
+
TestDoExchangeClientWriteOptionsBegin(); \
|
| 229 |
+
} \
|
| 230 |
+
TEST_F(FIXTURE, TestDoExchangeServerWriteOptions) { \
|
| 231 |
+
TestDoExchangeServerWriteOptions(); \
|
| 232 |
+
}
|
| 233 |
+
|
| 234 |
+
/// \brief Tests of data plane methods with CUDA memory.
|
| 235 |
+
///
|
| 236 |
+
/// If not built with ARROW_CUDA, tests are no-ops.
|
| 237 |
+
class ARROW_FLIGHT_EXPORT CudaDataTest : public FlightTest {
|
| 238 |
+
public:
|
| 239 |
+
void SetUpTest() override;
|
| 240 |
+
void TearDownTest() override;
|
| 241 |
+
|
| 242 |
+
// Test methods
|
| 243 |
+
void TestDoGet();
|
| 244 |
+
void TestDoPut();
|
| 245 |
+
void TestDoExchange();
|
| 246 |
+
|
| 247 |
+
private:
|
| 248 |
+
class Impl;
|
| 249 |
+
std::unique_ptr<FlightClient> client_;
|
| 250 |
+
std::unique_ptr<FlightServerBase> server_;
|
| 251 |
+
std::shared_ptr<Impl> impl_;
|
| 252 |
+
};
|
| 253 |
+
|
| 254 |
+
#define ARROW_FLIGHT_TEST_CUDA_DATA(FIXTURE) \
|
| 255 |
+
static_assert(std::is_base_of<CudaDataTest, FIXTURE>::value, \
|
| 256 |
+
ARROW_STRINGIFY(FIXTURE) " must inherit from CudaDataTest"); \
|
| 257 |
+
TEST_F(FIXTURE, TestDoGet) { TestDoGet(); } \
|
| 258 |
+
TEST_F(FIXTURE, TestDoPut) { TestDoPut(); } \
|
| 259 |
+
TEST_F(FIXTURE, TestDoExchange) { TestDoExchange(); }
|
| 260 |
+
|
| 261 |
+
/// \brief Tests of error handling.
|
| 262 |
+
class ARROW_FLIGHT_EXPORT ErrorHandlingTest : public FlightTest {
|
| 263 |
+
public:
|
| 264 |
+
void SetUpTest() override;
|
| 265 |
+
void TearDownTest() override;
|
| 266 |
+
|
| 267 |
+
// Test methods
|
| 268 |
+
void TestGetFlightInfo();
|
| 269 |
+
void TestGetFlightInfoMetadata();
|
| 270 |
+
void TestAsyncGetFlightInfo();
|
| 271 |
+
void TestDoPut();
|
| 272 |
+
void TestDoExchange();
|
| 273 |
+
|
| 274 |
+
protected:
|
| 275 |
+
struct Impl;
|
| 276 |
+
|
| 277 |
+
std::vector<std::pair<std::string, std::string>> GetHeaders();
|
| 278 |
+
|
| 279 |
+
std::shared_ptr<Impl> impl_;
|
| 280 |
+
std::unique_ptr<FlightClient> client_;
|
| 281 |
+
std::unique_ptr<FlightServerBase> server_;
|
| 282 |
+
};
|
| 283 |
+
|
| 284 |
+
#define ARROW_FLIGHT_TEST_ERROR_HANDLING(FIXTURE) \
|
| 285 |
+
static_assert(std::is_base_of<ErrorHandlingTest, FIXTURE>::value, \
|
| 286 |
+
ARROW_STRINGIFY(FIXTURE) " must inherit from ErrorHandlingTest"); \
|
| 287 |
+
TEST_F(FIXTURE, TestAsyncGetFlightInfo) { TestAsyncGetFlightInfo(); } \
|
| 288 |
+
TEST_F(FIXTURE, TestGetFlightInfo) { TestGetFlightInfo(); } \
|
| 289 |
+
TEST_F(FIXTURE, TestGetFlightInfoMetadata) { TestGetFlightInfoMetadata(); } \
|
| 290 |
+
TEST_F(FIXTURE, TestDoPut) { TestDoPut(); } \
|
| 291 |
+
TEST_F(FIXTURE, TestDoExchange) { TestDoExchange(); }
|
| 292 |
+
|
| 293 |
+
/// \brief Tests of the async client.
|
| 294 |
+
class ARROW_FLIGHT_EXPORT AsyncClientTest : public FlightTest {
|
| 295 |
+
public:
|
| 296 |
+
void SetUpTest() override;
|
| 297 |
+
void TearDownTest() override;
|
| 298 |
+
|
| 299 |
+
// Test methods
|
| 300 |
+
void TestGetFlightInfo();
|
| 301 |
+
void TestGetFlightInfoFuture();
|
| 302 |
+
void TestListenerLifetime();
|
| 303 |
+
|
| 304 |
+
private:
|
| 305 |
+
std::unique_ptr<FlightClient> client_;
|
| 306 |
+
std::unique_ptr<FlightServerBase> server_;
|
| 307 |
+
};
|
| 308 |
+
|
| 309 |
+
// DISABLED TestListenerLifetime: https://github.com/apache/arrow/issues/45120
|
| 310 |
+
#define ARROW_FLIGHT_TEST_ASYNC_CLIENT(FIXTURE) \
|
| 311 |
+
static_assert(std::is_base_of<AsyncClientTest, FIXTURE>::value, \
|
| 312 |
+
ARROW_STRINGIFY(FIXTURE) " must inherit from AsyncClientTest"); \
|
| 313 |
+
TEST_F(FIXTURE, TestGetFlightInfo) { TestGetFlightInfo(); } \
|
| 314 |
+
TEST_F(FIXTURE, TestGetFlightInfoFuture) { TestGetFlightInfoFuture(); } \
|
| 315 |
+
TEST_F(FIXTURE, DISABLED_TestListenerLifetime) { TestListenerLifetime(); }
|
| 316 |
+
|
| 317 |
+
} // namespace flight
|
| 318 |
+
} // namespace arrow
|
venv/lib/python3.10/site-packages/pyarrow/include/arrow/flight/test_flight_server.h
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 <memory>
|
| 21 |
+
|
| 22 |
+
#include "arrow/flight/server.h"
|
| 23 |
+
#include "arrow/flight/type_fwd.h"
|
| 24 |
+
#include "arrow/flight/visibility.h"
|
| 25 |
+
#include "arrow/status.h"
|
| 26 |
+
|
| 27 |
+
namespace arrow::flight {
|
| 28 |
+
|
| 29 |
+
class ARROW_FLIGHT_EXPORT TestFlightServer : public FlightServerBase {
|
| 30 |
+
public:
|
| 31 |
+
static std::unique_ptr<FlightServerBase> Make();
|
| 32 |
+
|
| 33 |
+
Status ListFlights(const ServerCallContext& context, const Criteria* criteria,
|
| 34 |
+
std::unique_ptr<FlightListing>* listings) override;
|
| 35 |
+
|
| 36 |
+
Status GetFlightInfo(const ServerCallContext& context, const FlightDescriptor& request,
|
| 37 |
+
std::unique_ptr<FlightInfo>* out) override;
|
| 38 |
+
|
| 39 |
+
Status DoGet(const ServerCallContext& context, const Ticket& request,
|
| 40 |
+
std::unique_ptr<FlightDataStream>* data_stream) override;
|
| 41 |
+
|
| 42 |
+
Status DoPut(const ServerCallContext&, std::unique_ptr<FlightMessageReader> reader,
|
| 43 |
+
std::unique_ptr<FlightMetadataWriter> writer) override;
|
| 44 |
+
|
| 45 |
+
Status DoExchange(const ServerCallContext& context,
|
| 46 |
+
std::unique_ptr<FlightMessageReader> reader,
|
| 47 |
+
std::unique_ptr<FlightMessageWriter> writer) override;
|
| 48 |
+
|
| 49 |
+
// A simple example - act like DoGet.
|
| 50 |
+
Status RunExchangeGet(std::unique_ptr<FlightMessageReader> reader,
|
| 51 |
+
std::unique_ptr<FlightMessageWriter> writer);
|
| 52 |
+
|
| 53 |
+
// A simple example - act like DoPut
|
| 54 |
+
Status RunExchangePut(std::unique_ptr<FlightMessageReader> reader,
|
| 55 |
+
std::unique_ptr<FlightMessageWriter> writer);
|
| 56 |
+
|
| 57 |
+
// Read some number of record batches from the client, send a
|
| 58 |
+
// metadata message back with the count, then echo the batches back.
|
| 59 |
+
Status RunExchangeCounter(std::unique_ptr<FlightMessageReader> reader,
|
| 60 |
+
std::unique_ptr<FlightMessageWriter> writer);
|
| 61 |
+
|
| 62 |
+
// Read int64 batches from the client, each time sending back a
|
| 63 |
+
// batch with a running sum of columns.
|
| 64 |
+
Status RunExchangeTotal(std::unique_ptr<FlightMessageReader> reader,
|
| 65 |
+
std::unique_ptr<FlightMessageWriter> writer);
|
| 66 |
+
|
| 67 |
+
// Echo the client's messages back.
|
| 68 |
+
Status RunExchangeEcho(std::unique_ptr<FlightMessageReader> reader,
|
| 69 |
+
std::unique_ptr<FlightMessageWriter> writer);
|
| 70 |
+
|
| 71 |
+
// Regression test for ARROW-13253
|
| 72 |
+
Status RunExchangeLargeBatch(std::unique_ptr<FlightMessageReader>,
|
| 73 |
+
std::unique_ptr<FlightMessageWriter> writer);
|
| 74 |
+
|
| 75 |
+
Status RunAction1(const Action& action, std::unique_ptr<ResultStream>* out);
|
| 76 |
+
|
| 77 |
+
Status RunAction2(std::unique_ptr<ResultStream>* out);
|
| 78 |
+
|
| 79 |
+
Status ListIncomingHeaders(const ServerCallContext& context, const Action& action,
|
| 80 |
+
std::unique_ptr<ResultStream>* out);
|
| 81 |
+
|
| 82 |
+
Status DoAction(const ServerCallContext& context, const Action& action,
|
| 83 |
+
std::unique_ptr<ResultStream>* out) override;
|
| 84 |
+
|
| 85 |
+
Status ListActions(const ServerCallContext& context,
|
| 86 |
+
std::vector<ActionType>* out) override;
|
| 87 |
+
|
| 88 |
+
Status GetSchema(const ServerCallContext& context, const FlightDescriptor& request,
|
| 89 |
+
std::unique_ptr<SchemaResult>* schema) override;
|
| 90 |
+
};
|
| 91 |
+
|
| 92 |
+
} // namespace arrow::flight
|