lib/result-builder.js
function preprocessRawResults(rawResults, resolvedConfig) {
    rawResults.forEach((rawResult, resultId) => {
        if (!rawResult.attributePath) return; // e.g. sub-filter results don't need indexing

        // link resultIds into attribute tree (per DataSource):
        const attrNode = getAttribute(rawResult.attributePath, resolvedConfig);
        attrNode.dataSources[rawResult.dataSourceName].resultId = resultId;

        // index rows by childKey if available
        // (top-level result has no childKey and does not need to be indexed):
        if (rawResult.childKey) {
            const keyAttr = rawResult.childKey.length === 1 ? rawResult.childKey[0] : null;
            rawResult.indexedData = {};
            rawResult.data.forEach((row, i) => {
                function dereferenceKeyAttr(keyAttrib) {
                    const keyVal = row[keyAttrib];
                    if (keyVal === undefined) {
                        const attrPath =
                            rawResult.attributePath.length > 0 ? rawResult.attributePath.join('.') : '{root}';
                        throw new DataError(
                            `Result-row ${i} of "${attrPath}" (DataSource "${
                                rawResult.dataSourceName
                            }") misses child key attribute "${keyAttr}"`
                        );
                    }
                    return keyVal;
                }

                const key = keyAttr
                    ? '' + dereferenceKeyAttr(keyAttr) // speed up non-composite keys
                    : rawResult.childKey.map(dereferenceKeyAttr).join(keySeparator);

                if (!rawResult.uniqueChildKey) {
                    if (!rawResult.indexedData[key]) rawResult.indexedData[key] = [];
                    rawResult.indexedData[key].push(row);
                } else {
                    if (rawResult.indexedData[key]) {
                        const attrPath =
                            rawResult.attributePath.length > 0 ? rawResult.attributePath.join('.') : '{root}';
                        throw new DataError(
                            `Result-row ${i} of "${attrPath}" (DataSource "${
                                rawResult.dataSourceName
                            }") has duplicate child key "${key}"`
                        );
                    }
                    rawResult.indexedData[key] = row;
                }
            });
        }
    });
}
function preprocessRawResults(rawResults, resolvedConfig) {
    rawResults.forEach((rawResult, resultId) => {
        if (!rawResult.attributePath) return; // e.g. sub-filter results don't need indexing

        // link resultIds into attribute tree (per DataSource):
        const attrNode = getAttribute(rawResult.attributePath, resolvedConfig);
        attrNode.dataSources[rawResult.dataSourceName].resultId = resultId;

        // index rows by childKey if available
        // (top-level result has no childKey and does not need to be indexed):
        if (rawResult.childKey) {
            const keyAttr = rawResult.childKey.length === 1 ? rawResult.childKey[0] : null;
            rawResult.indexedData = {};
            rawResult.data.forEach((row, i) => {
                function dereferenceKeyAttr(keyAttrib) {
                    const keyVal = row[keyAttrib];
                    if (keyVal === undefined) {
                        const attrPath =
                            rawResult.attributePath.length > 0 ? rawResult.attributePath.join('.') : '{root}';
                        throw new DataError(
                            `Result-row ${i} of "${attrPath}" (DataSource "${
                                rawResult.dataSourceName
                            }") misses child key attribute "${keyAttr}"`
                        );
                    }
                    return keyVal;
                }

                const key = keyAttr
                    ? '' + dereferenceKeyAttr(keyAttr) // speed up non-composite keys
                    : rawResult.childKey.map(dereferenceKeyAttr).join(keySeparator);

                if (!rawResult.uniqueChildKey) {
                    if (!rawResult.indexedData[key]) rawResult.indexedData[key] = [];
                    rawResult.indexedData[key].push(row);
                } else {
                    if (rawResult.indexedData[key]) {
                        const attrPath =
                            rawResult.attributePath.length > 0 ? rawResult.attributePath.join('.') : '{root}';
                        throw new DataError(
                            `Result-row ${i} of "${attrPath}" (DataSource "${
                                rawResult.dataSourceName
                            }") has duplicate child key "${key}"`
                        );
                    }
                    rawResult.indexedData[key] = row;
                }
            });
        }
    });
}
function preprocessRawResults ( rawResults , resolvedConfig ) { rawResults . forEach ( ( rawResult , resultId ) => { if ( ! rawResult . attributePath ) return ; // e.g. sub-filter results don't need indexing // link resultIds into attribute tree (per DataSource): const attrNode = getAttribute ( rawResult . attributePath , resolvedConfig ) ; attrNode . dataSources [ rawResult . dataSourceName ] . resultId = resultId ; // index rows by childKey if available // (top-level result has no childKey and does not need to be indexed): if ( rawResult . childKey ) { const keyAttr = rawResult . childKey . length === 1 ? rawResult . childKey [ 0 ] : null ; rawResult . indexedData = { } ; rawResult . data . forEach ( ( row , i ) => { function dereferenceKeyAttr ( keyAttrib ) { const keyVal = row [ keyAttrib ] ; if ( keyVal === undefined ) { const attrPath = rawResult . attributePath . length > 0 ? rawResult . attributePath . join ( '.' ) : '{root}' ; throw new DataError ( ` ${ i } ${ attrPath } ${ rawResult . dataSourceName } ${ keyAttr } ` ) ; } return keyVal ; } const key = keyAttr ? '' + dereferenceKeyAttr ( keyAttr ) // speed up non-composite keys : rawResult . childKey . map ( dereferenceKeyAttr ) . join ( keySeparator ) ; if ( ! rawResult . uniqueChildKey ) { if ( ! rawResult . indexedData [ key ] ) rawResult . indexedData [ key ] = [ ] ; rawResult . indexedData [ key ] . push ( row ) ; } else { if ( rawResult . indexedData [ key ] ) { const attrPath = rawResult . attributePath . length > 0 ? rawResult . attributePath . join ( '.' ) : '{root}' ; throw new DataError ( ` ${ i } ${ attrPath } ${ rawResult . dataSourceName } ${ key } ` ) ; } rawResult . indexedData [ key ] = row ; } } ) ; } } ) ; }
Link resultIds into attribute tree and index rows by key.

@private
Link resultIds into attribute tree and index rows by key .