private _calcChunkedData()

in src/InMemoryProvider.ts [299:335]


    private _calcChunkedData(): Dictionary<ItemType[]> | Dictionary<ItemType> {
        if (!this._indexSchema) {
            // Primary key -- use data intact
            return this._mergedData;
        }

        // If it's not the PK index, re-pivot the data to be keyed off the key value built from the keypath
        let data: Dictionary<ItemType[]> = {};
        each(this._mergedData, item => {
            // Each item may be non-unique so store as an array of items for each key
            let keys: string[];
            if (this._indexSchema!!!.fullText) {
                keys = map(getFullTextIndexWordsForItem(<string>this._keyPath, item), val =>
                    serializeKeyToString(val, <string>this._keyPath));
            } else if (this._indexSchema!!!.multiEntry) {
                // Have to extract the multiple entries into this alternate table...
                const valsRaw = getValueForSingleKeypath(item, <string>this._keyPath);
                if (valsRaw) {
                    keys = map(arrayify(valsRaw), val =>
                        serializeKeyToString(val, <string>this._keyPath));
                } else {
                    keys = [];
                }
            } else {
                keys = [getSerializedKeyForKeypath(item, this._keyPath)!!!];
            }

            for (const key of keys) {
                if (!data[key]) {
                    data[key] = [item];
                } else {
                    data[key].push(item);
                }
            }
        });
        return data;
    }