Apps     Components     Interfaces     All Files     Source Tree     source: tos.lib.TinyDB.DBBufferC.nc

Component: DBBufferC

Required Interfaces

Provided Interfaces

Variables

Function Index

Function Descriptions

DBBuffer.alloc

command TinyDBError DBBuffer.alloc (uint8_t bufferId, BufferType type, uint16_t size, BufferPolicy policy, ParsedQuery *schema, char *name, bool *pending, long data)

Allocate the buffer with the specified size sizes is an array of sizes of each field, with one entry per field

Note that this may keep a reference to schema or name until after pending is complete (so neither may be allocated on the callers stack!)

Signals allocComplete when allocation is complete if *pending is true on return

Parameters:

bufferId - The buffer to allocate

type - The type of the buffer (see DBBuffer.h -- only kRAM and kRADIO are supported)

size - The size (in rows) of the buffer

policy - The eviction policy to use with the buffer (see DBBuffer.h)

schema - The schema (layout) of rows in this buffer (expressed as a query)

name - The name of the schema (or NULL if it has no name)

pending - On return, set to true if the buffer is still being allocated (expect allocComplete if true).

data - is currently unused

Returns: err_UnsupportedPolicy if the specified policy can't be applied


DBBuffer.getField

command TinyDBError DBBuffer.getField (uint8_t bufferId, QueryResult *qr, uint8_t idx, char *resultBuf)

Copy data from the idxth field of qr into resultBuf. qr must have been produced via a call to peek() or getResult() on the same bufferId.

DBBuffer.getBufferId

command TinyDBError DBBuffer.getBufferId (uint8_t bufIdx, bool special, uint8_t *bufferId)

Returns: the buffer id that corresponds to the specified bufIdx if special is false, bufIdx is just the query id that we want to read from otherwise, it's the index into special buffers -- e.g. catalog buffers -- that we want to use

CatalogTable.catalogFieldSize

command uint8_t CatalogTable.catalogFieldSize (uint8_t bufIdx, uint8_t fieldNo)

Return the size of the requested field in a "special" catalog table. Return 0 if the field number is out of range or bufIdx is an unknown field.

getBuf

TinyDBError getBuf(uint8_t bufId, DBBufferC.Buffer **buf)

(PRIVATE) Return a pointer to buffer bufId in buf if bufId is a valid buf. Otherwise, return err_InvalidIndex

cleanupBuffer

void cleanupBuffer(int b, int lineNo)

(PRIVATE) Clean up buffer id b. Deallocates all associated memory and sets the buffer use bits appropriately. Note that this should work even an allocation is partly completed -- it checks for NULL before deallocating.