libmoost
|
#include <dataset.hpp>
Classes | |
struct | mmd_header |
class | section_info |
class | writer |
Public Types | |
typedef std::map< std::string, section_info > | section_map_type |
Public Member Functions | |
memory_mapped_dataset (const std::string &map_file_name, const std::string &dataset_name, boost::uint32_t format_version) | |
std::string | description () const |
const section_info & | find (const std::string §ion, const std::string &type) const |
template<typename T > | |
const T * | data (size_t offset=0, size_t count=1) const |
const std::string & | filename () const |
Static Public Member Functions | |
static void | warm_cache (const void *beg, const void *end) |
Private Attributes | |
const std::string | m_file |
const std::string | m_format |
boost::iostreams::mapped_file | m_map |
section_map_type | m_section_map |
Static Private Attributes | |
static const boost::uint32_t | MMD_MAGIC = 0x7473614C |
helps us to identify the file and verify byte order | |
static const boost::uint32_t | MMD_VERSION = 1 |
increment in case of incompatible format changes | |
static const size_t | MAP_PAGE_SIZE = 4096 |
page size used for "warming" the mapping cache |
Representation of a memory-mapped dataset
Each instance of this class represents a memory-mapped dataset. Sections within the dataset can be accessed using accessor classes, e.g. mmd_vector, mmd_hash_multimap or mmd_archive.
The dataset class as well as the accessor classes contain writer classes than be used to easily implement methods for writing a dataset to disk.
Definition at line 63 of file dataset.hpp.
typedef std::map<std::string, section_info> moost::container::memory_mapped_dataset::section_map_type |
Definition at line 174 of file dataset.hpp.
moost::container::memory_mapped_dataset::memory_mapped_dataset | ( | const std::string & | map_file_name, |
const std::string & | dataset_name, | ||
boost::uint32_t | format_version | ||
) | [inline] |
Memory-mapped dataset constructor
Used to map an existing on-disk dataset into memory. Performs a whole variety of checks to ensure the dataset is consistent and matches the specification given by dataset_name and format_version.
map_file_name | name of the dataset file to map into memory |
dataset_name | name of the dataset, used for validation |
format_version | dataset format version, used for validation |
Definition at line 385 of file dataset.hpp.
const T* moost::container::memory_mapped_dataset::data | ( | size_t | offset = 0 , |
size_t | count = 1 |
||
) | const [inline] |
Access mapped data
T | type to access |
offset | offset relative to start of mapped file |
count | number of items of type T to access |
Definition at line 489 of file dataset.hpp.
std::string moost::container::memory_mapped_dataset::description | ( | ) | const [inline] |
Definition at line 440 of file dataset.hpp.
const std::string& moost::container::memory_mapped_dataset::filename | ( | ) | const [inline] |
Return name of mapped file
Definition at line 504 of file dataset.hpp.
const section_info& moost::container::memory_mapped_dataset::find | ( | const std::string & | section, |
const std::string & | type | ||
) | const [inline] |
Find a section in the dataset's index
Will throw an exception if the section cannot be found or is corrupt.
section | section name |
type | section type |
Definition at line 455 of file dataset.hpp.
static void moost::container::memory_mapped_dataset::warm_cache | ( | const void * | beg, |
const void * | end | ||
) | [inline, static] |
Warm the cache for a particular data structure
This is intended to be called by the individual data structure's cache warming method. Cache warming is useful _only_ if there's a chance for the particular data structure to fit into memory and it's most effective when the data structure in question is randomly accessed very frequently (i.e. several thousand times per second).
Definition at line 518 of file dataset.hpp.
const std::string moost::container::memory_mapped_dataset::m_file [private] |
Definition at line 541 of file dataset.hpp.
const std::string moost::container::memory_mapped_dataset::m_format [private] |
Definition at line 542 of file dataset.hpp.
boost::iostreams::mapped_file moost::container::memory_mapped_dataset::m_map [private] |
Definition at line 543 of file dataset.hpp.
Definition at line 544 of file dataset.hpp.
const size_t moost::container::memory_mapped_dataset::MAP_PAGE_SIZE = 4096 [static, private] |
page size used for "warming" the mapping cache
Definition at line 69 of file dataset.hpp.
const boost::uint32_t moost::container::memory_mapped_dataset::MMD_MAGIC = 0x7473614C [static, private] |
helps us to identify the file and verify byte order
Definition at line 66 of file dataset.hpp.
const boost::uint32_t moost::container::memory_mapped_dataset::MMD_VERSION = 1 [static, private] |
increment in case of incompatible format changes
Definition at line 67 of file dataset.hpp.