Пример #1
0
int32_t
ORMatcher_next(ORMatcher *self) {
    if (self->size == 0) {
        return 0;
    }
    else {
        int32_t last_doc_id = self->top_hmd->doc;
        while (self->top_hmd->doc == last_doc_id) {
            int32_t top_doc_id = SI_top_next(self);
            if (!top_doc_id && self->size == 0) {
                return 0;
            }
        }
        return self->top_hmd->doc;
    }
}
Пример #2
0
int32_t
ORMatcher_Next_IMP(ORMatcher *self) {
    ORMatcherIVARS *const ivars = ORMatcher_IVARS(self);
    if (ivars->size == 0) {
        return 0;
    }
    else {
        int32_t last_doc_id = ivars->top_hmd->doc;
        while (ivars->top_hmd->doc == last_doc_id) {
            int32_t top_doc_id = SI_top_next(self, ivars);
            if (!top_doc_id && ivars->size == 0) {
                return 0;
            }
        }
        return ivars->top_hmd->doc;
    }
}
Пример #3
0
static int32_t
S_advance_after_current(ORScorer *self, ORScorerIVARS *ivars) {
    float *const     scores = ivars->scores;
    Matcher *child;

    // Get the top Matcher, or bail because there are no Matchers left.
    if (!ivars->size) { return 0; }
    else              { child = ivars->top_hmd->matcher; }

    // The top matcher will already be at the correct doc, so start there.
    ivars->doc_id        = ivars->top_hmd->doc;
    scores[0]            = Matcher_Score(child);
    ivars->matching_kids = 1;

    do {
        // Attempt to advance past current doc.
        int32_t top_doc_id
            = SI_top_next((ORMatcher*)self, (ORMatcherIVARS*)ivars);
        if (!top_doc_id) {
            if (!ivars->size) {
                break; // bail, no more to advance
            }
        }

        if (top_doc_id != ivars->doc_id) {
            // Bail, least doc in queue is now past the one we're scoring.
            break;
        }
        else {
            // Accumulate score.
            child = ivars->top_hmd->matcher;
            scores[ivars->matching_kids] = Matcher_Score(child);
            ivars->matching_kids++;
        }
    } while (true);

    return ivars->doc_id;
}