~mdw
/
sgt
/
agedu
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
index.c, instead of storing a distinct tree root for every entry in
[sgt/agedu]
/
index.c
diff --git
a/index.c
b/index.c
index
56d657d
..
3431d98
100644
(file)
--- a/
index.c
+++ b/
index.c
@@
-2,10
+2,7
@@
* index.c: Implementation of index.h.
*/
* index.c: Implementation of index.h.
*/
-#include <assert.h>
-#include <stdio.h>
-#include <stddef.h>
-
+#include "agedu.h"
#include "trie.h"
#include "index.h"
#include "alloc.h"
#include "trie.h"
#include "index.h"
#include "alloc.h"
@@
-261,7
+258,13
@@
void indexbuild_add(indexbuild *ib, const struct trie_file *tf)
{
off_t node = OFFSET(ib->t, tf);
ib->currroot = avl_insert(ib, ib->currroot, node);
{
off_t node = OFFSET(ib->t, tf);
ib->currroot = avl_insert(ib, ib->currroot, node);
- ib->roots[ib->n++] = OFFSET(ib->t, ib->currroot);
+ ib->roots[ib->n++] = 0;
+}
+
+void indexbuild_tag(indexbuild *ib)
+{
+ if (ib->n > 0)
+ ib->roots[ib->n - 1] = OFFSET(ib->t, ib->currroot);
ib->firstmutable = ib->nodes + ib->nnodes;
}
ib->firstmutable = ib->nodes + ib->nnodes;
}
@@
-272,6
+275,7
@@
off_t indexbuild_realsize(indexbuild *ib)
void indexbuild_free(indexbuild *ib)
{
void indexbuild_free(indexbuild *ib)
{
+ assert(ib->n == trie_count(ib->t));
sfree(ib);
}
sfree(ib);
}
@@
-290,6
+294,7
@@
unsigned long long index_query(const void *t, int n, unsigned long long at)
if (n > count)
n = count;
if (n > count)
n = count;
+ assert(roots[n-1]);
node = NODE(t, roots[n-1]);
ret = 0;
node = NODE(t, roots[n-1]);
ret = 0;
@@
-321,6
+326,7
@@
unsigned long long index_order_stat(const void *t, double f)
roots = (const off_t *)((const char *)t + trie_get_index_offset(t));
count = trie_count(t);
roots = (const off_t *)((const char *)t + trie_get_index_offset(t));
count = trie_count(t);
+ assert(roots[count-1]);
node = NODE(t, roots[count-1]);
size = node->totalsize * f;
node = NODE(t, roots[count-1]);
size = node->totalsize * f;