mirror of
https://github.com/mhx/dwarfs.git
synced 2025-09-13 14:27:30 -04:00
Factor out block_range and iovec_read_buf types
This commit is contained in:
parent
0a34cf943b
commit
9915b3e1f4
@ -28,6 +28,7 @@
|
||||
#include <memory>
|
||||
|
||||
#include "dwarfs/block_compressor.h"
|
||||
#include "dwarfs/block_range.h"
|
||||
#include "dwarfs/fstypes.h"
|
||||
|
||||
namespace dwarfs {
|
||||
@ -35,7 +36,6 @@ namespace dwarfs {
|
||||
struct block_cache_options;
|
||||
struct cache_tidy_config;
|
||||
|
||||
class block_range;
|
||||
class fs_section;
|
||||
class logger;
|
||||
class mmif;
|
||||
|
48
include/dwarfs/block_range.h
Normal file
48
include/dwarfs/block_range.h
Normal file
@ -0,0 +1,48 @@
|
||||
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||
/**
|
||||
* \author Marcus Holland-Moritz (github@mhxnet.de)
|
||||
* \copyright Copyright (c) Marcus Holland-Moritz
|
||||
*
|
||||
* This file is part of dwarfs.
|
||||
*
|
||||
* dwarfs is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dwarfs is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with dwarfs. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
namespace dwarfs {
|
||||
|
||||
class cached_block;
|
||||
|
||||
class block_range {
|
||||
public:
|
||||
block_range(uint8_t const* data, size_t offset, size_t size);
|
||||
block_range(std::shared_ptr<cached_block const> block, size_t offset,
|
||||
size_t size);
|
||||
|
||||
uint8_t const* data() const { return begin_; }
|
||||
uint8_t const* begin() const { return begin_; }
|
||||
uint8_t const* end() const { return end_; }
|
||||
size_t size() const { return end_ - begin_; }
|
||||
|
||||
private:
|
||||
uint8_t const* const begin_;
|
||||
uint8_t const* const end_;
|
||||
std::shared_ptr<cached_block const> block_;
|
||||
};
|
||||
|
||||
} // namespace dwarfs
|
@ -35,6 +35,7 @@
|
||||
#include <folly/Expected.h>
|
||||
#include <folly/dynamic.h>
|
||||
|
||||
#include "dwarfs/block_range.h"
|
||||
#include "dwarfs/fstypes.h"
|
||||
#include "dwarfs/metadata_types.h"
|
||||
#include "dwarfs/types.h"
|
||||
|
@ -24,46 +24,13 @@
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <iosfwd>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <folly/portability/IOVec.h>
|
||||
#include <folly/small_vector.h>
|
||||
|
||||
#include "dwarfs/block_compressor.h" // TODO: or the other way round?
|
||||
#include "dwarfs/checksum.h"
|
||||
|
||||
namespace dwarfs {
|
||||
|
||||
class cached_block;
|
||||
|
||||
// TODO: move elsewhere
|
||||
class block_range {
|
||||
public:
|
||||
block_range(uint8_t const* data, size_t offset, size_t size);
|
||||
block_range(std::shared_ptr<cached_block const> block, size_t offset,
|
||||
size_t size);
|
||||
|
||||
uint8_t const* data() const { return begin_; }
|
||||
uint8_t const* begin() const { return begin_; }
|
||||
uint8_t const* end() const { return end_; }
|
||||
size_t size() const { return end_ - begin_; }
|
||||
|
||||
private:
|
||||
uint8_t const* const begin_;
|
||||
uint8_t const* const end_;
|
||||
std::shared_ptr<cached_block const> block_;
|
||||
};
|
||||
|
||||
// TODO: move elsewhere
|
||||
struct iovec_read_buf {
|
||||
// This covers more than 95% of reads
|
||||
static constexpr size_t inline_storage = 16;
|
||||
|
||||
folly::small_vector<struct ::iovec, inline_storage> buf;
|
||||
folly::small_vector<block_range, inline_storage> ranges;
|
||||
};
|
||||
|
||||
constexpr uint8_t MAJOR_VERSION = 2;
|
||||
constexpr uint8_t MINOR_VERSION = 5;
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include <folly/Expected.h>
|
||||
|
||||
#include "dwarfs/block_range.h"
|
||||
#include "dwarfs/metadata_types.h"
|
||||
#include "dwarfs/types.h"
|
||||
|
||||
|
39
include/dwarfs/iovec_read_buf.h
Normal file
39
include/dwarfs/iovec_read_buf.h
Normal file
@ -0,0 +1,39 @@
|
||||
/* vim:set ts=2 sw=2 sts=2 et: */
|
||||
/**
|
||||
* \author Marcus Holland-Moritz (github@mhxnet.de)
|
||||
* \copyright Copyright (c) Marcus Holland-Moritz
|
||||
*
|
||||
* This file is part of dwarfs.
|
||||
*
|
||||
* dwarfs is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* dwarfs is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with dwarfs. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <folly/portability/IOVec.h>
|
||||
#include <folly/small_vector.h>
|
||||
|
||||
#include "dwarfs/block_range.h"
|
||||
|
||||
namespace dwarfs {
|
||||
|
||||
struct iovec_read_buf {
|
||||
// This covers more than 95% of reads
|
||||
static constexpr size_t inline_storage = 16;
|
||||
|
||||
folly::small_vector<struct ::iovec, inline_storage> buf;
|
||||
folly::small_vector<block_range, inline_storage> ranges;
|
||||
};
|
||||
|
||||
} // namespace dwarfs
|
@ -36,6 +36,7 @@
|
||||
#include "dwarfs/block_cache.h"
|
||||
#include "dwarfs/fstypes.h"
|
||||
#include "dwarfs/inode_reader_v2.h"
|
||||
#include "dwarfs/iovec_read_buf.h"
|
||||
#include "dwarfs/logger.h"
|
||||
#include "dwarfs/offset_cache.h"
|
||||
#include "dwarfs/performance_monitor.h"
|
||||
|
@ -66,6 +66,7 @@
|
||||
#include "dwarfs/file_stat.h"
|
||||
#include "dwarfs/filesystem_v2.h"
|
||||
#include "dwarfs/fstypes.h"
|
||||
#include "dwarfs/iovec_read_buf.h"
|
||||
#include "dwarfs/logger.h"
|
||||
#include "dwarfs/metadata_v2.h"
|
||||
#include "dwarfs/mmap.h"
|
||||
|
@ -31,6 +31,7 @@
|
||||
#include "dwarfs/file_stat.h"
|
||||
#include "dwarfs/filesystem_v2.h"
|
||||
#include "dwarfs/filesystem_writer.h"
|
||||
#include "dwarfs/iovec_read_buf.h"
|
||||
#include "dwarfs/logger.h"
|
||||
#include "dwarfs/options.h"
|
||||
#include "dwarfs/progress.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user