| 825 | } |
| 826 | |
| 827 | void Retrieval::getInversionCandidates(InversionCandidateList& inversions, |
| 828 | IndexScratchList& fromIndexScratches, |
| 829 | unsigned scope) const |
| 830 | { |
| 831 | const double cardinality = csb->csb_rpt[stream].csb_cardinality; |
| 832 | fb_assert(cardinality); |
| 833 | const double minSelectivity = MIN(MAXIMUM_SELECTIVITY / cardinality, DEFAULT_SELECTIVITY); |
| 834 | |
| 835 | // Walk through indexes to calculate selectivity / candidate |
| 836 | MatchedBooleanList matches; |
| 837 | |
| 838 | for (auto& scratch : fromIndexScratches) |
| 839 | { |
| 840 | scratch.scopeCandidate = false; |
| 841 | scratch.lowerCount = 0; |
| 842 | scratch.upperCount = 0; |
| 843 | scratch.nonFullMatchedSegments = MAX_INDEX_SEGMENTS + 1; |
| 844 | scratch.usePartialKey = false; |
| 845 | scratch.useMultiStartingKeys = false; |
| 846 | scratch.useRootListScan = false; |
| 847 | |
| 848 | const auto idx = scratch.index; |
| 849 | |
| 850 | if (scratch.candidate) |
| 851 | { |
| 852 | matches.assign(scratch.matches); |
| 853 | scratch.selectivity = MAXIMUM_SELECTIVITY; |
| 854 | |
| 855 | bool unique = false; |
| 856 | unsigned listCount = 0; |
| 857 | auto maxSelectivity = scratch.selectivity; |
| 858 | |
| 859 | for (unsigned j = 0; j < scratch.segments.getCount(); j++) |
| 860 | { |
| 861 | const auto& segment = scratch.segments[j]; |
| 862 | |
| 863 | auto scanType = segment.scanType; |
| 864 | |
| 865 | if (segment.scope == scope) |
| 866 | scratch.scopeCandidate = true; |
| 867 | |
| 868 | const USHORT iType = idx->idx_rpt[j].idx_itype; |
| 869 | |
| 870 | if (iType >= idx_first_intl_string) |
| 871 | { |
| 872 | auto textType = INTL_texttype_lookup(tdbb, INTL_INDEX_TO_TEXT(iType)); |
| 873 | |
| 874 | if (scanType != segmentScanMissing && !(idx->idx_flags & idx_unique)) |
| 875 | { |
| 876 | if (textType->getFlags() & TEXTTYPE_SEPARATE_UNIQUE) |
| 877 | { |
| 878 | // ASF: Order is more precise than equivalence class. |
| 879 | // We can't use the next segments, and we'll need to use |
| 880 | // INTL_KEY_PARTIAL to construct the last segment's key. |
| 881 | scratch.usePartialKey = true; |
| 882 | } |
| 883 | } |
| 884 |
nothing calls this directly
no test coverage detected