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),
43 ((TFile*)mFile)->SetReadaheadSize(50 * 1024 * 1024);
60 auto objectPath = capability.lfn2objectPath(
source.path());
61 void* handle = capability.getHandle(shared_from_this(), objectPath);
65 return std::make_shared<RootObjectHandler>(handle, capability.factory().format());
76 auto objectPath = capability.lfn2objectPath(
source.path());
78 void* handle = capability.getHandle(shared_from_this(), objectPath);
88 auto directory = (TDirectoryFile*)mFile->GetObjectChecked(
source.path().c_str(), TClass::GetClass<TDirectory>());
90 return std::shared_ptr<VirtualRootFileSystemBase>(
new TFileFileSystem(directory, 50 * 1024 * 1024, mObjectFactory));
97 arrow::fs::FileInfo
result;
98 result.set_type(arrow::fs::FileType::NotFound);
100 arrow::dataset::FileSource
source(
path, shared_from_this());
105 if (std::dynamic_pointer_cast<TFileFileSystem>(fs)) {
106 result.set_type(arrow::fs::FileType::Directory);
111 result.set_type(arrow::fs::FileType::File);
117 const std::string&
path,
118 const std::shared_ptr<const arrow::KeyValueMetadata>& metadata)
121 return std::make_shared<TDirectoryFileOutputStream>(this->
GetFile());
124 auto* dir =
dynamic_cast<TDirectoryFile*
>(this->
GetFile()->Get(path.c_str()));
126 return arrow::Status::Invalid(fmt::format(
"Unable to open directory {} in file {} ",
path.c_str(),
GetFile()->GetName()));
128 auto stream = std::make_shared<TDirectoryFileOutputStream>(dir);
134 arrow::fs::FileInfo
result;
135 result.set_type(arrow::fs::FileType::NotFound);
141 arrow::fs::FileInfoVector results;
142 auto selected = this->
GetFileInfo(select.base_dir);
144 results.emplace_back(*selected);
151 return arrow::Status::NotImplemented(
"Read only filesystem");
156 return arrow::Status::NotImplemented(
"Read only filesystem");
161 return arrow::Status::NotImplemented(
"Read only filesystem");
166 return arrow::Status::NotImplemented(
"Read only filesystem");
171 return arrow::Status::NotImplemented(
"Read only filesystem");
176 return arrow::Status::NotImplemented(
"Read only filesystem");
181 return arrow::Status::NotImplemented(
"Read only filesystem");
186 return arrow::Status::NotImplemented(
"Non streamable filesystem");
191 return arrow::Status::NotImplemented(
"No random access file system");
195 const std::string&
path,
196 const std::shared_ptr<const arrow::KeyValueMetadata>& metadata)
198 return arrow::Status::NotImplemented(
"Non streamable filesystem");
202 const std::string&
path,
203 const std::shared_ptr<const arrow::KeyValueMetadata>& metadata)
205 return arrow::Status::NotImplemented(
"No random access file system");
216 mDirectory->GetFile()->Close();
217 return arrow::Status::OK();
222 return arrow::Result<int64_t>(arrow::Status::NotImplemented(
"Cannot move"));
227 return arrow::Status::NotImplemented(
"Cannot write raw bytes to a TTree");
232 return mDirectory->GetFile()->IsOpen() ==
false;
238 mFilesystem(nullptr),
239 mObjectFactory(factory)
245 arrow::fs::FileInfo
result;
246 result.set_type(arrow::fs::FileType::NotFound);
248 arrow::dataset::FileSource
source(
path, shared_from_this());
251 if (!mFilesystem.get()) {
255 auto info = mFilesystem->GetFileInfo(
path);
260 result.set_type(info->type());
270 auto objectPath = capability.lfn2objectPath(
source.path());
272 mBuffer->SetBufferOffset(0);
274 TClass* serializedClass = mBuffer->ReadClass();
275 mBuffer->SetBufferOffset(0);
278 if (!serializedClass) {
282 bool supports = capability.checkSupport(serializedClass->GetName());
296 auto objectPath = capability.lfn2objectPath(
source.path());
297 void* handle = capability.getHandle(shared_from_this(), objectPath);
301 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