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;

/** Configure major components of an index.
 *
 * By default, a Lucy index consists of several main parts: lexicon,
 * postings, stored documents, deletions, and highlight data.  The readers and
 * writers for that data are spawned by Architecture.  Each component operates
 * at the segment level; Architecture's factory methods are used to build up
 * [](cfish:SegWriter) and
 * [](cfish:SegReader).
 */
public class Lucy::Plan::Architecture nickname Arch inherits Clownfish::Obj {

    /** Constructor.  Takes no arguments.
     */
    public inert incremented Architecture*
    new();

    /** Initialize an Architecture.
     */
    public inert Architecture*
    init(Architecture *self);

    /** Initialize a SegWriter, adding DataWriter components.
     *
     * @param writer A SegWriter.
     */
    void
    Init_Seg_Writer(Architecture *self, SegWriter *writer);

    /** Spawn a LexiconWriter and [](cfish:SegWriter.Register) it with the supplied SegWriter,
     * but don't add it to the SegWriter's writer stack.
     *
     * @param writer A SegWriter.
     */
    void
    Register_Lexicon_Writer(Architecture *self, SegWriter *writer);

    /** Spawn a PostingListWriter and [](cfish:SegWriter.Register) it with the supplied
     * SegWriter, adding it to the SegWriter's writer stack.  The SegWriter
     * must contain a previously registered LexiconWriter.
     *
     * @param writer A SegWriter.
     */
    void
    Register_Posting_List_Writer(Architecture *self, SegWriter *writer);

    /** Spawn a DataWriter and [](cfish:SegWriter.Register) it with the supplied SegWriter,
     * adding it to the SegWriter's writer stack.
     *
     * @param writer A SegWriter.
     */
    public void
    Register_Doc_Writer(Architecture *self, SegWriter *writer);

    /** Spawn a SortWriter and [](cfish:SegWriter.Register) it with the supplied SegWriter,
     * adding it to the SegWriter's writer stack.
     *
     * @param writer A SegWriter.
     */
    void
    Register_Sort_Writer(Architecture *self, SegWriter *writer);

    /** Spawn a HighlightWriter and [](cfish:SegWriter.Register) it with the supplied SegWriter,
     * adding it to the SegWriter's writer stack.
     *
     * @param writer A SegWriter.
     */
    void
    Register_Highlight_Writer(Architecture *self, SegWriter *writer);

    /** Spawn a DeletionsWriter and [](cfish:SegWriter.Register) it with the supplied SegWriter,
     * also calling [](cfish:SegWriter.Set_Del_Writer).
     *
     * @param writer A SegWriter.
     */
    void
    Register_Deletions_Writer(Architecture *self, SegWriter *writer);

    /** Initialize a SegReader, registering DataReaders.
     */
    void
    Init_Seg_Reader(Architecture *self, SegReader *reader);

    /** Spawn a DocReader and register it with the supplied SegReader.
     *
     * @param reader A SegReader.
     */
    public void
    Register_Doc_Reader(Architecture *self, SegReader *reader);

    /** Spawn a PostingListReader and [](cfish:SegReader.Register) it with the supplied SegReader.
     *
     * @param reader A SegReader.
     */
    void
    Register_Posting_List_Reader(Architecture *self, SegReader *reader);

    /** Spawn a SortReader and [](cfish:SegReader.Register) it with the supplied SegReader.
     *
     * @param reader A SegReader.
     */
    void
    Register_Sort_Reader(Architecture *self, SegReader *reader);

    /** Spawn a HighlightReader and [](cfish:SegReader.Register) it with the supplied
     * SegReader.
     *
     * @param reader A SegReader.
     */
    void
    Register_Highlight_Reader(Architecture *self, SegReader *reader);

    /** Spawn a LexiconReader and [](cfish:SegReader.Register) it with the supplied SegReader.
     *
     * @param reader A SegReader.
     */
    void
    Register_Lexicon_Reader(Architecture *self, SegReader *reader);

    /** Spawn a DeletionsReader and [](cfish:SegReader.Register) it with the supplied SegReader.
     *
     * @param reader A SegReader.
     */
    void
    Register_Deletions_Reader(Architecture *self, SegReader *reader);

    /** Factory method for creating a new Similarity object.
     */
    incremented Similarity*
    Make_Similarity(Architecture *self);

    int32_t
    Index_Interval(Architecture *self);

    int32_t
    Skip_Interval(Architecture *self);

    /** Returns true for any Architecture object. Subclasses should override
     * this weak check.
     */
    public bool
    Equals(Architecture *self, Obj *other);
}