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;

/** Read postings data.
 *
 * PostingListReaders produce L<PostingList|Lucy::Index::PostingList>
 * objects which convey document matching information.
 */
public class Lucy::Index::PostingListReader nickname PListReader
    inherits Lucy::Index::DataReader {

    inert PostingListReader*
    init(PostingListReader *self, Schema *schema = NULL,
         Folder *folder = NULL, Snapshot *snapshot = NULL,
         VArray *segments = NULL, int32_t seg_tick = -1);

    /** Returns a PostingList, or NULL if either <code>field</code> is NULL or
     * <code>field</code> is not present in any documents.
     *
     * @param field A field name.
     * @param term If supplied, the PostingList will be pre-located to this
     * term using Seek().
     */
    public abstract incremented nullable PostingList*
    Posting_List(PostingListReader *self, String *field = NULL,
                 Obj *term = NULL);

    abstract LexiconReader*
    Get_Lex_Reader(PostingListReader *self);

    /** Returns NULL since PostingLists may only be iterated at the segment
     * level.
     */
    public incremented nullable PostingListReader*
    Aggregator(PostingListReader *self, VArray *readers, I32Array *offsets);
}

class Lucy::Index::DefaultPostingListReader nickname DefPListReader
    inherits Lucy::Index::PostingListReader {

    LexiconReader *lex_reader;

    inert incremented DefaultPostingListReader*
    new(Schema *schema, Folder *folder, Snapshot *snapshot, VArray *segments,
        int32_t seg_tick, LexiconReader *lex_reader);

    inert DefaultPostingListReader*
    init(DefaultPostingListReader *self, Schema *schema, Folder *folder,
         Snapshot *snapshot, VArray *segments, int32_t seg_tick,
         LexiconReader *lex_reader);

    public incremented nullable SegPostingList*
    Posting_List(DefaultPostingListReader *self, String *field = NULL,
                 Obj *term = NULL);

    LexiconReader*
    Get_Lex_Reader(DefaultPostingListReader *self);

    public void
    Close(DefaultPostingListReader *self);

    public void
    Destroy(DefaultPostingListReader *self);
}