fixes a bug in the advance method of word_iterator, a=chris
fixes a bug in the advance method of word_iterator, a=chris
diff --git a/lib/index_bundle_iterators/group_iterator.php b/lib/index_bundle_iterators/group_iterator.php
index bacbbdae8..cb5ff829b 100644
--- a/lib/index_bundle_iterators/group_iterator.php
+++ b/lib/index_bundle_iterators/group_iterator.php
@@ -217,6 +217,7 @@ class GroupIterator extends IndexBundleIterator
$done = true;
}
} while(!$done);
+
return $pages;
}
diff --git a/lib/index_bundle_iterators/intersect_iterator.php b/lib/index_bundle_iterators/intersect_iterator.php
index 55dbc2b70..557d33b03 100644
--- a/lib/index_bundle_iterators/intersect_iterator.php
+++ b/lib/index_bundle_iterators/intersect_iterator.php
@@ -188,6 +188,7 @@ class IntersectIterator extends IndexBundleIterator
{
$biggest_gen_offset = $this->index_bundle_iterators[
0]->currentGenDocOffsetWithWord();
+ $old_biggest_gen_offset = $biggest_gen_offset;
for($i = 0; $i < $this->num_iterators; $i++) {
$old_gen_doc_offset[$i] = NULL;
@@ -200,7 +201,7 @@ class IntersectIterator extends IndexBundleIterator
$this->index_bundle_iterators[
$i]->currentGenDocOffsetWithWord();
if($new_gen_doc_offset[$i] == $old_gen_doc_offset[$i] &&
- $new_gen_doc_offset[$i] != $biggest_gen_offset) {
+ $new_gen_doc_offset[$i] != $old_biggest_gen_offset) {
return -1;
}
@@ -217,6 +218,7 @@ class IntersectIterator extends IndexBundleIterator
$all_same = false;
}
}
+ $old_biggest_gen_offset = $biggest_gen_offset;
if($all_same) {
return 1;
}
diff --git a/lib/index_bundle_iterators/word_iterator.php b/lib/index_bundle_iterators/word_iterator.php
index df9fc946b..0c2a31037 100644
--- a/lib/index_bundle_iterators/word_iterator.php
+++ b/lib/index_bundle_iterators/word_iterator.php
@@ -250,10 +250,12 @@ class WordIterator extends IndexBundleIterator
$this->current_offset = $this->next_offset;
} else {
$this->advanceGeneration();
+ $this->next_offset = $this->current_offset;
}
if($this->current_offset > $this->last_offset) {
$this->advanceGeneration();
+ $this->next_offset = $this->current_offset;
}
if($gen_doc_offset !== null) {
$last_current_generation = -1;
@@ -263,16 +265,16 @@ class WordIterator extends IndexBundleIterator
$last_current_generation = $this->current_generation;
$this->next_offset = $this->current_offset;
}
-
$this->index->setCurrentShard($this->current_generation, true);
-
- $this->current_offset =
- $this->index->getCurrentShard(
- )->nextPostingOffsetDocOffset($this->next_offset,
- $this->last_offset, $gen_doc_offset[1]);
- if($this->current_offset === false) {
- $this->current_offset = $this->last_offset + 1;
- $this->advanceGeneration();
+ if($this->current_generation == $gen_doc_offset[0]) {
+ $this->current_offset =
+ $this->index->getCurrentShard(
+ )->nextPostingOffsetDocOffset($this->next_offset,
+ $this->last_offset, $gen_doc_offset[1]);
+ if($this->current_offset === false) {
+ $this->advanceGeneration();
+ $this->next_offset = $this->current_offset;
+ }
}
$this->seen_docs =
($this->current_offset - $this->start_offset)/
diff --git a/models/phrase_model.php b/models/phrase_model.php
index 4a229ea31..c94085cda 100755
--- a/models/phrase_model.php
+++ b/models/phrase_model.php
@@ -286,6 +286,7 @@ class PhraseModel extends Model
if(isset($results['PAGES'])){
ksort($results['PAGES']);
+ $results["PAGES"] = array_values($results["PAGES"]);
}
if(count($results) == 0) {
$results = NULL;
@@ -308,7 +309,7 @@ class PhraseModel extends Model
$format_words = NULL;
}
- $results["PAGES"] = array_values($results["PAGES"]);
+
$output = $this->formatPageResults($results, $format_words);