File: space.h

package info (click to toggle)
tarantool 1.5.2.20.g5f5d924-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 26,568 kB
  • ctags: 18,697
  • sloc: ansic: 109,092; sh: 21,312; cpp: 20,633; xml: 9,666; asm: 2,488; python: 2,195; java: 1,759; perl: 1,002; makefile: 679
file content (64 lines) | stat: -rw-r--r-- 1,371 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#ifndef TS_SPACE_H_INCLUDED
#define TS_SPACE_H_INCLUDED

enum ts_space_key_type {
	TS_SPACE_KEY_UNKNOWN = -1,
	TS_SPACE_KEY_NUM = 0,
	TS_SPACE_KEY_NUM64,
	TS_SPACE_KEY_STRING
};

enum ts_space_compact {
	TS_SPACE_COMPACT_CHECKSUM,
	TS_SPACE_COMPACT_SPARSE
};

struct ts_space_key_field {
	enum ts_space_key_type type;
	int n;
};

struct ts_space_key {
	struct ts_space_key_field *fields;
	int count;
};

struct ts_space {
	enum ts_space_compact c;
	int key_size;
	int key_div;

	uint32_t id;
	struct mh_pk_t *index;
	struct ts_space_key pk;
};

struct ts_spaces {
	struct mh_u32ptr_t *t;
};

int ts_space_init(struct ts_spaces *s);
void ts_space_free(struct ts_spaces *s);
void ts_space_recycle(struct ts_spaces *s);

struct ts_space *ts_space_create(struct ts_spaces *s, uint32_t id);
struct ts_space *ts_space_match(struct ts_spaces *s, uint32_t id);

int ts_space_fill(struct ts_spaces *s, struct ts_options *opts);

struct ts_key*
ts_space_keyalloc(struct ts_space *s, struct tnt_tuple *t, int fileid,
                  uint64_t offset, int attach);

void
ts_space_keyfree(struct ts_space *s, struct ts_key *k);

static inline size_t
ts_space_keysize(struct ts_space *s, struct ts_key *k) {
	size_t size = sizeof(struct ts_key) + s->key_size;
	if (k->flags == TS_KEY_WITH_DATA)
		size += sizeof(uint32_t) + *(uint32_t*)(k->key + s->key_size);
	return size;
}

#endif