~ubuntu-branches/ubuntu/raring/clucene-core/raring-proposed

« back to all changes in this revision

Viewing changes to src/core/CLucene/search/FilterResultCache.h

  • Committer: Package Import Robot
  • Author(s): Fathi Boudra
  • Date: 2012-08-11 09:33:38 UTC
  • mfrom: (1.1.5)
  • Revision ID: package-import@ubuntu.com-20120811093338-fgrx41ftqew3qt6a
Tags: 2.3.3.4-1
* New upstream release (Closes: #661703).
* Convert package to multiarch.
* Drop obsolete patches:
  - 01_add_missing_include_bug505667.diff
  - 02_posixness_fix_bug530308.diff
* Add patches:
  - Fixing_ZLIB_configuration_in_shared_CMakeLists.patch
  - Fix-pkgconfig-file-by-adding-clucene-shared-library.patch
  - Install-contribs-lib.patch
  - multiarch.patch
* Update debian/compat: bump to 8.
* Update debian/control:
  - update build dependencies (add cmake, libboost-dev and libz-dev).
  - bump Standards-Version to 3.9.3.
  - rename packages due to ABI bump: libclucene0ldbl -> libclucene-core1.
  - add libclucene-contribs1 package.
* Update debian/rules:
  - rewrite to use CMake.
  - add multiarch support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*------------------------------------------------------------------------------
 
2
* Copyright (C) 2003-2006 Ben van Klinken and the CLucene Team
 
3
 
4
* Distributable under the terms of either the Apache License (Version 2.0) or 
 
5
* the GNU Lesser General Public License, as specified in the COPYING file.
 
6
------------------------------------------------------------------------------*/
 
7
#ifndef _lucene_search_FilterResultCache_
 
8
#define _lucene_search_FilterResultCache_
 
9
 
 
10
CL_CLASS_DEF(index,IndexReader)
 
11
 
 
12
CL_NS_DEF(search)
 
13
 
 
14
/**
 
15
 * Holds one cached result
 
16
 */
 
17
template<class T>
 
18
class ResultHolder : LUCENE_BASE
 
19
{
 
20
        bool deleteRes;
 
21
public:
 
22
        T* result;
 
23
        
 
24
        ResultHolder( T * result, bool deleteRes )
 
25
    {
 
26
                this->result = result;
 
27
                this->deleteRes = deleteRes;
 
28
        }
 
29
        ~ResultHolder(){
 
30
                if ( deleteRes )
 
31
                        _CLDELETE( result );
 
32
        }       
 
33
};
 
34
 
 
35
/**
 
36
 * Wraps another filter's result and caches it.  The purpose is to allow
 
37
 * filters to implement this and allow itself to be cached. Alternatively,
 
38
 * use the CachingWrapperFilter to cache the filter.
 
39
 */
 
40
template<class T>
 
41
class FilterResultCache
 
42
{
 
43
        typedef CL_NS(util)::CLHashMap<
 
44
        CL_NS(index)::IndexReader*, 
 
45
        BitSetHolder*, 
 
46
        CL_NS(util)::Compare::Void<CL_NS(index)::IndexReader>,
 
47
        CL_NS(util)::Equals::Void<CL_NS(index)::IndexReader>,
 
48
        CL_NS(util)::Deletor::Object<CL_NS(index)::IndexReader>, 
 
49
        CL_NS(util)::Deletor::Object<ResultHolder<T> > 
 
50
    > CacheType; 
 
51
 
 
52
        CacheType   cache;
 
53
    bool        bDeleteResults;
 
54
        DEFINE_MUTEX( cache_LOCK )
 
55
 
 
56
 
 
57
public:
 
58
        FilterResultCache( bool bDeleteResults );
 
59
    virtual ~FilterResultCache();
 
60
 
 
61
    T* getResult( CL_NS(index)::IndexReader* reader );
 
62
 
 
63
protected:
 
64
    void closeCallback( CL_NS(index)::IndexReader* reader, void* param );
 
65
};
 
66
 
 
67
CL_NS_END
 
68
#endif