| 841 | |
| 842 | #if PG_VERSION_NUM >= PG_VERSION_NUM_18 |
| 843 | bool deeplake_table_am_routine::scan_bitmap_next_tuple( |
| 844 | TableScanDesc scan, TupleTableSlot* slot, bool* recheck, uint64* lossy_pages, uint64* exact_pages) |
| 845 | { |
| 846 | CHECK_FOR_INTERRUPTS(); |
| 847 | DeeplakeScanData* scan_data = get_scan_data(scan); |
| 848 | |
| 849 | if (!scan_data->bitmap_scan_active) { |
| 850 | scan_data->bitmap_scan_active = true; |
| 851 | scan_data->current_offset = 0; |
| 852 | *lossy_pages = 0; |
| 853 | *exact_pages = 0; |
| 854 | |
| 855 | // Get the merged TBMIterator from scan descriptor |
| 856 | TBMIterator* iter = &scan->st.rs_tbmiterator; |
| 857 | TBMIterateResult tbmres; |
| 858 | |
| 859 | while (tbm_iterate(iter, &tbmres)) { |
| 860 | if (tbmres.lossy) { |
| 861 | // Lossy page - all tuples in this block |
| 862 | int64_t block_start = static_cast<int64_t>(tbmres.blockno) * pg::DEEPLAKE_TUPLES_PER_BLOCK; |
| 863 | int64_t block_end = block_start + pg::DEEPLAKE_TUPLES_PER_BLOCK; |
| 864 | for (int64_t row = block_start; row < block_end; ++row) { |
| 865 | scan_data->bitmap_row_numbers.push_back(row); |
| 866 | } |
| 867 | ++(*lossy_pages); |
| 868 | } else { |
| 869 | // Exact tuples - extract offsets |
| 870 | OffsetNumber offsets[TBM_MAX_TUPLES_PER_PAGE]; |
| 871 | int32_t ntuples = tbm_extract_page_tuple(&tbmres, offsets, TBM_MAX_TUPLES_PER_PAGE); |
| 872 | for (int32_t i = 0; i < ntuples; i++) { |
| 873 | // Convert (block, offset) to row number |
| 874 | ItemPointerData tid; |
| 875 | ItemPointerSet(&tid, tbmres.blockno, offsets[i]); |
| 876 | int64_t row_num = pg::utils::tid_to_row_number(&tid); |
| 877 | scan_data->bitmap_row_numbers.push_back(row_num); |
| 878 | } |
| 879 | ++(*exact_pages); |
| 880 | } |
| 881 | } |
| 882 | } |
| 883 | |
| 884 | if (scan_data->current_offset >= scan_data->bitmap_row_numbers.size()) { |
| 885 | return false; // No more tuples |
| 886 | } |
| 887 | |
| 888 | *recheck = false; |
| 889 | // Get next row number |
| 890 | int64_t row_num = scan_data->bitmap_row_numbers[scan_data->current_offset++]; |
| 891 | scan_data->scan_state.set_current_position(row_num); |
| 892 | return scan_data->scan_state.get_next_tuple(slot); |
| 893 | } |
| 894 | #endif |
| 895 | |
| 896 | bool deeplake_table_am_routine::scan_sample_next_block(TableScanDesc scan, struct SampleScanState* scanstate) |
nothing calls this directly
no test coverage detected