![]() |
<Database> |
[ Shared data | Schema Declarations | tuple | relation | vector | lock | sql ]
All variables declarations preceeded by the modifier shared will be persistent and shared among all session threads and will be managed by <bigwig>'s internal database. Fine grained concurrency control is not provided by the compiler and must be programmed explicitly by the service programmer.
The macro package "sql.wigmac" provides an SQL like interface to the database.
All tuples, relations, and vector variables need to be declared according to some schema. The schemas themselves are declared explicitly as follows:
schema ::= schema id { field_list }
field_list ::= field*
field ::= type id_list ;
It is also possible to extend already declared schemas. This has the following syntax:
schema ::= schema id extends id { field_list }
Note that schemas are only allowed to contain basic types.
The tuple type is defined relative to a schema which is essentially a mapping of identifiers to basic types. A tuple value is thus a mapping from identifiers to basic types corresponding to the names and types of the associated schema. The tuple identifiers are commonly referred to as attributes. The following constructor is available for creating tuples:
The expression list must be assignments to identifiers that are the attribute names. Below is a list of the operators for manipulating tuples.
| Operator | Description |
|---|---|
| __==__ | equal. The conjunction of the equality of the tuple's constituents. |
| __!=__ | not equal. The negation of the conjunction of the equality of the tuple's constituents. |
| __=__ | assignment. Conceptually assign-by-value, but implemented as copy-on-write. |
| __<<__ | left tuple overwrite. Creates a tuple with the union of all the attributes of the two tuples. Whenever both tuples have a given attribute, the value of the rightmost argument tuple is taken. |
| __>>__ | right tuple overwrite. Creates a tuple with the union of all the attributes of the two tuples. Whenever both tuples have a given attribute, the value of the leftmost argument tuple is taken. |
| __.__ | tuple member reference. Accesses a member field in a tuple. |
| __\+__ | tuple project. Creates a copy of the left argument tuple, keepin only the attributes mentioned in the right argument (a comma separated list of identifiers in parentheses). |
| __\-__ | tuple project complement. Creates a copy of the left argument tuple, projecting away all attributes mentioned in the right argument (a comma separated list of identifiers in parentheses). |
A relation is a set of tuples with no notion of order and where no value is present twice (any redundant values are implicitly removed). The following two operators operate on relations:
| Operator | Description |
|---|---|
| __=__ | assignment. Conceptually assign-by-value, but implemented as copy-on-write. |
| |__| | size. Returns the number of tuples in the relation. |
The following built-in functions operate on relations:
The next case is when a comma separated list of identifiers is supplied after the semi-colon. The relation resulting from the evaluation of the expression argument is projected onto these attributes forming a new relation for which any duplicates are removed. The statement will then be executed once per tuple in this relation, setting "#" to the value of the current tuple. The remaining attributes will be available in the variable "@" (or "@1") that will be a relation containing all tuples that contributed to the current "#" tuple.
Finally, multiple expressions may be given as arguments. In this case, all expressions are evaluated to relations from left to right. If no identifiers are specified, the type of "#" will be a tuple with the intersection of the attributes from all the expressions. As usual, the statement will be executed on the relation with all such tuples, setting "#" to the current. The individual contributions from the expressions will be available in the variables "@1" to "@n", where "n" is the number of identifiers specified ("@" is a shortcut for "@1").
There are two kinds of Vectors (a.k.a. lists or arrays) in <bigwig>; basic vectors and tuple vectors. Basic vectors are capable of storing lists of basic values, while tuple vectors contain lists of tuples. Both kinds can be multi-dimensional. The following operators operate on vectors:
| Operator | Description |
|---|---|
| __=__ | assignment. Conceptually assign-by-value, but implemented as copy-on-write. |
| __+__ | concatenation. Returns the concatenation of two vectors. |
| __+=__ | concatenation, then assignment. Concatenates the left and right hand side expressions and assigns the result to the leftmost. |
| __[__] | index. Takes a vector and an integer (n) in square parentheses and extracts the nth element from the vector. |
| __[__..__] | range. Takes a vector and two integers (low and high) separated by two dots and extracts the subvector beginning with low and ending in high-1. |
| |__| | length. Returns the number of elements in the vector. |
The following built-in functions operate on vectors:
|
bigwig@brics.dk Last updated: November 2, 2001 |
|