Skip to content

Commit d05fc06

Browse files
committed
Remove vector use in sqib.h and move fns to util.h
1 parent 5c065af commit d05fc06

4 files changed

Lines changed: 673 additions & 689 deletions

File tree

src/btree_handler.h

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#ifndef BP_TREE_H
2-
#define BP_TREE_H
1+
#ifndef SIARA_BP_TREE_H
2+
#define SIARA_BP_TREE_H
33
#include <cstdio>
44
#include <cstring>
55
#include <iostream>
@@ -14,40 +14,19 @@
1414
#define BPT_BLK_TYPE_LEAF 128
1515
#define BPT_BLK_TYPE_OVFL 255
1616

17-
#define DEFAULT_BLOCK_SIZE 4096
17+
#define BPT_DEFAULT_BLOCK_SIZE 4096
1818

1919
#define descendant static_cast<T*>(this)
2020

21-
class util {
22-
public:
23-
static int compare(const uint8_t *v1, int len1, const uint8_t *v2,
24-
int len2, int k = 0) {
25-
int lim = (len2 < len1 ? len2 : len1);
26-
while (k < lim) {
27-
uint8_t c1 = v1[k];
28-
uint8_t c2 = v2[k];
29-
k++;
30-
if (c1 < c2)
31-
return -k;
32-
else if (c1 > c2)
33-
return k;
34-
}
35-
if (len1 == len2)
36-
return 0;
37-
k++;
38-
return (len1 < len2 ? -k : k);
39-
}
40-
};
41-
4221
union page_ptr {
4322
unsigned long page;
4423
uint8_t *ptr;
4524
};
4625

47-
#define MAX_LVL_COUNT 10
26+
#define BPT_MAX_LVL_COUNT 10
4827
class bptree_iter_ctx {
4928
public:
50-
page_ptr pages[MAX_LVL_COUNT];
29+
page_ptr pages[BPT_MAX_LVL_COUNT];
5130
int found_page_pos;
5231
int8_t last_page_lvl;
5332
int8_t found_page_idx;
@@ -97,7 +76,7 @@ class btree_handler {
9776
size_t block_size;
9877
int cache_size;
9978
const char *filename;
100-
btree_handler(uint32_t block_sz = DEFAULT_BLOCK_SIZE, int cache_sz_kb = 0,
79+
btree_handler(uint32_t block_sz = BPT_DEFAULT_BLOCK_SIZE, int cache_sz_kb = 0,
10180
const char *fname = NULL, int start_page_num = 0, bool whether_btree = false) :
10281
block_size (block_sz), cache_size (cache_sz_kb), filename (fname) {
10382
descendant->init_derived();

0 commit comments

Comments
 (0)