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

Loading...
Searching...
No Matches
FieldCache.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 FIELDCACHE_H
8#define FIELDCACHE_H
9
10#include <boost/any.hpp>
11#include "LuceneObject.h"
12
13 namespace Lucene {
14
17 class LPPAPI FieldCache {
18 public:
19 virtual ~FieldCache();
20 LUCENE_INTERFACE(FieldCache);
21
22 public:
24 enum CacheType {
25 CACHE_BYTE = 1,
26 CACHE_INT,
27 CACHE_LONG,
28 CACHE_DOUBLE,
29 CACHE_STRING,
30 CACHE_STRING_INDEX
31 };
32
35 static const int32_t STRING_INDEX;
36
37 public:
39 static FieldCachePtr DEFAULT();
40
42 static ByteParserPtr DEFAULT_BYTE_PARSER();
43
45 static IntParserPtr DEFAULT_INT_PARSER();
46
48 static LongParserPtr DEFAULT_LONG_PARSER();
49
51 static DoubleParserPtr DEFAULT_DOUBLE_PARSER();
52
55 static IntParserPtr NUMERIC_UTILS_INT_PARSER();
56
59 static LongParserPtr NUMERIC_UTILS_LONG_PARSER();
60
63 static DoubleParserPtr NUMERIC_UTILS_DOUBLE_PARSER();
64
71 virtual Collection<uint8_t> getBytes(const IndexReaderPtr& reader, const String& field);
72
80 virtual Collection<uint8_t> getBytes(const IndexReaderPtr& reader, const String& field, const ByteParserPtr& parser);
81
88 virtual Collection<int32_t> getInts(const IndexReaderPtr& reader, const String& field);
89
97 virtual Collection<int32_t> getInts(const IndexReaderPtr& reader, const String& field, const IntParserPtr& parser);
98
105 virtual Collection<int64_t> getLongs(const IndexReaderPtr& reader, const String& field);
106
114 virtual Collection<int64_t> getLongs(const IndexReaderPtr& reader, const String& field, const LongParserPtr& parser);
115
122 virtual Collection<double> getDoubles(const IndexReaderPtr& reader, const String& field);
123
131 virtual Collection<double> getDoubles(const IndexReaderPtr& reader, const String& field, const DoubleParserPtr& parser);
132
139 virtual Collection<String> getStrings(const IndexReaderPtr& reader, const String& field);
140
147 virtual StringIndexPtr getStringIndex(const IndexReaderPtr& reader, const String& field);
148
150 virtual Collection<FieldCacheEntryPtr> getCacheEntries() = 0;
151
155 virtual void purgeAllCaches() = 0;
156
160 virtual void purge(const IndexReaderPtr& r) = 0;
161
164 virtual void setInfoStream(const InfoStreamPtr& stream);
165
167 virtual InfoStreamPtr getInfoStream();
168};
169
170 class LPPAPI CreationPlaceholder : public LuceneObject {
171 public:
172 virtual ~CreationPlaceholder();
173 LUCENE_CLASS(CreationPlaceholder);
174
175 public:
176 boost::any value;
177};
178
180 class LPPAPI StringIndex : public LuceneObject {
181 public:
182 StringIndex(Collection<int32_t> values, Collection<String> lookup);
183 virtual ~StringIndex();
184
185 LUCENE_CLASS(StringIndex);
186
187 public:
189 Collection<String> lookup;
190
192 Collection<int32_t> order;
193
194 public:
195 int32_t binarySearchLookup(const String& key);
196};
197
200 class LPPAPI Parser : public LuceneObject {
201 public:
202 virtual ~Parser();
203 LUCENE_CLASS(Parser);
204};
205
208 class LPPAPI ByteParser : public Parser {
209 public:
210 virtual ~ByteParser();
211 LUCENE_CLASS(ByteParser);
212
213 public:
215 virtual uint8_t parseByte(const String& string);
216};
217
220 class LPPAPI IntParser : public Parser {
221 public:
222 virtual ~IntParser();
223 LUCENE_CLASS(IntParser);
224
225 public:
227 virtual int32_t parseInt(const String& string);
228};
229
232 class LPPAPI LongParser : public Parser {
233 public:
234 virtual ~LongParser();
235 LUCENE_CLASS(LongParser);
236
237 public:
239 virtual int64_t parseLong(const String& string);
240};
241
244 class LPPAPI DoubleParser : public Parser {
245 public:
246 virtual ~DoubleParser();
247 LUCENE_CLASS(DoubleParser);
248
249 public:
251 virtual double parseDouble(const String& string);
252};
253
255 class LPPAPI FieldCacheEntry : public LuceneObject {
256 public:
257 virtual ~FieldCacheEntry();
258 LUCENE_CLASS(FieldCacheEntry);
259
260 public:
261 virtual LuceneObjectPtr getReaderKey() = 0;
262 virtual String getFieldName() = 0;
263 virtual int32_t getCacheType() = 0;
264 virtual boost::any getCustom() = 0;
265 virtual boost::any getValue() = 0;
266
267 virtual String toString();
268};
269
270}
271
272#endif
LuceneObject.h
LUCENE_CLASS
#define LUCENE_CLASS(Name)
Definition LuceneObject.h:24
LUCENE_INTERFACE
#define LUCENE_INTERFACE(Name)
Definition LuceneObject.h:19
Lucene::ByteParser
Interface to parse bytes from document fields.
Definition FieldCache.h:208
Lucene::ByteParser::~ByteParser
virtual ~ByteParser()
Lucene::ByteParser::parseByte
virtual uint8_t parseByte(const String &string)
Return a single Byte representation of this field's value.
Lucene::Collection
Utility template class to handle collections that can be safely copied and shared.
Definition Collection.h:17
Lucene::CreationPlaceholder
Definition FieldCache.h:170
Lucene::CreationPlaceholder::~CreationPlaceholder
virtual ~CreationPlaceholder()
Lucene::CreationPlaceholder::value
boost::any value
Definition FieldCache.h:176
Lucene::DoubleParser
Interface to parse doubles from document fields.
Definition FieldCache.h:244
Lucene::DoubleParser::parseDouble
virtual double parseDouble(const String &string)
Return a double representation of this field's value.
Lucene::DoubleParser::~DoubleParser
virtual ~DoubleParser()
Lucene::FieldCacheEntry
A unique Identifier/Description for each item in the FieldCache. Can be useful for logging/debugging.
Definition FieldCache.h:255
Lucene::FieldCacheEntry::toString
virtual String toString()
Returns a string representation of the object.
Lucene::FieldCacheEntry::getValue
virtual boost::any getValue()=0
Lucene::FieldCacheEntry::getCustom
virtual boost::any getCustom()=0
Lucene::FieldCacheEntry::~FieldCacheEntry
virtual ~FieldCacheEntry()
Lucene::FieldCacheEntry::getCacheType
virtual int32_t getCacheType()=0
Lucene::FieldCacheEntry::getReaderKey
virtual LuceneObjectPtr getReaderKey()=0
Lucene::FieldCacheEntry::getFieldName
virtual String getFieldName()=0
Lucene::FieldCache
Maintains caches of term values.
Definition FieldCache.h:17
Lucene::FieldCache::CacheType
CacheType
Specifies whether and how a field should be stored.
Definition FieldCache.h:24
Lucene::FieldCache::CACHE_STRING
@ CACHE_STRING
Definition FieldCache.h:29
Lucene::FieldCache::CACHE_DOUBLE
@ CACHE_DOUBLE
Definition FieldCache.h:28
Lucene::FieldCache::CACHE_INT
@ CACHE_INT
Definition FieldCache.h:26
Lucene::FieldCache::CACHE_LONG
@ CACHE_LONG
Definition FieldCache.h:27
Lucene::FieldCache::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::FieldCache::DEFAULT_DOUBLE_PARSER
static DoubleParserPtr DEFAULT_DOUBLE_PARSER()
The default parser for double values, which are encoded by StringUtils::toDouble.
Lucene::FieldCache::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::FieldCache::NUMERIC_UTILS_INT_PARSER
static IntParserPtr NUMERIC_UTILS_INT_PARSER()
A parser instance for int values encoded by NumericUtils#prefixCodedToInt(String),...
Lucene::FieldCache::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::FieldCache::NUMERIC_UTILS_DOUBLE_PARSER
static DoubleParserPtr NUMERIC_UTILS_DOUBLE_PARSER()
A parser instance for double values encoded by NumericUtils, eg. when indexed via NumericField/Numeri...
Lucene::FieldCache::STRING_INDEX
static const int32_t STRING_INDEX
Indicator for StringIndex values in the cache. NOTE: the value assigned to this constant must not be ...
Definition FieldCache.h:35
Lucene::FieldCache::DEFAULT_LONG_PARSER
static LongParserPtr DEFAULT_LONG_PARSER()
The default parser for int values, which are encoded by StringUtils::toLong.
Lucene::FieldCache::~FieldCache
virtual ~FieldCache()
Lucene::FieldCache::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::FieldCache::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::FieldCache::getCacheEntries
virtual Collection< FieldCacheEntryPtr > getCacheEntries()=0
Generates an array of CacheEntry objects representing all items currently in the FieldCache.
Lucene::FieldCache::NUMERIC_UTILS_LONG_PARSER
static LongParserPtr NUMERIC_UTILS_LONG_PARSER()
A parser instance for long values encoded by NumericUtils#prefixCodedToLong(String),...
Lucene::FieldCache::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::FieldCache::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::FieldCache::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::FieldCache::getInfoStream
virtual InfoStreamPtr getInfoStream()
Lucene::FieldCache::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::FieldCache::DEFAULT_BYTE_PARSER
static ByteParserPtr DEFAULT_BYTE_PARSER()
The default parser for byte values, which are encoded by StringUtils::toInt.
Lucene::FieldCache::DEFAULT
static FieldCachePtr DEFAULT()
The cache used internally by sorting and range query classes.
Lucene::FieldCache::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::FieldCache::purge
virtual void purge(const IndexReaderPtr &r)=0
Drops all cache entries associated with this reader. NOTE: this reader must precisely match the reade...
Lucene::FieldCache::purgeAllCaches
virtual void purgeAllCaches()=0
Instructs the FieldCache to forcibly expunge all entries from the underlying caches....
Lucene::FieldCache::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::FieldCache::DEFAULT_INT_PARSER
static IntParserPtr DEFAULT_INT_PARSER()
The default parser for int values, which are encoded by StringUtils::toInt.
Lucene::IntParser
Interface to parse ints from document fields.
Definition FieldCache.h:220
Lucene::IntParser::parseInt
virtual int32_t parseInt(const String &string)
Return a integer representation of this field's value.
Lucene::IntParser::~IntParser
virtual ~IntParser()
Lucene::LongParser
Interface to parse longs from document fields.
Definition FieldCache.h:232
Lucene::LongParser::parseLong
virtual int64_t parseLong(const String &string)
Return a long representation of this field's value.
Lucene::LongParser::~LongParser
virtual ~LongParser()
Lucene::LuceneObject
Base class for all Lucene classes.
Definition LuceneObject.h:31
Lucene::Parser
Marker interface as super-interface to all parsers. It is used to specify a custom parser to SortFiel...
Definition FieldCache.h:200
Lucene::Parser::~Parser
virtual ~Parser()
Lucene::StringIndex
Stores term text values and document ordering data.
Definition FieldCache.h:180
Lucene::StringIndex::binarySearchLookup
int32_t binarySearchLookup(const String &key)
Lucene::StringIndex::~StringIndex
virtual ~StringIndex()
Lucene::StringIndex::lookup
Collection< String > lookup
All the term values, in natural order.
Definition FieldCache.h:189
Lucene::StringIndex::order
Collection< int32_t > order
For each document, an index into the lookup array.
Definition FieldCache.h:192
Lucene::StringIndex::StringIndex
StringIndex(Collection< int32_t > values, Collection< String > lookup)
Lucene
Definition AbstractAllTermDocs.h:12
Lucene::LongParserPtr
boost::shared_ptr< LongParser > LongParserPtr
Definition LuceneTypes.h:378
Lucene::InfoStreamPtr
boost::shared_ptr< InfoStream > InfoStreamPtr
Definition LuceneTypes.h:532
Lucene::LuceneObjectPtr
boost::shared_ptr< LuceneObject > LuceneObjectPtr
Definition LuceneTypes.h:539
Lucene::ByteParserPtr
boost::shared_ptr< ByteParser > ByteParserPtr
Definition LuceneTypes.h:289
Lucene::IntParserPtr
boost::shared_ptr< IntParser > IntParserPtr
Definition LuceneTypes.h:376
Lucene::DoubleParserPtr
boost::shared_ptr< DoubleParser > DoubleParserPtr
Definition LuceneTypes.h:328
Lucene::FieldCachePtr
boost::shared_ptr< FieldCache > FieldCachePtr
Definition LuceneTypes.h:334
Lucene::IndexReaderPtr
boost::shared_ptr< IndexReader > IndexReaderPtr
Definition LuceneTypes.h:157
Lucene::StringIndexPtr
boost::shared_ptr< StringIndex > StringIndexPtr
Definition LuceneTypes.h:460

clucene.sourceforge.net