CUBRID Engine  latest
uca_support.c File Reference
#include <assert.h>
#include <errno.h>
#include "utility.h"
#include "environment_variable.h"
#include "locale_support.h"
#include "error_manager.h"
#include "porting.h"
#include "intl_support.h"
#include "uca_support.h"
#include "unicode_support.h"
Include dependency graph for uca_support.c:

Go to the source code of this file.

Classes

struct  uca_coll_ce
 
struct  uca_coll_ce_list
 
struct  uca_chr_seq
 
struct  uca_coll_contr_id
 
struct  uca_coll_key
 
struct  uca_weight_key_list
 
struct  uca_storage
 

Macros

#define strlen(s1)   ((int) strlen(s1))
 
#define DUCET_FILE   "ducet.txt"
 
#define MAX_WEIGHT_LEVELS   4
 
#define MAX_UCA_WEIGHT   0xFFFF
 
#define MAX_UCA_CODEPOINT   0xFFFF
 
#define UCA_CONTR_EXP_CNT_GROW   8
 
#define MAX_LOGICAL_POS   14
 
#define GET_UCA_WEIGHT(ce_list, i, w)   ((ce_list)->ce[(i)].weight[(w)])
 
#define SET_UCA_WEIGHT(ce_list, i, w, val)
 

Typedefs

typedef struct uca_coll_ce UCA_COLL_CE
 
typedef struct uca_coll_ce_list UCA_COLL_CE_LIST
 
typedef struct uca_chr_seq UCA_CHR_SEQ
 
typedef UCA_CHR_SEQ UCA_CONTRACTION
 
typedef UCA_CHR_SEQ UCA_EXPANSION
 
typedef struct uca_coll_contr_id UCA_COLL_CONTR_ID
 
typedef struct uca_coll_key UCA_COLL_KEY
 
typedef struct uca_storage UCA_STORAGE
 
typedef struct uca_weight_key_list UCA_WEIGHT_KEY_LIST
 

Enumerations

enum  UCA_COLL_KEY_TYPE { COLL_KEY_TYPE_CP = 0, COLL_KEY_TYPE_CONTR, COLL_KEY_TYPE_EXP }
 

Functions

static int load_ducet (const char *file_path, const int sett_contr_policy)
 
static int init_uca_instance (LOCALE_COLLATION *lc)
 
static int destroy_uca_instance (void)
 
static int build_key_list_groups (LOCALE_COLLATION *lc)
 
static void sort_coll_key_lists (LOCALE_COLLATION *lc)
 
static void sort_one_coll_key_list (LOCALE_COLLATION *lc, int weight_index)
 
static int uca_comp_func_coll_key_fo (const void *arg1, const void *arg2)
 
static int uca_comp_func_coll_key (const void *arg1, const void *arg2)
 
static UCA_COLL_CE_LISTget_ce_list_from_coll_key (const UCA_COLL_KEY *key)
 
static int create_opt_weights (LOCALE_COLLATION *lc)
 
static int optimize_coll_contractions (LOCALE_COLLATION *lc)
 
static int set_next_value_for_coll_key (LOCALE_COLLATION *lc, const UCA_COLL_KEY *coll_key, const UCA_COLL_KEY *next_key)
 
static int add_opt_coll_contraction (LOCALE_COLLATION *lc, const UCA_COLL_KEY *contr_key, const unsigned int wv, bool use_expansions)
 
static int compare_ce_list (UCA_COLL_CE_LIST *ce_list1, UCA_COLL_CE_LIST *ce_list2, UCA_OPTIONS *uca_opt)
 
static UCA_COLL_KEYget_key_with_ce_sublist (UCA_COLL_CE_LIST *uca_item, const int lvl)
 
static void make_coll_key (UCA_COLL_KEY *key, UCA_COLL_KEY_TYPE type, const int key_id)
 
static int find_contr_id (const unsigned int *cp_array, const int cp_count, UCA_STORAGE *st)
 
static int find_exp_id (const unsigned int *cp_array, const int cp_count, UCA_STORAGE *st)
 
static int apply_tailoring_rule (TAILOR_DIR dir, UCA_COLL_KEY *anchor_key, UCA_COLL_KEY *key, UCA_COLL_KEY *ref_key, T_LEVEL lvl)
 
static int apply_tailoring_rule_identity (UCA_COLL_KEY *key, UCA_COLL_KEY *ref_key)
 
static int apply_tailoring_rule_w_dir (TAILOR_DIR dir, UCA_COLL_KEY *anchor_key, UCA_COLL_KEY *key, UCA_COLL_KEY *ref_key, T_LEVEL lvl)
 
static int apply_tailoring_rules (LOCALE_COLLATION *lc)
 
