18#include <TFileCacheRead.h>
35 LOG(error) <<
"Failed to open TF file for reading (mmap).";
42 madvise((
void*)
mFileMap.data(),
mFileMap.size(), MADV_HUGEPAGE | MADV_SEQUENTIAL | MADV_DONTDUMP);
78 LOGP(fatal,
"Requested buffer size {} exceeds max allowed {}", s,
MaxBuffSize);
82 return const_cast<unsigned char*
>(
reinterpret_cast<const unsigned char*
>(
mFileMap.data() +
mFileOffset));
88 if (
len != lToIgnore) {
89 LOGP(error,
"BinFileOpLocal: request to ignore bytes beyond the file end. pos={} size={} len={}, closing the file {}",
mFileOffset,
mFileSize,
len,
mFileName);
103 mFile.reset(TFile::Open(fmt::format(
"{}?filetype=raw",
name).c_str()));
105 LOGP(error,
"Failed to open file {} for reading.",
name);
127 if (lToRead !=
len) {
137 LOGP(
debug,
"read_advance(fast) {} from {}", lToRead,
position());
139 std::memcpy(
ptr, lptr,
len);
142 LOGP(
debug,
"read_advance(slow) {} from {}", lToRead,
position());
143 if (
mFile->ReadBuffer(
reinterpret_cast<char*
>(
ptr), lToRead)) {
144 LOGP(error,
"BinFileOpGrid: failed to read {} bytes from position {} of file {}, closing it", lToRead,
mFileOffset,
mFileName);
154 LOGP(fatal,
"Requested buffer size {} exceeds max allowed {}", s,
MaxBuffSize);
169 LOGP(error,
"BinFileOpGrid:bufferize failed to read {} bytes from position {} of file {}, closing it", s,
mFileOffset,
mFileName);
179 if (
len != lToIgnore) {
180 LOGP(error,
"BinFileOpGrid: request to ignore bytes beyond the file end. pos={} size={} len={}, closing the file {}",
mFileOffset,
mFileSize,
len,
mFileName);
bool ignore_nbytes(size_t len) override
std::vector< unsigned char > mBuffer
unsigned char * bufferize(size_t &s) override
std::unique_ptr< TFile > mFile
bool isGood() const override
bool read_advance(void *ptr, size_t len) override
void set_position(size_t pos) override
BinFileOpGrid(const std::string &name)
~BinFileOpLocal() override
bool read_advance(void *ptr, size_t len) override
bool ignore_nbytes(size_t len) override
boost::iostreams::mapped_file_source mFileMap
BinFileOpLocal(const std::string &name)
unsigned char * bufferize(size_t &s) override
static constexpr size_t MaxBuffSize
size_t distance_to_eof() const
static BinFileOp * open(const std::string &name)
virtual bool isGood() const =0
GLuint const GLchar * name
GLenum GLenum GLsizei len
static bool beginsWith(const std::string &s, const std::string &start)
LOG(info)<< "Compressed in "<< sw.CpuTime()<< " s"