filehash/ffdb_page.c
void
ffdb_pgin_routine (void* arg, pgno_t pgno, void* page)
{
  ffdb_htab_t* hashp;
  unsigned int chksum = 0;

  hashp = (ffdb_htab_t *)arg;

  /* calculate checksum before byte swapped */
  chksum = _ffdb_page_checksum (hashp, page);

#if 0
  /* First swap the header to disk */
  if (hashp->mborder == LITTLE_ENDIAN) 
    _ffdb_swap_page_metainfo_in (page);
#endif

#if 1
  if (hashp->hdr.lorder != hashp->mborder)
    _ffdb_swap_page_metainfo_in (page);  
#endif

#ifdef _FFDB_DEBUG
  fprintf (stderr, "Read page %d in at memory %p\n", pgno, page);
  fprintf (stderr, "Page Information: PGNO %d PREV PGNO %d NEXT PGNO %d PAGE SIGN 0x%x\n",
	   CURR_PGNO(page), PREV_PGNO(page),NEXT_PGNO(page), PAGE_SIGN(page));
  fprintf (stderr, "Page TYPE 0x%x OFFSET %d\n", TYPE(page), OFFSET(page));
#endif  
  
  if (PAGE_SIGN(page) != FFDB_PAGE_MAGIC) {
    /* This is a unintialized page */
    _ffdb_init_page (hashp, page, pgno, HASH_DELETED_PAGE);
  }
  else {
    if (chksum != CHKSUM(page)) {
      /* The check sum chould 0 because this page is empty page */
      fprintf (stderr, "Reading page %d checksum mismatch 0x%x (new) != 0x%x (on disk)\n", pgno, chksum, CHKSUM(page));
      exit (123);
    }
  }
}
/**
 * This is the routine called right after a page is read
 */
This is the routine called right after a page is read
This is the routine called right after a page is read
void
ffdb_pgin_routine (void* arg, pgno_t pgno, void* page)
{
  ffdb_htab_t* hashp;
  unsigned int chksum = 0;
  hashp = (ffdb_htab_t *)arg;
  chksum = _ffdb_page_checksum (hashp, page);
#if 0
  if (hashp->mborder == LITTLE_ENDIAN) 
    _ffdb_swap_page_metainfo_in (page);
#endif
#if 1
  if (hashp->hdr.lorder != hashp->mborder)
    _ffdb_swap_page_metainfo_in (page);  
#endif
#ifdef _FFDB_DEBUG
  fprintf (stderr, "Read page %d in at memory %p\n", pgno, page);
  fprintf (stderr, "Page Information: PGNO %d PREV PGNO %d NEXT PGNO %d PAGE SIGN 0x%x\n",
	   CURR_PGNO(page), PREV_PGNO(page),NEXT_PGNO(page), PAGE_SIGN(page));
  fprintf (stderr, "Page TYPE 0x%x OFFSET %d\n", TYPE(page), OFFSET(page));
#endif  
  if (PAGE_SIGN(page) != FFDB_PAGE_MAGIC) {
    _ffdb_init_page (hashp, page, pgno, HASH_DELETED_PAGE);
  }
  else {
    if (chksum != CHKSUM(page)) {
      fprintf (stderr, "Reading page %d checksum mismatch 0x%x (new) != 0x%x (on disk)\n", pgno, chksum, CHKSUM(page));
      exit (123);
    }
  }
}
void ffdb_pgin_routine ( void * arg , pgno_t pgno , void * page ) { ffdb_htab_t * hashp ; unsigned int chksum = 0 ; hashp = ( ffdb_htab_t * ) arg ; chksum = _ffdb_page_checksum ( hashp , page ) ; #if 0 if ( hashp -> mborder == LITTLE_ENDIAN ) _ffdb_swap_page_metainfo_in ( page ) ; #endif #if 1 if ( hashp -> hdr . lorder != hashp -> mborder ) _ffdb_swap_page_metainfo_in ( page ) ; #endif #ifdef _FFDB_DEBUG fprintf ( stderr , " \n " , pgno , page ) ; fprintf ( stderr , " \n " , CURR_PGNO ( page ) , PREV_PGNO ( page ) , NEXT_PGNO ( page ) , PAGE_SIGN ( page ) ) ; fprintf ( stderr , " \n " , TYPE ( page ) , OFFSET ( page ) ) ; #endif if ( PAGE_SIGN ( page ) != FFDB_PAGE_MAGIC ) { _ffdb_init_page ( hashp , page , pgno , HASH_DELETED_PAGE ) ; } else { if ( chksum != CHKSUM ( page ) ) { fprintf ( stderr , " \n " , pgno , chksum , CHKSUM ( page ) ) ; exit ( 123 ) ; } } }
This is the routine called right after a page is read
This is the routine called right after a page is read
/* calculate checksum before byte swapped */ /* First swap the header to disk */ /* This is a unintialized page */ /* The check sum chould 0 because this page is empty page */