14#include <arrow/array/array_nested.h>
15#include <arrow/array/array_primitive.h>
16#include <arrow/array/builder_nested.h>
17#include <arrow/array/builder_primitive.h>
20#include <TBufferFile.h>
21#include <TDirectoryFile.h>
22#include <arrow/type.h>
23#include <arrow/type_fwd.h>
24#include <arrow/dataset/file_base.h>
25#include <arrow/result.h>
26#include <arrow/status.h>
27#include <fmt/format.h>
31 std::shared_ptr<arrow::Array>;
40 mObjectFactory(factory)
42 ((TFile*)mFile)->SetReadaheadSize(50 * 1024 * 1024);
57 auto objectPath = capability.lfn2objectPath(
source.path());
58 void* handle = capability.getHandle(shared_from_this(), objectPath);
62 return std::make_shared<RootObjectHandler>(handle, capability.factory().format());
73 auto objectPath = capability.lfn2objectPath(
source.path());
75 void* handle = capability.getHandle(shared_from_this(), objectPath);
85 auto directory = (TDirectoryFile*)mFile->GetObjectChecked(
source.path().c_str(), TClass::GetClass<TDirectory>());
87 return std::shared_ptr<VirtualRootFileSystemBase>(
new TFileFileSystem(directory, 50 * 1024 * 1024, mObjectFactory));
94 arrow::fs::FileInfo
result;
95 result.set_type(arrow::fs::FileType::NotFound);
97 arrow::dataset::FileSource
source(
path, shared_from_this());
102 if (std::dynamic_pointer_cast<TFileFileSystem>(fs)) {
103 result.set_type(arrow::fs::FileType::Directory);
108 result.set_type(arrow::fs::FileType::File);
114 const std::string&
path,
115 const std::shared_ptr<const arrow::KeyValueMetadata>& metadata)
118 return std::make_shared<TDirectoryFileOutputStream>(this->
GetFile());
121 auto* dir =
dynamic_cast<TDirectoryFile*
>(this->
GetFile()->Get(path.c_str()));
123 return arrow::Status::Invalid(fmt::format(
"Unable to open directory {} in file {} ",
path.c_str(),
GetFile()->GetName()));
125 auto stream = std::make_shared<TDirectoryFileOutputStream>(dir);
131 arrow::fs::FileInfo
result;
132 result.set_type(arrow::fs::FileType::NotFound);
138 arrow::fs::FileInfoVector results;
139 auto selected = this->
GetFileInfo(select.base_dir);
141 results.emplace_back(*selected);
148 return arrow::Status::NotImplemented(
"Read only filesystem");
153 return arrow::Status::NotImplemented(
"Read only filesystem");
158 return arrow::Status::NotImplemented(
"Read only filesystem");
163 return arrow::Status::NotImplemented(
"Read only filesystem");
168 return arrow::Status::NotImplemented(
"Read only filesystem");
173 return arrow::Status::NotImplemented(
"Read only filesystem");
178 return arrow::Status::NotImplemented(
"Read only filesystem");
183 return arrow::Status::NotImplemented(
"Non streamable filesystem");
188 return arrow::Status::NotImplemented(
"No random access file system");
192 const std::string&
path,
193 const std::shared_ptr<const arrow::KeyValueMetadata>& metadata)
195 return arrow::Status::NotImplemented(
"Non streamable filesystem");
199 const std::string&
path,
200 const std::shared_ptr<const arrow::KeyValueMetadata>& metadata)
202 return arrow::Status::NotImplemented(
"No random access file system");
213 mDirectory->GetFile()->Close();
214 return arrow::Status::OK();
219 return arrow::Result<int64_t>(arrow::Status::NotImplemented(
"Cannot move"));
224 return arrow::Status::NotImplemented(
"Cannot write raw bytes to a TTree");
229 return mDirectory->GetFile()->IsOpen() ==
false;
235 mFilesystem(nullptr),
236 mObjectFactory(factory)
242 arrow::fs::FileInfo
result;
243 result.set_type(arrow::fs::FileType::NotFound);
245 arrow::dataset::FileSource
source(
path, shared_from_this());
248 if (!mFilesystem.get()) {
252 auto info = mFilesystem->GetFileInfo(
path);
257 result.set_type(info->type());
267 auto objectPath = capability.lfn2objectPath(
source.path());
269 mBuffer->SetBufferOffset(0);
271 TClass* serializedClass = mBuffer->ReadClass();
272 mBuffer->SetBufferOffset(0);
275 if (!serializedClass) {
279 bool supports = capability.checkSupport(serializedClass->GetName());
293 auto objectPath = capability.lfn2objectPath(
source.path());
294 void* handle = capability.getHandle(shared_from_this(), objectPath);
298 return std::make_shared<RootObjectHandler>(handle, capability.factory().format());
TBufferFileFS(TBufferFile *f, RootObjectReadingFactory &)
arrow::Result< arrow::fs::FileInfo > GetFileInfo(const std::string &path) override
std::shared_ptr< RootObjectHandler > GetObjectHandler(arrow::dataset::FileSource source) override
bool CheckSupport(arrow::dataset::FileSource source) override
TDirectoryFileOutputStream(TDirectoryFile *)
bool closed() const override
arrow::Status Write(const void *data, int64_t nbytes) override
arrow::Result< int64_t > Tell() const override
arrow::Status Close() override
virtual std::shared_ptr< VirtualRootFileSystemBase > GetSubFilesystem(arrow::dataset::FileSource source)
~TFileFileSystem() override
bool CheckSupport(arrow::dataset::FileSource source) override
arrow::Result< arrow::fs::FileInfo > GetFileInfo(const std::string &path) override
arrow::Result< std::shared_ptr< arrow::io::OutputStream > > OpenOutputStream(const std::string &path, const std::shared_ptr< const arrow::KeyValueMetadata > &metadata) override
std::shared_ptr< RootObjectHandler > GetObjectHandler(arrow::dataset::FileSource source) override
TDirectoryFile * GetFile()
arrow::Status DeleteDir(const std::string &path) override
arrow::Status Move(const std::string &src, const std::string &dest) override
arrow::Status DeleteFile(const std::string &path) override
arrow::Status DeleteDirContents(const std::string &path, bool missing_dir_ok) override
arrow::Status CreateDir(const std::string &path, bool recursive) override
arrow::Status CopyFile(const std::string &src, const std::string &dest) override
arrow::Result< arrow::fs::FileInfo > GetFileInfo(const std::string &path) override
arrow::Result< std::shared_ptr< arrow::io::OutputStream > > OpenOutputStream(const std::string &path, const std::shared_ptr< const arrow::KeyValueMetadata > &metadata) override
arrow::Result< std::shared_ptr< arrow::io::InputStream > > OpenInputStream(const std::string &path) override
arrow::Result< std::shared_ptr< arrow::io::OutputStream > > OpenAppendStream(const std::string &path, const std::shared_ptr< const arrow::KeyValueMetadata > &metadata) override
arrow::Status DeleteRootDirContents() override
arrow::Result< std::shared_ptr< arrow::io::RandomAccessFile > > OpenInputFile(const std::string &path) override
GLsizei GLsizei GLchar * source
GLsizei const GLchar *const * path
Defining PrimaryVertex explicitly as messageable.
std::vector< InputSpec > select(char const *matcher="")
RuntimeErrorRef runtime_error_f(const char *,...)
~RootObjectHandler() noexcept(false)
std::vector< RootObjectReadingCapability > capabilities