BUILD from an INDEX Definition

[attrname := ] BUILD( indexdef [, options ] );

Form 3 creates an index file by using a previously defined INDEX definition.

Example:

nameKey := INDEX(mainTable,{surname,forename,filepos},'name.idx');
BUILD(nameKey); //gets all info from the INDEX definition

[attrname := ] BUILD( indexdef, dataset [, options ] );

Form 4 creates an index file on a dataset using a previously defined INDEX definition.

This is used to build an index where the dataset definition is complex. This allows the index to be logically separated from the dataset from which it is created. This is especially useful when the dataset definition is very complicated (Mb of source) because when the index is subsequently used in a query, all the code to create it is also parsed.

Example:

ds = DATASET(100, TRANSFORM({ unsigned id }, SELF.id := COUNTER));
i := INDEX({ unsigned id }, 'myIndex');
BUILD(i, ds);