MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
genhash core

Classes

struct  hash_ops

Typedefs

typedef struct _genhash genhash_t

Enumerations

enum  update_type { MODIFICATION, NEW }

Functions

MEMCACHED_PUBLIC_API genhash_tgenhash_init (int est, struct hash_ops ops)
MEMCACHED_PUBLIC_API void genhash_free (genhash_t *h)
MEMCACHED_PUBLIC_API void genhash_store (genhash_t *h, const void *k, size_t klen, const void *v, size_t vlen)
MEMCACHED_PUBLIC_API void * genhash_find (genhash_t *h, const void *k, size_t klen)
MEMCACHED_PUBLIC_API int genhash_delete (genhash_t *h, const void *k, size_t klen)
MEMCACHED_PUBLIC_API int genhash_delete_all (genhash_t *h, const void *k, size_t klen)
MEMCACHED_PUBLIC_API enum
update_type 
genhash_update (genhash_t *h, const void *k, size_t klen, const void *v, size_t vlen)
MEMCACHED_PUBLIC_API enum
update_type 
genhash_fun_update (genhash_t *h, const void *key, size_t klen, void *(*upd)(const void *k, const void *oldv, size_t *ns, void *a), void(*fr)(void *), void *arg, const void *def, size_t deflen)
MEMCACHED_PUBLIC_API void genhash_iter (genhash_t *h, void(*iterfunc)(const void *key, size_t nkey, const void *val, size_t nval, void *arg), void *arg)
MEMCACHED_PUBLIC_API void genhash_iter_key (genhash_t *h, const void *key, size_t nkey, void(*iterfunc)(const void *key, size_t inkey, const void *val, size_t inval, void *arg), void *arg)
MEMCACHED_PUBLIC_API int genhash_size (genhash_t *h)
MEMCACHED_PUBLIC_API int genhash_clear (genhash_t *h)
MEMCACHED_PUBLIC_API int genhash_size_for_key (genhash_t *h, const void *k, size_t nkey)
MEMCACHED_PUBLIC_API int genhash_string_hash (const void *k, size_t nkey)

Detailed Description

Typedef Documentation

typedef struct _genhash genhash_t

The hash table structure.

Definition at line 70 of file genhash.h.

Enumeration Type Documentation

Type of update performed by an update function.

Enumerator:
MODIFICATION 

This update is modifying an existing entry

NEW 

This update is creating a new entry

Definition at line 75 of file genhash.h.

Function Documentation

MEMCACHED_PUBLIC_API int genhash_clear ( genhash_t h)

Remove all items from a genhash.

Parameters
hthe genhash
Returns
the number of items removed

Definition at line 276 of file genhash.c.

Here is the caller graph for this function:

MEMCACHED_PUBLIC_API int genhash_delete ( genhash_t h,
const void *  k,
size_t  klen 
)

Delete the most recent value stored for a key.

Parameters
hthe genhash
kthe key
Returns
the number of items deleted

Definition at line 214 of file genhash.c.

Here is the caller graph for this function:

MEMCACHED_PUBLIC_API int genhash_delete_all ( genhash_t h,
const void *  k,
size_t  klen 
)

Delete all mappings of a given key.

Parameters
hthe genhash
kthe key
Returns
the number of items deleted

Definition at line 249 of file genhash.c.

Here is the call graph for this function:

MEMCACHED_PUBLIC_API void* genhash_find ( genhash_t h,
const void *  k,
size_t  klen 
)

Get the most recent value stored for the given key.

Parameters
hthe genhash
kthe key
Returns
the value, or NULL if one cannot be found

Definition at line 141 of file genhash.c.

MEMCACHED_PUBLIC_API void genhash_free ( genhash_t h)

Free a gen hash.

Parameters
hthe genhash to free (may be NULL)

Definition at line 91 of file genhash.c.

Here is the call graph for this function:

MEMCACHED_PUBLIC_API enum update_type genhash_fun_update ( genhash_t h,
const void *  key,
size_t  klen,
void *(*)(const void *k, const void *oldv, size_t *ns, void *a)  upd,
void(*)(void *)  fr,
void *  arg,
const void *  def,
size_t  deflen 
)

Create or update an item in-place with a function.

Parameters
hhashtable
keythe key of the item
updfunction that will be called with the key and current value. Should return the new value.
frfunction to free the return value returned by the update function
defdefault value
Returns
an indicator of whether this created a new item or updated an existing one
MEMCACHED_PUBLIC_API genhash_t* genhash_init ( int  est,
struct hash_ops  ops 
)

Create a new generic hashtable.

Parameters
estthe estimated number of items to store (must be > 0)
opsthe key and value operations
Returns
the new genhash_t or NULL if one cannot be created

Definition at line 67 of file genhash.c.

MEMCACHED_PUBLIC_API void genhash_iter ( genhash_t h,
void(*)(const void *key, size_t nkey, const void *val, size_t nval, void *arg)  iterfunc,
void *  arg 
)

Iterate all keys and values in a hash table.

Parameters
hthe genhash
iterfunca function that will be called once for every k/v pair
argan argument to be passed to the iterfunc on each iteration

Definition at line 259 of file genhash.c.

Here is the caller graph for this function:

MEMCACHED_PUBLIC_API void genhash_iter_key ( genhash_t h,
const void *  key,
size_t  nkey,
void(*)(const void *key, size_t inkey, const void *val, size_t inval, void *arg)  iterfunc,
void *  arg 
)

Iterate all values for a given key in a hash table.

Parameters
hthe genhash
keythe key to iterate
iterfunca function that will be called once for every k/v pair
argan argument to be passed to the iterfunc on each iteration

Here is the caller graph for this function:

MEMCACHED_PUBLIC_API int genhash_size ( genhash_t h)

Get the total number of entries in this hash table.

Parameters
hthe genhash
Returns
the number of entries in the hash table

Definition at line 302 of file genhash.c.

Here is the call graph for this function:

MEMCACHED_PUBLIC_API int genhash_size_for_key ( genhash_t h,
const void *  k,
size_t  nkey 
)

Get the total number of entries in this hash table that map to the given key.

Parameters
hthe genhash
ka key
Returns
the number of entries keyed with the given key

Definition at line 310 of file genhash.c.

Here is the call graph for this function:

MEMCACHED_PUBLIC_API void genhash_store ( genhash_t h,
const void *  k,
size_t  klen,
const void *  v,
size_t  vlen 
)

Store an item.

Parameters
hthe genhash
kthe key
vthe value

Definition at line 100 of file genhash.c.

Here is the caller graph for this function:

MEMCACHED_PUBLIC_API int genhash_string_hash ( const void *  k,
size_t  nkey 
)

Convenient hash function for strings.

Parameters
ka null-terminated string key.
Returns
a hash value for this string.

Definition at line 340 of file genhash.c.

MEMCACHED_PUBLIC_API enum update_type genhash_update ( genhash_t h,
const void *  k,
size_t  klen,
const void *  v,
size_t  vlen 
)

Create or update an item in-place.

Parameters
hthe genhash
kthe key
vthe new value to store for this key
Returns
an indicator of whether this created a new item or updated an existing one

Definition at line 155 of file genhash.c.

Here is the call graph for this function: