summaryrefslogtreecommitdiffstats
path: root/3rdparty/clucene/src/CLucene/search/CachingWrapperFilter.h
diff options
context:
space:
mode:
authorQt by Nokia <qt-info@nokia.com>2011-04-27 12:05:43 +0200
committeraxis <qt-info@nokia.com>2011-04-27 12:05:43 +0200
commit50123887ba0f33cf47520bee7c419d68742af2d1 (patch)
tree0eb8679b9e4e4370e59b44bfdcae616816e39aca /3rdparty/clucene/src/CLucene/search/CachingWrapperFilter.h
Initial import from the monolithic Qt.
This is the beginning of revision history for this module. If you want to look at revision history older than this, please refer to the Qt Git wiki for how to use Git history grafting. At the time of writing, this wiki is located here: http://qt.gitorious.org/qt/pages/GitIntroductionWithQt If you have already performed the grafting and you don't see any history beyond this commit, try running "git log" with the "--follow" argument. Branched from the monolithic repo, Qt master branch, at commit 896db169ea224deb96c59ce8af800d019de63f12
Diffstat (limited to '3rdparty/clucene/src/CLucene/search/CachingWrapperFilter.h')
-rw-r--r--3rdparty/clucene/src/CLucene/search/CachingWrapperFilter.h80
1 files changed, 80 insertions, 0 deletions
diff --git a/3rdparty/clucene/src/CLucene/search/CachingWrapperFilter.h b/3rdparty/clucene/src/CLucene/search/CachingWrapperFilter.h
new file mode 100644
index 000000000..e48a18292
--- /dev/null
+++ b/3rdparty/clucene/src/CLucene/search/CachingWrapperFilter.h
@@ -0,0 +1,80 @@
+/*------------------------------------------------------------------------------
+* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
+*
+* Distributable under the terms of either the Apache License (Version 2.0) or
+* the GNU Lesser General Public License, as specified in the COPYING file.
+------------------------------------------------------------------------------*/
+#ifndef _lucene_search_CachingWrapperFilter_
+#define _lucene_search_CachingWrapperFilter_
+
+#include "CLucene/util/BitSet.h"
+#include "CLucene/index/IndexReader.h"
+#include "Filter.h"
+
+CL_NS_DEF(search)
+/**
+ * Wraps another filter's result and caches it. The purpose is to allow
+ * filters to implement this and allow itself to be cached. Alternatively,
+ * use the CachingWrapperFilter to cache the filter.
+ */
+class AbstractCachingFilter: public Filter
+{
+ class BitSetHolder: LUCENE_BASE{
+ bool deleteBs;
+ public:
+ BitSetHolder(CL_NS(util)::BitSet* bits, bool deleteBs);
+ ~BitSetHolder();
+ CL_NS(util)::BitSet* bits;
+ };
+ void closeCallback(CL_NS(index)::IndexReader* reader, void* param);
+ typedef CL_NS(util)::CLHashMap<CL_NS(index)::IndexReader*,
+ BitSetHolder*,
+ CL_NS(util)::Compare::Void<CL_NS(index)::IndexReader>,
+ CL_NS(util)::Equals::Void<CL_NS(index)::IndexReader>,
+ CL_NS(util)::Deletor::Object<CL_NS(index)::IndexReader>,
+ CL_NS(util)::Deletor::Object<BitSetHolder> > CacheType;
+
+ CacheType cache;
+
+protected:
+ AbstractCachingFilter( const AbstractCachingFilter& copy );
+ virtual CL_NS(util)::BitSet* doBits( CL_NS(index)::IndexReader* reader ) = 0;
+ virtual bool doShouldDeleteBitSet( CL_NS(util)::BitSet* bits ){ return false; }
+ AbstractCachingFilter();
+public:
+ virtual ~AbstractCachingFilter();
+
+ /** Returns a BitSet with true for documents which should be permitted in
+ search results, and false for those that should not. */
+ CL_NS(util)::BitSet* bits( CL_NS(index)::IndexReader* reader );
+
+ virtual Filter *clone() const = 0;
+ virtual TCHAR *toString() = 0;
+
+ bool shouldDeleteBitSet( const CL_NS(util)::BitSet* bits ) const{ return false; }
+};
+
+/**
+ * Wraps another filter's result and caches it. The purpose is to allow
+ * filters to simply filter, and then wrap with this class to add
+ * caching, keeping the two concerns decoupled yet composable.
+ */
+class CachingWrapperFilter: public AbstractCachingFilter
+{
+private:
+ Filter* filter;
+ bool deleteFilter;
+protected:
+ CachingWrapperFilter( const CachingWrapperFilter& copy );
+ CL_NS(util)::BitSet* doBits( CL_NS(index)::IndexReader* reader );
+ bool doShouldDeleteBitSet( CL_NS(util)::BitSet* bits );
+public:
+ CachingWrapperFilter( Filter* filter, bool deleteFilter=true );
+ ~CachingWrapperFilter();
+
+ Filter *clone() const;
+ TCHAR *toString();
+};
+
+CL_NS_END
+#endif