コード例 #1
0
ファイル: DocVector.c プロジェクト: github188/SimpleCode
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);
}
コード例 #2
0
ファイル: DocVector.c プロジェクト: github188/SimpleCode
void
DocVec_Destroy_IMP(DocVector *self) {
    DocVectorIVARS *const ivars = DocVec_IVARS(self);
    DECREF(ivars->field_bufs);
    DECREF(ivars->field_vectors);
    SUPER_DESTROY(self, DOCVECTOR);
}
コード例 #3
0
ファイル: DocVector.c プロジェクト: github188/SimpleCode
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;
}
コード例 #4
0
ファイル: DocVector.c プロジェクト: github188/SimpleCode
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;
}
コード例 #5
0
ファイル: DocVector.c プロジェクト: github188/SimpleCode
VArray*
DocVec_Field_Names_IMP(DocVector *self) {
    DocVectorIVARS *const ivars = DocVec_IVARS(self);
    return Hash_Keys(ivars->field_bufs);
}
コード例 #6
0
ファイル: DocVector.c プロジェクト: github188/SimpleCode
ByteBuf*
DocVec_Field_Buf_IMP(DocVector *self, String *field) {
    DocVectorIVARS *const ivars = DocVec_IVARS(self);
    return (ByteBuf*)Hash_Fetch(ivars->field_bufs, (Obj*)field);
}
コード例 #7
0
ファイル: DocVector.c プロジェクト: github188/SimpleCode
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));
}
コード例 #8
0
ファイル: DocVector.c プロジェクト: github188/SimpleCode
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);
}
コード例 #9
0
ファイル: DocVector.c プロジェクト: theory/lucy
ByteBuf*
DocVec_field_buf(DocVector *self, const CharBuf *field) {
    DocVectorIVARS *const ivars = DocVec_IVARS(self);
    return (ByteBuf*)Hash_Fetch(ivars->field_bufs, (Obj*)field);
}
コード例 #10
0
ファイル: DocVector.c プロジェクト: theory/lucy
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));
}