Mailing List Archive

r3741 - in trunk: c_src/KinoSearch/Index perl/t
Author: creamyg
Date: 2008-08-19 13:44:38 -0700 (Tue, 19 Aug 2008)
New Revision: 3741

Modified:
trunk/c_src/KinoSearch/Index/DelDocs.bp
trunk/c_src/KinoSearch/Index/DelDocs.c
trunk/c_src/KinoSearch/Index/DocWriter.c
trunk/c_src/KinoSearch/Index/PostingPool.c
trunk/c_src/KinoSearch/Index/TermVectorsWriter.c
trunk/perl/t/210-deldocs.t
Log:
Have DelDocs map around deleted docs using 0 rather than -1.


Modified: trunk/c_src/KinoSearch/Index/DelDocs.bp
===================================================================
--- trunk/c_src/KinoSearch/Index/DelDocs.bp 2008-08-19 20:38:48 UTC (rev 3740)
+++ trunk/c_src/KinoSearch/Index/DelDocs.bp 2008-08-19 20:44:38 UTC (rev 3741)
@@ -38,13 +38,13 @@

/** Produce an array of i32_t which wraps around deleted documents. The
* position in the array represents the original doc number, and the value
- * represents the new number. Deleted docs are assigned the value -1. So
+ * represents the new number. Deleted docs are assigned the value - 0, so
* if you had 4 docs and doc 2 was deleted, the array would have the
- * values... { 1, -1, 2, 3 }.
+ * values... { 1, 0, 2, 3 }.
*
* @param offset Value which gets added to each valid document number.
* With an offset of 1000, the array in the previous example would be
- * { 1001, -1, 1002, 1003 }.
+ * { 1001, 0, 1002, 1003 }.
*/
incremented IntMap*
Generate_Doc_Map(DelDocs *self, i32_t offset);

Modified: trunk/c_src/KinoSearch/Index/DelDocs.c
===================================================================
--- trunk/c_src/KinoSearch/Index/DelDocs.c 2008-08-19 20:38:48 UTC (rev 3740)
+++ trunk/c_src/KinoSearch/Index/DelDocs.c 2008-08-19 20:44:38 UTC (rev 3741)
@@ -123,16 +123,13 @@
DelDocs_generate_doc_map(DelDocs *self, i32_t offset)
{
i32_t max = self->seg_info->doc_count;
- i32_t *doc_map = MALLOCATE(max + 1, i32_t);
+ i32_t *doc_map = CALLOCATE(max + 1, i32_t);
i32_t new_doc_num;
i32_t i;

- /* -1 for a deleted doc, a new number otherwise */
- doc_map[0] = -1;
+ /* 0 for a deleted doc, a new number otherwise */
for (i = 1, new_doc_num = 1; i <= max; i++) {
- if (DelDocs_Get(self, i))
- doc_map[i] = -1;
- else
+ if (!DelDocs_Get(self, i))
doc_map[i] = offset + new_doc_num++;
}


Modified: trunk/c_src/KinoSearch/Index/DocWriter.c
===================================================================
--- trunk/c_src/KinoSearch/Index/DocWriter.c 2008-08-19 20:38:48 UTC (rev 3740)
+++ trunk/c_src/KinoSearch/Index/DocWriter.c 2008-08-19 20:44:38 UTC (rev 3741)
@@ -105,7 +105,7 @@
u32_t orig, max;

for (orig = 1, max = SegReader_Max_Docs(reader); orig <= max; orig++) {
- if (IntMap_Get(doc_map, orig) != -1) {
+ if (IntMap_Get(doc_map, orig)) {
u64_t start = OutStream_Tell(ds_out);

/* Copy record over. */

Modified: trunk/c_src/KinoSearch/Index/PostingPool.c
===================================================================
--- trunk/c_src/KinoSearch/Index/PostingPool.c 2008-08-19 20:38:48 UTC (rev 3740)
+++ trunk/c_src/KinoSearch/Index/PostingPool.c 2008-08-19 20:44:38 UTC (rev 3741)
@@ -284,7 +284,7 @@
if (doc_map != NULL) {
const i32_t remapped = IntMap_Get(doc_map,
raw_posting->doc_num - doc_base);
- if (remapped == -1)
+ if ( !remapped )
continue;
raw_posting->doc_num = remapped;
}

Modified: trunk/c_src/KinoSearch/Index/TermVectorsWriter.c
===================================================================
--- trunk/c_src/KinoSearch/Index/TermVectorsWriter.c 2008-08-19 20:38:48 UTC (rev 3740)
+++ trunk/c_src/KinoSearch/Index/TermVectorsWriter.c 2008-08-19 20:44:38 UTC (rev 3741)
@@ -170,7 +170,7 @@
OutStream *tvx_out = self->tvx_out;
for (orig = 1; orig <= max_docs; orig++) {
/* Skip deleted docs. */
- if (doc_map && IntMap_Get(doc_map, orig) == -1)
+ if (doc_map && !IntMap_Get(doc_map, orig))
continue;

/* Write file pointer. */

Modified: trunk/perl/t/210-deldocs.t
===================================================================
--- trunk/perl/t/210-deldocs.t 2008-08-19 20:38:48 UTC (rev 3740)
+++ trunk/perl/t/210-deldocs.t 2008-08-19 20:44:38 UTC (rev 3741)
@@ -36,15 +36,15 @@
is( $deldocs->count, 1, "set increments num_deletions, once" );

my $doc_map = $deldocs->generate_doc_map(0);
-my @correct = ( 1, 2, undef, 3, 4 );
+my @correct = ( 1, 2, 0, 3, 4 );
my @got;
push @got, $doc_map->get($_) for 1 .. 5;
is_deeply( \@got, \@correct, "doc map maps around deleted docs" );

$doc_map = $deldocs->generate_doc_map(100);
is( $doc_map->get(4), 103, "doc map handles offset correctly" );
-is( $doc_map->get(3), undef, "doc_map handled deletions correctly" );
-is( $doc_map->get(6), undef, "doc_map returns undef for out of range" );
+ok( !$doc_map->get(3), "doc_map handled deletions correctly" );
+ok( !$doc_map->get(6), "doc_map handles out of range doc numbers correctly" );

$deldocs->clear(3);
$deldocs->clear(3);


_______________________________________________
kinosearch-commits mailing list
kinosearch-commits@rectangular.com
http://www.rectangular.com/mailman/listinfo/kinosearch-commits