OpenMPI 0.1.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

Data Structures | Typedefs | Functions
opal_hash_table.h File Reference

A hash table that may be indexed with either fixed length (e.g. More...

`#include "opal_config.h"`
`#include "opal/class/opal_list.h"`

Go to the source code of this file.

## Data Structures
struct | opal_hash_table_t

## Typedefs
typedef struct opal_hash_table_t | opal_hash_table_t

## Functions
BEGIN_C_DECLS OPAL_DECLSPEC | OBJ_CLASS_DECLARATION (opal_hash_table_t)
OPAL_DECLSPEC int | opal_hash_table_init (opal_hash_table_t *ht, size_t table_size)
| Initializes the table size, must be called before using the table. More...
static size_t | opal_hash_table_get_size (opal_hash_table_t *ht)
| Returns the number of elements currently stored in the table. More...
OPAL_DECLSPEC int | opal_hash_table_remove_all (opal_hash_table_t *ht)
| Remove all elements from the table. More...
OPAL_DECLSPEC int | opal_hash_table_get_value_uint32 (opal_hash_table_t *table, uint32_t key, void **ptr)
| Retrieve value via uint32_t key. More...
OPAL_DECLSPEC int | opal_hash_table_set_value_uint32 (opal_hash_table_t *table, uint32_t key, void *value)
| Set value based on uint32_t key. More...
OPAL_DECLSPEC int | opal_hash_table_remove_value_uint32 (opal_hash_table_t *table, uint32_t key)
| Remove value based on uint32_t key. More...
OPAL_DECLSPEC int | opal_hash_table_get_value_uint64 (opal_hash_table_t *table, uint64_t key, void **ptr)
| Retrieve value via uint64_t key. More...
OPAL_DECLSPEC int | opal_hash_table_set_value_uint64 (opal_hash_table_t *table, uint64_t key, void *value)
| Set value based on uint64_t key. More...
OPAL_DECLSPEC int | opal_hash_table_remove_value_uint64 (opal_hash_table_t *table, uint64_t key)
| Remove value based on uint64_t key. More...
OPAL_DECLSPEC int | opal_hash_table_get_value_ptr (opal_hash_table_t *table, const void *key, size_t keylen, void **ptr)
| Retrieve value via arbitrary length binary key. More...
OPAL_DECLSPEC int | opal_hash_table_set_value_ptr (opal_hash_table_t *table, const void *key, size_t keylen, void *value)
| Set value based on arbitrary length binary key. More...
OPAL_DECLSPEC int | opal_hash_table_remove_value_ptr (opal_hash_table_t *table, const void *key, size_t keylen)
| Remove value based on arbitrary length binary key. More...
OPAL_DECLSPEC int | opal_hash_table_get_first_key_uint32 (opal_hash_table_t *table, uint32_t *key, void **value, void **node)
| The following functions are only for allowing iterating through the hash table. More...
OPAL_DECLSPEC int | opal_hash_table_get_next_key_uint32 (opal_hash_table_t *table, uint32_t *key, void **value, void *in_node, void **out_node)
| Get the next 32 bit key from the hash table, knowing the current key. More...
OPAL_DECLSPEC int | opal_hash_table_get_first_key_uint64 (opal_hash_table_t *table, uint64_t *key, void **value, void **node)
| Get the first 64 key from the hash table, which can be used later to get the next key. More...
OPAL_DECLSPEC int | opal_hash_table_get_next_key_uint64 (opal_hash_table_t *table, uint64_t *key, void **value, void *in_node, void **out_node)
| Get the next 64 bit key from the hash table, knowing the current key. More...

## Detailed Description

A hash table that may be indexed with either fixed length (e.g.

uint32_t/uint64_t) or arbitrary size binary key values. However, only one key type may be used in a given table concurrently.

## Function Documentation

OPAL_DECLSPEC int opal_hash_table_get_first_key_uint32 | ( | opal_hash_table_t * | table,
|  | uint32_t * | key,
|  | void ** | value,
|  | void ** | node
| ) |  |

The following functions are only for allowing iterating through the hash table.

The calls return along with a key, a pointer to the hash node with the current key, so that subsequent calls do not have to traverse all over again to the key (although it may just be a simple thing - to go to the array element and then traverse through the individual list). But lets take out this inefficiency too. This is similar to having an STL iterator in functionality Get the first 32 bit key from the hash table, which can be used later to get the next key

Parameters

  table | The hash table pointer (IN)
  key | The first key (OUT)
  value | The value corresponding to this key (OUT)
  node | The pointer to the hash table internal node which stores the key-value pair (this is required for subsequent calls to get_next_key) (OUT)

Returns
  OPAL error code

References opal_hash_table_t::ht_table, opal_hash_table_t::ht_table_size, opal_list_get_first(), and opal_list_get_size().

Referenced by ompi_attr_copy_all(), and ompi_attr_delete_all().

OPAL_DECLSPEC int opal_hash_table_get_first_key_uint64 | ( | opal_hash_table_t * | table,
|  | uint64_t * | key,
|  | void ** | value,
|  | void ** | node
| ) |  |

Get the first 64 key from the hash table, which can be used later to get the next key.

Parameters

  table | The hash table pointer (IN)
  key | The first key (OUT)
  value | The value corresponding to this key (OUT)
  node | The pointer to the hash table internal node which stores the key-value pair (this is required for subsequent calls to get_next_key) (OUT)

Returns
  OPAL error code

References opal_hash_table_t::ht_table, opal_hash_table_t::ht_table_size, opal_list_get_first(), and opal_list_get_size().

OPAL_DECLSPEC int opal_hash_table_get_next_key_uint32 | ( | opal_hash_table_t * | table,
|  | uint32_t * | key,
|  | void ** | value,
|  | void * | in_node,
|  | void ** | out_node
| ) |  |

Get the next 32 bit key from the hash table, knowing the current key.

Parameters

  table | The hash table pointer (IN)
  key | The key (OUT)
  value | The value corresponding to this key (OUT)
  in_node | The node pointer from previous call to either get_first or get_next (IN)
  out_node | The pointer to the hash table internal node which stores the key-value pair (this is required for subsequent calls to get_next_key) (OUT)

Returns
  OPAL error code

References opal_hash_table_t::ht_table, opal_list_get_end(), opal_list_get_first(), opal_list_get_next, and opal_list_get_size().

Referenced by ompi_attr_copy_all(), and ompi_attr_delete_all().

OPAL_DECLSPEC int opal_hash_table_get_next_key_uint64 | ( | opal_hash_table_t * | table,
|  | uint64_t * | key,
|  | void ** | value,
|  | void * | in_node,
|  | void ** | out_node
| ) |  |

Get the next 64 bit key from the hash table, knowing the current key.

Parameters

  table | The hash table pointer (IN)
  key | The key (OUT)
  value | The value corresponding to this key (OUT)
  in_node | The node pointer from previous call to either get_first or get_next (IN)
  out_node | The pointer to the hash table internal node which stores the key-value pair (this is required for subsequent calls to get_next_key) (OUT)

Returns
  OPAL error code

References opal_hash_table_t::ht_table, opal_list_get_end(), opal_list_get_first(), opal_list_get_next, and opal_list_get_size().

static size_t opal_hash_table_get_size | ( | opal_hash_table_t * | ht | ) |
| inline static

Returns the number of elements currently stored in the table.

Parameters

  table | The input hash table (IN).

Returns
  The number of elements in the table.

References opal_hash_table_t::ht_size.

OPAL_DECLSPEC int opal_hash_table_get_value_ptr | ( | opal_hash_table_t * | table,
|  | const void * | key,
|  | size_t | keylen,
|  | void ** | ptr
| ) |  |

Retrieve value via arbitrary length binary key.

Parameters

  table | The input hash table (IN).
  key | The input key (IN).
  ptr | The value associated with the key

Returns
  integer return code:
  - OPAL_SUCCESS if key was found
  - OPAL_ERR_NOT_FOUND if key was not found
  - OPAL_ERROR other error

References opal_hash_table_t::ht_table, opal_hash_table_t::ht_table_size, opal_list_get_end(), opal_list_get_first(), opal_list_get_next, and opal_output().

OPAL_DECLSPEC int opal_hash_table_get_value_uint32 | ( | opal_hash_table_t * | table,
|  | uint32_t | key,
|  | void ** | ptr
| ) |  |

Retrieve value via uint32_t key.

Parameters

  table | The input hash table (IN).
  key | The input key (IN).
  ptr | The value associated with the key

Returns
  integer return code:
  - OPAL_SUCCESS if key was found
  - OPAL_ERR_NOT_FOUND if key was not found
  - OPAL_ERROR other error

References opal_hash_table_t::ht_table, opal_hash_table_t::ht_table_size, opal_list_get_end(), opal_list_get_first(), opal_list_get_next, and opal_output().

Referenced by ompi_attr_copy_all(), ompi_attr_delete(), and ompi_attr_free_keyval().

OPAL_DECLSPEC int opal_hash_table_get_value_uint64 | ( | opal_hash_table_t * | table,
|  | uint64_t | key,
|  | void ** | ptr
| ) |  |

Retrieve value via uint64_t key.

Parameters

  table | The input hash table (IN).
  key | The input key (IN).
  ptr | The value associated with the key

Returns
  integer return code:
  - OPAL_SUCCESS if key was found
  - OPAL_ERR_NOT_FOUND if key was not found
  - OPAL_ERROR other error

References opal_hash_table_t::ht_table, opal_hash_table_t::ht_table_size, opal_list_get_end(), opal_list_get_first(), opal_list_get_next, and opal_output().

Referenced by mca_oob_tcp_peer_lookup(), mca_oob_tcp_resolve(), and mca_oob_tcp_set_addr().

OPAL_DECLSPEC int opal_hash_table_init | ( | opal_hash_table_t * | ht,
|  | size_t | table_size
| ) |  |

Initializes the table size, must be called before using the table.

Parameters

  table | The input hash table (IN).
  size | The size of the table, which will be rounded up (if required) to the next highest power of two (IN).

Returns
  OPAL error code.

References opal_hash_table_t::ht_table, opal_hash_table_t::ht_table_size, and OBJ_CONSTRUCT.

Referenced by mca_btl_ud_add_procs(), ompi_attr_hash_init(), ompi_attr_init(), and ompi_mpi_init().

OPAL_DECLSPEC int opal_hash_table_remove_all | ( | opal_hash_table_t * | ht | ) |

Remove all elements from the table.

Parameters

  table | The input hash table (IN).

Returns
  OPAL return code.

References opal_hash_table_t::ht_nodes, opal_hash_table_t::ht_size, opal_hash_table_t::ht_table, opal_hash_table_t::ht_table_size, OBJ_RELEASE, opal_list_get_size(), and opal_list_remove_first().

OPAL_DECLSPEC int opal_hash_table_remove_value_ptr | ( | opal_hash_table_t * | table,
|  | const void * | key,
|  | size_t | keylen
| ) |  |

Remove value based on arbitrary length binary key.

Parameters

  table | The input hash table (IN).
  key | The input key (IN).

Returns
  OPAL return code.

References opal_hash_table_t::ht_nodes, opal_hash_table_t::ht_size, opal_hash_table_t::ht_table, opal_hash_table_t::ht_table_size, opal_list_append, opal_list_get_end(), opal_list_get_first(), opal_list_get_next, opal_list_remove_item(), and opal_output().

OPAL_DECLSPEC int opal_hash_table_remove_value_uint32 | ( | opal_hash_table_t * | table,
|  | uint32_t | key
| ) |  |

Remove value based on uint32_t key.

Parameters

  table | The input hash table (IN).
  key | The input key (IN).

Returns
  OPAL return code.

References opal_hash_table_t::ht_nodes, opal_hash_table_t::ht_size, opal_hash_table_t::ht_table, opal_hash_table_t::ht_table_size, opal_list_append, opal_list_get_end(), opal_list_get_first(), opal_list_get_next, opal_list_remove_item(), and opal_output().

Referenced by ompi_attr_delete().

OPAL_DECLSPEC int opal_hash_table_remove_value_uint64 | ( | opal_hash_table_t * | table,
|  | uint64_t | key
| ) |  |

Remove value based on uint64_t key.

Parameters

  table | The input hash table (IN).
  key | The input key (IN).

Returns
  OPAL return code.

References opal_hash_table_t::ht_nodes, opal_hash_table_t::ht_size, opal_hash_table_t::ht_table, opal_hash_table_t::ht_table_size, opal_list_append, opal_list_get_end(), opal_list_get_first(), opal_list_get_next, opal_list_remove_item(), and opal_output().

Referenced by mca_btl_ud_del_procs().

OPAL_DECLSPEC int opal_hash_table_set_value_ptr | ( | opal_hash_table_t * | table,
|  | const void * | key,
|  | size_t | keylen,
|  | void * | value
| ) |  |

Set value based on arbitrary length binary key.

Parameters

  table | The input hash table (IN).
  key | The input key (IN).
  value | The value to be associated with the key (IN).

Returns
  OPAL return code.

References opal_hash_table_t::ht_nodes, opal_hash_table_t::ht_size, opal_hash_table_t::ht_table, opal_hash_table_t::ht_table_size, opal_list_append, opal_list_get_end(), opal_list_get_first(), opal_list_get_next, opal_list_remove_first(), and opal_output().

OPAL_DECLSPEC int opal_hash_table_set_value_uint32 | ( | opal_hash_table_t * | table,
|  | uint32_t | key,
|  | void * | value
| ) |  |

Set value based on uint32_t key.

Parameters

  table | The input hash table (IN).
  key | The input key (IN).
  value | The value to be associated with the key (IN).

Returns
  OPAL return code.

References opal_hash_table_t::ht_nodes, opal_hash_table_t::ht_size, opal_hash_table_t::ht_table, opal_hash_table_t::ht_table_size, opal_list_append, opal_list_get_end(), opal_list_get_first(), opal_list_get_next, opal_list_remove_first(), and opal_output().

OPAL_DECLSPEC int opal_hash_table_set_value_uint64 | ( | opal_hash_table_t * | table,
|  | uint64_t | key,
|  | void * | value
| ) |  |

Set value based on uint64_t key.

Parameters

  table | The input hash table (IN).
  key | The input key (IN).
  value | The value to be associated with the key (IN).

Returns
  OPAL return code.

References opal_hash_table_t::ht_nodes, opal_hash_table_t::ht_size, opal_hash_table_t::ht_table, opal_hash_table_t::ht_table_size, opal_list_append, opal_list_get_end(), opal_list_get_first(), opal_list_get_next, opal_list_remove_first(), and opal_output().

Referenced by mca_btl_ud_add_procs(), mca_oob_tcp_peer_lookup(), and mca_oob_tcp_set_addr().