Ejemplo n.º 1
0
void
SegWriter_Add_Doc_IMP(SegWriter *self, Doc *doc, float boost) {
    SegWriterIVARS *const ivars = SegWriter_IVARS(self);
    int32_t doc_id = (int32_t)Seg_Increment_Count(ivars->segment, 1);
    Inverter_Invert_Doc(ivars->inverter, doc);
    Inverter_Set_Boost(ivars->inverter, boost);
    SegWriter_Add_Inverted_Doc(self, ivars->inverter, doc_id);
}
Ejemplo n.º 2
0
// Adjust current doc id. We create our own doc_count rather than rely on
// SegReader's number because the DeletionsWriter and the SegReader are
// probably out of sync.
static void
S_adjust_doc_id(SegWriter *self, SegReader *reader, I32Array *doc_map) {
    SegWriterIVARS *const ivars = SegWriter_IVARS(self);
    int32_t doc_count = SegReader_Doc_Max(reader);
    for (size_t i = 1, max = I32Arr_Get_Size(doc_map); i < max; i++) {
        if (I32Arr_Get(doc_map, i) == 0) { doc_count--; }
    }
    Seg_Increment_Count(ivars->segment, doc_count);
}
Ejemplo n.º 3
0
static void
test_count(TestBatchRunner *runner) {
    Segment *segment = Seg_new(100);

    TEST_TRUE(runner, Seg_Get_Count(segment) == 0, "count starts off at 0");
    Seg_Set_Count(segment, 120);
    TEST_TRUE(runner, Seg_Get_Count(segment) == 120, "Set_Count");
    TEST_TRUE(runner, Seg_Increment_Count(segment, 10) == 130,
              "Increment_Count");

    DECREF(segment);
}