filehash/ffdb_page.c
static int
_ffdb_update_key_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, next;
  void* kpagep;
  pgno_t kp, newkp;
  ffdb_data_header_t *header = 0;
  ffdb_datap_t* datap = 0;

  next = FIRST_DATA_POS(pagep);
  for (i = 0; i < NUM_ENT(pagep); i++) {
    header = BIG_DATA_HEADER(pagep, next);

    /* get key page pointed back by this header */
    kpagep = ffdb_get_page (hashp, header->key_page, HASH_RAW_PAGE, 0, &kp);
    if (!kpagep) {
      fprintf (stderr, "Cannot get key page %d from data page %d item %d\n",
	       header->key_page, oldpage, i);
      return -1;
    }
    
    /* change information on the key page */
    datap = DATAP(kpagep, header->key_idx);

#ifdef _FFDB_DEBUG
    fprintf (stderr, "page %d Datap checksum = 0x%x header key = %d\n", oldpage,
	     datap->chksum, header->key_page);
#endif

    assert (datap->first == oldpage);

    /* Key page data item entry points to this new page */
    datap->first = newpage;

    /* Check whether the key page actually is going to be moved */
    /* this works based on assumption data pages are moved first */
    /* the data page entry points back to the new hash page that
     * is going to be moved to newkp
     */
    if (header->key_page >= oldfirst && header->key_page <= oldlast) {
      newkp = newfirst + (header->key_page - oldfirst);
#ifdef _FFDB_DEBUG
      fprintf (stderr, "Data Page %d contains hash key entry %d that moves to %d\n", oldpage, header->key_page, newkp);
#endif
      /* Now my header has to be changed to point to new page as well */
      header->key_page = newkp;
    }
    
    next = header->next;

    /* Put back the page */
    ffdb_put_page (hashp, kpagep, TYPE(kpagep), 1);
  }
  return 0;
}
/**
 * Update all Key Pages (either primary or overflow) content when a data page
 * is moved. The data page contains one or more key page information through
 * key_page field. A new hash key item is accessed through key_page and 
 * key_indx pair. The data pointer value (datap->first) of this hash item
 * has to be updated to the new page.
 *
 * If the key_page is also among pages that are moved, the data header's 
 * key_page will be updated to its new location.
 */
Update all Key Pages (either primary or overflow) content when a data page
is moved. The data page contains one or more key page information through
key_page field. A new hash key item is accessed through key_page and
key_indx pair. The data pointer value (datap->first) of this hash item
has to be updated to the new page.

If the key_page is also among pages that are moved, the data header's
key_page will be updated to its new location.
Update all Key Pages ( either primary or overflow ) content when a data page is moved . The data page contains one or more key page information through key_page field . A new hash key item is accessed through key_page and key_indx pair . The data pointer value ( datap - > first ) of this hash item has to be updated to the new page . If the key_page is also among pages that are moved the data header ' s key_page will be updated to its new location .
static int
_ffdb_update_key_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, next;
  void* kpagep;
  pgno_t kp, newkp;
  ffdb_data_header_t *header = 0;
  ffdb_datap_t* datap = 0;
  next = FIRST_DATA_POS(pagep);
  for (i = 0; i < NUM_ENT(pagep); i++) {
    header = BIG_DATA_HEADER(pagep, next);
    kpagep = ffdb_get_page (hashp, header->key_page, HASH_RAW_PAGE, 0, &kp);
    if (!kpagep) {
      fprintf (stderr, "Cannot get key page %d from data page %d item %d\n",
	       header->key_page, oldpage, i);
      return -1;
    }
    datap = DATAP(kpagep, header->key_idx);
#ifdef _FFDB_DEBUG
    fprintf (stderr, "page %d Datap checksum = 0x%x header key = %d\n", oldpage,
	     datap->chksum, header->key_page);
#endif
    assert (datap->first == oldpage);
    datap->first = newpage;
    if (header->key_page >= oldfirst && header->key_page <= oldlast) {
      newkp = newfirst + (header->key_page - oldfirst);
#ifdef _FFDB_DEBUG
      fprintf (stderr, "Data Page %d contains hash key entry %d that moves to %d\n", oldpage, header->key_page, newkp);
#endif
      header->key_page = newkp;
    }
    next = header->next;
    ffdb_put_page (hashp, kpagep, TYPE(kpagep), 1);
  }
  return 0;
}
static int _ffdb_update_key_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 , next ; void * kpagep ; pgno_t kp , newkp ; ffdb_data_header_t * header = 0 ; ffdb_datap_t * datap = 0 ; next = FIRST_DATA_POS ( pagep ) ; for ( i = 0 ; i < NUM_ENT ( pagep ) ; i ++ ) { header = BIG_DATA_HEADER ( pagep , next ) ; kpagep = ffdb_get_page ( hashp , header -> key_page , HASH_RAW_PAGE , 0 , & kp ) ; if ( ! kpagep ) { fprintf ( stderr , " \n " , header -> key_page , oldpage , i ) ; return -1 ; } datap = DATAP ( kpagep , header -> key_idx ) ; #ifdef _FFDB_DEBUG fprintf ( stderr , " \n " , oldpage , datap -> chksum , header -> key_page ) ; #endif assert ( datap -> first == oldpage ) ; datap -> first = newpage ; if ( header -> key_page >= oldfirst && header -> key_page <= oldlast ) { newkp = newfirst + ( header -> key_page - oldfirst ) ; #ifdef _FFDB_DEBUG fprintf ( stderr , " \n " , oldpage , header -> key_page , newkp ) ; #endif header -> key_page = newkp ; } next = header -> next ; ffdb_put_page ( hashp , kpagep , TYPE ( kpagep ) , 1 ) ; } return 0 ; }
Update all Key Pages (either primary or overflow) content when a data page
 is moved.
Update all Key Pages ( either primary or overflow ) content when a data page is moved .
/* get key page pointed back by this header */ /* change information on the key page */ /* Key page data item entry points to this new page */ /* Check whether the key page actually is going to be moved */ /* this works based on assumption data pages are moved first */ /* the data page entry points back to the new hash page that
     * is going to be moved to newkp
     */ /* Now my header has to be changed to point to new page as well */ /* Put back the page */