pike.git
/
src
/
modules
/
_WhiteFish
/
whitefish.c
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/modules/_WhiteFish/whitefish.c:204:
struct object *res, int docid, double *field_c[65], double mc ) { int i, j, k; unsigned char *nhits = malloc( nblobs*2 ); unsigned char *first = nhits+nblobs; int matrix[65]; double accum = 0.0;
+
int base_hit = 0;
MEMSET(matrix, 0, sizeof(matrix) ); for( i = 0; i<nblobs; i++ ) { nhits[i] = wf_blob_nhits( blobs[i] ); first[i] = 0; } for( i = 0; i<nhits[0]; i++) { double add; int hit = 1; Hit m = wf_blob_hit( blobs[0], i ); int h = m.raw; if( (add = (*field_c)[ MOFF(m) ]) == 0.0 ) continue;
-
+
if (h > base_hit)
+
base_hit = h;
for( j = 1; j<nblobs; j++) for( k = first[j]; k<nhits[j]; k++ ) { int h2 = wf_blob_hit_raw( blobs[j], k ); if( h2 > h ) { first[j]=k; if( h2-j == h ) hit++;
-
+
if (h2 - j > base_hit)
+
base_hit = h2 - j;
break; } } if( hit == nblobs ) accum += add/mc; }
-
+
/* Determine which blobs to step forward */
+
if (base_hit > 0) {
+
int did_next = 0;
+
for (i = 0; i < nblobs; i++)
+
if (nhits[i]) {
+
int max_hit = wf_blob_hit_raw(blobs[i], nhits[i] - 1);
+
if (max_hit < base_hit + i) {
+
wf_blob_next(blobs[i]);
+
did_next = 1;
+
}
+
}
+
if (!did_next)
+
base_hit = 0;
+
}
+
if (!base_hit) {
+
for (i = 0; i < nblobs; i++)
+
wf_blob_next(blobs[i]);
+
}
+
free( nhits ); if( accum > 0.0 ) wf_resultset_add( res, docid, (int)(accum*100) ); } static struct object *low_do_query_phrase( Blob **blobs, int nblobs, double field_c[65]) { struct object *res = wf_resultset_new();
pike.git/src/modules/_WhiteFish/whitefish.c:276:
if( max_c != 0.0 ) { /* Time to do the real work. :-) */ for( i = 0; i<nblobs; i++ ) /* Forward to first element */ wf_blob_next( blobs[i] ); /* Main loop: Find the smallest element in the blob array. */ while( 1 ) { unsigned int min = 0x7fffffff;
+
int test_phrase = 1;
for( i = 0; i<nblobs; i++ ) if( blobs[i]->eof ) goto end; else if( ((unsigned int)blobs[i]->docid) < min ) min = blobs[i]->docid; if( min == 0x7fffffff ) goto end; for( j = 0, i = 0; i < nblobs; i++ )
-
if( blobs[i]->docid != min )
-
goto
next
;
+
if( blobs[i]->docid != min )
{
+
test_phrase
= 0
;
+
break;
+
}
-
+
if (test_phrase) {
+
/* Test if hit is valid and advance in some or all blobs */
handle_phrase_hit( blobs, nblobs, res, min, &field_c, max_c );
-
-
next:
+
}
else
{
for( i = 0; i<nblobs; i++ ) if( blobs[i]->docid == min ) wf_blob_next( blobs[i] ); } }
-
+
}
end: /* Free workarea and return the result. */ UNSET_ONERROR( e ); __f->res = 0; free_stuff( __f ); return res; } static struct object *low_do_query_and( Blob **blobs, int nblobs,