| 1 |
/****************************************************************************** |
| 2 |
* |
| 3 |
* Project: GDAL |
| 4 |
* Purpose: Arrow virtual file system using VSI |
| 5 |
* Author: Even Rouault, <even.rouault at spatialys.com> |
| 6 |
* |
| 7 |
****************************************************************************** |
| 8 |
* Copyright (c) 2024, Even Rouault, <even.rouault at spatialys.com> |
| 9 |
* |
| 10 |
* SPDX-License-Identifier: MIT |
| 11 |
****************************************************************************/ |
| 12 |
|
| 13 |
#include "cpl_error.h" |
| 14 |
|
| 15 |
#include "../arrow_common/ogr_include_arrow.h" |
| 16 |
#include "../arrow_common/vsiarrowfilesystem.hpp" |
| 17 |
|
| 18 |
// Only available since Arrow 17.0 |
| 19 |
#ifndef ARROW_REGISTER_FILESYSTEM |
| 20 |
namespace arrow::fs |
| 21 |
{ |
| 22 |
#define ARROW_REGISTER_FILESYSTEM(scheme, factory_function, finalizer) \ |
| 23 |
::arrow::fs::FileSystemRegistrar \ |
| 24 |
{ \ |
| 25 |
scheme, ::arrow::fs::FileSystemFactory{factory_function}, finalizer \ |
| 26 |
} |
| 27 |
} // namespace arrow::fs |
| 28 |
#endif |
| 29 |
|
| 30 |
auto kVSIFileSystemModule = ARROW_REGISTER_FILESYSTEM( |
| 31 |
[]() |
| 32 |
{ |
| 33 |
CPLDebugOnly("ARROW", "Register VSI Arrow file system"); |
| 34 |
return "gdalvsi"; |
| 35 |
}(), |
| 36 |
[](const arrow::fs::Uri &uri, const arrow::io::IOContext & /* io_context */, |
| 37 |
std::string *out_path) |
| 38 |
-> arrow::Result<std::shared_ptr<arrow::fs::FileSystem>> |
| 39 |
{ |
| 40 |
constexpr std::string_view kScheme = "gdalvsi://"; |
| 41 |
if (out_path) |
| 42 |
*out_path = uri.ToString().substr(kScheme.size()); |
| 43 |
return std::make_shared<VSIArrowFileSystem>("ARROW", std::string()); |
| 44 |
}, |
| 45 |
{}); |