예제 #1
0
파일: BitVecMatcher.c 프로젝트: apache/lucy
int32_t
BitVecMatcher_Next_IMP(BitVecMatcher *self) {
    BitVecMatcherIVARS *const ivars = BitVecMatcher_IVARS(self);
    ivars->doc_id
        = BitVec_Next_Hit(ivars->bit_vec, (size_t)(ivars->doc_id + 1));
    return ivars->doc_id == -1 ? 0 : ivars->doc_id;
}
예제 #2
0
static void
test_Clear_All(TestBatch *batch) {
    BitVector *bit_vec = BitVec_new(64);
    BitVec_Flip_Block(bit_vec, 0, 63);
    BitVec_Clear_All(bit_vec);
    TEST_INT_EQ(batch, BitVec_Next_Hit(bit_vec, 0), -1, "Clear_All");
    DECREF(bit_vec);
}
예제 #3
0
static void
test_Next_Hit(TestBatchRunner *runner) {
    for (int i = 24; i <= 33; i++) {
        BitVector *bit_vec = BitVec_new(64);
        BitVec_Set(bit_vec, (size_t)i);
        TEST_INT_EQ(runner, BitVec_Next_Hit(bit_vec, 0), i,
                    "Next_Hit for 0 is %d", i);
        TEST_INT_EQ(runner, BitVec_Next_Hit(bit_vec, 0), i,
                    "Next_Hit for 1 is %d", i);
        for (int probe = 15; probe <= i; probe++) {
            TEST_INT_EQ(runner, BitVec_Next_Hit(bit_vec, (size_t)probe), i,
                        "Next_Hit for %d is %d", probe, i);
        }
        for (int probe = i + 1; probe <= i + 9; probe++) {
            TEST_INT_EQ(runner, BitVec_Next_Hit(bit_vec, (size_t)probe), -1,
                        "no Next_Hit for %d when max is %d", probe, i);
        }
        DECREF(bit_vec);
    }
}
예제 #4
0
static void
test_Next_Hit(TestBatch *batch) {
    int i;

    for (i = 24; i <= 33; i++) {
        int probe;
        BitVector *bit_vec = BitVec_new(64);
        BitVec_Set(bit_vec, i);
        TEST_INT_EQ(batch, BitVec_Next_Hit(bit_vec, 0), i,
                    "Next_Hit for 0 is %d", i);
        TEST_INT_EQ(batch, BitVec_Next_Hit(bit_vec, 0), i,
                    "Next_Hit for 1 is %d", i);
        for (probe = 15; probe <= i; probe++) {
            TEST_INT_EQ(batch, BitVec_Next_Hit(bit_vec, probe), i,
                        "Next_Hit for %d is %d", probe, i);
        }
        for (probe = i + 1; probe <= i + 9; probe++) {
            TEST_INT_EQ(batch, BitVec_Next_Hit(bit_vec, probe), -1,
                        "no Next_Hit for %d when max is %d", probe, i);
        }
        DECREF(bit_vec);
    }
}
예제 #5
0
파일: BitVecMatcher.c 프로젝트: apache/lucy
int32_t
BitVecMatcher_Advance_IMP(BitVecMatcher *self, int32_t target) {
    BitVecMatcherIVARS *const ivars = BitVecMatcher_IVARS(self);
    ivars->doc_id = BitVec_Next_Hit(ivars->bit_vec, (size_t)target);
    return ivars->doc_id == -1 ? 0 : ivars->doc_id;
}
예제 #6
0
int32_t
BitVecMatcher_advance(BitVecMatcher *self, int32_t target) 
{
    self->doc_id = BitVec_Next_Hit(self->bit_vec, target);
    return self->doc_id == -1 ? 0 : self->doc_id;
}
예제 #7
0
int32_t
BitVecMatcher_next(BitVecMatcher *self)
{
    self->doc_id = BitVec_Next_Hit(self->bit_vec, self->doc_id + 1);
    return self->doc_id == -1 ? 0 : self->doc_id;
}