static int compute_weights_per_level_stats (void)
 
static int add_key_to_weight_stats_list (const UCA_COLL_KEY *key, UCA_W wv)
 
static int remove_key_from_weight_stats_list (const UCA_COLL_KEY *key, UCA_W wv)
 
static int change_key_weight_list (const UCA_COLL_KEY *key, UCA_W w_from, UCA_W w_to)
 
static int string_to_coll_ce_list (char *s, UCA_COLL_CE_LIST *ui)
 
static int apply_absolute_tailoring_rules (LOCALE_COLLATION *lc)
 
static UCA_CONTRACTIONnew_contraction (UCA_STORAGE *storage)
 
static int add_uca_contr_or_exp (LOCALE_COLLATION *lc, UCA_STORAGE *storage, const unsigned int *cp_array, const int cp_count, const UCA_COLL_KEY_TYPE seq_type)
 
static int read_cp_from_tag (unsigned char *buffer, CP_BUF_TYPE type, UCA_CP *cp)
 
static int comp_func_coll_contr_bin (const void *arg1, const void *arg2)
 
static int create_opt_ce_w_exp (LOCALE_COLLATION *lc)
 
static int uca_comp_func_coll_list_exp_fo (const void *arg1, const void *arg2)
 
static int uca_comp_func_coll_list_exp (const void *arg1, const void *arg2)
 
static void build_compressed_uca_w_l13 (const UCA_COLL_CE_LIST *ce_list, UCA_L13_W *uca_w_l13)
 
static void build_uca_w_l4 (const UCA_COLL_CE_LIST *ce_list, UCA_L4_W *uca_w_l4)
 
int uca_process_collation (LOCALE_COLLATION *lc, bool is_verbose)
 
void uca_free_data (void)
 
static UCA_EXPANSIONnew_expansion (UCA_STORAGE *storage)
 

Variables

static UCA_STORAGE ducet
 
static UCA_STORAGE curr_uca
 
static UCA_Ww_occurences [MAX_WEIGHT_LEVELS]
 
static UCA_WEIGHT_KEY_LISTweight_key_list
 
static int logical_pos_cp [MAX_LOGICAL_POS]
 
static UCA_OPTIONSuca_tailoring_options = NULL
 

Macro Definition Documentation

#define DUCET_FILE   "ducet.txt"

Definition at line 39 of file uca_support.c.

Referenced by init_uca_instance().

#define MAX_LOGICAL_POS   14

Definition at line 48 of file uca_support.c.

Referenced by apply_tailoring_rules().

#define SET_UCA_WEIGHT (   ce_list,
  i,
  w,
  val 
)
Value:
do { \
(ce_list)->ce[(i)].weight[(w)] = (val); \
} while (0);
int i
Definition: dynamic_load.c:954

Definition at line 65 of file uca_support.c.

Referenced by add_uca_contr_or_exp(), apply_absolute_tailoring_rules(), apply_tailoring_rule_w_dir(), compute_weights_per_level_stats(), load_ducet(), and string_to_coll_ce_list().

#define strlen (   s1)    ((int) strlen(s1))
#define UCA_CONTR_EXP_CNT_GROW   8

Definition at line 46 of file uca_support.c.

Referenced by new_contraction(), and new_expansion().

Typedef Documentation

typedef struct uca_chr_seq UCA_CHR_SEQ

Definition at line 71 of file uca_support.c.

typedef struct uca_coll_ce UCA_COLL_CE

Definition at line 51 of file uca_support.c.

Definition at line 57 of file uca_support.c.

Definition at line 84 of file uca_support.c.

typedef struct uca_coll_key UCA_COLL_KEY

Definition at line 99 of file uca_support.c.

Definition at line 80 of file uca_support.c.

Definition at line 81 of file uca_support.c.

typedef struct uca_storage UCA_STORAGE

Definition at line 111 of file uca_support.c.

Definition at line 113 of file uca_support.c.

Enumeration Type Documentation

Enumerator
COLL_KEY_TYPE_CP 
COLL_KEY_TYPE_CONTR 
COLL_KEY_TYPE_EXP 

Definition at line 92 of file uca_support.c.

Function Documentation

static int add_key_to_weight_stats_list ( const UCA_COLL_KEY key,
UCA_W  wv 
)
static

Definition at line 2853 of file uca_support.c.

References assert, ER_LOC_GEN, uca_weight_key_list::list_count, LOG_LOCALE_ERROR, NO_ERROR, and NULL.

Referenced by add_uca_contr_or_exp(), and change_key_weight_list().

Here is the caller graph for this function:

static int apply_tailoring_rule ( TAILOR_DIR  dir,
UCA_COLL_KEY anchor_key,
UCA_COLL_KEY key,
UCA_COLL_KEY ref_key,
T_LEVEL  lvl 
)
static

