INDEX: use of external record structures for keyed and payload fields

Description

Syntax check fails for the second index, although both index definitions look the same:

id_rec := RECORD string2 f1; string2 f2; END; full_rec := RECORD integer did; id_rec; END; ds := DATASET ('aaa_file', full_rec, THOR); key_aaa := INDEX (ds, {did}, {f1, f2}, 'aaa'); key_bbb := INDEX (ds, {did}, id_rec, 'bbb'); // this fails the syntax BUILDINDEX (key_aaa, 'aaa', update); BUILDINDEX (key_bbb, 'bbb', update);

Index definition as it appears in Language Reference:

attr := INDEX([ baserecset, ] keys, payload, indexfile [,...

Apparently BUILDINDEX cannot use payload, if it is defined as a stand-alone record; same it true for keys record structure as well. Curiously, INDEX definition itself is perfectly fine, error appears only when using BUILDINDEX.

There are certain important benefits in allowing the use of external records' definitions, so it'd be nice to have this ability. If not possible, then Language Reference must provide a clarification.

Conclusion

None

Activity

Show:

Jim DeFabia March 8, 2023 at 4:38 PM

I believe there is enough information to continue

Vladimir Myullyari January 19, 2018 at 4:39 PM

, thank you, second approach is close to what I'm looking for, but still won't work under the circumstances: it requires exported definitions for each ds, which is almost never the case (talking about existing code).

, language reference need a comment in INDEX documentation, to the effect that record structures for keys and payload defined out-of-line have to be derived from the basereset. (Incidentally, documentation on build has a number of defects on its own.)

Gavin Halliday January 19, 2018 at 11:31 AM

 Please check if the LRM covers this.  It should say that if the index is used in a BUILD statement then the records must also define the values of the fields, or you should use the second build syntax.

Gavin Halliday January 19, 2018 at 11:29 AM

There are two different ways of doing what you want.  The first is to use an out of line definition which also defines the values:

 

x_id_rec := RECORD string2 f1 := ds.f1; string2 f2 := ds.f2; END; key_ccc := INDEX (ds, {did}, x_id_rec, 'bbb'); BUILDINDEX (key_ccc, 'ccc', update);

The second (and strongly recommended) is to use the syntax introduced in https://hpccsystems.atlassian.net/browse/HPCC-12869#icft=HPCC-12869.  

BUILDINDEX (key_bbb, ds, update);

It allows the index to have no reference to ds:

 

key_ddd := INDEX ({ integer did}, id_rec, 'ddd'); BUILDINDEX (key_ddd, ds, update);

 

 

Fixed
Pinned fields
Click on the next to a field label to start pinning.

Details

Components

Assignee

Reporter

Priority

Compatibility

Minor

Fix versions

Created January 18, 2018 at 8:38 PM
Updated June 8, 2023 at 3:52 PM
Resolved June 8, 2023 at 3:52 PM

Flag notifications