X-Git-Url: http://git.nguyen.vg/gitweb/?a=blobdiff_plain;f=FMIndexBuilder.h;fp=FMIndexBuilder.h;h=a18540b91888c29b9f70267a5f50f24d3d12ee8c;hb=89dc22aee980ba16f757cd9a7f77478c2da50051;hp=0000000000000000000000000000000000000000;hpb=443151511a86083b21c1c06eb610f86b3aed35be;p=SXSI%2FTextCollection.git diff --git a/FMIndexBuilder.h b/FMIndexBuilder.h new file mode 100644 index 0000000..a18540b --- /dev/null +++ b/FMIndexBuilder.h @@ -0,0 +1,85 @@ +/****************************************************************************** + * Copyright (C) 2009 by Niko Valimaki * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Lesser General Public License as published * + * by the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Lesser General Public License for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ******************************************************************************/ + +#ifndef _SXSI_FMIndexBuilder_h_ +#define _SXSI_FMIndexBuilder_h_ + +#include "TextCollectionBuilder.h" +#include "TextStorage.h" +#include "Tools.h" // Defines ulong and uchar. + +#include +#include +#include // Defines std::pair. +#include // Defines std::strlen, added by Kim + +// Un-comment to compare BWT against a BWT generated from class dynFMI: +//#define TCB_TEST_BWT + + +namespace SXSI +{ + struct TCBuilderRep; // Pimpl + + /** + * Build an instance of the TextCollection class. + */ + class FMIndexBuilder : public TextCollectionBuilder + { + public: + FMIndexBuilder(unsigned samplerate, ulong estimatedInputLength); + + virtual ~FMIndexBuilder(); + + /** + * Insert text + * + * Must be a zero-terminated string from alphabet [1,255]. + * Can not be called after makeStatic(). + * The i'th text insertion gets an identifier value i-1. + * In other words, document identifiers start from 0. + * + * Second parameter tells if the text will be added to the + * index also. If false, text is added only to the TextCollection + * and can not be searched for. + */ + virtual void InsertText(uchar const *, bool index = true); + /** + * Make static + * + * Convert to a static collection. + * New texts can not be inserted after this operation. + * + * TextStorage type defaults to TYPE_PLAIN_TEXT, another + * possible type is TYPE_LZ_INDEX. + */ + virtual TextCollection * InitTextCollection(char type = TextStorage::TYPE_PLAIN_TEXT); + + private: + FMIndexBuilder(); + + // Using Pimpl idiom to hide RLCSA implementation. + struct TCBuilderRep * p_; + + // No copy constructor or assignment + FMIndexBuilder(FMIndexBuilder const&); + FMIndexBuilder& operator = (FMIndexBuilder const&); + }; +} +#endif