The am_getnext purpose function can find and store several qualified index entries in shared memory before it returns control to the database server. The following steps set up and fill a multiple-index entry buffer in shared memory:
Figure 15 shows the preceding steps. For more information about these functions, refer to Descriptor Function Reference.
mi_integer sample_beginscan(MI_AM_SCAN_DESC *sd) { mi_integer nrows = 512; MI_AM_TABLE_DESC *td=mi_scan_table(sd); mi_tab_setniorows(td, nrows); } mi_integer sample_getnext(MI_AM_SCAN_DESC *sd, MI_ROW **retrow, MI_AM_ROWID_DESC *ridDesc) { mi_integer nrows, row, nextrowid, nextfragid; MI_ROW *nextrow=NULL; /* MI_ROW structure is not typically used.*/ MI_AM_TABLE_DESC *td =mi_scan_table(sd); nrows = mi_tab_niorows(td); if (nrows > 0) {/*Store qualified results in shared memory.buffer.*/ for (row = 0; row < nrows; ++row) { /* Evaluate rows until we get one to return to caller. */ find_good_row(sd, &nextrow, &nextrowid, &fragid); mi_tab_setnextrow(td, nextrow, nextrowid, nextfragid); } /* End of loop for nrows times to fill shared memory.*/ }/*End (nrows > 0). */ else {/*Only one result per call to am_getnext. */ find_good_row(sd, &nextrow, &nextrowid, &nextfragid); mi_id_setrowid(ridDesc, nextrowid); mi_id_setfragid(ridDesc, nextfragid); } /* When reach the end of data, return MI_NO_MORE_RESULTS, else return MI_ROWS. */ }
Typically, a secondary access method does not create rows from key data. However, if you intend to set the am_keyscan purpose flag for a secondary access method, the access method must create an MI_ROW structure that contains key values in the appropriate order and of the appropriate data type to match the query specifications for a projected row.
For information about am_keyscan, refer to Bypassing Table Scans.
Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]