Ejemplo n.º 1
0
TermVector*
DocVec_Term_Vector_IMP(DocVector *self, String *field,
                       String *term_text) {
    DocVectorIVARS *const ivars = DocVec_IVARS(self);
    Hash *field_vector = (Hash*)Hash_Fetch(ivars->field_vectors, (Obj*)field);

    // If no cache hit, try to fill cache.
    if (field_vector == NULL) {
        ByteBuf *field_buf
            = (ByteBuf*)Hash_Fetch(ivars->field_bufs, (Obj*)field);

        // Bail if there's no content or the field isn't highlightable.
        if (field_buf == NULL) { return NULL; }

        field_vector = S_extract_tv_cache(field_buf);
        Hash_Store(ivars->field_vectors, (Obj*)field, (Obj*)field_vector);
    }

    // Get a buf for the term text or bail.
    ByteBuf *tv_buf = (ByteBuf*)Hash_Fetch(field_vector, (Obj*)term_text);
    if (tv_buf == NULL) {
        return NULL;
    }

    return S_extract_tv_from_tv_buf(field, term_text, tv_buf);
}
Ejemplo n.º 2
0
void
DocVec_Destroy_IMP(DocVector *self) {
    DocVectorIVARS *const ivars = DocVec_IVARS(self);
    DECREF(ivars->field_bufs);
    DECREF(ivars->field_vectors);
    SUPER_DESTROY(self, DOCVECTOR);
}
Ejemplo n.º 3
0
DocVector*
DocVec_Deserialize_IMP(DocVector *self, InStream *instream) {
    DocVectorIVARS *const ivars = DocVec_IVARS(self);
    ivars->field_bufs    = Freezer_read_hash(instream);
    ivars->field_vectors = Freezer_read_hash(instream);
    return self;
}
Ejemplo n.º 4
0
DocVector*
DocVec_init(DocVector *self) {
    DocVectorIVARS *const ivars = DocVec_IVARS(self);
    ivars->field_bufs    = Hash_new(0);
    ivars->field_vectors = Hash_new(0);
    return self;
}
Ejemplo n.º 5
0
VArray*
DocVec_Field_Names_IMP(DocVector *self) {
    DocVectorIVARS *const ivars = DocVec_IVARS(self);
    return Hash_Keys(ivars->field_bufs);
}
Ejemplo n.º 6
0
ByteBuf*
DocVec_Field_Buf_IMP(DocVector *self, String *field) {
    DocVectorIVARS *const ivars = DocVec_IVARS(self);
    return (ByteBuf*)Hash_Fetch(ivars->field_bufs, (Obj*)field);
}
Ejemplo n.º 7
0
void
DocVec_Add_Field_Buf_IMP(DocVector *self, String *field,
                         ByteBuf *field_buf) {
    DocVectorIVARS *const ivars = DocVec_IVARS(self);
    Hash_Store(ivars->field_bufs, (Obj*)field, INCREF(field_buf));
}
Ejemplo n.º 8
0
void
DocVec_Serialize_IMP(DocVector *self, OutStream *outstream) {
    DocVectorIVARS *const ivars = DocVec_IVARS(self);
    Freezer_serialize_hash(ivars->field_bufs, outstream);
    Freezer_serialize_hash(ivars->field_vectors, outstream);
}
Ejemplo n.º 9
0
ByteBuf*
DocVec_field_buf(DocVector *self, const CharBuf *field) {
    DocVectorIVARS *const ivars = DocVec_IVARS(self);
    return (ByteBuf*)Hash_Fetch(ivars->field_bufs, (Obj*)field);
}
Ejemplo n.º 10
0
void
DocVec_add_field_buf(DocVector *self, const CharBuf *field,
                     ByteBuf *field_buf) {
    DocVectorIVARS *const ivars = DocVec_IVARS(self);
    Hash_Store(ivars->field_bufs, (Obj*)field, INCREF(field_buf));
}