libmoost
moost::container::memory_mapped_dataset Class Reference

#include <dataset.hpp>

Inheritance diagram for moost::container::memory_mapped_dataset:
Collaboration diagram for moost::container::memory_mapped_dataset:

List of all members.

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_infofind (const std::string &section, 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

Detailed Description

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.


Member Typedef Documentation

Definition at line 174 of file dataset.hpp.


Constructor & Destructor Documentation

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.

Parameters:
map_file_namename of the dataset file to map into memory
dataset_namename of the dataset, used for validation
format_versiondataset format version, used for validation

Definition at line 385 of file dataset.hpp.


Member Function Documentation

template<typename T >
const T* moost::container::memory_mapped_dataset::data ( size_t  offset = 0,
size_t  count = 1 
) const [inline]

Access mapped data

Template Parameters:
Ttype to access
Parameters:
offsetoffset relative to start of mapped file
countnumber of items of type T to access
Returns:
a pointer to the requested type at a certain offset relative to the start of the mapped file.

Definition at line 489 of file dataset.hpp.

Here is the call graph for this function:

Here is the caller graph for this function:

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.

Parameters:
sectionsection name
typesection type
Returns:
reference to a section_info object describing the section

Definition at line 455 of file dataset.hpp.

Here is the caller graph for this function:

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.


Member Data Documentation

Definition at line 541 of file dataset.hpp.

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.

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.


The documentation for this class was generated from the following file: