PolyLexicon* PolyLex_init(PolyLexicon *self, String *field, Vector *sub_readers) { uint32_t num_sub_readers = Vec_Get_Size(sub_readers); Vector *seg_lexicons = Vec_new(num_sub_readers); // Init. Lex_init((Lexicon*)self, field); PolyLexiconIVARS *const ivars = PolyLex_IVARS(self); ivars->term = NULL; ivars->lex_q = SegLexQ_new(num_sub_readers); // Derive. for (uint32_t i = 0; i < num_sub_readers; i++) { LexiconReader *lex_reader = (LexiconReader*)Vec_Fetch(sub_readers, i); if (lex_reader && CERTIFY(lex_reader, LEXICONREADER)) { Lexicon *seg_lexicon = LexReader_Lexicon(lex_reader, field, NULL); if (seg_lexicon != NULL) { Vec_Push(seg_lexicons, (Obj*)seg_lexicon); } } } ivars->seg_lexicons = seg_lexicons; PolyLex_Reset(self); return self; }
void PostPool_Add_Segment_IMP(PostingPool *self, SegReader *reader, I32Array *doc_map, int32_t doc_base) { PostingPoolIVARS *const ivars = PostPool_IVARS(self); LexiconReader *lex_reader = (LexiconReader*)SegReader_Fetch( reader, Class_Get_Name(LEXICONREADER)); Lexicon *lexicon = lex_reader ? LexReader_Lexicon(lex_reader, ivars->field, NULL) : NULL; if (lexicon) { PostingListReader *plist_reader = (PostingListReader*)SegReader_Fetch( reader, Class_Get_Name(POSTINGLISTREADER)); PostingList *plist = plist_reader ? PListReader_Posting_List(plist_reader, ivars->field, NULL) : NULL; if (!plist) { THROW(ERR, "Got a Lexicon but no PostingList for '%o' in '%o'", ivars->field, SegReader_Get_Seg_Name(reader)); } PostingPool *run = PostPool_new(ivars->schema, ivars->snapshot, ivars->segment, ivars->polyreader, ivars->field, ivars->lex_writer, ivars->mem_pool, ivars->lex_temp_out, ivars->post_temp_out, ivars->skip_out); PostingPoolIVARS *const run_ivars = PostPool_IVARS(run); run_ivars->lexicon = lexicon; run_ivars->plist = plist; run_ivars->doc_base = doc_base; run_ivars->doc_map = (I32Array*)INCREF(doc_map); PostPool_Add_Run(self, (SortExternal*)run); } }