2007-11-29 14:18:54 +00:00
|
|
|
#ident "Copyright (c) 2007 Tokutek Inc. All rights reserved."
|
|
|
|
|
2007-10-10 19:33:31 +00:00
|
|
|
#include "pma.h"
|
|
|
|
#include "mempool.h"
|
2007-07-13 19:37:47 +00:00
|
|
|
|
|
|
|
struct pma {
|
|
|
|
enum typ_tag tag;
|
2007-11-14 17:58:38 +00:00
|
|
|
int dup_mode;
|
2007-12-05 19:41:39 +00:00
|
|
|
unsigned int N; /* How long is the array? Always a power of two >= 4. */
|
2007-07-13 19:37:47 +00:00
|
|
|
int n_pairs_present; /* How many array elements are non-null. */
|
2008-04-02 23:40:36 +00:00
|
|
|
LEAFENTRY *pairs;
|
2007-07-13 19:37:47 +00:00
|
|
|
int uplgN; /* The smallest power of two >= lg(N) */
|
2007-08-30 15:15:14 +00:00
|
|
|
double udt_step; /* upper density threshold step */
|
|
|
|
/* Each doubling decreases the density by density step.
|
2007-07-13 19:37:47 +00:00
|
|
|
* For example if array_len=256 and uplgN=8 then there are 5 doublings.
|
|
|
|
* Regions of size 8 are full. Regions of size 16 are 90% full.
|
|
|
|
* Regions of size 32 are 80% full. Regions of size 64 are 70% full.
|
|
|
|
* Regions of size 128 are 60% full. Regions of size 256 are 50% full.
|
2007-08-30 15:15:14 +00:00
|
|
|
* The density step is 0.10. */
|
|
|
|
double ldt_step; /* lower density threshold step */
|
2007-11-14 17:58:38 +00:00
|
|
|
pma_compare_fun_t compare_fun;
|
|
|
|
pma_compare_fun_t dup_compare_fun;
|
2007-11-26 21:51:36 +00:00
|
|
|
DB *db; /* Passed to the compare functions. */
|
|
|
|
FILENUM filenum; /* Passed to logging. */
|
2007-07-23 20:10:16 +00:00
|
|
|
void *skey, *sval; /* used in dbts */
|
2007-10-10 19:33:31 +00:00
|
|
|
struct mempool kvspace;
|
2007-07-13 19:37:47 +00:00
|
|
|
};
|
|
|
|
|
2008-04-02 23:40:36 +00:00
|
|
|
int toku_pmainternal_count_region (LEAFENTRY pairs[], int lo, int hi);
|
2007-11-20 00:32:25 +00:00
|
|
|
void toku_pmainternal_calculate_parameters (PMA pma);
|
2008-04-02 23:40:36 +00:00
|
|
|
int toku_pmainternal_smooth_region (TOKULOGGER, FILENUM, DISKOFF, LEAFENTRY/*pairs*/[], int /*n*/, int /*idx*/, int /*base*/, PMA /*pma*/, int */*new_idx*/, LSN */*node_lsn*/);
|
|
|
|
int toku_pmainternal_printpairs (LEAFENTRY pairs[], int N);
|
2008-02-08 19:54:00 +00:00
|
|
|
int toku_pmainternal_make_space_at (TOKULOGGER, FILENUM, DISKOFF, PMA pma, int idx, unsigned int *new_index, LSN *node_lsn);
|
2007-11-26 21:51:36 +00:00
|
|
|
int toku_pmainternal_find (PMA pma, DBT *); // The DB is so the comparison fuction can be called.
|
2007-11-20 00:32:25 +00:00
|
|
|
void toku_print_pma (PMA pma); /* useful for debugging, so keep the name short. I.e., not pmainternal_print_pma() */
|
2007-08-03 17:21:20 +00:00
|
|
|
|
2007-08-30 15:15:14 +00:00
|
|
|
/* density thresholds */
|
|
|
|
#define PMA_LDT_HIGH 0.25
|
|
|
|
#define PMA_LDT_LOW 0.40
|
|
|
|
#define PMA_UDT_HIGH 1.00
|
|
|
|
#define PMA_UDT_LOW 0.50
|
|
|
|
|
|
|
|
/* minimum array size */
|
|
|
|
#define PMA_MIN_ARRAY_SIZE 4
|