WYRDTEK Home Features Reference Downloads About


The es_mbq interface is designed to parse and execute a query language expression. The exstreamspeed query language is used to define and execute a sequence of aggregator queries.

Query Example

Here is an example query expression that aggregates PV01 by Maturity year/month and ProductId.

# define aggregator query
mba( refmbc=Result
     addformula( field=Maturity def="100 * MaturityYear+MaturityMonth" type=i32 )
     addkey( field=ProductId )
     addkey( field=Maturity )
     addresult( field=PV01 aggtype=sum )
     addmembership( field=ProductId refmbm=ProductF )
     addfilter( def="Maturity > 0" ) )

The query language can be used to define result database (root) classes, membership filters and aggregators. Membership filters can be constructed from the results of previous queries or from other root nodes in an input database. For example:

# define membership for DivisionId
mbm( id=DivisionF memtype=in
     addsd( refsd=Division value="Division001" ) )

# define ProductF node to contain ProductIds
mbc( id=ProductF batch=1024 index=Private )

# populate ProductF with ProductIds corresponding to DivisionId
mba( refmbc=ProductF
     addkey( field=ProductId )
     addmembership( field=DivisionId refmbm=DivisionF ) )

# define new membership from ProductId list
mbm( id=ProductF
     adddb( refmbc=ProductF field=ProductId ) )

[Back To Top]

Query Language Reference

The basic syntactic grammar of the query language is as follows.

Query           ::= ( Comment | FunctionToken )*

Token           ::= SimpleToken | FunctionToken | Comment

FunctionToken   ::= FunctionTokenId '(' Token* ')

SimpleToken     ::= SimpleTokenId '=' TokenString

TokenString     ::= AnyNonWSChar* | '"' AnyChar* '"'

FunctionTokenId ::= 'mbc' | 'mbm' | 'mba' | 
                    'addfld' | 'addfldidx' | 'add' | 'addrange' | 'addsd' |
                    'adddb' | 'addkey' | 'addformula' | 'addresult' |
                    'addmembership' | 'addfilter'

SimpleTokenId   ::= 'id' | 'batch' | 'index' | 'field' | 'aggtype' | 'type' |
                    'memtype' | 'refsd' | 'value' | 'refmbm' | 'def'

Comment         ::= '#' AnyChar* NewLine

AnyChar         ::= <any character excluding newline >

AnyNonWSChar    ::= <any character excluding white space >

FunctionTokens denote some action or function and consist of both SimpleTokens and other FunctionTokens that designate parameters. Only three FunctionaTokens are valid at the top-level: mbc, mbm and mba.
mbc Define a database class


id Name of database class in result database.

batch Batch size parameter in bytes.

index Index type. Either None, Private or Shared


addfld Add field definition to database class.

field Name of database field.

type Type of field. Either i8, i16, i32, i64 or f64.

addfldidx Define field to be part of index.

field Name of database field to add to index.
mbm Define a membership filter.


id Name of membership filter.

memtype Membership type. Either in or notin.


add Add integer value to filter.

value Integer value to add to filter.

addsd Add string-id corresponding to filter.

refsd Name of string dictionary to reference.

value String value from which to determine string-id.

addrange Add range of integer values to filter.

low Lowest integer value in range.

high Highest integer value in range.

adddb Add column of values from a database node to filer.

refmbc Name of (root) database class/node from which to derive filter.

field Name of (integer) database field (column) from which to derivate values.
mba Define a database aggregator.


refmbc Name of result database class.


addformula Add formula to aggregator definition.

field Name of formula field.

def Formula Definition - remember to enclose in quotes if any whitespace or reserved words are used.

type Type of formula value. Either: i8, i16, i32, i64 or f64.

addkey Add key field to aggregator definition.

field Name of database or formula field used as key.

addresult Add result field to agggregator definition.

field Name of database or formula field used as result.

aggtype Aggregation type. Either: sum, min, max or count.

addmembership Bind membership filter to aggregator definition.

field Name of database field to bind membership filter to.

refmbm Name of membership filter, previously declared via mbm token.

addfilter Add filter formula definition to aggregator.

def Filter formula definition - remember to enclose in quotes if any whitespace or reserved words are used.

[Back To Top]


es_mbq_new Create new database query.
es_mbq_delete Destroy database query.
es_mbq_add Add null-terminated line of input to database query.
es_mbq_add_v Add non null-terminated line of input to database query.
es_mbq_addint Add string representation of integer to database query.
es_mbq_addflt Add string representation of double to database query.
es_mbq_addfile Add query expression from file to database query.
es_mbq_prepare Parse and prepare database query for execution.
es_mbq_exec Execute database query and generate result database.

[Back To Top]

[Back To Reference]