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

Interface: DBBuffer

The DBBuffer interface provides a place for queries to output their results to or fetch results from.

Buffers can be in RAM or simply drain out to the network. In the case of RAM buffers, they have a fixed (preallocated) number of rows that are recycled according to some eviction policy. Radio buffers have a single logical row that is written out via a RadioQueue interface.
Author: Sam Madden (madden@cs.berkeley.edu)

Components providing this interface:
tos.lib.TinyDB.DBBufferC

Components requiring this interface:
tos.lib.TinyDB.ParsedQuery
tos.lib.TinyDB.Tuple
tos.lib.TinyDB.TupleRouterM

Commands

Events

Commands - Details

peek

TinyDBError peek(uint8_t bufferId, QueryResult *buf, bool *pending)

Copy the top most result in the specified buffer into buf if *pending is true on return, the result will not be available until getComplete is signalled, Otherwise, the result is available immediately. No further calls to dequeue/peek/getResult are allowed until putComplete is signalled.

Note that this routine may return a QueryResult that contains pointers into DBBuffer-local data structures which will be deallocated as soon as pop() is called.
Returns: err_NoMoreResults if no results are available


getFieldId

TinyDBError getFieldId(uint8_t bufferId, FieldPtr f, uint8_t *id)

Gets the index of field f in the specified buffer.

Parameters:

bufferId - The bufferId (returned from getBufferId) to look for field f in

f - The name of the desired field

id - (On return) The index of the specified field in bufferId, if the return code == err_NoError

Returns: err_NoError on no error, err_UnsupportedBuffer or err_InvalidIndex on failure

getField

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

Gets the specified field from the QueryResult produced by reading from bufferId and writes the value into resultBuf.

Parameters:

bufferId - The bufferId (returned from getBufferId) that this is a query result for

qr - The query result (return from peek or getResult) to get the field from

idx - The index of the field to retrieve

resultBuf - The buffer to write the value of the field into


alloc

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

Allocate the specified buffer with the specified size sizes is an array of sizes of each field, with one entry per field Signals allocComplete when allocation is complete if *pending is true on return Data is buffer type specific data If *pending is true on return, the result will not be available until getComplete is signalled, Otherwise, the result is available immediately. No further calls to dequeue/peek/getResult are allowed until putComplete is signalled.
Returns: err_UnsupportedPolicy if the specified policy can't be applied
  err_ResultBufferBusy If other buffer requests are currently outstanding

getBufferId

TinyDBError getBufferId(uint8_t qid, bool isSpecial, uint8_t *bufferId)

Looks up the buffer id that corresponds to the specified query id in bufferId


Parameters:

qid - The query id to lookup

bufferId - (on return) The id of the buffer corresponding to qid

isSpecial - Is this a "special" (e.g. catalog buffer), or does it correspond to the results of an actual query

Returns: err_InvalidIndex if no such buffer exists