VArray* IxManager_segreaders_to_merge(IndexManager *self, PolyReader *reader, bool_t all) { VArray *seg_readers = VA_Shallow_Copy(PolyReader_Get_Seg_Readers(reader)); UNUSED_VAR(self); if (!all) { u32_t i; u32_t total_docs = 0; u32_t threshold = 0; const u32_t num_seg_readers = VA_Get_Size(seg_readers); /* Sort by ascending size in docs. */ VA_Sort(seg_readers, S_compare_doc_count); /* Find sparsely populated segments. */ for (i = 0; i < num_seg_readers; i++) { SegReader *seg_reader = (SegReader*)VA_Fetch(seg_readers, i); total_docs += SegReader_Doc_Count(seg_reader); if (total_docs < Math_fibonacci(i + 5)) { threshold = i + 1; } } VA_Splice(seg_readers, threshold, num_seg_readers); } return seg_readers; }
SortSpec* SortSpec_init(SortSpec *self, VArray *rules) { SortSpecIVARS *const ivars = SortSpec_IVARS(self); ivars->rules = VA_Shallow_Copy(rules); for (int32_t i = 0, max = VA_Get_Size(rules); i < max; i++) { SortRule *rule = (SortRule*)VA_Fetch(rules, i); CERTIFY(rule, SORTRULE); } return self; }
HeatMap* HeatMap_init(HeatMap *self, VArray *spans, uint32_t window) { VArray *spans_copy = VA_Shallow_Copy(spans); VArray *spans_plus_boosts; self->spans = NULL; self->window = window; VA_Sort(spans_copy, NULL, NULL); spans_plus_boosts = HeatMap_Generate_Proximity_Boosts(self, spans_copy); VA_Push_VArray(spans_plus_boosts, spans_copy); VA_Sort(spans_plus_boosts, NULL, NULL); self->spans = HeatMap_Flatten_Spans(self, spans_plus_boosts); DECREF(spans_plus_boosts); DECREF(spans_copy); return self; }
VArray* PolyReader_seg_readers(PolyReader *self) { PolyReaderIVARS *const ivars = PolyReader_IVARS(self); return (VArray*)VA_Shallow_Copy(ivars->sub_readers); }