src_other/tuplebase/ZTupleIndex_FullText.h

00001 /*  @(#) $Id: ZTupleIndex_FullText.h,v 1.4 2007/04/01 12:46:17 agreen Exp $ */
00002 
00003 /* ------------------------------------------------------------
00004 Copyright (c) 2007 Andrew Green and Learning in Motion, Inc.
00005 http://www.zoolib.org
00006 
00007 Permission is hereby granted, free of charge, to any person obtaining a copy
00008 of this software and associated documentation files (the "Software"), to deal
00009 in the Software without restriction, including without limitation the rights
00010 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00011 copies of the Software, and to permit persons to whom the Software is
00012 furnished to do so, subject to the following conditions:
00013 
00014 The above copyright notice and this permission notice shall be included in
00015 all copies or substantial portions of the Software.
00016 
00017 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00018 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00020 COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00021 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00022 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00023 ------------------------------------------------------------ */
00024 
00025 #ifndef __ZTupleIndex_FullText__
00026 #define __ZTupleIndex_FullText__
00027 #include "zconfig.h"
00028 
00029 #include "ZCONFIG_SPI.h"
00030 
00031 // FullText is dependent on ICU features.
00032 #if ZCONFIG_SPI_Enabled(ICU)
00033 
00034 #include "ZTupleIndex.h"
00035 
00036 #include <map>
00037 
00038 // =================================================================================================
00039 #pragma mark -
00040 #pragma mark * ZTupleIndex_FullText
00041 
00042 class ZTupleIndex_FullText : public ZTupleIndex
00043         {
00044 public:
00045         ZTupleIndex_FullText(const ZTuplePropName& iPropName);
00046 
00047         virtual void Add(uint64 iID, const ZTuple* iTuple);
00048 
00049         virtual void Remove(uint64 iID, const ZTuple* iTuple);
00050 
00051         virtual void Find(const std::set<uint64>& iSkipIDs,
00052                 std::vector<const ZTBSpec::Criterion*>& ioCriteria, std::vector<uint64>& oIDs);
00053 
00054         virtual size_t CanHandle(const ZTBSpec::CriterionSect& iCriterionSect);
00055 
00056         virtual void WriteDescription(const ZStrimW& s);
00057 
00058 private:
00059         struct CPChunk
00060                 {
00061                 CPChunk(UTF32 iCPs[3]);
00062                 CPChunk(UTF32 iCP0, UTF32 iCP1, UTF32 iCP2);
00063                 
00064                 bool operator<(const CPChunk& iOther) const;
00065                 bool operator==(const CPChunk& iOther) const;
00066                 bool operator!=(const CPChunk& iOther) const;
00067 
00068                 const UTF32 fCP0;
00069                 const UTF32 fCP1;
00070                 const UTF32 fCP2;
00071                 };
00072 
00073         static void sGetCPChunks(const string& iPattern, set<CPChunk>& oCPChunks);
00074 
00075         size_t fCountTuples;
00076         map<CPChunk, set<uint64> > fMap;
00077 
00078         ZTuplePropName fPropName;
00079         };
00080 
00081 // =================================================================================================
00082 #pragma mark -
00083 #pragma mark * ZTupleIndexFactory_FullText
00084 
00085 class ZTupleIndexFactory_FullText : public ZTupleIndexFactory
00086         {
00087 public:
00088         ZTupleIndexFactory_FullText(const std::string& iPropName);
00089         virtual ZTupleIndex* Make();
00090 
00091 private:
00092         std::string fPropName;
00093         };
00094 
00095 #endif // ZCONFIG_SPI_Enabled(ICU)
00096 
00097 #endif // __ZTupleIndex_FullText__

Generated on Thu Jul 26 11:21:59 2007 for ZooLib by  doxygen 1.4.7