BUILD a Payload Index

[attrname := ] BUILD(baserecset, keys, payload, indexfile [, options ] );

Form 2 creates an index file containing extra payload fields in addition to the keys. This form is used primarily to create indexes used by "half-key" JOIN operations to eliminate the need to directly access the baserecset, thus increasing performance over the "full-keyed" version of the same operation (done with the KEYED option on the JOIN).

By default, the payload fields are sorted during the BUILDINDEX operation to minimize space on the leaf nodes of the key. This sorting can be controlled by using sortIndexPayload in a #OPTION statement.

Example:

Vehicles := DATASET('vehicles',
     {STRING2 st,
      STRING20 city,
      STRING20 lname,
      UNSIGNED8 filepos{VIRTUAL(fileposition)}},
      FLAT);
BUILD(Vehicles,{st,city},{lname},'vkey::st.city1');
//build key into Vehicles dataset on state and city
//payload the last name

//same index build using non-inline RECORD structures

SearchTerms := RECORD
  Vehicles.st;
  Vehicles.city;
END; 
Payload := RECORD
  Vehicles.lname;
END; 
BUILD(Vehicles,SearchTerms,Payload,'vkey::st.city2');