[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-recutils] [PATCH 11/13] src: support index t rees that point to a l
From: |
Michał Masłowski |
Subject: |
[bug-recutils] [PATCH 11/13] src: support index t rees that point to a leaf too left of the key searched f or. |
Date: |
Mon, 20 Aug 2012 18:21:32 +0200 |
This is needed for performance tests to get correct results on a 20000
record set. This is a bug, would need better unit tests to fix
correctly.
---
ChangeLog | 7 +++++++
src/rec-idx-tree.c | 25 +++++++++++++++----------
2 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 78c97b3..7650fd2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2012-08-20 Michał Masłowski <address@hidden>
+
+ src: support index trees that point to a leaf too left of the key
+ searched for.
+ * src/rec-idx-tree.c (rec_idx_tree_scan_common): Check for
+ next-node offset before using the comparison result.
+
2012-08-19 Michał Masłowski <address@hidden>
src: keep indexes in rsets.
diff --git a/src/rec-idx-tree.c b/src/rec-idx-tree.c
index c641e71..751230c 100644
--- a/src/rec-idx-tree.c
+++ b/src/rec-idx-tree.c
@@ -562,12 +562,13 @@ rec_idx_tree_scan_common (rec_idx_tree_t idx_tree,
node = (const uint64_t*) root;
n_entries = (int) node[0];
- node++;
+ root = (const uint8_t*) &node[1];
empty = true;
while (n_entries > 0)
{
n_entries--;
+ node = (const uint64_t*) root;
if (root + sizeof (node[0]) * 2 >= idx_tree->end)
{
@@ -656,15 +657,6 @@ rec_idx_tree_scan_common (rec_idx_tree_t idx_tree,
return NULL; /* truncated index */
}
- if ((comparison < 0) || (left_ind > 0)
- || ((line & REC_IDX_TREE_NONFIRST_MASK) && first_only))
- {
- /* Skip the record, it has too small key or index. */
- left_ind--;
- right_ind--;
- continue;
- }
-
/* We could have parsed the last entry of the node. In that
case go to the start of the next one so the iterator always
starts at a leaf node entry. */
@@ -691,6 +683,19 @@ rec_idx_tree_scan_common (rec_idx_tree_t idx_tree,
}
}
+ if ((comparison < 0) || (left_ind > 0)
+ || ((line & REC_IDX_TREE_NONFIRST_MASK) && first_only))
+ {
+ /* Skip the record, it has too small key or index. */
+ if (left_ind > 0)
+ {
+ left_ind--;
+ }
+
+ right_ind--;
+ continue;
+ }
+
/* Prepare the iterator. */
iter_state = malloc (sizeof (*iter_state));
if (!iter_state)
--
1.7.11.4
- [bug-recutils] Index trees, Michał Masłowski, 2012/08/20
- [bug-recutils] [PATCH 01/13] src,torture: imple ment abstract record iterators., Michał Masłowski, 2012/08/20
- [bug-recutils] [PATCH 02/13] src,torture: imple ment initial index tree support without nodes., Michał Masłowski, 2012/08/20
- [bug-recutils] [PATCH 06/13] utils,doc: make re cfix --build-index add index trees., Michał Masłowski, 2012/08/20
- [bug-recutils] [PATCH 05/13] src: fix index file builder., Michał Masłowski, 2012/08/20
- [bug-recutils] [PATCH 04/13] src,torture: imple ment index builder., Michał Masłowski, 2012/08/20
- [bug-recutils] [PATCH 12/13] src: implement a tri vial query planner., Michał Masłowski, 2012/08/20
- [bug-recutils] [PATCH 09/13] src,torture: suppo rt duplicating index tree objects., Michał Masłowski, 2012/08/20
- [bug-recutils] [PATCH 10/13] src: keep indexes in rsets., Michał Masłowski, 2012/08/20
- [bug-recutils] [PATCH 11/13] src: support index t rees that point to a leaf too left of the key searched f or.,
Michał Masłowski <=
- [bug-recutils] [PATCH 08/13] utils: add recfix -- add-index command., Michał Masłowski, 2012/08/20
- [bug-recutils] [PATCH 13/13] torture: use index t rees for performance tests., Michał Masłowski, 2012/08/20
- [bug-recutils] [PATCH 07/13] src: fix index range checks., Michał Masłowski, 2012/08/20
- [bug-recutils] [PATCH 03/13] src,torture: imple ment index tree scans., Michał Masłowski, 2012/08/20