Tkrzw
Public Member Functions | List of all members
tkrzw::MemoryMapFile Class Referenceabstract

Interface for memory mapping file implementations. More...

#include <tkrzw_file_mmap.h>

Public Member Functions

virtual ~MemoryMapFile ()=default
 Destructor. More...
 
virtual Status LockMemory (size_t size)=0
 Locks the memory of the beginning region of the file, not to be swapped out. More...
 
- Public Member Functions inherited from tkrzw::File
virtual ~File ()=default
 Destructor. More...
 
virtual Status Open (const std::string &path, bool writable, int32_t options=OPEN_DEFAULT)=0
 Opens a file. More...
 
virtual Status Close ()=0
 Closes the file. More...
 
virtual Status Read (int64_t off, void *buf, size_t size)=0
 Reads data. More...
 
virtual std::string ReadSimple (int64_t off, size_t size)
 Reads data, in a simple way. More...
 
virtual Status Write (int64_t off, const void *buf, size_t size)=0
 Writes data. More...
 
virtual bool WriteSimple (int64_t off, std::string_view data)
 Writes data, in a simple way. More...
 
virtual Status Append (const void *buf, size_t size, int64_t *off=nullptr)=0
 Appends data at the end of the file. More...
 
virtual int64_t AppendSimple (const std::string &data)
 Appends data at the end of the file, in a simple way. More...
 
virtual Status Expand (size_t inc_size, int64_t *old_size=nullptr)=0
 Expands the file size without writing data. More...
 
virtual int64_t ExpandSimple (size_t inc_size)
 Expands the file size without writing data, in a simple way. More...
 
virtual Status Truncate (int64_t size)=0
 Truncates the file. More...
 
virtual Status TruncateFakely (int64_t size)=0
 Truncate the file fakely. More...
 
virtual Status Synchronize (bool hard, int64_t off=0, int64_t size=0)=0
 Synchronizes the content of the file to the file system. More...
 
virtual Status GetSize (int64_t *size)=0
 Gets the size of the file. More...
 
virtual int64_t GetSizeSimple ()
 Gets the size of the file, in a simple way. More...
 
virtual Status SetAllocationStrategy (int64_t init_size, double inc_factor)=0
 Sets allocation strategy. More...
 
virtual Status CopyProperties (File *file)=0
 Copies internal properties to another file object. More...
 
virtual Status GetPath (std::string *path)=0
 Gets the path of the file. More...
 
virtual std::string GetPathSimple ()
 Gets the path of the file, in a simple way. More...
 
virtual Status Rename (const std::string &new_path)=0
 Renames the file. More...
 
virtual Status DisablePathOperations ()=0
 Disables operations related to the path. More...
 
virtual bool IsOpen () const =0
 Checks whether the file is open. More...
 
virtual bool IsMemoryMapping () const =0
 Checks whether operations are done by memory mapping. More...
 
virtual bool IsAtomic () const =0
 Checks whether updating operations are atomic and thread-safe. More...
 
virtual std::unique_ptr< FileMakeFile () const =0
 Makes a new file object of the same concrete class. More...
 
const std::type_info & GetType () const
 Gets the type information of the actual class. More...
 

Additional Inherited Members

- Public Types inherited from tkrzw::File
enum  OpenOption : int32_t {
  OPEN_DEFAULT = 0 , OPEN_TRUNCATE = 1 << 0 , OPEN_NO_CREATE = 1 << 1 , OPEN_NO_WAIT = 1 << 2 ,
  OPEN_NO_LOCK = 1 << 3 , OPEN_SYNC_HARD = 1 << 4
}
 Enumeration of options for Open. More...
 
- Static Public Attributes inherited from tkrzw::File
static constexpr int64_t DEFAULT_ALLOC_INIT_SIZE = 1LL << 20
 The default value of the initial allocation size. More...
 
static constexpr double DEFAULT_ALLOC_INC_FACTOR = 2.0
 The default value of the allocation increment factor. More...
 

Detailed Description

Interface for memory mapping file implementations.

Constructor & Destructor Documentation

◆ ~MemoryMapFile()

virtual tkrzw::MemoryMapFile::~MemoryMapFile ( )
virtualdefault

Destructor.

Member Function Documentation

◆ LockMemory()

virtual Status tkrzw::MemoryMapFile::LockMemory ( size_t  size)
pure virtual

Locks the memory of the beginning region of the file, not to be swapped out.

Parameters
sizeThe size of the beginning region to lock.
Returns
The result status.

This method must be called after the file is opened.

Implemented in tkrzw::MemoryMapAtomicFile, and tkrzw::MemoryMapParallelFile.