Mailing List Archive

r3745 - in trunk: c_src/KinoSearch/Index c_src/KinoSearch/Search c_src/KinoSearch/Util perl/lib/KinoSearch/Util
Author: creamyg
Date: 2008-08-22 18:15:30 -0700 (Fri, 22 Aug 2008)
New Revision: 3745

Modified:
trunk/c_src/KinoSearch/Index/MultiReader.c
trunk/c_src/KinoSearch/Index/TermVector.c
trunk/c_src/KinoSearch/Search/FieldDocCollator.c
trunk/c_src/KinoSearch/Search/MultiSearcher.c
trunk/c_src/KinoSearch/Search/PhraseQuery.c
trunk/c_src/KinoSearch/Search/RangeScorer.c
trunk/c_src/KinoSearch/Search/Scorer.c
trunk/c_src/KinoSearch/Search/TermQuery.c
trunk/c_src/KinoSearch/Util/IntMap.bp
trunk/c_src/KinoSearch/Util/IntMap.c
trunk/perl/lib/KinoSearch/Util/IntMap.pm
Log:
Replace direct accesses for IntMap "size" member with Get_Size() method calls.


Modified: trunk/c_src/KinoSearch/Index/MultiReader.c
===================================================================
--- trunk/c_src/KinoSearch/Index/MultiReader.c 2008-08-22 23:39:36 UTC (rev 3744)
+++ trunk/c_src/KinoSearch/Index/MultiReader.c 2008-08-23 01:15:30 UTC (rev 3745)
@@ -202,7 +202,7 @@
IntMap *const starts = self->starts;
u32_t lo = 0;
u32_t mid;
- u32_t hi_tick = starts->size - 1;
+ u32_t hi_tick = IntMap_Get_Size(starts) - 1;
u32_t hi = hi_tick;