Definition at line 2161 of file uca_support.c.

References apply_tailoring_rule_identity(), apply_tailoring_rule_w_dir(), and TAILOR_IDENTITY.

Referenced by apply_tailoring_rules().

Here is the caller graph for this function:

static int apply_tailoring_rule_identity ( UCA_COLL_KEY key,
UCA_COLL_KEY ref_key 
)
static

Definition at line 2180 of file uca_support.c.

References assert, change_key_weight_list(), ER_LOC_GEN, get_ce_list_from_coll_key(), GET_UCA_WEIGHT, LOG_LOCALE_ERROR, NO_ERROR, NULL, and uca_coll_ce_list::num.

Referenced by apply_tailoring_rule().

Here is the caller graph for this function:

static int apply_tailoring_rule_w_dir ( TAILOR_DIR  dir,
UCA_COLL_KEY anchor_key,
UCA_COLL_KEY key,
UCA_COLL_KEY ref_key,
T_LEVEL  lvl 
)
static
static void build_compressed_uca_w_l13 ( const UCA_COLL_CE_LIST ce_list,
UCA_L13_W uca_w_l13 
)
static

Definition at line 3544 of file uca_support.c.

References assert, GET_UCA_WEIGHT, i, NULL, and uca_coll_ce_list::num.

Referenced by add_opt_coll_contraction(), and create_opt_ce_w_exp().

Here is the caller graph for this function:

static void build_uca_w_l4 ( const UCA_COLL_CE_LIST ce_list,
UCA_L4_W uca_w_l4 
)
static

Definition at line 3573 of file uca_support.c.

References assert, GET_UCA_WEIGHT, i, NULL, and uca_coll_ce_list::num.

Referenced by create_opt_ce_w_exp().

Here is the caller graph for this function:

static int change_key_weight_list ( const UCA_COLL_KEY key,
UCA_W  w_from,
UCA_W  w_to 
)
static

Definition at line 2945 of file uca_support.c.

References add_key_to_weight_stats_list(), assert, NO_ERROR, NULL, and remove_key_from_weight_stats_list().

Referenced by apply_tailoring_rule_identity(), and apply_tailoring_rule_w_dir().

Here is the caller graph for this function:

static int comp_func_coll_contr_bin ( const void *  arg1,
const void *  arg2 
)
static

Definition at line 3249 of file uca_support.c.

References coll_contraction::c_buf, and uca_coll_contr_id::contr_ref.

Referenced by optimize_coll_contractions().

Here is the caller graph for this function:

static int compare_ce_list ( UCA_COLL_CE_LIST ce_list1,
UCA_COLL_CE_LIST ce_list2,
UCA_OPTIONS uca_opt 
)
static
static int compute_weights_per_level_stats ( void  )
static
static int find_contr_id ( const unsigned int *  cp_array,
const int  cp_count,
UCA_STORAGE st 
)
static

Definition at line 2491 of file uca_support.c.

References assert, uca_storage::coll_contr, uca_storage::count_contr, uca_chr_seq::cp_count, uca_chr_seq::cp_list, i, LOC_MAX_UCA_CHARS_SEQ, MAX_UNICODE_CHARS, and NULL.

Referenced by apply_tailoring_rules().

Here is the caller graph for this function:

static int find_exp_id ( const unsigned int *  cp_array,
const int  cp_count,
UCA_STORAGE st 
)
static

Definition at line 2547 of file uca_support.c.

References assert, uca_storage::coll_exp, uca_storage::count_exp, uca_chr_seq::cp_count, uca_chr_seq::cp_list, i, LOC_MAX_UCA_CHARS_SEQ, MAX_UNICODE_CHARS, and NULL.

Referenced by apply_tailoring_rules().

Here is the caller graph for this function:

static UCA_COLL_KEY * get_key_with_ce_sublist ( UCA_COLL_CE_LIST uca_item,
const int  lvl 
)
static

Definition at line 2401 of file uca_support.c.

References assert, get_ce_list_from_coll_key(), GET_UCA_WEIGHT, i, uca_weight_key_list::key_list, uca_weight_key_list::list_count, NULL, and uca_coll_ce_list::num.

Referenced by apply_tailoring_rule_w_dir().

Here is the caller graph for this function:

static UCA_CONTRACTION * new_contraction ( UCA_STORAGE storage)
static
static UCA_EXPANSION* new_expansion ( UCA_STORAGE storage)
static

Definition at line 3009 of file uca_support.c.

References assert, uca_storage::coll_exp, uca_storage::count_exp, ER_LOC_GEN, LOG_LOCALE_ERROR, uca_storage::max_exp, NULL, and UCA_CONTR_EXP_CNT_GROW.

