1 /******************************************************************************
2 * Copyright (C) 2009 by Niko Valimaki <nvalimak@cs.helsinki.fi> *
3 * Text collection interface for an in-memory XQuery/XPath engine *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU Lesser General Public License as published *
7 * by the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU Lesser General Public License for more details. *
15 * You should have received a copy of the GNU Lesser General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ******************************************************************************/
21 #ifndef _SXSI_TextCollectionBuilder_h_
22 #define _SXSI_TextCollectionBuilder_h_
24 #include "TextCollection.h"
25 #include "Tools.h" // Defines ulong and uchar.
27 #include <utility> // Defines std::pair.
28 #include <cstring> // Defines std::strlen, added by Kim
30 // Un-comment to compare BWT against a BWT generated from class dynFMI:
31 //#define TCB_TEST_BWT
33 // Default samplerate for suffix array samples
34 #define TEXTCOLLECTION_DEFAULT_SAMPLERATE 64
40 struct TCBuilderRep; // Pimpl
43 * Build an instance of the TextCollection class.
45 class TextCollectionBuilder
48 explicit TextCollectionBuilder(unsigned samplerate = TEXTCOLLECTION_DEFAULT_SAMPLERATE);
49 ~TextCollectionBuilder();
54 * Must be a zero-terminated string from alphabet [1,255].
55 * Can not be called after makeStatic().
56 * The i'th text insertion gets an identifier value i-1.
57 * In other words, document identifiers start from 0.
59 void InsertText(uchar const *);
63 * Convert to a static collection; reduces space and time complexities.
64 * New texts can not be inserted after this operation.
66 TextCollection * InitTextCollection();
69 struct TCBuilderRep * p_;
71 // No copy constructor or assignment
72 TextCollectionBuilder(TextCollectionBuilder const&);
73 TextCollectionBuilder& operator = (TextCollectionBuilder const&);