Skip to content

File memory_hash.c

FileList > base > memory_hash.c

Go to the source code of this file

  • #include "config.h"
  • #include <stdio.h>
  • #include <assert.h>
  • #include "memory_hash.h"
  • #include "chartype.h"
  • #include "misc_string.h"
  • #include "error_manager.h"
  • #include "memory_alloc.h"
  • #include "message_catalog.h"
  • #include "environment_variable.h"
  • #include "set_object.h"
  • #include "language_support.h"
  • #include "intl_support.h"
  • #include "object_primitive.h"
  • #include "object_representation.h"
  • #include "dbtype.h"
  • #include "memory_wrapper.hpp"

Public Types

Type Name
typedef enum mht_put_opt MHT_PUT_OPT
enum mht_put_opt

Public Static Attributes

Type Name
const float MHT_REHASH_FACTOR = 1.3f
const float MHT_REHASH_TRESHOLD = 0.7f
const unsigned int mht_Primes = /* multi line expression */
const unsigned int mht_prime_for_pow2

Public Functions

Type Name
unsigned int mht_1strhash (const void * key, const unsigned int ht_size)
unsigned int mht_1strlowerhash (const void * key, const unsigned int ht_size)
unsigned int mht_2str_pseudo_key (const void * key, int key_size)
unsigned int mht_2strhash (const void * key, const unsigned int ht_size)
unsigned int mht_3strhash (const void * key, const unsigned int ht_size)
unsigned int mht_4strhash (const void * key, const unsigned int ht_size)
unsigned int mht_5strhash (const void * key, const unsigned int ht_size)
int mht_adjust_lru_list (MHT_TABLE * ht, HENTRY_PTR hentry)
unsigned int mht_calculate_htsize (unsigned int ht_size)
unsigned int mht_calculate_htsize_for_pow2 (unsigned int ht_size)
int mht_clear (MHT_TABLE * ht, int(*)(const void *key, void *data, void *args) rem_func, void * func_args)
int mht_clear_hls (MHT_HLS_TABLE * ht, int(*)(const void *key, void *data, void *args) rem_func, void * func_args)
int mht_compare_dbvalues_are_equal (const void * key1, const void * key2)
int mht_compare_identifiers_equal (const void * key1, const void * key2)
int mht_compare_ints_are_equal (const void * key1, const void * key2)
int mht_compare_logpageids_are_equal (const void * key1, const void * key2)
int mht_compare_ptrs_are_equal (const void * key1, const void * key2)
int mht_compare_strings_are_equal (const void * key1, const void * key2)
unsigned int mht_count (const MHT_TABLE * ht)
MHT_TABLE * mht_create (const char * name, int est_size, unsigned int(*)(const void *key, unsigned int ht_size) hash_func, int(*)(const void *key1, const void *key2) cmp_func)
MHT_HLS_TABLE * mht_create_hls (const char * name, int est_size, unsigned int(*)(const void *key, unsigned int ht_size) hash_func, int(*)(const void *key1, const void *key2) cmp_func)
void mht_destroy (MHT_TABLE * ht)
void mht_destroy_hls (MHT_HLS_TABLE * ht)
int mht_dump (THREAD_ENTRY * thread_p, FILE * out_fp, const MHT_TABLE * ht, const int print_id_opt, int(*)(THREAD_ENTRY *thread_p, FILE *fp, const void *key, void *data, void *args) print_func, void * func_args)
int mht_dump_hls (THREAD_ENTRY * thread_p, FILE * out_fp, const MHT_HLS_TABLE * ht, const int print_id_opt, int(*)(THREAD_ENTRY *thread_p, FILE *fp, const void *data, const void *type_list, void *args) print_func, const void * type_list, void * func_args)
void * mht_get (MHT_TABLE * ht, const void * key)
void * mht_get2 (const MHT_TABLE * ht, const void * key, void ** last)
unsigned int mht_get_hash_number (const unsigned int ht_size, const DB_VALUE * val)
void * mht_get_hls (const MHT_HLS_TABLE * ht, const void * key, void ** last)
void * mht_get_next_hls (const MHT_HLS_TABLE * ht, const void * key, void ** last)
int mht_map (const MHT_TABLE * ht, int(*)(const void *key, void *data, void *args) map_func, void * func_args)
int mht_map_no_key (THREAD_ENTRY * thread_p, const MHT_TABLE * ht, int(*)(THREAD_ENTRY *thread_p, void *data, void *args) map_func, void * func_args)
unsigned int mht_numhash (const void * key, const unsigned int ht_size)
unsigned int mht_ptrhash (const void * key, const unsigned int ht_size)
const void * mht_put (MHT_TABLE * ht, const void * key, void * data)
const void * mht_put2 (MHT_TABLE * ht, const void * key, void * data)
const void * mht_put2_data (MHT_TABLE * ht, const void * key, void * data)
const void * mht_put2_new (MHT_TABLE * ht, const void * key, void * data)
const void * mht_put_data (MHT_TABLE * ht, const void * key, void * data)
const void * mht_put_hls (MHT_HLS_TABLE * ht, const void * key, void * data)
const void * mht_put_if_not_exists (MHT_TABLE * ht, const void * key, void * data)
const void * mht_put_new (MHT_TABLE * ht, const void * key, void * data)
int mht_rem (MHT_TABLE * ht, const void * key, int(*)(const void *key, void *data, void *args) rem_func, void * func_args)
int mht_rem2 (MHT_TABLE * ht, const void * key, const void * data, int(*)(const void *key, void *data, void *args) rem_func, void * func_args)
unsigned int mht_valhash (const void * key, const unsigned int ht_size)

