The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
parcel KinoSearch cnick Kino;

/** Writer for sortable fields.
 *
 * Changes for format version 3:
 *    
 *   * Big-endian byte order instead of native byte order for ".ord" files.
 *   * "ord_widths" key added to metadata.
 *   * In variable-width cache formats, NULL entries get a file pointer in the
 *     ".ix" file instead of -1.
 */

class KinoSearch::Index::SortWriter inherits KinoSearch::Index::DataWriter {

    VArray     *field_writers;
    Hash       *counts;
    Hash       *null_ords;
    Hash       *ord_widths;
    OutStream  *temp_ord_out;
    OutStream  *temp_ix_out;
    OutStream  *temp_dat_out;
    MemoryPool *mem_pool;
    size_t      mem_thresh;  
    bool_t      flush_at_finish;

    inert int32_t current_file_format;

    inert incremented SortWriter*
    new(Schema *schema, Snapshot *snapshot, Segment *segment,
        PolyReader *polyreader);

    inert SortWriter* 
    init(SortWriter *self, Schema *schema, Snapshot *snapshot,
         Segment *segment, PolyReader *polyreader);

    /* Test only. */
    inert void
    set_default_mem_thresh(size_t mem_thresh);

    public void
    Add_Inverted_Doc(SortWriter *self, Inverter *inverter, int32_t doc_id);

    public void
    Add_Segment(SortWriter *self, SegReader *reader, 
                I32Array *doc_map = NULL); 

    public incremented Hash*
    Metadata(SortWriter *self);

    public int32_t
    Format(SortWriter *self);

    public void
    Finish(SortWriter *self);

    public void
    Destroy(SortWriter *self);
}

/* Copyright 2006-2011 Marvin Humphrey
 *
 * This program is free software; you can redistribute it and/or modify
 * under the same terms as Perl itself.
 */