nl_tokens: Prepares the query that uses the specified filter and record order for execution on this storage .
pl_tokens: function prepareQuery ( thisStorage , filter , order ) { order = normalizeKeyPath ( order ) let expectedSortingDirection = order [ 0 ] . charAt ( 0 ) === "!" let canSortingBeOptimized canSortingBeOptimized = canOptimizeSorting ( expectedSortingDirection , order ) let storages = new Map ( ) storages . set ( normalizeKeyPath ( thisStorage . keyPath ) , { storage : thisStorage , <mask> : 1 // traversing storage is faster than fetching records by index } ) for ( let indexName of thisStorage . indexNames ) { let index = thisStorage . getIndex ( indexName ) if ( ! index . multiEntry ) { storages . set ( normalizeKeyPath ( index . keyPath ) , { storage : index , score : 0 } ) } } let simplifiedOrderFieldPaths = simplifyOrderingFieldPaths ( order ) if ( canSortingBeOptimized ) { prepareSortingOptimization ( storages , simplifiedOrderFieldPaths ) } prepareFilteringOptimization ( storages , filter ) return chooseStorageForQuery ( storages , order , simplifiedOrderFieldPaths , canSortingBeOptimized , expectedSortingDirection ) }