while (hi >= lo) {

Modified: trunk/c_src/KinoSearch/Index/TermVector.c
===================================================================
--- trunk/c_src/KinoSearch/Index/TermVector.c 2008-08-22 23:39:36 UTC (rev 3744)
+++ trunk/c_src/KinoSearch/Index/TermVector.c 2008-08-23 01:15:30 UTC (rev 3745)
@@ -20,16 +20,16 @@
/* Assign. */
self->field = CB_Clone(field);
self->text = CB_Clone(text);
- self->num_pos = positions->size;
+ self->num_pos = IntMap_Get_Size(positions);
self->positions = REFCOUNT_INC(positions);
self->start_offsets = REFCOUNT_INC(start_offsets);
self->end_offsets = REFCOUNT_INC(end_offsets);

- if ( positions->size != start_offsets->size
- || positions->size != end_offsets->size
+ if ( IntMap_Get_Size(start_offsets) != self->num_pos
+ || IntMap_Get_Size(end_offsets) != self->num_pos
) {
- CONFESS("Unbalanced arrays: %u32 %u32 %u32", positions->size,
- start_offsets->size, end_offsets->size);
+ CONFESS("Unbalanced arrays: %u32 %u32 %u32", self->num_pos,
+ IntMap_Get_Size(start_offsets), IntMap_Get_Size(end_offsets));
}

return self;

Modified: trunk/c_src/KinoSearch/Search/FieldDocCollator.c
===================================================================
--- trunk/c_src/KinoSearch/Search/FieldDocCollator.c 2008-08-22 23:39:36 UTC (rev 3744)
+++ trunk/c_src/KinoSearch/Search/FieldDocCollator.c 2008-08-23 01:15:30 UTC (rev 3745)
@@ -52,7 +52,7 @@

self->sort_caches[ self->size ] = REFCOUNT_INC(sort_cache);
self->reversed[ self->size ] = rev;
- self->cache_sizes[ self->size ] = sort_cache->size;
+ self->cache_sizes[ self->size ] = IntMap_Get_Size(sort_cache);
self->size++;
}


Modified: trunk/c_src/KinoSearch/Search/MultiSearcher.c
===================================================================
--- trunk/c_src/KinoSearch/Search/MultiSearcher.c 2008-08-22 23:39:36 UTC (rev 3744)
+++ trunk/c_src/KinoSearch/Search/MultiSearcher.c 2008-08-23 01:15:30 UTC (rev 3745)
@@ -73,9 +73,11 @@
static u32_t
subsearcher_tick(MultiSearcher *self, u32_t doc_num)
{
- u32_t tick;
- for (tick = 1; tick < self->starts->size; tick++) {
- if ((u32_t)IntMap_Get(self->starts, tick) > doc_num) {
+ IntMap *starts = self->starts;
+ u32_t max = IntMap_Get_Size(starts);
+ u32_t tick;
+ for (tick = 1; tick < max; tick++) {
+ if ((u32_t)IntMap_Get(starts, tick) > doc_num) {
return tick - 1;
}
}

Modified: trunk/c_src/KinoSearch/Search/PhraseQuery.c
===================================================================
--- trunk/c_src/KinoSearch/Search/PhraseQuery.c 2008-08-22 23:39:36 UTC (rev 3744)
+++ trunk/c_src/KinoSearch/Search/PhraseQuery.c 2008-08-23 01:15:30 UTC (rev 3745)
@@ -327,7 +327,7 @@
/* Set initial positions from first term. */
u32_t j;
IntMap *positions = term_vector->positions;
- for (j = positions->size; j > 0; j--) {
+ for (j = IntMap_Get_Size(positions); j > 0; j--) {
BitVec_Set(posit_vec, IntMap_Get(positions, j - 1));
}
}
@@ -337,7 +337,7 @@
IntMap *positions = term_vector->positions;

BitVec_Clear_All(other_posit_vec);
- for (j = positions->size; j > 0; j--) {
+ for (j = IntMap_Get_Size(positions); j > 0; j--) {
i32_t pos = IntMap_Get(positions, j - 1) - i;
if (pos >= 0) {
BitVec_Set(other_posit_vec, pos);
@@ -357,25 +357,27 @@
IntMap *tv_end_offsets = last_tv->end_offsets;
u32_t num_terms = terms->size - 1;
IntMap *valid_posits = BitVec_To_Array(posit_vec);
+ u32_t num_valid_posits = IntMap_Get_Size(valid_posits);
u32_t j = 0;
u32_t posit_tick;
float weight = Compiler_Get_Weight(self);
i = 0;

/* Add only those starts/ends that belong to a valid position. */
- for (posit_tick = 0; posit_tick < valid_posits->size; posit_tick++) {
+ for (posit_tick = 0; posit_tick < num_valid_posits; posit_tick++) {
i32_t valid_start_posit = IntMap_Get(valid_posits, posit_tick);
i32_t valid_end_posit = valid_start_posit + num_terms;
i32_t start_offset = 0, end_offset = 0;
Span *span;
+ u32_t max;

- for ( ; i < (u32_t)tv_start_positions->size; i++) {
+ for (max = IntMap_Get_Size(tv_start_positions); i < max; i++) {
if (IntMap_Get(tv_start_positions, i) == valid_start_posit) {
start_offset = IntMap_Get(tv_start_offsets, i);
break;
}
}
- for ( ; j < (u32_t)tv_end_positions->size; j++) {
+ for (max = IntMap_Get_Size(tv_end_positions); j < max; j++) {
if (IntMap_Get(tv_end_positions, j) == valid_end_posit) {
end_offset = IntMap_Get(tv_end_offsets, j);
break;

Modified: trunk/c_src/KinoSearch/Search/RangeScorer.c
===================================================================
--- trunk/c_src/KinoSearch/Search/RangeScorer.c 2008-08-22 23:39:36 UTC (rev 3744)
+++ trunk/c_src/KinoSearch/Search/RangeScorer.c 2008-08-23 01:15:30 UTC (rev 3745)
@@ -27,7 +27,7 @@
self->sort_cache = REFCOUNT_INC(sort_cache);

/* Derive. */
- self->max_docs = sort_cache->size;
+ self->max_docs = IntMap_Get_Size(sort_cache);

return self;
}

Modified: trunk/c_src/KinoSearch/Search/Scorer.c
===================================================================
--- trunk/c_src/KinoSearch/Search/Scorer.c 2008-08-22 23:39:36 UTC (rev 3744)
+++ trunk/c_src/KinoSearch/Search/Scorer.c 2008-08-23 01:15:30 UTC (rev 3745)
@@ -36,11 +36,12 @@
Scorer_collect(Scorer *self, HitCollector *hit_collector, u32_t start,
u32_t limit, u32_t hits_per_seg, IntMap *seg_starts)
{
- u32_t seg_num = 0;
- u32_t doc_num_thresh = 0;
- u32_t hits_this_seg = 0;
- u32_t hits_thresh = hits_per_seg;
- u32_t doc_num;
+ u32_t seg_num = 0;
+ u32_t doc_num_thresh = 0;
+ u32_t hits_this_seg = 0;
+ u32_t hits_thresh = hits_per_seg;
+ u32_t num_seg_starts = seg_starts ? IntMap_Get_Size(seg_starts) : 0;
+ u32_t doc_num;

if (start == 0)
CONFESS("start must be greater than 0.");
@@ -59,20 +60,20 @@
/* Bail out of loop if we've hit the user-spec'd limit. */
return;
}
- else if (seg_starts == NULL || seg_starts->size == 0) {
+ else if (seg_starts == NULL || num_seg_starts == 0) {
/* Must supply seg_starts to enable pruning. */
hits_thresh = U32_MAX;
doc_num_thresh = limit;
}
- else if (seg_num == (u32_t)seg_starts->size) {
+ else if (seg_num == num_seg_starts) {
/* We've finished the last segment. */
return;
}
else {
/* Get start of upcoming segment. */
- i32_t next_start = (seg_num + 1) < seg_starts->size
+ i32_t next_start = (seg_num + 1) < num_seg_starts
? IntMap_Get(seg_starts, seg_num + 1) : -1;
- i32_t this_start = seg_num < seg_starts->size
+ i32_t this_start = seg_num < num_seg_starts
? IntMap_Get(seg_starts, seg_num) : -1;
seg_num++;


Modified: trunk/c_src/KinoSearch/Search/TermQuery.c
===================================================================
--- trunk/c_src/KinoSearch/Search/TermQuery.c 2008-08-22 23:39:36 UTC (rev 3744)
+++ trunk/c_src/KinoSearch/Search/TermQuery.c 2008-08-23 01:15:30 UTC (rev 3745)
@@ -230,7 +230,7 @@
VArray *spans = VA_new(0);
TermVector *term_vector;
IntMap *starts, *ends;
- u32_t i;
+ u32_t i, max;
UNUSED_VAR(searchable);

if (!CB_Equals(parent->field, (Obj*)field)) return spans;
@@ -241,7 +241,7 @@

starts = term_vector->start_offsets;
ends = term_vector->end_offsets;
- for (i = 0; i < starts->size; i++) {
+ for (i = 0, max = IntMap_Get_Size(starts); i < max; i++) {
i32_t start = IntMap_Get(starts, i);
i32_t length = IntMap_Get(ends, i) - start;
Span *span = Span_new(start, length, TermCompiler_Get_Weight(self));

Modified: trunk/c_src/KinoSearch/Util/IntMap.bp
===================================================================
--- trunk/c_src/KinoSearch/Util/IntMap.bp 2008-08-22 23:39:36 UTC (rev 3744)
+++ trunk/c_src/KinoSearch/Util/IntMap.bp 2008-08-23 01:15:30 UTC (rev 3745)
@@ -19,6 +19,11 @@
i32_t
Get(IntMap *self, i32_t num);

+ /** Accessor.
+ */
+ u32_t
+ Get_Size(IntMap *self);
+
void
Destroy(IntMap *self);
}

Modified: trunk/c_src/KinoSearch/Util/IntMap.c
===================================================================
--- trunk/c_src/KinoSearch/Util/IntMap.c 2008-08-22 23:39:36 UTC (rev 3744)
+++ trunk/c_src/KinoSearch/Util/IntMap.c 2008-08-23 01:15:30 UTC (rev 3745)
@@ -35,6 +35,9 @@
return self->ints[num];
}

+u32_t
+IntMap_get_size(IntMap *self) { return self->size; }
+
void
IntMap_destroy(IntMap *self)
{

Modified: trunk/perl/lib/KinoSearch/Util/IntMap.pm
===================================================================
--- trunk/perl/lib/KinoSearch/Util/IntMap.pm 2008-08-22 23:39:36 UTC (rev 3744)
+++ trunk/perl/lib/KinoSearch/Util/IntMap.pm 2008-08-23 01:15:30 UTC (rev 3745)
@@ -45,9 +45,10 @@
{
AV *out_av = newAV();
chy_u32_t i;
+ chy_u32_t size = Kino_IntMap_Get_Size(self);

- av_extend(out_av, self->size);
- for (i = 0; i < self->size; i++) {
+ av_extend(out_av, size);
+ for (i = 0; i < size; i++) {
chy_i32_t result = Kino_IntMap_Get(self, i);
SV* result_sv = result == -1 ? newSV(0) : newSViv(result);
av_push(out_av, result_sv);
@@ -59,8 +60,7 @@
__AUTO_XS__

{ "KinoSearch::Util::IntMap" => {
- bind_methods => [qw( get )],
- make_getters => [qw( size )],
+ bind_methods => [qw( get get_size )],
}
}



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