Referenced by add_uca_contr_or_exp().

Here is the caller graph for this function:

static int read_cp_from_tag ( unsigned char *  buffer,
CP_BUF_TYPE  type,
UCA_CP cp 
)
static

Definition at line 3162 of file uca_support.c.

References assert, BUF_TYPE_CHAR, BUF_TYPE_CODE, ER_LOC_GEN, ERR_MSG_SIZE, intl_count_utf8_chars(), intl_utf8_to_cp(), LOG_LOCALE_ERROR, NO_ERROR, NULL, str_to_int32(), and strlen.

Referenced by apply_absolute_tailoring_rules().

Here is the caller graph for this function:

static int remove_key_from_weight_stats_list ( const UCA_COLL_KEY key,
UCA_W  wv 
)
static

Definition at line 2884 of file uca_support.c.

References assert, i, uca_weight_key_list::list_count, and NO_ERROR.

Referenced by change_key_weight_list().

Here is the caller graph for this function:

static void sort_coll_key_lists ( LOCALE_COLLATION lc)
static

Definition at line 1462 of file uca_support.c.

References MAX_UCA_WEIGHT, and sort_one_coll_key_list().

Referenced by uca_process_collation().

Here is the caller graph for this function:

static void sort_one_coll_key_list ( LOCALE_COLLATION lc,
int  weight_index 
)
static

Definition at line 1484 of file uca_support.c.

References assert, MAX_UCA_WEIGHT, and uca_comp_func_coll_key_fo().

Referenced by sort_coll_key_lists().

Here is the caller graph for this function:

static int string_to_coll_ce_list ( char *  s,
UCA_COLL_CE_LIST ui 
)
static

Definition at line 2603 of file uca_support.c.

References ER_LOC_GEN, LOG_LOCALE_ERROR, MAX_UCA_WEIGHT, MAX_WEIGHT_LEVELS, NO_ERROR, uca_coll_ce_list::num, SET_UCA_WEIGHT, str_to_int32(), strlen, and uca_coll_ce::weight.

Referenced by apply_absolute_tailoring_rules().

Here is the caller graph for this function:

static int uca_comp_func_coll_key ( const void *  arg1,
const void *  arg2 
)
static

Definition at line 1551 of file uca_support.c.

References assert, compare_ce_list(), get_ce_list_from_coll_key(), NULL, and uca_tailoring_options.

Referenced by uca_comp_func_coll_key_fo(), and uca_comp_func_coll_list_exp().

Here is the caller graph for this function:

static int uca_comp_func_coll_key_fo ( const void *  arg1,
const void *  arg2 
)
static

Definition at line 1510 of file uca_support.c.

References cmp, COLL_KEY_TYPE_CONTR, uca_coll_key::cp, uca_coll_key::type, uca_comp_func_coll_key(), and uca_coll_key::val.

Referenced by sort_one_coll_key_list().

Here is the caller graph for this function:

static int uca_comp_func_coll_list_exp ( const void *  arg1,
const void *  arg2 
)
static

Definition at line 3499 of file uca_support.c.

References COLL_KEY_TYPE_CONTR, COLL_KEY_TYPE_CP, INTL_GET_NEXT_CONTR_ID, INTL_IS_NEXT_CONTR, make_coll_key(), and uca_comp_func_coll_key().

Referenced by create_opt_ce_w_exp(), and uca_comp_func_coll_list_exp_fo().

Here is the caller graph for this function:

static int uca_comp_func_coll_list_exp_fo ( const void *  arg1,
const void *  arg2 
)
static

Definition at line 3474 of file uca_support.c.

References cmp, and uca_comp_func_coll_list_exp().

Referenced by create_opt_ce_w_exp().

Here is the caller graph for this function:

void uca_free_data ( void  )

Variable Documentation

UCA_STORAGE curr_uca
static
Initial value:
= {
NULL, 0, 0,
NULL, 0, 0,
}
#define NULL
Definition: freelistheap.h:34

Definition at line 147 of file uca_support.c.

UCA_STORAGE ducet
static
Initial value:
= {
NULL, 0, 0,
NULL, 0, 0,
}
#define NULL
Definition: freelistheap.h:34

Definition at line 140 of file uca_support.c.

int logical_pos_cp[MAX_LOGICAL_POS]
static

Definition at line 158 of file uca_support.c.

Referenced by apply_tailoring_rules(), and load_ducet().

UCA_OPTIONS* uca_tailoring_options = NULL
static

Definition at line 161 of file uca_support.c.

Referenced by create_opt_ce_w_exp(), and uca_comp_func_coll_key().

UCA_WEIGHT_KEY_LIST* weight_key_list
static

Definition at line 156 of file uca_support.c.