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 a segment's sort caches.
 */
abstract class Lucy::Index::SortReader
    inherits Lucy::Index::DataReader {

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

    abstract nullable SortCache*
    Fetch_Sort_Cache(SortReader *self, String *field);

    /** Returns NULL, since multi-segment sort caches cannot be produced by
     * the default implementation.
     */
    public incremented nullable DataReader*
    Aggregator(SortReader *self, Vector *readers, I32Array *offsets);

}

class Lucy::Index::DefaultSortReader nickname DefSortReader
    inherits Lucy::Index::SortReader {

    Hash *caches;
    Hash *counts;
    Hash *null_ords;
    Hash *ord_widths;
    int32_t format;

    inert incremented DefaultSortReader*
    new(Schema *schema, Folder *folder, Snapshot *snapshot, Vector *segments,
        int32_t seg_tick);

    inert DefaultSortReader*
    init(DefaultSortReader *self, Schema *schema, Folder *folder,
         Snapshot *snapshot, Vector *segments, int32_t seg_tick);

    nullable SortCache*
    Fetch_Sort_Cache(DefaultSortReader *self, String *field);

    void
    Close(DefaultSortReader *self);

    public void
    Destroy(DefaultSortReader *self);
}