filehash/ffdb_page.c
static int
_ffdb_write_key_datap_to_page (ffdb_htab_t* hashp, FFDB_DBT* key, 
			       ffdb_datap_t *datap,
			       void* pagep, pgno_t page)
{
  unsigned int n, off, soff;
  int status;
  
  n = NUM_ENT(pagep);
  /* Find place to put the key */
  off = OFFSET(pagep) - key->size + 1;
  memmove (pagep + off, key->data, key->size);

  /* Set Key Offset Value */
  KEY_OFF(pagep, n) = off;
  KEY_LEN(pagep, n) = key->size;

  /*  Find place to put data pointer value */
  off -= sizeof(ffdb_datap_t);
  soff = off;
  /* I have to align this pointer to 4 byte boundary */
  ALIGN_DATAP_OFFSET_VAL(off);

  /* I will fill 0 to the gap of data and key */
  /* ------off---soff-----000key */
  if (off != soff) 
    memset (pagep + off + sizeof(ffdb_datap_t), 0, soff - off);

  /* write data pointer value */
  memmove (pagep + off, datap, sizeof(ffdb_datap_t));
  DATAP_OFF(pagep, n) = off;

  /* Need update data item information about key page and key index */
  /* The data items are on data pages, this could be slow           */
  status = _ffdb_update_data_info (hashp, datap, page, n);

  /* Update this page information */
  NUM_ENT(pagep) = n + 1;
  OFFSET(pagep) = off - 1;

  return status;
}
/**
 * Just copy content of key and its associated data pointer to a page
 * at the right location
 * We already checked this page can fit this key and data pointer
 */
Just copy content of key and its associated data pointer to a page
at the right location
We already checked this page can fit this key and data pointer
Just copy content of key and its associated data pointer to a page at the right location We already checked this page can fit this key and data pointer
static int
_ffdb_write_key_datap_to_page (ffdb_htab_t* hashp, FFDB_DBT* key, 
			       ffdb_datap_t *datap,
			       void* pagep, pgno_t page)
{
  unsigned int n, off, soff;
  int status;
  n = NUM_ENT(pagep);
  off = OFFSET(pagep) - key->size + 1;
  memmove (pagep + off, key->data, key->size);
  KEY_OFF(pagep, n) = off;
  KEY_LEN(pagep, n) = key->size;
  off -= sizeof(ffdb_datap_t);
  soff = off;
  ALIGN_DATAP_OFFSET_VAL(off);
  if (off != soff) 
    memset (pagep + off + sizeof(ffdb_datap_t), 0, soff - off);
  memmove (pagep + off, datap, sizeof(ffdb_datap_t));
  DATAP_OFF(pagep, n) = off;
  status = _ffdb_update_data_info (hashp, datap, page, n);
  NUM_ENT(pagep) = n + 1;
  OFFSET(pagep) = off - 1;
  return status;
}
static int _ffdb_write_key_datap_to_page ( ffdb_htab_t * hashp , FFDB_DBT * key , ffdb_datap_t * datap , void * pagep , pgno_t page ) { unsigned int n , off , soff ; int status ; n = NUM_ENT ( pagep ) ; off = OFFSET ( pagep ) - key -> size + 1 ; memmove ( pagep + off , key -> data , key -> size ) ; KEY_OFF ( pagep , n ) = off ; KEY_LEN ( pagep , n ) = key -> size ; off -= sizeof ( ffdb_datap_t ) ; soff = off ; ALIGN_DATAP_OFFSET_VAL ( off ) ; if ( off != soff ) memset ( pagep + off + sizeof ( ffdb_datap_t ) , 0 , soff - off ) ; memmove ( pagep + off , datap , sizeof ( ffdb_datap_t ) ) ; DATAP_OFF ( pagep , n ) = off ; status = _ffdb_update_data_info ( hashp , datap , page , n ) ; NUM_ENT ( pagep ) = n + 1 ; OFFSET ( pagep ) = off - 1 ; return status ; }
Just copy content of key and its associated data pointer to a page
 at the right location
 We already checked this page can fit this key and data pointer
Just copy content of key and its associated data pointer to a page at the right location We already checked this page can fit this key and data pointer
/* Find place to put the key */ /* Set Key Offset Value */ /*  Find place to put data pointer value */ /* I have to align this pointer to 4 byte boundary */ /* I will fill 0 to the gap of data and key */ /* ------off---soff-----000key */ /* write data pointer value */ /* Need update data item information about key page and key index */ /* The data items are on data pages, this could be slow           */ /* Update this page information */