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


FieldCacheImpl.h
Go to the documentation of this file.
1
2// 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
12namespace Lucene {
13
15class FieldCacheImpl : public FieldCache, public LuceneObject {
16public:
18 virtual ~FieldCacheImpl();
19
21
22protected:
23 MapStringCache caches;
25
26public:
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
51class Entry : public LuceneObject {
52public:
54 Entry(const String& field, const boost::any& custom);
55 virtual ~Entry();
56
58
59public:
60 String field; // which Fieldable
61 boost::any custom; // which custom comparator or parser
62
63public:
65 virtual bool equals(const LuceneObjectPtr& other);
66
68 virtual int32_t hashCode();
69};
70
72class Cache : public LuceneObject {
73public:
74 Cache(const FieldCachePtr& wrapper = FieldCachePtr());
75 virtual ~Cache();
76
78
79public:
81 WeakMapLuceneObjectMapEntryAny readerCache;
82
83protected:
84 virtual boost::any createValue(const IndexReaderPtr& reader, const EntryPtr& key) = 0;
85
86public:
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
94class ByteCache : public Cache {
95public:
97 virtual ~ByteCache();
98
100
101protected:
102 virtual boost::any createValue(const IndexReaderPtr& reader, const EntryPtr& key);
103};
104
105class IntCache : public Cache {
106public:
108 virtual ~IntCache();
109
111
112protected:
113 virtual boost::any createValue(const IndexReaderPtr& reader, const EntryPtr& key);
114};
115
116class LongCache : public Cache {
117public:
119 virtual ~LongCache();
120
122
123protected:
124 virtual boost::any createValue(const IndexReaderPtr& reader, const EntryPtr& key);
125};
126
127class DoubleCache : public Cache {
128public:
130 virtual ~DoubleCache();
131
133
134protected:
135 virtual boost::any createValue(const IndexReaderPtr& reader, const EntryPtr& key);
136};
137
138class StringCache : public Cache {
139public:
141 virtual ~StringCache();
142
144
145protected:
146 virtual boost::any createValue(const IndexReaderPtr& reader, const EntryPtr& key);
147};
148
149class StringIndexCache : public Cache {
150public:
153
155
156protected:
157 virtual boost::any createValue(const IndexReaderPtr& reader, const EntryPtr& key);
158};
159
161public:
162 FieldCacheEntryImpl(const LuceneObjectPtr& readerKey, const String& fieldName, int32_t cacheType, const boost::any& custom, const boost::any& value);
164
166
167protected:
169 String fieldName;
170 int32_t cacheType;
171 boost::any custom;
172 boost::any value;
173
174public:
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
#define LUCENE_CLASS(Name)
Definition: LuceneObject.h:24
Definition: FieldCacheImpl.h:94
virtual ~ByteCache()
ByteCache(const FieldCachePtr &wrapper=FieldCachePtr())
virtual boost::any createValue(const IndexReaderPtr &reader, const EntryPtr &key)
Internal cache.
Definition: FieldCacheImpl.h:72
virtual void printNewInsanity(const InfoStreamPtr &infoStream, const boost::any &value)
virtual void purge(const IndexReaderPtr &r)
Remove this reader from the cache, if present.
virtual ~Cache()
Cache(const FieldCachePtr &wrapper=FieldCachePtr())
WeakMapLuceneObjectMapEntryAny readerCache
Definition: FieldCacheImpl.h:81
virtual boost::any get(const IndexReaderPtr &reader, const EntryPtr &key)
virtual boost::any createValue(const IndexReaderPtr &reader, const EntryPtr &key)=0
FieldCacheWeakPtr _wrapper
Definition: FieldCacheImpl.h:80
Definition: FieldCacheImpl.h:127
virtual ~DoubleCache()
DoubleCache(const FieldCachePtr &wrapper=FieldCachePtr())
virtual boost::any createValue(const IndexReaderPtr &reader, const EntryPtr &key)
Definition: FieldCacheImpl.h:51
virtual ~Entry()
virtual bool equals(const LuceneObjectPtr &other)
Two of these are equal if they reference the same field and type.
virtual int32_t hashCode()
Composes a hashcode based on the field and type.
Entry(const String &field, const boost::any &custom)
Creates one of these objects for a custom comparator/parser.
String field
Definition: FieldCacheImpl.h:60
boost::any custom
Definition: FieldCacheImpl.h:61
Definition: FieldCacheImpl.h:160
virtual boost::any getCustom()
boost::any value
Definition: FieldCacheImpl.h:172
virtual int32_t getCacheType()
String fieldName
Definition: FieldCacheImpl.h:169
FieldCacheEntryImpl(const LuceneObjectPtr &readerKey, const String &fieldName, int32_t cacheType, const boost::any &custom, const boost::any &value)
virtual boost::any getValue()
boost::any custom
Definition: FieldCacheImpl.h:171
virtual LuceneObjectPtr getReaderKey()
int32_t cacheType
Definition: FieldCacheImpl.h:170
virtual String getFieldName()
LuceneObjectPtr readerKey
Definition: FieldCacheImpl.h:168
A unique Identifier/Description for each item in the FieldCache. Can be useful for logging/debugging.
Definition: FieldCache.h:255
The default cache implementation, storing all values in memory. A WeakHashMap is used for storage.
Definition: FieldCacheImpl.h:15
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...
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...
InfoStreamPtr infoStream
Definition: FieldCacheImpl.h:24
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...
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...
virtual void setInfoStream(const InfoStreamPtr &stream)
If non-null, FieldCacheImpl will warn whenever entries are created that are not sane according to Fie...
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...
virtual void initialize()
Called directly after instantiation to create objects that depend on this object being fully construc...
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...
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...
virtual void purgeAllCaches()
Instructs the FieldCache to forcibly expunge all entries from the underlying caches....
MapStringCache caches
Definition: FieldCacheImpl.h:23
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...
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...
virtual void purge(const IndexReaderPtr &r)
Drops all cache entries associated with this reader. NOTE: this reader must precisely match the reade...
virtual Collection< FieldCacheEntryPtr > getCacheEntries()
Generates an array of CacheEntry objects representing all items currently in the FieldCache.
virtual InfoStreamPtr getInfoStream()
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...
Maintains caches of term values.
Definition: FieldCache.h:17
Definition: FieldCacheImpl.h:105
IntCache(const FieldCachePtr &wrapper=FieldCachePtr())
virtual boost::any createValue(const IndexReaderPtr &reader, const EntryPtr &key)
virtual ~IntCache()
Definition: FieldCacheImpl.h:116
virtual boost::any createValue(const IndexReaderPtr &reader, const EntryPtr &key)
LongCache(const FieldCachePtr &wrapper=FieldCachePtr())
virtual ~LongCache()
Base class for all Lucene classes.
Definition: LuceneObject.h:31
Definition: FieldCacheImpl.h:138
virtual ~StringCache()
StringCache(const FieldCachePtr &wrapper=FieldCachePtr())
virtual boost::any createValue(const IndexReaderPtr &reader, const EntryPtr &key)
Definition: FieldCacheImpl.h:149
virtual boost::any createValue(const IndexReaderPtr &reader, const EntryPtr &key)
StringIndexCache(const FieldCachePtr &wrapper=FieldCachePtr())
Definition: AbstractAllTermDocs.h:12
boost::shared_ptr< LongParser > LongParserPtr
Definition: LuceneTypes.h:378
boost::shared_ptr< InfoStream > InfoStreamPtr
Definition: LuceneTypes.h:532
boost::weak_ptr< FieldCache > FieldCacheWeakPtr
Definition: LuceneTypes.h:334
boost::shared_ptr< LuceneObject > LuceneObjectPtr
Definition: LuceneTypes.h:539
boost::shared_ptr< ByteParser > ByteParserPtr
Definition: LuceneTypes.h:289
boost::shared_ptr< IntParser > IntParserPtr
Definition: LuceneTypes.h:376
boost::shared_ptr< DoubleParser > DoubleParserPtr
Definition: LuceneTypes.h:328
boost::shared_ptr< FieldCache > FieldCachePtr
Definition: LuceneTypes.h:334
boost::shared_ptr< Entry > EntryPtr
Definition: LuceneTypes.h:331
boost::shared_ptr< IndexReader > IndexReaderPtr
Definition: LuceneTypes.h:157
boost::shared_ptr< StringIndex > StringIndexPtr
Definition: LuceneTypes.h:460

clucene.sourceforge.net