VRS
A file format for sensor data.
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
vrs::RecordManager Class Reference

VRS internal class to manage the records of a specific Recordable after their creation. More...

#include <RecordManager.h>

Public Member Functions

 RecordManager (const RecordManager &)=delete
 
void operator= (const RecordManager &)=delete
 
RecordcreateRecord (double timestamp, Record::Type type, uint32_t formatVersion, const DataSource &data)
 
RecordcreateUncompressedRecord (double timestamp, Record::Type type, uint32_t formatVersion, const DataSource &data, std::unique_ptr< DirectWriteRecordData > &&directWriteData)
 
uint32_t purgeOldRecords (double oldestTimestamp, bool recycleBuffers=true)
 
void purgeCache ()
 Release as much memory as possible, by deleting all the records in the cache.
 
void collectOldRecords (double maxAge, list< Record * > &outCollectedRecords)
 
CompressionPreset getCompression () const
 
void setCompression (CompressionPreset compression)
 
void setMaxCacheSize (size_t max)
 
size_t getCurrentCacheSize () const
 

Friends

class Record
 

Detailed Description

VRS internal class to manage the records of a specific Recordable after their creation.

Each Recordable has its own RecordManager to minimize (ideally avoid) inter-thread locking. All timestamps are in seconds since some arbitrary point in time, and must be using the same time domain for the entire VRS file.

Member Function Documentation

◆ collectOldRecords()

void vrs::RecordManager::collectOldRecords ( double  maxAge,
list< Record * > &  outCollectedRecords 
)

Collect records older than a specific timestamp. The ownership of the records returned is transferred to the caller.

Parameters
maxAgeMax timestamp value of the records to collect.
collectedRecordsA container that will contain the collected records.

◆ createRecord()

Record * vrs::RecordManager::createRecord ( double  timestamp,
Record::Type  type,
uint32_t  formatVersion,
const DataSource data 
)

Create & hold a record using the given parameters. RecordManager is responsible for deleting the record. Copies the data referenced by the DataSource.

Parameters
timestampTimestamp of the record, in seconds.
typeType of the record.
formatVersionVersion number of the format of the record, so that when the record is read, the data can be interpreted appropriately.
dataA DataSource that points to the payload to copy in the record.
Returns
A pointer to the record created.

◆ createUncompressedRecord()

Record * vrs::RecordManager::createUncompressedRecord ( double  timestamp,
Record::Type  type,
uint32_t  formatVersion,
const DataSource data,
std::unique_ptr< DirectWriteRecordData > &&  directWriteData 
)

Create & hold a record using the given parameters. RecordManager is responsible for deleting the record. Copies the data referenced by the first DataSource, and takes ownership of directWriteData, which will be used to write the last part of the record directly in the file.

Parameters
timestampTimestamp of the record, in seconds.
typeType of the record.
formatVersionVersion number of the format of the record, so that when the record is read, the data can be interpreted appropriately.
dataA DataSource that points to the payload to copy in the record immediately.
directWriteDatadata to write directly in the file at the end of the record.
Returns
A pointer to the record created.

◆ getCompression()

CompressionPreset vrs::RecordManager::getCompression ( ) const
inline

Get the compression preset to use when writing the records of this RecordManager.

Returns
The compression preset.

◆ getCurrentCacheSize()

size_t vrs::RecordManager::getCurrentCacheSize ( ) const
inline

Get the count of recycled records are currently waiting to be reused.

Returns
Number of recycled records available.

◆ purgeOldRecords()

uint32_t vrs::RecordManager::purgeOldRecords ( double  oldestTimestamp,
bool  recycleBuffers = true 
)

Recycle or delete buffers older than a time.

Parameters
oldestTimestampMax timestamp of the records to purge.
recycleBuffersTell if old records should be recycled (true) or delete (false).
Returns
Number of records purged.

◆ setCompression()

void vrs::RecordManager::setCompression ( CompressionPreset  compression)
inline

Set the compression preset to use when writing the records of this RecordManager, to override the default value: CompressionPreset::Default.

Parameters
compressionCompressionPreset to use.

◆ setMaxCacheSize()

void vrs::RecordManager::setMaxCacheSize ( size_t  max)
inline

If you know that you have a lot samples that are small. You can increase the cache size to avoid allocations. The default value is kMaxCacheSize = 10.

Parameters
maxThe maximum amount of reusable records to keep around.

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