Author: rooneg
Date: Tue Mar 1 20:15:04 2005
New Revision: 155871
URL: http://svn.apache.org/viewcvs?view=rev&rev=155871
Log:
Fix reading docs from segments other than the first and iterating
over results from indices that have more than one segments.
Tests to follow tomorrow when I'm not so tired.
* src/index/segments.c
(lcn_segments_get_document): the actual document we want to return
needs to have the starting doc in that segment subtracted from it.
* src/index/index.c
(lcn_doc_iter_next): deal with the fact that segments may not have
a given term in them.
(lcn_index_term_docs): ditto. this should probably be moved into
a helper function of some sort.
Modified:
incubator/lucene4c/trunk/src/index/index.c
incubator/lucene4c/trunk/src/index/segments.c
Modified: incubator/lucene4c/trunk/src/index/index.c
URL:
http://svn.apache.org/viewcvs/incubator/lucene4c/trunk/src/index/index.c?view=diff&r1=155870&r2=155871
==============================================================================
--- incubator/lucene4c/trunk/src/index/index.c (original)
+++ incubator/lucene4c/trunk/src/index/index.c Tue Mar 1 20:15:04 2005
@@ -88,20 +88,30 @@
{
if (++itr->idx_in_seg == itr->count_in_seg)
{
- if (++itr->cur_seg == itr->num_segs)
- return lcn_error_create (APR_EOF, NULL, "iteration finished");
+ while (++itr->cur_seg < itr->num_segs)
+ {
+ lcn_error_t *err;
+
+ apr_pool_clear (itr->temppool);
+
+ itr->idx_in_seg = 0;
+
+ err = lcn_segments_term_docs (&itr->count_in_seg,
+ &itr->seg_docnums,
+ &itr->seg_freqnums,
+ itr->index->segments,
+ itr->cur_seg,
+ itr->term,
+ itr->temppool);
+ if (err && err->apr_err == APR_ENOENT)
+ lcn_error_clear (err);
+ else if (err)
+ return err;
+ else
+ return LCN_NO_ERROR;
+ }
- apr_pool_clear (itr->temppool);
-
- itr->idx_in_seg = 0;
-
- LCN_ERR (lcn_segments_term_docs (&itr->count_in_seg,
- &itr->seg_docnums,
- &itr->seg_freqnums,
- itr->index->segments,
- itr->cur_seg,
- itr->term,
- itr->temppool));
+ return lcn_error_create (APR_EOF, NULL, "iteration finished");
}
return LCN_NO_ERROR;
@@ -134,13 +144,29 @@
itr->temppool = lcn_pool_create (pool);
- LCN_ERR (lcn_segments_term_docs (&itr->count_in_seg,
- &itr->seg_docnums,
- &itr->seg_freqnums,
- idx->segments,
- itr->cur_seg,
- itr->term,
- itr->temppool));
+ for (itr->cur_seg = 0; itr->cur_seg < itr->num_segs; ++itr->cur_seg)
+ {
+ lcn_error_t *err;
+
+ apr_pool_clear (itr->temppool);
+
+ itr->idx_in_seg = 0;
+
+ err = lcn_segments_term_docs (&itr->count_in_seg,
+ &itr->seg_docnums,
+ &itr->seg_freqnums,
+ itr->index->segments,
+ itr->cur_seg,
+ itr->term,
+ itr->temppool);
+
+ if (err && err->apr_err == APR_ENOENT)
+ lcn_error_clear (err);
+ else if (err)
+ return err;
+ else
+ break;
+ }
*i = itr;
Modified: incubator/lucene4c/trunk/src/index/segments.c
URL:
http://svn.apache.org/viewcvs/incubator/lucene4c/trunk/src/index/segments.c?view=diff&r1=155870&r2=155871
==============================================================================
--- incubator/lucene4c/trunk/src/index/segments.c (original)
+++ incubator/lucene4c/trunk/src/index/segments.c Tue Mar 1 20:15:04 2005
@@ -218,6 +218,9 @@
idx,
lcn_segment_t *);
- return lcn_segment_get_document (doc, seg, docnum, pool);
+ return lcn_segment_get_document (doc,
+ seg,
+ docnum - segments->starts[idx],
+ pool);
}
}