qm. CircularRecordBuffer
Source: qminerdoc.
Circular buffer for storing records. Size of buffer is defined at start and is denoted in number of records. When buffer is full, old records are removed from the buffer and new records are stored in their place. For adding and deleting a callback is called. Records are stored by their IDs.
Methods
new CircularRecordBuffer([params])
Example
// TODO
Parameters
Name | Type | Optional | Description |
---|---|---|---|
params |
Object |
Yes |
Constructor parameters. |
param.store |
|
Store for the records in the buffer. |
|
param.size |
number |
|
Size of the buffer (number of records). |
param.onAdd |
function() |
Yes |
Callback executed when new record is
added to the buffer. Callback is give two parameters:
|
param.onDelete |
function() |
Yes |
Callback executed when record is removed
from the buffer. Callback is give two parameters:
|
Methods
load(fin)
Load circular buffer from input stream. Assumes store, onAdd and onDelete were already initialized in constructor.
Example
// TODO
Parameter
Name | Type | Optional | Description |
---|---|---|---|
fin |
|
input stream. |
push(rec)
Add new record to the buffer.
Example
// TODO
Parameter
Name | Type | Optional | Description |
---|---|---|---|
rec |
|
New record. |
save(fout) → module:fs.FOut
Saves circular buffer to the output stream. Does not save store, onAdd and onDelete callbacks.
Example
// TODO
Parameter
Name | Type | Optional | Description |
---|---|---|---|
fout |
|
Output stream. |
- Returns
-
module:fs.FOut
B The output streamfout
.