aboutsummaryrefslogtreecommitdiffstats
path: root/libibex/dumpindex.c
diff options
context:
space:
mode:
Diffstat (limited to 'libibex/dumpindex.c')
-rw-r--r--libibex/dumpindex.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/libibex/dumpindex.c b/libibex/dumpindex.c
index 92f4b08845..cf4f02cc8a 100644
--- a/libibex/dumpindex.c
+++ b/libibex/dumpindex.c
@@ -9,6 +9,30 @@
extern void ibex_hash_dump(struct _IBEXIndex *index);
+static void
+index_iterate(struct _IBEXIndex *index)
+{
+ struct _IBEXCursor *idc;
+ int len;
+ char *key;
+ int total = 0, totallen = 0;
+
+ idc = index->klass->get_cursor(index);
+ key = idc->klass->next_key(idc, &len);
+ while (len) {
+ total++;
+ totallen += len;
+ printf("%s\n", key);
+ g_free(key);
+ key = idc->klass->next_key(idc, &len);
+ }
+ g_free(key);
+
+ idc->klass->close(idc);
+
+ printf("Iterate Totals: %d items, total bytes %d\n", total, totallen);
+}
+
int main(int argc, char **argv)
{
ibex *ib;
@@ -26,6 +50,9 @@ int main(int argc, char **argv)
ibex_hash_dump(ib->words->wordindex);
ibex_hash_dump(ib->words->nameindex);
+ index_iterate(ib->words->wordindex);
+ index_iterate(ib->words->nameindex);
+
ibex_close(ib);
return 0;