Hash* SortWriter_metadata(SortWriter *self) { SortWriterIVARS *const ivars = SortWriter_IVARS(self); Hash *const metadata = DataWriter_metadata((DataWriter*)self); Hash_Store_Str(metadata, "counts", 6, INCREF(ivars->counts)); Hash_Store_Str(metadata, "null_ords", 9, INCREF(ivars->null_ords)); Hash_Store_Str(metadata, "ord_widths", 10, INCREF(ivars->ord_widths)); return metadata; }
Hash* LexWriter_metadata(LexiconWriter *self) { Hash *const metadata = DataWriter_metadata((DataWriter*)self); Hash *const counts = (Hash*)INCREF(self->counts); Hash *const ix_counts = (Hash*)INCREF(self->ix_counts); /* Placeholders. */ if (Hash_Get_Size(counts) == 0) { Hash_Store_Str(counts, "none", 4, (Obj*)CB_newf("%i32", (i32_t)0) ); Hash_Store_Str(ix_counts, "none", 4, (Obj*)CB_newf("%i32", (i32_t)0) ); } Hash_Store_Str(metadata, "counts", 6, (Obj*)counts); Hash_Store_Str(metadata, "index_counts", 12, (Obj*)ix_counts); return metadata; }
Hash* DefDelWriter_metadata(DefaultDeletionsWriter *self) { DefaultDeletionsWriterIVARS *const ivars = DefDelWriter_IVARS(self); Hash *const metadata = DataWriter_metadata((DataWriter*)self); Hash *const files = Hash_new(0); for (uint32_t i = 0, max = VA_Get_Size(ivars->seg_readers); i < max; i++) { SegReader *seg_reader = (SegReader*)VA_Fetch(ivars->seg_readers, i); if (ivars->updated[i]) { BitVector *deldocs = (BitVector*)VA_Fetch(ivars->bit_vecs, i); Segment *segment = SegReader_Get_Segment(seg_reader); Hash *mini_meta = Hash_new(2); Hash_Store_Str(mini_meta, "count", 5, (Obj*)CB_newf("%u32", (uint32_t)BitVec_Count(deldocs))); Hash_Store_Str(mini_meta, "filename", 8, (Obj*)S_del_filename(self, seg_reader)); Hash_Store(files, (Obj*)Seg_Get_Name(segment), (Obj*)mini_meta); } } Hash_Store_Str(metadata, "files", 5, (Obj*)files); return metadata; }