MCPcopy Create free account
hub / github.com/KentBeck/BPlusTree3 / BPlusTree_init

Function BPlusTree_init

python/bplustree_c_src/bplustree_module.c:37–65  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37int
38BPlusTree_init(BPlusTree *self, PyObject *args, PyObject *kwds) {
39 static char *kwlist[] = {"capacity", NULL};
40 int capacity = DEFAULT_CAPACITY;
41
42 if (!PyArg_ParseTupleAndKeywords(args, kwds, "|i", kwlist, &capacity)) {
43 return -1;
44 }
45
46 if (capacity < MIN_CAPACITY) {
47 PyErr_Format(PyExc_ValueError,
48 "capacity must be at least %d, got %d",
49 MIN_CAPACITY, capacity);
50 return -1;
51 }
52
53 self->capacity = capacity;
54 self->min_keys = capacity / 2;
55
56 /* Create initial root (leaf) */
57 self->root = node_create(NODE_LEAF, capacity);
58 if (!self->root) {
59 return -1;
60 }
61 self->leaves = self->root;
62
63
64 return 0;
65}
66
67void
68BPlusTree_dealloc(BPlusTree *self) {

Callers

nothing calls this directly

Calls 1

node_createFunction · 0.85

Tested by

no test coverage detected