fix index shard tests cases, a=chris

Chris Pollett [2011-08-28 05:Aug:th]
fix index shard tests cases, a=chris
Filename
lib/index_shard.php
tests/index_shard_test.php
diff --git a/lib/index_shard.php b/lib/index_shard.php
index 5f3243a34..14ccbf81e 100644
--- a/lib/index_shard.php
+++ b/lib/index_shard.php
@@ -535,7 +535,13 @@ class IndexShard extends PersistentStructure implements

         $num_docs_so_far = 0;
         $results = array();
-        $end = min($this->file_len - $this->docids_len, $last_offset);
+        /* wd_len is a kludgy fix because word_docs_len can get out of sync
+           when things are file-based and am still tracking down why
+        */
+        $wd_len = (isset($this->file_len )) ?
+            $this->file_len - $this->docids_len : $this->word_docs_len;
+        $end = min($wd_len, $last_offset);
+
         $num_docs_or_links =
             self::numDocsOrLinks($start_offset, $last_offset);

@@ -867,7 +873,6 @@ class IndexShard extends PersistentStructure implements
     {
         $results = array();
         $info = $this->getWordInfo($word_id, true);
-
         if($info !== false) {
             list($first_offset, $last_offset,
                 $num_docs_or_links) = $info;
diff --git a/tests/index_shard_test.php b/tests/index_shard_test.php
index ce2553c92..d19e8a5be 100644
--- a/tests/index_shard_test.php
+++ b/tests/index_shard_test.php
@@ -88,7 +88,7 @@ class IndexShardTest extends UnitTest
         $docid = "AAAAAAAA";
         $doc_hash = "BBBBBBBB";
         $doc_hosts_url = "CCCCCCCC";
-        $docid .= $doc_hash.$doc_hosts_url;
+        $docid .= $doc_hash . $doc_hosts_url;
         $offset = 5;
         $word_counts = array(
             'BBBBBBBB' => array(1, 3),
ViewGit