1 /******************************************************************************
2 * Copyright (C) 2009 by Niko Valimaki <nvalimak@cs.helsinki.fi> *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU Lesser General Public License as published *
6 * by the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12 * GNU Lesser General Public License for more details. *
14 * You should have received a copy of the GNU Lesser General Public License *
15 * along with this program; if not, write to the *
16 * Free Software Foundation, Inc., *
17 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
18 ******************************************************************************/
20 #ifndef _SXSI_FMIndexBuilder_h_
21 #define _SXSI_FMIndexBuilder_h_
23 #include "TextCollectionBuilder.h"
24 #include "TextStorage.h"
25 #include "Tools.h" // Defines ulong and uchar.
29 #include <utility> // Defines std::pair.
30 #include <cstring> // Defines std::strlen, added by Kim
32 // Un-comment to compare BWT against a BWT generated from class dynFMI:
33 //#define TCB_TEST_BWT
38 struct TCBuilderRep; // Pimpl
41 * Build an instance of the TextCollection class.
43 class FMIndexBuilder : public TextCollectionBuilder
46 FMIndexBuilder(unsigned samplerate, ulong estimatedInputLength);
48 virtual ~FMIndexBuilder();
53 * Must be a zero-terminated string from alphabet [1,255].
54 * Can not be called after makeStatic().
55 * The i'th text insertion gets an identifier value i-1.
56 * In other words, document identifiers start from 0.
58 * Second parameter tells if the text will be added to the
59 * index also. If false, text is added only to the TextCollection
60 * and can not be searched for.
62 virtual void InsertText(uchar const *, bool index = true);
66 * Convert to a static collection.
67 * New texts can not be inserted after this operation.
69 * TextStorage type defaults to TYPE_PLAIN_TEXT, another
70 * possible type is TYPE_LZ_INDEX.
72 virtual TextCollection * InitTextCollection(char type = TextStorage::TYPE_PLAIN_TEXT);
77 // Using Pimpl idiom to hide RLCSA implementation.
78 struct TCBuilderRep * p_;
80 // No copy constructor or assignment
81 FMIndexBuilder(FMIndexBuilder const&);
82 FMIndexBuilder& operator = (FMIndexBuilder const&);