Lucene++ - a full-featured, c++ search engine
API Documentation


FieldCacheImpl.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2014 Alan Wright. All rights reserved.
3 // Distributable under the terms of either the Apache License (Version 2.0)
4 // or the GNU Lesser General Public License.
6 
7 #ifndef FIELDCACHEIMPL_H
8 #define FIELDCACHEIMPL_H
9 
10 #include "FieldCache.h"
11 
12 namespace Lucene {
13 
15 class FieldCacheImpl : public FieldCache, public LuceneObject {
16 public:
18  virtual ~FieldCacheImpl();
19 
21 
22 protected:
23  MapStringCache caches;
25 
26 public:
27  virtual void initialize();
28  virtual void purgeAllCaches();
29  virtual void purge(const IndexReaderPtr& r);
31 
32  virtual Collection<uint8_t> getBytes(const IndexReaderPtr& reader, const String& field);
33  virtual Collection<uint8_t> getBytes(const IndexReaderPtr& reader, const String& field, const ByteParserPtr& parser);
34 
35  virtual Collection<int32_t> getInts(const IndexReaderPtr& reader, const String& field);
36  virtual Collection<int32_t> getInts(const IndexReaderPtr& reader, const String& field, const IntParserPtr& parser);
37 
38  virtual Collection<int64_t> getLongs(const IndexReaderPtr& reader, const String& field);
39  virtual Collection<int64_t> getLongs(const IndexReaderPtr& reader, const String& field, const LongParserPtr& parser);
40 
41  virtual Collection<double> getDoubles(const IndexReaderPtr& reader, const String& field);
42  virtual Collection<double> getDoubles(const IndexReaderPtr& reader, const String& field, const DoubleParserPtr& parser);
43 
44  virtual Collection<String> getStrings(const IndexReaderPtr& reader, const String& field);
45  virtual StringIndexPtr getStringIndex(const IndexReaderPtr& reader, const String& field);
46 
47  virtual void setInfoStream(const InfoStreamPtr& stream);
49 };
50 
51 class Entry : public LuceneObject {
52 public:
54  Entry(const String& field, const boost::any& custom);
55  virtual ~Entry();
56 
58 
59 public:
60  String field; // which Fieldable
61  boost::any custom; // which custom comparator or parser
62 
63 public:
65  virtual bool equals(const LuceneObjectPtr& other);
66 
68  virtual int32_t hashCode();
69 };
70 
72 class Cache : public LuceneObject {
73 public:
74  Cache(const FieldCachePtr& wrapper = FieldCachePtr());
75  virtual ~Cache();
76 
78 
79 public:
81  WeakMapLuceneObjectMapEntryAny readerCache;
82 
83 protected:
84  virtual boost::any createValue(const IndexReaderPtr& reader, const EntryPtr& key) = 0;
85 
86 public:
88  virtual void purge(const IndexReaderPtr& r);
89 
90  virtual boost::any get(const IndexReaderPtr& reader, const EntryPtr& key);
91  virtual void printNewInsanity(const InfoStreamPtr& infoStream, const boost::any& value);
92 };
93 
94 class ByteCache : public Cache {
95 public:
96  ByteCache(const FieldCachePtr& wrapper = FieldCachePtr());
97  virtual ~ByteCache();
98 
100 
101 protected:
102  virtual boost::any createValue(const IndexReaderPtr& reader, const EntryPtr& key);
103 };
104 
105 class IntCache : public Cache {
106 public:
107  IntCache(const FieldCachePtr& wrapper = FieldCachePtr());
108  virtual ~IntCache();
109 
111 
112 protected:
113  virtual boost::any createValue(const IndexReaderPtr& reader, const EntryPtr& key);
114 };
115 
116 class LongCache : public Cache {
117 public:
118  LongCache(const FieldCachePtr& wrapper = FieldCachePtr());
119  virtual ~LongCache();
120 
122 
123 protected:
124  virtual boost::any createValue(const IndexReaderPtr& reader, const EntryPtr& key);
125 };
126 
127 class DoubleCache : public Cache {
128 public:
130  virtual ~DoubleCache();
131 
133 
134 protected:
135  virtual boost::any createValue(const IndexReaderPtr& reader, const EntryPtr& key);
136 };
137 
138 class StringCache : public Cache {
139 public:
141  virtual ~StringCache();
142 
144 
145 protected:
146  virtual boost::any createValue(const IndexReaderPtr& reader, const EntryPtr& key);
147 };
148 
149 class StringIndexCache : public Cache {
150 public:
152  virtual ~StringIndexCache();
153 
155 
156 protected:
157  virtual boost::any createValue(const IndexReaderPtr& reader, const EntryPtr& key);
158 };
159 
161 public:
162  FieldCacheEntryImpl(const LuceneObjectPtr& readerKey, const String& fieldName, int32_t cacheType, const boost::any& custom, const boost::any& value);
164 
166 
167 protected:
169  String fieldName;
170  int32_t cacheType;
171  boost::any custom;
172  boost::any value;
173 
174 public:
176  virtual String getFieldName();
177  virtual int32_t getCacheType();
178  virtual boost::any getCustom();
179  virtual boost::any getValue();
180 };
181 
182 }
183 
184 #endif
Lucene::FieldCacheImpl::FieldCacheImpl
FieldCacheImpl()
Lucene::Cache::createValue
virtual boost::any createValue(const IndexReaderPtr &reader, const EntryPtr &key)=0
Lucene::Cache::_wrapper
FieldCacheWeakPtr _wrapper
Definition: FieldCacheImpl.h:77
Lucene::FieldCacheImpl::setInfoStream
virtual void setInfoStream(const InfoStreamPtr &stream)
If non-null, FieldCacheImpl will warn whenever entries are created that are not sane according to Fie...
Lucene::FieldCacheImpl::getDoubles
virtual Collection< double > getDoubles(const IndexReaderPtr &reader, const String &field)
Checks the internal cache for an appropriate entry, and if none are found, reads the terms in field a...
Lucene::Cache
Internal cache.
Definition: FieldCacheImpl.h:72
Lucene::IntCache::createValue
virtual boost::any createValue(const IndexReaderPtr &reader, const EntryPtr &key)
LUCENE_CLASS
#define LUCENE_CLASS(Name)
Definition: LuceneObject.h:24
Lucene::StringIndexPtr
boost::shared_ptr< StringIndex > StringIndexPtr
Definition: LuceneTypes.h:460
Lucene::FieldCacheImpl::getLongs
virtual Collection< int64_t > getLongs(const IndexReaderPtr &reader, const String &field, const LongParserPtr &parser)
Checks the internal cache for an appropriate entry, and if none are found, reads the terms in field a...
Lucene::Entry::field
String field
Definition: FieldCacheImpl.h:57
Lucene::FieldCacheEntryImpl::FieldCacheEntryImpl
FieldCacheEntryImpl(const LuceneObjectPtr &readerKey, const String &fieldName, int32_t cacheType, const boost::any &custom, const boost::any &value)
Lucene::Collection< FieldCacheEntryPtr >
Lucene::FieldCacheEntryImpl::getFieldName
virtual String getFieldName()
Lucene::FieldCacheImpl::getStringIndex
virtual StringIndexPtr getStringIndex(const IndexReaderPtr &reader, const String &field)
Checks the internal cache for an appropriate entry, and if none are found reads the term values in fi...
Lucene::FieldCacheEntryImpl::readerKey
LuceneObjectPtr readerKey
Definition: FieldCacheImpl.h:165
Lucene::LuceneObjectPtr
boost::shared_ptr< LuceneObject > LuceneObjectPtr
Definition: LuceneTypes.h:539
Lucene::FieldCacheImpl::getInts
virtual Collection< int32_t > getInts(const IndexReaderPtr &reader, const String &field, const IntParserPtr &parser)
Checks the internal cache for an appropriate entry, and if none are found, reads the terms in field a...
Lucene::Entry::~Entry
virtual ~Entry()
Lucene::FieldCacheImpl::infoStream
InfoStreamPtr infoStream
Definition: FieldCacheImpl.h:24
Lucene::DoubleCache::~DoubleCache
virtual ~DoubleCache()
Lucene::FieldCacheEntryImpl::custom
boost::any custom
Definition: FieldCacheImpl.h:171
Lucene::FieldCacheEntryImpl::fieldName
String fieldName
Definition: FieldCacheImpl.h:169
Lucene::StringCache::createValue
virtual boost::any createValue(const IndexReaderPtr &reader, const EntryPtr &key)
Lucene::FieldCacheEntryImpl::getCacheType
virtual int32_t getCacheType()
Lucene::FieldCacheEntry
A unique Identifier/Description for each item in the FieldCache. Can be useful for logging/debugging.
Definition: FieldCache.h:255
Lucene::DoubleCache::DoubleCache
DoubleCache(const FieldCachePtr &wrapper=FieldCachePtr())
Lucene::FieldCacheImpl::purge
virtual void purge(const IndexReaderPtr &r)
Drops all cache entries associated with this reader. NOTE: this reader must precisely match the reade...
Lucene::FieldCacheImpl::getStrings
virtual Collection< String > getStrings(const IndexReaderPtr &reader, const String &field)
Checks the internal cache for an appropriate entry, and if none are found, reads the term values in f...
Lucene::FieldCacheEntryImpl::getReaderKey
virtual LuceneObjectPtr getReaderKey()
Lucene::DoubleCache
Definition: FieldCacheImpl.h:127
Lucene::FieldCache
Maintains caches of term values.
Definition: FieldCache.h:17
Lucene::FieldCacheEntryImpl::cacheType
int32_t cacheType
Definition: FieldCacheImpl.h:170
Lucene::LongCache::createValue
virtual boost::any createValue(const IndexReaderPtr &reader, const EntryPtr &key)
Lucene::FieldCacheImpl::caches
MapStringCache caches
Definition: FieldCacheImpl.h:20
Lucene::Entry::Entry
Entry(const String &field, const boost::any &custom)
Creates one of these objects for a custom comparator/parser.
Lucene::StringCache
Definition: FieldCacheImpl.h:138
Lucene::FieldCacheWeakPtr
boost::weak_ptr< FieldCache > FieldCacheWeakPtr
Definition: LuceneTypes.h:334
Lucene
Definition: AbstractAllTermDocs.h:12
Lucene::LongCache::~LongCache
virtual ~LongCache()
Lucene::LuceneObject
Base class for all Lucene classes.
Definition: LuceneObject.h:31
Lucene::DoubleParserPtr
boost::shared_ptr< DoubleParser > DoubleParserPtr
Definition: LuceneTypes.h:328
Lucene::IndexReaderPtr
boost::shared_ptr< IndexReader > IndexReaderPtr
Definition: LuceneTypes.h:157
Lucene::LongParserPtr
boost::shared_ptr< LongParser > LongParserPtr
Definition: LuceneTypes.h:378
Lucene::LongCache::LongCache
LongCache(const FieldCachePtr &wrapper=FieldCachePtr())
Lucene::Entry::hashCode
virtual int32_t hashCode()
Composes a hashcode based on the field and type.
Lucene::IntParserPtr
boost::shared_ptr< IntParser > IntParserPtr
Definition: LuceneTypes.h:376
Lucene::Cache::purge
virtual void purge(const IndexReaderPtr &r)
Remove this reader from the cache, if present.
Lucene::FieldCacheEntryImpl::getCustom
virtual boost::any getCustom()
Lucene::LongCache
Definition: FieldCacheImpl.h:116
Lucene::StringIndexCache::createValue
virtual boost::any createValue(const IndexReaderPtr &reader, const EntryPtr &key)
Lucene::Cache::get
virtual boost::any get(const IndexReaderPtr &reader, const EntryPtr &key)
Lucene::StringIndexCache::~StringIndexCache
virtual ~StringIndexCache()
Lucene::FieldCacheImpl::getInfoStream
virtual InfoStreamPtr getInfoStream()
Lucene::Entry::equals
virtual bool equals(const LuceneObjectPtr &other)
Two of these are equal if they reference the same field and type.
Lucene::FieldCacheImpl::getDoubles
virtual Collection< double > getDoubles(const IndexReaderPtr &reader, const String &field, const DoubleParserPtr &parser)
Checks the internal cache for an appropriate entry, and if none are found, reads the terms in field a...
Lucene::ByteCache::createValue
virtual boost::any createValue(const IndexReaderPtr &reader, const EntryPtr &key)
Lucene::FieldCacheImpl::getBytes
virtual Collection< uint8_t > getBytes(const IndexReaderPtr &reader, const String &field, const ByteParserPtr &parser)
Checks the internal cache for an appropriate entry, and if none are found, reads the terms in field a...
Lucene::IntCache::~IntCache
virtual ~IntCache()
Lucene::Cache::printNewInsanity
virtual void printNewInsanity(const InfoStreamPtr &infoStream, const boost::any &value)
Lucene::StringCache::~StringCache
virtual ~StringCache()
Lucene::Entry::custom
boost::any custom
Definition: FieldCacheImpl.h:61
Lucene::StringIndexCache
Definition: FieldCacheImpl.h:149
FieldCache.h
Lucene::IntCache::IntCache
IntCache(const FieldCachePtr &wrapper=FieldCachePtr())
Lucene::Cache::Cache
Cache(const FieldCachePtr &wrapper=FieldCachePtr())
Lucene::FieldCacheEntryImpl::value
boost::any value
Definition: FieldCacheImpl.h:172
Lucene::FieldCacheImpl::getCacheEntries
virtual Collection< FieldCacheEntryPtr > getCacheEntries()
Generates an array of CacheEntry objects representing all items currently in the FieldCache.
Lucene::ByteParserPtr
boost::shared_ptr< ByteParser > ByteParserPtr
Definition: LuceneTypes.h:289
Lucene::FieldCacheEntryImpl::getValue
virtual boost::any getValue()
Lucene::FieldCachePtr
boost::shared_ptr< FieldCache > FieldCachePtr
Definition: LuceneTypes.h:334
Lucene::FieldCacheImpl
The default cache implementation, storing all values in memory. A WeakHashMap is used for storage.
Definition: FieldCacheImpl.h:15
Lucene::FieldCacheImpl::~FieldCacheImpl
virtual ~FieldCacheImpl()
Lucene::FieldCacheImpl::initialize
virtual void initialize()
Called directly after instantiation to create objects that depend on this object being fully construc...
Lucene::ByteCache::ByteCache
ByteCache(const FieldCachePtr &wrapper=FieldCachePtr())
Lucene::FieldCacheEntryImpl
Definition: FieldCacheImpl.h:160
Lucene::FieldCacheEntryImpl::~FieldCacheEntryImpl
virtual ~FieldCacheEntryImpl()
Lucene::InfoStreamPtr
boost::shared_ptr< InfoStream > InfoStreamPtr
Definition: LuceneTypes.h:532
Lucene::EntryPtr
boost::shared_ptr< Entry > EntryPtr
Definition: LuceneTypes.h:331
Lucene::FieldCacheImpl::getLongs
virtual Collection< int64_t > getLongs(const IndexReaderPtr &reader, const String &field)
Checks the internal cache for an appropriate entry, and if none are found, reads the terms in field a...
Lucene::Cache::~Cache
virtual ~Cache()
Lucene::Cache::readerCache
WeakMapLuceneObjectMapEntryAny readerCache
Definition: FieldCacheImpl.h:81
Lucene::DoubleCache::createValue
virtual boost::any createValue(const IndexReaderPtr &reader, const EntryPtr &key)
Lucene::FieldCacheImpl::getBytes
virtual Collection< uint8_t > getBytes(const IndexReaderPtr &reader, const String &field)
Checks the internal cache for an appropriate entry, and if none are found, reads the terms in field a...
Lucene::FieldCacheImpl::purgeAllCaches
virtual void purgeAllCaches()
Instructs the FieldCache to forcibly expunge all entries from the underlying caches....
Lucene::FieldCacheImpl::getInts
virtual Collection< int32_t > getInts(const IndexReaderPtr &reader, const String &field)
Checks the internal cache for an appropriate entry, and if none are found, reads the terms in field a...
Lucene::Entry
Definition: FieldCacheImpl.h:51
Lucene::StringIndexCache::StringIndexCache
StringIndexCache(const FieldCachePtr &wrapper=FieldCachePtr())
Lucene::ByteCache::~ByteCache
virtual ~ByteCache()
Lucene::StringCache::StringCache
StringCache(const FieldCachePtr &wrapper=FieldCachePtr())
Lucene::IntCache
Definition: FieldCacheImpl.h:105
Lucene::ByteCache
Definition: FieldCacheImpl.h:94

clucene.sourceforge.net