Public Static Functions

Type Name
unsigned int mht_1str_pseudo_key (const void * key, int key_size)
unsigned int mht_3str_pseudo_key (const void * key, int key_size, const unsigned int max_value)
unsigned int mht_4str_pseudo_key (const void * key, int key_size)
unsigned int mht_5str_pseudo_key (const void * key, int key_size)
unsigned int mht_get32_next_power_of_2 (unsigned int const ht_size)
unsigned int mht_get_linear_hash32 (const unsigned int key, const unsigned int ht_size)
unsigned int mht_get_shiftmult32 (unsigned int key, const unsigned int ht_size)
const void * mht_put2_internal (MHT_TABLE * ht, const void * key, void * data, MHT_PUT_OPT opt)
const void * mht_put_hls_internal (MHT_HLS_TABLE * ht, const void * key, void * data, MHT_PUT_OPT opt)
const void * mht_put_internal (MHT_TABLE * ht, const void * key, void * data, MHT_PUT_OPT opt)
int mht_rehash (MHT_TABLE * ht)

Macros

Type Name
define GET_PTR_FOR_HASH (key) ((([**UINT64**](broker__monitor_8c.md#function-timeout))(key)) & 0xFFFFFFFFUL)
define NPRIMES 170
define NPRIMES_POW2 30

Public Types Documentation

typedef MHT_PUT_OPT

typedef enum mht_put_opt MHT_PUT_OPT;

enum mht_put_opt

enum mht_put_opt {
    MHT_OPT_DEFAULT = 0,
    MHT_OPT_KEEP_KEY = 1,
    MHT_OPT_INSERT_ONLY = 2,
    MHT_OPT_INSERT_IF_NOT_EXISTS = 4
};

Public Static Attributes Documentation

variable MHT_REHASH_FACTOR

const float MHT_REHASH_FACTOR;

variable MHT_REHASH_TRESHOLD

const float MHT_REHASH_TRESHOLD;

variable mht_Primes

const unsigned int mht_Primes[170];

variable mht_prime_for_pow2

const unsigned int mht_prime_for_pow2[];

Public Functions Documentation

function mht_1strhash

unsigned  int mht_1strhash (
    const  void * key,
    const  unsigned  int ht_size
) 

function mht_1strlowerhash

unsigned  int mht_1strlowerhash (
    const  void * key,
    const  unsigned  int ht_size
) 

function mht_2str_pseudo_key

unsigned  int mht_2str_pseudo_key (
    const  void * key,
    int key_size
) 

function mht_2strhash

unsigned  int mht_2strhash (
    const  void * key,
    const  unsigned  int ht_size
) 

function mht_3strhash

unsigned  int mht_3strhash (
    const  void * key,
    const  unsigned  int ht_size
) 

function mht_4strhash

unsigned  int mht_4strhash (
    const  void * key,
    const  unsigned  int ht_size
) 

function mht_5strhash

unsigned  int mht_5strhash (
    const  void * key,
    const  unsigned  int ht_size
) 

function mht_adjust_lru_list

int mht_adjust_lru_list (
    MHT_TABLE * ht,
    HENTRY_PTR hentry
) 

function mht_calculate_htsize

unsigned  int mht_calculate_htsize (
    unsigned  int ht_size
) 

function mht_calculate_htsize_for_pow2

unsigned  int mht_calculate_htsize_for_pow2 (
    unsigned  int ht_size
) 

function mht_clear

int mht_clear (
    MHT_TABLE * ht,
    int (*)( const  void *key, void *data, void *args) rem_func,
    void * func_args
) 

function mht_clear_hls

int mht_clear_hls (
    MHT_HLS_TABLE * ht,
    int (*)( const  void *key, void *data, void *args) rem_func,
    void * func_args
) 

function mht_compare_dbvalues_are_equal

int mht_compare_dbvalues_are_equal (
    const  void * key1,
    const  void * key2
) 

function mht_compare_identifiers_equal

int mht_compare_identifiers_equal (
    const  void * key1,
    const  void * key2
) 

function mht_compare_ints_are_equal

int mht_compare_ints_are_equal (
    const  void * key1,
    const  void * key2
) 

function mht_compare_logpageids_are_equal

int mht_compare_logpageids_are_equal (
    const  void * key1,
    const  void * key2
) 

function mht_compare_ptrs_are_equal

int mht_compare_ptrs_are_equal (
    const  void * key1,
    const  void * key2
) 

function mht_compare_strings_are_equal

int mht_compare_strings_are_equal (
    const  void * key1,
    const  void * key2
) 

function mht_count

unsigned  int mht_count (
    const  MHT_TABLE * ht
) 

function mht_create

MHT_TABLE * mht_create (
    const  char * name,
    int est_size,
    unsigned  int (*)( const  void *key, unsigned  int  ht_size ) hash_func,
    int (*)( const  void *key1, const  void *key2) cmp_func
) 

function mht_create_hls

MHT_HLS_TABLE * mht_create_hls (
    const  char * name,
    int est_size,
    unsigned  int (*)( const  void *key, unsigned  int  ht_size ) hash_func,
    int (*)( const  void *key1, const  void *key2) cmp_func
) 

function mht_destroy

void mht_destroy (
    MHT_TABLE * ht
) 

function mht_destroy_hls

void mht_destroy_hls (
    MHT_HLS_TABLE * ht
) 

function mht_dump

int mht_dump (
    THREAD_ENTRY * thread_p,
    FILE * out_fp,
    const  MHT_TABLE * ht,
    const  int print_id_opt,
    int (*)( THREAD_ENTRY *thread_p, FILE *fp, const  void *key, void *data, void *args) print_func,
    void * func_args
) 

function mht_dump_hls

int mht_dump_hls (
    THREAD_ENTRY * thread_p,
    FILE * out_fp,
    const  MHT_HLS_TABLE * ht,
    const  int print_id_opt,
    int (*)( THREAD_ENTRY *thread_p, FILE *fp, const  void *data, const  void *type_list, void *args) print_func,
    const  void * type_list,
    void * func_args
) 

function mht_get

void * mht_get (
    MHT_TABLE * ht,
    const  void * key
) 

function mht_get2

void * mht_get2 (
    const  MHT_TABLE * ht,
    const  void * key,
    void ** last
) 

function mht_get_hash_number

unsigned  int mht_get_hash_number (
    const  unsigned  int ht_size,
    const  DB_VALUE * val
) 

function mht_get_hls

void * mht_get_hls (
    const  MHT_HLS_TABLE * ht,
    const  void * key,
    void ** last
) 

function mht_get_next_hls

void * mht_get_next_hls (
    const  MHT_HLS_TABLE * ht,
    const  void * key,
    void ** last
) 

function mht_map

int mht_map (
    const  MHT_TABLE * ht,
    int (*)( const  void *key, void *data, void *args) map_func,
    void * func_args
) 

function mht_map_no_key

int mht_map_no_key (
    THREAD_ENTRY * thread_p,
    const  MHT_TABLE * ht,
    int (*)( THREAD_ENTRY *thread_p, void *data, void *args) map_func,
    void * func_args
) 

function mht_numhash

unsigned  int mht_numhash (
    const  void * key,
    const  unsigned  int ht_size
) 

function mht_ptrhash

unsigned  int mht_ptrhash (
    const  void * key,
    const  unsigned  int ht_size
) 

function mht_put

const  void * mht_put (
    MHT_TABLE * ht,
    const  void * key,
    void * data
) 

function mht_put2

const  void * mht_put2 (
    MHT_TABLE * ht,
    const  void * key,
    void * data
) 

function mht_put2_data

const  void * mht_put2_data (
    MHT_TABLE * ht,
    const  void * key,
    void * data
) 

function mht_put2_new

const  void * mht_put2_new (
    MHT_TABLE * ht,
    const  void * key,
    void * data
) 

function mht_put_data

const  void * mht_put_data (
    MHT_TABLE * ht,
    const  void * key,
    void * data
) 

function mht_put_hls

const  void * mht_put_hls (
    MHT_HLS_TABLE * ht,
    const  void * key,
    void * data
) 

function mht_put_if_not_exists

const  void * mht_put_if_not_exists (
    MHT_TABLE * ht,
    const  void * key,
    void * data
) 

function mht_put_new

const  void * mht_put_new (
    MHT_TABLE * ht,
    const  void * key,
    void * data
) 

function mht_rem

int mht_rem (
    MHT_TABLE * ht,
    const  void * key,
    int (*)( const  void *key, void *data, void *args) rem_func,
    void * func_args
) 

function mht_rem2

int mht_rem2 (
    MHT_TABLE * ht,
    const  void * key,
    const  void * data,
    int (*)( const  void *key, void *data, void *args) rem_func,
    void * func_args
) 

function mht_valhash

unsigned  int mht_valhash (
    const  void * key,
    const  unsigned  int ht_size
) 

Public Static Functions Documentation

function mht_1str_pseudo_key

static unsigned  int mht_1str_pseudo_key (
    const  void * key,
    int key_size
) 

function mht_3str_pseudo_key

static unsigned  int mht_3str_pseudo_key (
    const  void * key,
    int key_size,
    const  unsigned  int max_value
) 

function mht_4str_pseudo_key

static unsigned  int mht_4str_pseudo_key (
    const  void * key,
    int key_size
) 

function mht_5str_pseudo_key

static unsigned  int mht_5str_pseudo_key (
    const  void * key,
    int key_size
) 

function mht_get32_next_power_of_2

static unsigned  int mht_get32_next_power_of_2 (
    unsigned  int  const ht_size
) 

function mht_get_linear_hash32

static unsigned  int mht_get_linear_hash32 (
    const  unsigned  int key,
    const  unsigned  int ht_size
) 

function mht_get_shiftmult32

static unsigned  int mht_get_shiftmult32 (
    unsigned  int key,
    const  unsigned  int ht_size
) 

function mht_put2_internal

static const  void * mht_put2_internal (
    MHT_TABLE * ht,
    const  void * key,
    void * data,
    MHT_PUT_OPT opt
) 

function mht_put_hls_internal

static const  void * mht_put_hls_internal (
    MHT_HLS_TABLE * ht,
    const  void * key,
    void * data,
    MHT_PUT_OPT opt
) 

function mht_put_internal

static const  void * mht_put_internal (
    MHT_TABLE * ht,
    const  void * key,
    void * data,
    MHT_PUT_OPT opt
) 

function mht_rehash

static int mht_rehash (
    MHT_TABLE * ht
) 

Macro Definition Documentation

define GET_PTR_FOR_HASH

#define GET_PTR_FOR_HASH (
    key
) `((( UINT64 )(key)) & 0xFFFFFFFFUL)`

define NPRIMES

#define NPRIMES `170`

define NPRIMES_POW2

#define NPRIMES_POW2 `30`


The documentation for this class was generated from the following file cubrid/src/base/memory_hash.c