hatoku_cmp.h 2.42 KB
Newer Older
Zardosht Kasheff's avatar
Zardosht Kasheff committed
1 2 3 4 5 6 7 8 9 10 11 12 13
#ifndef _HATOKU_CMP
#define _HATOKU_CMP

#include "mysql_priv.h"

extern "C" {
#include "stdint.h"
}


#include <db.h>


Zardosht Kasheff's avatar
Zardosht Kasheff committed
14 15 16 17 18 19


typedef enum {
    toku_type_int = 0,
    toku_type_double,
    toku_type_float,
Zardosht Kasheff's avatar
Zardosht Kasheff committed
20 21
    toku_type_fixbinary,
    toku_type_fixstring,
Zardosht Kasheff's avatar
Zardosht Kasheff committed
22 23
    toku_type_varbinary,
    toku_type_varstring,
Zardosht Kasheff's avatar
Zardosht Kasheff committed
24
    toku_type_blob,
Zardosht Kasheff's avatar
Zardosht Kasheff committed
25
    toku_type_hpk, //for hidden primary key
Zardosht Kasheff's avatar
Zardosht Kasheff committed
26 27 28 29 30
    toku_type_unknown
} TOKU_TYPE;


inline TOKU_TYPE mysql_to_toku_type (enum_field_types mysql_type);
Zardosht Kasheff's avatar
Zardosht Kasheff committed
31 32


Zardosht Kasheff's avatar
Zardosht Kasheff committed
33
uchar* pack_toku_field(
Zardosht Kasheff's avatar
Zardosht Kasheff committed
34 35 36 37
    uchar* to_tokudb,
    uchar* from_mysql,
    Field* field,
    u_int32_t key_part_length //I really hope this is temporary as I phase out the pack_cmp stuff
Zardosht Kasheff's avatar
Zardosht Kasheff committed
38 39
    );

Zardosht Kasheff's avatar
Zardosht Kasheff committed
40
uchar* pack_key_toku_field(
Zardosht Kasheff's avatar
Zardosht Kasheff committed
41 42 43 44
    uchar* to_tokudb,
    uchar* from_mysql,
    Field* field,
    u_int32_t key_part_length //I really hope this is temporary as I phase out the pack_cmp stuff
Zardosht Kasheff's avatar
Zardosht Kasheff committed
45
    );
Zardosht Kasheff's avatar
Zardosht Kasheff committed
46

Zardosht Kasheff's avatar
Zardosht Kasheff committed
47
uchar* unpack_toku_field(
Zardosht Kasheff's avatar
Zardosht Kasheff committed
48 49 50 51 52
    uchar* to_mysql,
    uchar* from_tokudb,
    Field* field,
    u_int32_t key_part_length
    );
Zardosht Kasheff's avatar
Zardosht Kasheff committed
53

Zardosht Kasheff's avatar
Zardosht Kasheff committed
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
//
// for storing NULL byte in keys
//
#define NULL_COL_VAL 0
#define NONNULL_COL_VAL 1

//
// for storing if rest of key is +/- infinity
//
#define COL_NEG_INF 0 
#define COL_POS_INF 1

//
// information for hidden primary keys
//
#define TOKUDB_HIDDEN_PRIMARY_KEY_LENGTH 8

//
// function to convert a hidden primary key into a byte stream that can be stored in DBT
//
inline void hpk_num_to_char(uchar* to, ulonglong num) {
    int8store(to, num);
}

//
// function that takes a byte stream of a hidden primary key and returns a ulonglong
//
inline ulonglong hpk_char_to_num(uchar* val) {
    return uint8korr(val);
}

int tokudb_compare_two_keys(
    const void* new_key_data, 
    const u_int32_t new_key_size, 
    const void*  saved_key_data,
    const u_int32_t saved_key_size,
Zardosht Kasheff's avatar
Zardosht Kasheff committed
90 91
    const void*  row_desc,
    const u_int32_t row_desc_size,
Zardosht Kasheff's avatar
Zardosht Kasheff committed
92 93 94 95
    bool cmp_prefix
    );


Zardosht Kasheff's avatar
Zardosht Kasheff committed
96
int tokudb_cmp_dbt_key(DB *file, const DBT *keya, const DBT *keyb);
Zardosht Kasheff's avatar
Zardosht Kasheff committed
97

Zardosht Kasheff's avatar
Zardosht Kasheff committed
98
int tokudb_cmp_dbt_data(DB *file, const DBT *keya, const DBT *keyb);
Zardosht Kasheff's avatar
Zardosht Kasheff committed
99 100

//TODO: QQQ Only do one direction for prefix.
Zardosht Kasheff's avatar
Zardosht Kasheff committed
101
int tokudb_prefix_cmp_dbt_key(DB *file, const DBT *keya, const DBT *keyb);
Zardosht Kasheff's avatar
Zardosht Kasheff committed
102

Zardosht Kasheff's avatar
Zardosht Kasheff committed
103
int create_toku_key_descriptor(KEY* key, uchar* buf);
Zardosht Kasheff's avatar
Zardosht Kasheff committed
104

Zardosht Kasheff's avatar
Zardosht Kasheff committed
105 106 107 108 109 110 111 112
int create_toku_descriptor(
    uchar* buf, 
    bool is_first_hpk, 
    bool is_clustering_key, 
    KEY* first_key, 
    bool is_second_hpk, 
    KEY* second_key
    );
Zardosht Kasheff's avatar
Zardosht Kasheff committed
113 114
#endif