Author: rooneg
Date: Sun Mar  6 19:01:49 2005
New Revision: 156378

URL: http://svn.apache.org/viewcvs?view=rev&rev=156378
Log:
Now that we've got the starting offset in the segment, move the code
that accounts for the offset on document retrieval in there, instead
of doing it in the segments code.

* src/index/segment.c
  (lcn_segment_get_document): subtract the offset from the doc and add
   a check for an invalid document id.

* src/index/segments.c
  (lcn_segments_get_document): don't subtract the offset from the doc.

Modified:
    incubator/lucene4c/trunk/src/index/segment.c
    incubator/lucene4c/trunk/src/index/segments.c

Modified: incubator/lucene4c/trunk/src/index/segment.c
URL: 
http://svn.apache.org/viewcvs/incubator/lucene4c/trunk/src/index/segment.c?view=diff&r1=156377&r2=156378
==============================================================================
--- incubator/lucene4c/trunk/src/index/segment.c (original)
+++ incubator/lucene4c/trunk/src/index/segment.c Sun Mar  6 19:01:49 2005
@@ -160,6 +160,11 @@
   lcn_document_t *d;
   int i;
 
+  if (docnum < segment->offset)
+    return lcn_error_create (APR_EINVAL, NULL, "invalid document id given");
+
+  docnum -= segment->offset;
+
   LCN_ERR (lcn_fielddata_get_doc (&fields, segment->field_data, docnum, pool));
 
   d = lcn_document_create (pool);

Modified: incubator/lucene4c/trunk/src/index/segments.c
URL: 
http://svn.apache.org/viewcvs/incubator/lucene4c/trunk/src/index/segments.c?view=diff&r1=156377&r2=156378
==============================================================================
--- incubator/lucene4c/trunk/src/index/segments.c (original)
+++ incubator/lucene4c/trunk/src/index/segments.c Sun Mar  6 19:01:49 2005
@@ -219,7 +219,7 @@
 
       return lcn_segment_get_document (doc,
                                        seg,
-                                       docnum - segments->starts[idx],
+                                       docnum,
                                        pool);
     }
 }


Reply via email to