예제 #1
0
파일: DocReader.c 프로젝트: kidaa/lucy
void
PolyDocReader_Close_IMP(PolyDocReader *self) {
    PolyDocReaderIVARS *const ivars = PolyDocReader_IVARS(self);
    if (ivars->readers) {
        for (uint32_t i = 0, max = Vec_Get_Size(ivars->readers); i < max; i++) {
            DocReader *reader = (DocReader*)Vec_Fetch(ivars->readers, i);
            if (reader) { DocReader_Close(reader); }
        }
        Vec_Clear(ivars->readers);
    }
}
예제 #2
0
파일: LexiconReader.c 프로젝트: apache/lucy
void
PolyLexReader_Close_IMP(PolyLexiconReader *self) {
    PolyLexiconReaderIVARS *const ivars = PolyLexReader_IVARS(self);
    if (ivars->readers) {
        for (size_t i = 0, max = Vec_Get_Size(ivars->readers); i < max; i++) {
            LexiconReader *reader
                = (LexiconReader*)Vec_Fetch(ivars->readers, i);
            if (reader) { LexReader_Close(reader); }
        }
        Vec_Clear(ivars->readers);
    }
}
예제 #3
0
파일: r_main.c 프로젝트: fielder/drend
void
R_Init (void)
{
	camera.center_x = vid.w / 2.0;
	camera.center_y = vid.h / 2.0;

	camera.fov_x = fov_x * (M_PI / 180.0);
	camera.dist = (vid.w / 2.0) / tan(camera.fov_x / 2.0);
	camera.fov_y = 2.0 * atan((vid.h / 2.0) / camera.dist);

	Vec_Clear (camera.pos);
	camera.altitude = 0.0;
	camera.angle = 0.0;

	S_SpanInit ();
}
예제 #4
0
파일: QueryParser.c 프로젝트: kidaa/lucy
static void
S_do_prune(QueryParser *self, Query *query) {
    if (Query_is_a(query, NOTQUERY)) {
        // Don't allow double negatives.
        NOTQuery *not_query = (NOTQuery*)query;
        Query *neg_query = NOTQuery_Get_Negated_Query(not_query);
        if (!Query_is_a(neg_query, MATCHALLQUERY)
            && !S_has_valid_clauses(neg_query)
           ) {
            MatchAllQuery *matchall = MatchAllQuery_new();
            NOTQuery_Set_Negated_Query(not_query, (Query*)matchall);
            DECREF(matchall);
        }
    }
    else if (Query_is_a(query, POLYQUERY)) {
        PolyQuery *polyquery = (PolyQuery*)query;
        Vector    *children  = PolyQuery_Get_Children(polyquery);

        // Recurse.
        for (uint32_t i = 0, max = Vec_Get_Size(children); i < max; i++) {
            Query *child = (Query*)Vec_Fetch(children, i);
            S_do_prune(self, child);
        }

        if (PolyQuery_is_a(polyquery, REQUIREDOPTIONALQUERY)
            || PolyQuery_is_a(polyquery, ORQUERY)
           ) {
            // Don't allow 'foo OR (-bar)'.
            Vector *children = PolyQuery_Get_Children(polyquery);
            for (uint32_t i = 0, max = Vec_Get_Size(children); i < max; i++) {
                Query *child = (Query*)Vec_Fetch(children, i);
                if (!S_has_valid_clauses(child)) {
                    Vec_Store(children, i, (Obj*)NoMatchQuery_new());
                }
            }
        }
        else if (PolyQuery_is_a(polyquery, ANDQUERY)) {
            // Don't allow '(-bar AND -baz)'.
            if (!S_has_valid_clauses((Query*)polyquery)) {
                Vector *children = PolyQuery_Get_Children(polyquery);
                Vec_Clear(children);
            }
        }
    }
}
예제 #5
0
파일: SortWriter.c 프로젝트: apache/lucy
void
SortWriter_Finish_IMP(SortWriter *self) {
    SortWriterIVARS *const ivars = SortWriter_IVARS(self);
    Vector *const field_writers = ivars->field_writers;

    // If we have no data, bail out.
    if (!ivars->temp_ord_out) { return; }

    // If we've either flushed or added segments, flush everything so that any
    // one field can use the entire margin up to mem_thresh.
    if (ivars->flush_at_finish) {
        for (size_t i = 1, max = Vec_Get_Size(field_writers); i < max; i++) {
            SortFieldWriter *field_writer
                = (SortFieldWriter*)Vec_Fetch(field_writers, i);
            if (field_writer) {
                SortFieldWriter_Flush(field_writer);
            }
        }
    }

    // Close down temp streams.
    OutStream_Close(ivars->temp_ord_out);
    OutStream_Close(ivars->temp_ix_out);
    OutStream_Close(ivars->temp_dat_out);

    for (size_t i = 1, max = Vec_Get_Size(field_writers); i < max; i++) {
        SortFieldWriter *field_writer
            = (SortFieldWriter*)Vec_Delete(field_writers, i);
        if (field_writer) {
            String *field = Seg_Field_Name(ivars->segment, (int32_t)i);
            SortFieldWriter_Flip(field_writer);
            int32_t count = SortFieldWriter_Finish(field_writer);
            Hash_Store(ivars->counts, field, (Obj*)Str_newf("%i32", count));
            int32_t null_ord = SortFieldWriter_Get_Null_Ord(field_writer);
            if (null_ord != -1) {
                Hash_Store(ivars->null_ords, field,
                           (Obj*)Str_newf("%i32", null_ord));
            }
            int32_t ord_width = SortFieldWriter_Get_Ord_Width(field_writer);
            Hash_Store(ivars->ord_widths, field,
                       (Obj*)Str_newf("%i32", ord_width));
        }

        DECREF(field_writer);
    }
    Vec_Clear(field_writers);

    // Store metadata.
    Seg_Store_Metadata_Utf8(ivars->segment, "sort", 4,
                            (Obj*)SortWriter_Metadata(self));

    // Clean up.
    Folder *folder   = ivars->folder;
    String *seg_name = Seg_Get_Name(ivars->segment);
    String *ord_path = Str_newf("%o/sort_ord_temp", seg_name);
    Folder_Delete(folder, ord_path);
    DECREF(ord_path);
    String *ix_path = Str_newf("%o/sort_ix_temp", seg_name);
    Folder_Delete(folder, ix_path);
    DECREF(ix_path);
    String *dat_path = Str_newf("%o/sort_dat_temp", seg_name);
    Folder_Delete(folder, dat_path);
    DECREF(dat_path);
}