filehash/ffdb_page.c
static pgno_t
_ffdb_data_page (ffdb_htab_t* hashp, int new_page, int* reuse)
{
  pgno_t num = 0;
  pgno_t maxp = 0;
  /* get next level of overflow point */
  unsigned int level = hashp->hdr.ovfl_point + 1;

  *reuse = 0;
  if (hashp->curr_dpage == INVALID_PGNO) {
    /* The data page and overflow page starts at the following page number */
    BUCKET_TO_PAGE(hashp->hdr.high_mask, hashp->curr_dpage);
    hashp->curr_dpage++;

    BUCKET_TO_PAGE(hashp->hdr.max_bucket, maxp);
    fprintf (stderr, "Doubling at level %d max_bucket at %d data page starts at %d\n", hashp->hdr.ovfl_point, maxp, hashp->curr_dpage);

#ifdef _FFDB_DEBUG
    fprintf (stderr, "data page starts at %d for level %d\n",
	     hashp->curr_dpage, hashp->hdr.ovfl_point);
#endif
  }

  if (hashp->hdr.spares[level] == 0) 
    hashp->hdr.spares[level] = hashp->curr_dpage + 1;

  if (!new_page) 
    num = hashp->curr_dpage;
  else {
    num = _ffdb_reuse_free_ovflpage (hashp);
    if (num > 0) {
#ifdef _FFDB_DEBUG
      fprintf (stderr, "Reuse previously freed overflow page %d\n", num);
#endif
      *reuse = 1;
    }
    else {
      num = hashp->hdr.spares[level];
      hashp->hdr.spares[level]++;
    }
    hashp->curr_dpage = num;
  }
  return num;
}
/**
 * Find out what is next data page number given current page number
 * We need first to check freed overflow pages
 *
 * If there are somthing really wrong, the page released by this call
 * cannot be reclaimed. (We will live with the consequence)
 */
Find out what is next data page number given current page number
We need first to check freed overflow pages

If there are somthing really wrong, the page released by this call
cannot be reclaimed. (We will live with the consequence)
Find out what is next data page number given current page number We need first to check freed overflow pages If there are somthing really wrong the page released by this call cannot be reclaimed . ( We will live with the consequence )
static pgno_t
_ffdb_data_page (ffdb_htab_t* hashp, int new_page, int* reuse)
{
  pgno_t num = 0;
  pgno_t maxp = 0;
  unsigned int level = hashp->hdr.ovfl_point + 1;
  *reuse = 0;
  if (hashp->curr_dpage == INVALID_PGNO) {
    BUCKET_TO_PAGE(hashp->hdr.high_mask, hashp->curr_dpage);
    hashp->curr_dpage++;
    BUCKET_TO_PAGE(hashp->hdr.max_bucket, maxp);
    fprintf (stderr, "Doubling at level %d max_bucket at %d data page starts at %d\n", hashp->hdr.ovfl_point, maxp, hashp->curr_dpage);
#ifdef _FFDB_DEBUG
    fprintf (stderr, "data page starts at %d for level %d\n",
	     hashp->curr_dpage, hashp->hdr.ovfl_point);
#endif
  }
  if (hashp->hdr.spares[level] == 0) 
    hashp->hdr.spares[level] = hashp->curr_dpage + 1;
  if (!new_page) 
    num = hashp->curr_dpage;
  else {
    num = _ffdb_reuse_free_ovflpage (hashp);
    if (num > 0) {
#ifdef _FFDB_DEBUG
      fprintf (stderr, "Reuse previously freed overflow page %d\n", num);
#endif
      *reuse = 1;
    }
    else {
      num = hashp->hdr.spares[level];
      hashp->hdr.spares[level]++;
    }
    hashp->curr_dpage = num;
  }
  return num;
}
static pgno_t _ffdb_data_page ( ffdb_htab_t * hashp , int new_page , int * reuse ) { pgno_t num = 0 ; pgno_t maxp = 0 ; unsigned int level = hashp -> hdr . ovfl_point + 1 ; * reuse = 0 ; if ( hashp -> curr_dpage == INVALID_PGNO ) { BUCKET_TO_PAGE ( hashp -> hdr . high_mask , hashp -> curr_dpage ) ; hashp -> curr_dpage ++ ; BUCKET_TO_PAGE ( hashp -> hdr . max_bucket , maxp ) ; fprintf ( stderr , " \n " , hashp -> hdr . ovfl_point , maxp , hashp -> curr_dpage ) ; #ifdef _FFDB_DEBUG fprintf ( stderr , " \n " , hashp -> curr_dpage , hashp -> hdr . ovfl_point ) ; #endif } if ( hashp -> hdr . spares [ level ] == 0 ) hashp -> hdr . spares [ level ] = hashp -> curr_dpage + 1 ; if ( ! new_page ) num = hashp -> curr_dpage ; else { num = _ffdb_reuse_free_ovflpage ( hashp ) ; if ( num > 0 ) { #ifdef _FFDB_DEBUG fprintf ( stderr , " \n " , num ) ; #endif * reuse = 1 ; } else { num = hashp -> hdr . spares [ level ] ; hashp -> hdr . spares [ level ] ++ ; } hashp -> curr_dpage = num ; } return num ; }
Find out what is next data page number given current page number
 We need first to check freed overflow pages
Find out what is next data page number given current page number We need first to check freed overflow pages
/* get next level of overflow point */ /* The data page and overflow page starts at the following page number */