CMemoryMappedFile< T >模板类参考


详细描述

template<class T>
class shogun::CMemoryMappedFile< T >

memory mapped file

Implements a memory mapped file for super fast file access.

在文件MemoryMappedFile.h31行定义。

继承图,类CMemoryMappedFile< T >
Inheritance graph
[图例]

所有成员的列表。

公有成员

 CMemoryMappedFile (const char *fname, char flag='r', uint64_t fsize=0)
virtual ~CMemoryMappedFile ()
T * get_map ()
uint64_t get_length ()
uint64_t get_size ()
char * get_line (uint64_t &len, uint64_t &offs)
void write_line (const char *line, uint64_t len, uint64_t &offs)
void set_truncate_size (uint64_t *sz=0)
int32_t get_num_lines ()
operator[] (int32_t index) const
virtual const char * get_name () const

保护属性

int fd
uint64_t length
void * address
char rw
uint64_t last_written_byte

构造及析构函数文档

CMemoryMappedFile ( const char *  fname,
char  flag = 'r',
uint64_t  fsize = 0 
)

constructor

open a memory mapped file for read or read/write mode

参数:
fname name of file, zero terminated string
flag determines read or read write mode (can be 'r' or 'w')
fsize overestimate of expected file size (in bytes) when opened in write mode; Underestimating the file size will result in an error to occur upon writing. In case the exact file size is known later on, it can be reduced via set_truncate_size() before closing the file.

在文件MemoryMappedFile.h47行定义。

virtual ~CMemoryMappedFile (  )  [virtual]

destructor

在文件MemoryMappedFile.h94行定义。


成员函数文档

uint64_t get_length (  ) 

get the number of objects of type T cointained in the file

返回:
length of file

在文件MemoryMappedFile.h124行定义。

char* get_line ( uint64_t &  len,
uint64_t &  offs 
)

get next line from file

The returned line may be modfied in case the file was opened read/write. It is otherwise read-only.

参数:
len length of line (returned via reference)
offs offset to be passed for reading next line, should be 0 initially (returned via reference)
返回:
line (NOT ZERO TERMINATED)

在文件MemoryMappedFile.h149行定义。

T* get_map (  ) 

get the mapping address It can now be accessed via, e.g.

double* x = get_map() x[index]= foo; (for write mode) foo = x[index]; (for read and write mode)

返回:
length of file

在文件MemoryMappedFile.h115行定义。

virtual const char* get_name (  )  const [virtual]
返回:
object name

实现了CSGObject

在文件MemoryMappedFile.h238行定义。

int32_t get_num_lines (  ) 

count the number of lines in a file

返回:
number of lines

在文件MemoryMappedFile.h212行定义。

uint64_t get_size (  ) 

get the size of the file in bytes

返回:
size of file in bytes

在文件MemoryMappedFile.h133行定义。

T operator[] ( int32_t  index  )  const

operator overload for file read only access

DOES NOT DO ANY BOUNDS CHECKING

参数:
index index
返回:
element at index

在文件MemoryMappedFile.h232行定义。

void set_truncate_size ( uint64_t *  sz = 0  ) 

set file size

When the file is opened for read/write mode, it will be truncated upon destruction of the CMemoryMappedFile object. This is automagically determined when writing lines, but might have to be set manually for other data types, which is what this function is for.

参数:
sz byte number at which to truncate the file, zero to disable file truncation. Has an effect only when file is opened with in read/write mode 'w'

在文件MemoryMappedFile.h203行定义。

void write_line ( const char *  line,
uint64_t  len,
uint64_t &  offs 
)

write line to file

参数:
line string to be written (must not contain '
' and not required to be zero terminated)
len length of the string to be written
offs offset to be passed for writing next line, should be 0 initially (returned via reference)
返回:
line (NOT ZERO TERMINATED)

在文件MemoryMappedFile.h178行定义。


成员数据文档

void* address [protected]

mapping address

在文件MemoryMappedFile.h246行定义。

int fd [protected]

file descriptor

在文件MemoryMappedFile.h242行定义。

uint64_t last_written_byte [protected]

last_written_byte

在文件MemoryMappedFile.h251行定义。

uint64_t length [protected]

size of file

在文件MemoryMappedFile.h244行定义。

char rw [protected]

mode

在文件MemoryMappedFile.h248行定义。


该类的文档由以下文件生成:

SHOGUN Machine Learning Toolbox - Documentation