filehash/ffdb_hash.c
static int
_ffdb_hash_get (const FFDB_DB* dbp, const FFDB_DBT* key,
		FFDB_DBT* data, unsigned int flag)
{
  ffdb_htab_t* hashp;
  ffdb_hent_t item;
  unsigned int bucket;
  int status;

#ifdef _FFDB_DEBUG
  fprintf (stderr, "ffdb_hash_get key %s\n", (char *)key->data);
#endif

  hashp = (ffdb_htab_t *)dbp->internal;

#ifdef _FFDB_STATISTICS
  FFDB_LOCK (hashp->lock);
  hash_accesses++;
  FFDB_UNLOCK (hashp->lock);
#endif

  /* initialize item */
  memset (&item, 0, sizeof (ffdb_hent_t));
  /* Calculate the hash item size */
  item.seek_size = PAIRSIZE(key, data);

  /* calculate hash value for this key */
  bucket = _ffdb_call_hash (hashp, key->data, key->size);
  item.bucket = bucket;
  
#ifdef _FFDB_DEBUG
  fprintf (stderr, "Hash get Key %s hash bucket = %d\n", (char *)key->data, bucket);
#endif

  /* Now I need find a page on which this key may reside */
  status = ffdb_find_item (hashp, (FFDB_DBT *)key, 0, &item);
  if (status != 0){ /* Something is really wrong */
    return -1;
  }

  if (item.status == ITEM_NO_MORE) {
    ffdb_release_item (hashp, &item);
    return FFDB_NOT_FOUND;
  }

  /* Now the item is found, item contains page information */
  /* page os released after the call */
  status = ffdb_get_item (hashp, key, data, &item, 1);

  return status;
}
/**
 * Get key from the database
 * returns 0: on success
 * returns 1: where the key not found
 * returns -1: there is an error
 * currently there is no flag is used
 */
Get key from the database
returns 0: on success
returns 1: where the key not found
returns -1: there is an error
currently there is no flag is used
Get key from the database returns 0 : on success returns 1 : where the key not found returns - 1 : there is an error currently there is no flag is used
static int
_ffdb_hash_get (const FFDB_DB* dbp, const FFDB_DBT* key,
		FFDB_DBT* data, unsigned int flag)
{
  ffdb_htab_t* hashp;
  ffdb_hent_t item;
  unsigned int bucket;
  int status;
#ifdef _FFDB_DEBUG
  fprintf (stderr, "ffdb_hash_get key %s\n", (char *)key->data);
#endif
  hashp = (ffdb_htab_t *)dbp->internal;
#ifdef _FFDB_STATISTICS
  FFDB_LOCK (hashp->lock);
  hash_accesses++;
  FFDB_UNLOCK (hashp->lock);
#endif
  memset (&item, 0, sizeof (ffdb_hent_t));
  item.seek_size = PAIRSIZE(key, data);
  bucket = _ffdb_call_hash (hashp, key->data, key->size);
  item.bucket = bucket;
#ifdef _FFDB_DEBUG
  fprintf (stderr, "Hash get Key %s hash bucket = %d\n", (char *)key->data, bucket);
#endif
  status = ffdb_find_item (hashp, (FFDB_DBT *)key, 0, &item);
  if (status != 0){ 
    return -1;
  }
  if (item.status == ITEM_NO_MORE) {
    ffdb_release_item (hashp, &item);
    return FFDB_NOT_FOUND;
  }
  status = ffdb_get_item (hashp, key, data, &item, 1);
  return status;
}
static int _ffdb_hash_get ( const FFDB_DB * dbp , const FFDB_DBT * key , FFDB_DBT * data , unsigned int flag ) { ffdb_htab_t * hashp ; ffdb_hent_t item ; unsigned int bucket ; int status ; #ifdef _FFDB_DEBUG fprintf ( stderr , " \n " , ( char * ) key -> data ) ; #endif hashp = ( ffdb_htab_t * ) dbp -> internal ; #ifdef _FFDB_STATISTICS FFDB_LOCK ( hashp -> lock ) ; hash_accesses ++ ; FFDB_UNLOCK ( hashp -> lock ) ; #endif memset ( & item , 0 , sizeof ( ffdb_hent_t ) ) ; item . seek_size = PAIRSIZE ( key , data ) ; bucket = _ffdb_call_hash ( hashp , key -> data , key -> size ) ; item . bucket = bucket ; #ifdef _FFDB_DEBUG fprintf ( stderr , " \n " , ( char * ) key -> data , bucket ) ; #endif status = ffdb_find_item ( hashp , ( FFDB_DBT * ) key , 0 , & item ) ; if ( status != 0 ) { return -1 ; } if ( item . status == ITEM_NO_MORE ) { ffdb_release_item ( hashp , & item ) ; return FFDB_NOT_FOUND ; } status = ffdb_get_item ( hashp , key , data , & item , 1 ) ; return status ; }
Get key from the database
 returns 0: on success
 returns 1: where the key not found
 returns -1: there is an error
 currently there is no flag is used
Get key from the database returns 0 : on success returns 1 : where the key not found returns - 1 : there is an error currently there is no flag is used
/* initialize item */ /* Calculate the hash item size */ /* calculate hash value for this key */ /* Now I need find a page on which this key may reside */ /* Something is really wrong */ /* Now the item is found, item contains page information */ /* page os released after the call */