The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.
/* Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

parcel Lucy;

/**
 * External sorter for raw postings.
 */
class Lucy::Index::PostingPool nickname PostPool
    inherits Lucy::Util::SortExternal {

    Schema            *schema;
    Snapshot          *snapshot;
    Segment           *segment;
    PolyReader        *polyreader;
    String            *field;
    LexiconWriter     *lex_writer;
    Lexicon           *lexicon;
    PostingList       *plist;
    MemoryPool        *mem_pool;
    I32Array          *doc_map;
    int32_t            field_num;
    int32_t            doc_base;
    int32_t            last_doc_id;
    uint32_t           post_count;
    OutStream         *lex_temp_out;
    OutStream         *post_temp_out;
    OutStream         *skip_out;
    InStream          *lex_temp_in;
    InStream          *post_temp_in;
    FieldType         *type;
    Posting           *posting;
    SkipStepper       *skip_stepper;
    int64_t            lex_start;
    int64_t            post_start;
    int64_t            lex_end;
    int64_t            post_end;

    inert incremented PostingPool*
    new(Schema *schema, Snapshot *snapshot, Segment *segment,
        PolyReader *polyreader, String *field,
        LexiconWriter *lex_writer, MemoryPool *mem_pool,
        OutStream *lex_temp_out, OutStream *post_temp_out,
        OutStream *skip_out);

    inert PostingPool*
    init(PostingPool *self, Schema *schema, Snapshot *snapshot,
         Segment *segment, PolyReader *polyreader, String *field,
         LexiconWriter *lex_writer, MemoryPool *mem_pool,
         OutStream *lex_temp_out, OutStream *post_temp_out,
         OutStream *skip_out);

    /** Add a field's inverted content.
     */
    void
    Add_Inversion(PostingPool *self, Inversion *inversion, int32_t doc_id,
                  float doc_boost, float length_norm);

    MemoryPool*
    Get_Mem_Pool(PostingPool *self);

    void
    Add_Segment(PostingPool *self, SegReader *reader, I32Array *doc_map,
                int32_t doc_base);

    void
    Flip(PostingPool *self);

    uint32_t
    Refill(PostingPool *self);

    /** Compares two non-NULL RawPosting objects.
     */
    int
    Compare(PostingPool *self, Obj **ptr_a, Obj **ptr_b);

    void
    Finish(PostingPool *self);

    void
    Flush(PostingPool *self);

    public void
    Destroy(PostingPool *self);
}