The basic operation for extracting data from the record engine is the view. A view is a record with the following attributes:
**AdType** (*required*): Must be "View".
ForType (optional, defaults to undefined): Specifies what type of records are included in this view. The ForType value is a string. If this is defined, only records of that type are included; if not, all records are included (subject to the filter).
Filter (optional, defaults to true): Specifies how to control which records are included in this view. The filter expression is evaluated on each input record (prior to mapping). If the expression returns true, the record is included in the mapping step.
Select (optional if GroupBy is not specified): Specifies what to include from each record. Select is a list of records. If not defined, all attributes are included. Each record consists of:
Name (required): The name of the attribute to include in the output.
Expression (optional): The expression to evaluate for the result, in the context of the input record. If not given this defaults to the attribute given by Name.
Map (optional, defaults to an identity map): Specifies how to transform the input record prior to grouping, if desired. The map expression is a record literal, evaluated in the context of each candidate input record. Each value in the Map record is evaluated in the context of the input record and stored on a new intermediate record as the value for that attribute. The intermediate record is then used as the input record for the remainder of processing.
GroupBy (optional, but required to do an aggregation): Specifies how to aggregate all input records that have matching values. GroupBy is a list of expressions to group records by. Each expression in the list is evaluated in the context of the input record, and all records whose values all match are grouped. Aggregation functions can then be specified in Select, for example: [ Name="Count"; Expression=count(*) ].
OrderBy (optional, defaults to undefined order): Specifies the order of output records. OrderBy is an expression or a list of expressions. Each expression is evaluated in the context of the input record and the result is used to sort the output.
OrderByAscending (optional) Controls whether the order is ascending (the default) or descending
If OrderBy is specified, this is a boolean that controls whether the order is ascending (true) or descending. If OrderBy is a list, OrderByAscending can be either a list of booleans or a single boolean. If it is a list, it must have as many elements as OrderBy, and lets you specify ascending order for some items and descending for others.
Limit (optional, defaults to undefined) Specifies a maximum number of records to return.
If the limit attribute is a number, the view will not return more than that many records. If it is undefined or has a non-numeric type, there is no limit. If OrderBy is defined, the first Limit rows are returned. Otherwise, a maximum of Limit records are returned, but it is not defined which ones are returned.
The existing GUI operates on views with the following attributes:
- Detail views: The attribute names in the original records and their labels are listed in Select.
- Summary views: The partitions are stored in GroupBy. All other aggregations are stored in Select.
A view is “simple” if it meets the following requirements:
- Map must not be defined.
- ForType must be defined.
- GroupBy must be undefined or a list of attribute names.
Otherwise the view is “advanced”. Simple views can be edited with the existing GUI. (To support Filter, OrderBy, and Limit on simple views, the existing GUI can be enhanced with a textbox or custom controls for the filter, and attribute dropdowns for OrderBy.) Advanced views can be edited only by editing the constituent values of the View attribute directly.