filehash/ffdb_page.c
static int
_ffdb_update_data_pages_content (ffdb_htab_t* hashp, void *pagep, 
				 pgno_t oldpage, pgno_t newpage,
				 pgno_t oldfirst, pgno_t oldlast,
				 pgno_t newfirst, pgno_t newlast)
{
  unsigned int i;
  void* dpagep;
  pgno_t dp;
  ffdb_data_header_t *header = 0;
  ffdb_datap_t* datap = 0;

  for (i = 0; i < NUM_ENT(pagep); i++) {
    datap = DATAP(pagep, i);

    /* First check whether this data page pointed by datap->first
     * is a page to be moved. If yes, we are doing nothing, since
     * its key_page content is already updated when the data page
     * is moved
     */
    if (datap->first >= newfirst && datap->first <= newlast)
      continue;

    /* get data page pointed back by this pointer */
    dpagep = ffdb_get_page (hashp, datap->first, HASH_DATA_PAGE, 0, &dp);
    if (!dpagep) {
      fprintf (stderr, "Cannot get data page %d pointed by overflow page %d item %d\n",
	       datap->first, oldpage, i);
      return -1;
    }
    
    /* change information on the key page */
    header = BIG_DATA_HEADER(dpagep, datap->offset);

    assert (header->key_page == oldpage);

    /* key_page data item entry points to this new page */
    header->key_page = newpage;

    /* Put back the page */
    ffdb_put_page (hashp, dpagep, TYPE(dpagep), 1);
  }
  return 0;
}
/**
 * Update Data Page Content when a key page are rearranged to fill gaps.
 * Inside the key page (overflow), there are datap value pointing to
 * data pages which contain key_page information for each data. These
 * key_page value need to be updated to the new location.
 * 
 */
Update Data Page Content when a key page are rearranged to fill gaps.
Inside the key page (overflow), there are datap value pointing to
data pages which contain key_page information for each data. These
key_page value need to be updated to the new location.
Update Data Page Content when a key page are rearranged to fill gaps . Inside the key page ( overflow ) there are datap value pointing to data pages which contain key_page information for each data . These key_page value need to be updated to the new location .
static int
_ffdb_update_data_pages_content (ffdb_htab_t* hashp, void *pagep, 
				 pgno_t oldpage, pgno_t newpage,
				 pgno_t oldfirst, pgno_t oldlast,
				 pgno_t newfirst, pgno_t newlast)
{
  unsigned int i;
  void* dpagep;
  pgno_t dp;
  ffdb_data_header_t *header = 0;
  ffdb_datap_t* datap = 0;
  for (i = 0; i < NUM_ENT(pagep); i++) {
    datap = DATAP(pagep, i);
    if (datap->first >= newfirst && datap->first <= newlast)
      continue;
    dpagep = ffdb_get_page (hashp, datap->first, HASH_DATA_PAGE, 0, &dp);
    if (!dpagep) {
      fprintf (stderr, "Cannot get data page %d pointed by overflow page %d item %d\n",
	       datap->first, oldpage, i);
      return -1;
    }
    header = BIG_DATA_HEADER(dpagep, datap->offset);
    assert (header->key_page == oldpage);
    header->key_page = newpage;
    ffdb_put_page (hashp, dpagep, TYPE(dpagep), 1);
  }
  return 0;
}
static int _ffdb_update_data_pages_content ( ffdb_htab_t * hashp , void * pagep , pgno_t oldpage , pgno_t newpage , pgno_t oldfirst , pgno_t oldlast , pgno_t newfirst , pgno_t newlast ) { unsigned int i ; void * dpagep ; pgno_t dp ; ffdb_data_header_t * header = 0 ; ffdb_datap_t * datap = 0 ; for ( i = 0 ; i < NUM_ENT ( pagep ) ; i ++ ) { datap = DATAP ( pagep , i ) ; if ( datap -> first >= newfirst && datap -> first <= newlast ) continue ; dpagep = ffdb_get_page ( hashp , datap -> first , HASH_DATA_PAGE , 0 , & dp ) ; if ( ! dpagep ) { fprintf ( stderr , " \n " , datap -> first , oldpage , i ) ; return -1 ; } header = BIG_DATA_HEADER ( dpagep , datap -> offset ) ; assert ( header -> key_page == oldpage ) ; header -> key_page = newpage ; ffdb_put_page ( hashp , dpagep , TYPE ( dpagep ) , 1 ) ; } return 0 ; }
Update Data Page Content when a key page are rearranged to fill gaps.
Update Data Page Content when a key page are rearranged to fill gaps .
/* First check whether this data page pointed by datap->first
     * is a page to be moved. If yes, we are doing nothing, since
     * its key_page content is already updated when the data page
     * is moved
     */ /* get data page pointed back by this pointer */ /* change information on the key page */ /* key_page data item entry points to this new page */ /* Put back the page */