Turi Create  4.0
turi::fileio::cache_block Struct Reference

#include <core/storage/fileio/fixed_size_cache_manager.hpp>

Public Member Functions

bool extend_capacity (size_t new_capacity)
 
bool is_pointer () const
 
bool is_file () const
 
char * get_pointer () const
 
const size_t get_pointer_capacity () const
 
const size_t get_pointer_size () const
 
const std::string & get_filename () const
 
bool write_bytes_to_memory_cache (const char *c, std::streamsize bufsize)
 
std::shared_ptr< fileio_impl::general_fstream_sinkwrite_to_file ()
 
 ~cache_block ()
 

Detailed Description

A struct that contains either an array buffer or a file resource. This struct cannot be created by anything else other than the fixed_size_cache_manager.

This struct is not generally thread safe.

Definition at line 34 of file fixed_size_cache_manager.hpp.

Constructor & Destructor Documentation

◆ ~cache_block()

turi::fileio::cache_block::~cache_block ( )

Destructor. Clears all the memory in the cache block.

Member Function Documentation

◆ extend_capacity()

bool turi::fileio::cache_block::extend_capacity ( size_t  new_capacity)

If this points to an in-memory cache, attempts to extend the in-memory cache have capacity at least new_capacity. Returns true on success, false on failure. If false, this means that the cache block size has reached the maximum capacity permitted.

◆ get_filename()

const std::string& turi::fileio::cache_block::get_filename ( ) const
inline

Returns the disk backed filename.

Definition at line 82 of file fixed_size_cache_manager.hpp.

◆ get_pointer()

char* turi::fileio::cache_block::get_pointer ( ) const
inline

Returns the pointer to the in memory cache.

Definition at line 67 of file fixed_size_cache_manager.hpp.

◆ get_pointer_capacity()

const size_t turi::fileio::cache_block::get_pointer_capacity ( ) const
inline

Returns the total capacity of the in memory cache

Definition at line 72 of file fixed_size_cache_manager.hpp.

◆ get_pointer_size()

const size_t turi::fileio::cache_block::get_pointer_size ( ) const
inline

Returns the used capacity of the in memory cache

Definition at line 77 of file fixed_size_cache_manager.hpp.

◆ is_file()

bool turi::fileio::cache_block::is_file ( ) const
inline

Returns true if this points to a file

Definition at line 62 of file fixed_size_cache_manager.hpp.

◆ is_pointer()

bool turi::fileio::cache_block::is_pointer ( ) const
inline

Returns true if this points to an in memory cache.

Definition at line 57 of file fixed_size_cache_manager.hpp.

◆ write_bytes_to_memory_cache()

bool turi::fileio::cache_block::write_bytes_to_memory_cache ( const char *  c,
std::streamsize  bufsize 
)
inline

If this is an in memory cache, writes bufsize bytes to it. Returns true on success, false on failure.

Definition at line 88 of file fixed_size_cache_manager.hpp.

◆ write_to_file()

std::shared_ptr<fileio_impl::general_fstream_sink> turi::fileio::cache_block::write_to_file ( )

If this cache block is an in memory cache, dumps it to a file returning the output file handle. Fails if the cache block is not an in memory cache. Thread safe.


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