TermVector* TV_deserialize(TermVector *self, InStream *instream) { u32_t i; CharBuf *field = (CharBuf*)CB_deserialize(NULL, instream); CharBuf *text = (CharBuf*)CB_deserialize(NULL, instream); u32_t num_pos = InStream_Read_C32(instream); i32_t *posits, *starts, *ends; I32Array *positions, *start_offsets, *end_offsets; /* Read positional data. */ posits = MALLOCATE(num_pos, i32_t); starts = MALLOCATE(num_pos, i32_t); ends = MALLOCATE(num_pos, i32_t); for (i = 0; i < num_pos; i++) { posits[i] = InStream_Read_C32(instream); starts[i] = InStream_Read_C32(instream); ends[i] = InStream_Read_C32(instream); } positions = I32Arr_new_steal(posits, num_pos); start_offsets = I32Arr_new_steal(starts, num_pos); end_offsets = I32Arr_new_steal(ends, num_pos); self = self ? self : (TermVector*)VTable_Make_Obj(&TERMVECTOR); self = TV_init(self, field, text, positions, start_offsets, end_offsets); DECREF(positions); DECREF(start_offsets); DECREF(end_offsets); DECREF(text); DECREF(field); return self; }
PhraseQuery* PhraseQuery_deserialize(PhraseQuery *self, InStream *instream) { float boost = InStream_Read_F32(instream); CharBuf *field = CB_deserialize(NULL, instream); VArray *terms = VA_deserialize(NULL, instream); self = self ? self : (PhraseQuery*)VTable_Make_Obj(PHRASEQUERY); return S_do_init(self, field, terms, boost); }
Obj* Obj_deserialize(Obj *self, InStream *instream) { CharBuf *class_name = CB_deserialize(NULL, instream); if (!self) { VTable *vtable = VTable_singleton(class_name, (VTable*)&OBJ); self = VTable_Make_Obj(vtable); } else { CharBuf *my_class = VTable_Get_Name(self->vtable); if (!CB_Equals(class_name, (Obj*)my_class)) THROW("Class mismatch: %o %o", class_name, my_class); } DECREF(class_name); return Obj_init(self); }
DocVector* DefHLReader_fetch_doc_vec(DefaultHighlightReader *self, int32_t doc_id) { DocVector *doc_vec = DocVec_new(); int64_t file_pos; uint32_t num_fields; InStream_Seek(self->ix_in, doc_id * 8); file_pos = InStream_Read_I64(self->ix_in); InStream_Seek(self->dat_in, file_pos); num_fields = InStream_Read_C32(self->dat_in); while (num_fields--) { CharBuf *field = CB_deserialize(NULL, self->dat_in); ByteBuf *field_buf = BB_deserialize(NULL, self->dat_in); DocVec_Add_Field_Buf(doc_vec, field, field_buf); DECREF(field_buf); DECREF(field); } return doc_vec; }