filehash/ffdb_page.c
int ffdb_add_ovflpage (ffdb_htab_t* hashp,
		       FFDB_DBT* key, const FFDB_DBT* val,
		       ffdb_hent_t* item)
{
  pgno_t ovflpage, tp;
  void*  opagep;
  int    status, reuse;

  /* Find out next overflow page number */
  reuse = 0;
  ovflpage = _ffdb_ovfl_page (hashp, &reuse);
#ifdef _FFDB_DEBUG
  fprintf (stderr, "Allocate an overflow page %d for primary page %d at level %d\n",
	   ovflpage, item->pgno, hashp->hdr.ovfl_point);
#endif
  
  /* Get this page and this page is initialized */
  opagep = ffdb_get_page (hashp, ovflpage, HASH_OVFL_PAGE, FFDB_CREATE, &tp);
  if (!opagep) {
    fprintf (stderr, "Cannot get an over flow page %d for primary page %d\n",
	     ovflpage, item->pgno);
    /* Now I do not need this page */
    ffdb_put_page (hashp, item->pagep, HASH_BUCKET_PAGE, 0);
    return -1; 
  }
  if (reuse)
    _ffdb_init_page (hashp, opagep, ovflpage, HASH_OVFL_PAGE);

#ifdef _FFDB_STATISTICS
  hash_overflows++;
#endif
  
  /* Set up page link */
  NEXT_PGNO(item->pagep) = ovflpage;
  PREV_PGNO(opagep) = item->pgno;

  /* Add this pair to the new page */
  status = _ffdb_add_item_on_page (hashp, opagep, ovflpage,
				   key, val, item->data_chksum);

  if (status != 0) {
    ffdb_put_page (hashp, opagep, HASH_OVFL_PAGE, 0);
    ffdb_put_page (hashp, item->pagep, HASH_BUCKET_PAGE, 0);
  }
  else {
    ffdb_put_page (hashp, opagep, HASH_OVFL_PAGE, 1);
    ffdb_put_page (hashp, item->pagep, HASH_BUCKET_PAGE, 1);
  }
  return 0;
}
/**
 * Add a pair to an overflow page
 */
Add a pair to an overflow page
Add a pair to an overflow page
int ffdb_add_ovflpage (ffdb_htab_t* hashp,
		       FFDB_DBT* key, const FFDB_DBT* val,
		       ffdb_hent_t* item)
{
  pgno_t ovflpage, tp;
  void*  opagep;
  int    status, reuse;
  reuse = 0;
  ovflpage = _ffdb_ovfl_page (hashp, &reuse);
#ifdef _FFDB_DEBUG
  fprintf (stderr, "Allocate an overflow page %d for primary page %d at level %d\n",
	   ovflpage, item->pgno, hashp->hdr.ovfl_point);
#endif
  opagep = ffdb_get_page (hashp, ovflpage, HASH_OVFL_PAGE, FFDB_CREATE, &tp);
  if (!opagep) {
    fprintf (stderr, "Cannot get an over flow page %d for primary page %d\n",
	     ovflpage, item->pgno);
    ffdb_put_page (hashp, item->pagep, HASH_BUCKET_PAGE, 0);
    return -1; 
  }
  if (reuse)
    _ffdb_init_page (hashp, opagep, ovflpage, HASH_OVFL_PAGE);
#ifdef _FFDB_STATISTICS
  hash_overflows++;
#endif
  NEXT_PGNO(item->pagep) = ovflpage;
  PREV_PGNO(opagep) = item->pgno;
  status = _ffdb_add_item_on_page (hashp, opagep, ovflpage,
				   key, val, item->data_chksum);
  if (status != 0) {
    ffdb_put_page (hashp, opagep, HASH_OVFL_PAGE, 0);
    ffdb_put_page (hashp, item->pagep, HASH_BUCKET_PAGE, 0);
  }
  else {
    ffdb_put_page (hashp, opagep, HASH_OVFL_PAGE, 1);
    ffdb_put_page (hashp, item->pagep, HASH_BUCKET_PAGE, 1);
  }
  return 0;
}
int ffdb_add_ovflpage ( ffdb_htab_t * hashp , FFDB_DBT * key , const FFDB_DBT * val , ffdb_hent_t * item ) { pgno_t ovflpage , tp ; void * opagep ; int status , reuse ; reuse = 0 ; ovflpage = _ffdb_ovfl_page ( hashp , & reuse ) ; #ifdef _FFDB_DEBUG fprintf ( stderr , " \n " , ovflpage , item -> pgno , hashp -> hdr . ovfl_point ) ; #endif opagep = ffdb_get_page ( hashp , ovflpage , HASH_OVFL_PAGE , FFDB_CREATE , & tp ) ; if ( ! opagep ) { fprintf ( stderr , " \n " , ovflpage , item -> pgno ) ; ffdb_put_page ( hashp , item -> pagep , HASH_BUCKET_PAGE , 0 ) ; return -1 ; } if ( reuse ) _ffdb_init_page ( hashp , opagep , ovflpage , HASH_OVFL_PAGE ) ; #ifdef _FFDB_STATISTICS hash_overflows ++ ; #endif NEXT_PGNO ( item -> pagep ) = ovflpage ; PREV_PGNO ( opagep ) = item -> pgno ; status = _ffdb_add_item_on_page ( hashp , opagep , ovflpage , key , val , item -> data_chksum ) ; if ( status != 0 ) { ffdb_put_page ( hashp , opagep , HASH_OVFL_PAGE , 0 ) ; ffdb_put_page ( hashp , item -> pagep , HASH_BUCKET_PAGE , 0 ) ; } else { ffdb_put_page ( hashp , opagep , HASH_OVFL_PAGE , 1 ) ; ffdb_put_page ( hashp , item -> pagep , HASH_BUCKET_PAGE , 1 ) ; } return 0 ; }
Add a pair to an overflow page
Add a pair to an overflow page
/* Find out next overflow page number */ /* Get this page and this page is initialized */ /* Now I do not need this page */ /* Set up page link */ /* Add this pair to the new page */