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

Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes
Lucene::FieldCache Class Referenceabstract

Maintains caches of term values. More...

`#include <FieldCache.h>`

Inheritance diagram for Lucene::FieldCache:

## Public Types

enum | CacheType { CACHE_BYTE = 1 , CACHE_INT , CACHE_LONG , CACHE_DOUBLE , CACHE_STRING , CACHE_STRING_INDEX }
| Specifies whether and how a field should be stored. More...

## Public Member Functions

virtual | ~FieldCache ()
virtual String | getClassName ()
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 as a single byte and returns an array of size reader.maxDoc() of the value each document has in the given field. More...
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 as bytes and returns an array of size reader.maxDoc() of the value each document has in the given field. More...
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 as integers and returns an array of size reader.maxDoc() of the value each document has in the given field. More...
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 as integers and returns an array of size reader.maxDoc() of the value each document has in the given field. More...
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 as longs and returns an array of size reader.maxDoc() of the value each document has in the given field. More...
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 as longs and returns an array of size reader.maxDoc() of the value each document has in the given field. More...
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 as integers and returns an array of size reader.maxDoc() of the value each document has in the given field. More...
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 as doubles and returns an array of size reader.maxDoc() of the value each document has in the given field. More...
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 field and returns an array of size reader.maxDoc() containing the value each document has in the given field. More...
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 field and returns an array of them in natural order, along with an array telling which element in the term array each document uses. More...
virtual Collection< FieldCacheEntryPtr > | getCacheEntries ()=0
| Generates an array of CacheEntry objects representing all items currently in the FieldCache. More...
virtual void | purgeAllCaches ()=0
| Instructs the FieldCache to forcibly expunge all entries from the underlying caches. This is intended only to be used for test methods as a way to ensure a known base state of the Cache. It should not be relied on for "Cache maintenance" in general application code. More...
virtual void | purge (const IndexReaderPtr &r)=0
| Drops all cache entries associated with this reader. NOTE: this reader must precisely match the reader that the cache entry is keyed on. If you pass a top-level reader, it usually will have no effect as Lucene now caches at the segment reader level. More...
virtual void | setInfoStream (const InfoStreamPtr &stream)
| If non-null, FieldCacheImpl will warn whenever entries are created that are not sane according to FieldCacheSanityChecker. More...
virtual InfoStreamPtr | getInfoStream ()

## Static Public Member Functions

static String | _getClassName ()
static FieldCachePtr | DEFAULT ()
| The cache used internally by sorting and range query classes. More...
static ByteParserPtr | DEFAULT_BYTE_PARSER ()
| The default parser for byte values, which are encoded by StringUtils::toInt. More...
static IntParserPtr | DEFAULT_INT_PARSER ()
| The default parser for int values, which are encoded by StringUtils::toInt. More...
static LongParserPtr | DEFAULT_LONG_PARSER ()
| The default parser for int values, which are encoded by StringUtils::toLong. More...
static DoubleParserPtr | DEFAULT_DOUBLE_PARSER ()
| The default parser for double values, which are encoded by StringUtils::toDouble. More...
static IntParserPtr | NUMERIC_UTILS_INT_PARSER ()
| A parser instance for int values encoded by NumericUtils#prefixCodedToInt(String), eg. when indexed via NumericField/NumericTokenStream. More...
static LongParserPtr | NUMERIC_UTILS_LONG_PARSER ()
| A parser instance for long values encoded by NumericUtils#prefixCodedToLong(String), eg. when indexed via NumericField/NumericTokenStream. More...
static DoubleParserPtr | NUMERIC_UTILS_DOUBLE_PARSER ()
| A parser instance for double values encoded by NumericUtils, eg. when indexed via NumericField/NumericTokenStream. More...

## Static Public Attributes

static const int32_t | STRING_INDEX
| Indicator for StringIndex values in the cache. NOTE: the value assigned to this constant must not be the same as any of those in SortField. More...

## Detailed Description

Maintains caches of term values.

See also
  FieldCacheSanityChecker

## Member Enumeration Documentation

## ◆ CacheType

enum Lucene::FieldCache::CacheType

Specifies whether and how a field should be stored.

Enumerator
CACHE_BYTE |
CACHE_INT |
CACHE_LONG |
CACHE_DOUBLE |
CACHE_STRING |
CACHE_STRING_INDEX |

## Constructor & Destructor Documentation

## ◆ ~FieldCache()

virtual Lucene::FieldCache::~FieldCache | ( |  | ) |

virtual

## Member Function Documentation

## ◆ _getClassName()

static String Lucene::FieldCache::_getClassName | ( |  | ) |

inline static

## ◆ DEFAULT()

static FieldCachePtr Lucene::FieldCache::DEFAULT | ( |  | ) |

static

The cache used internally by sorting and range query classes.

## ◆ DEFAULT_BYTE_PARSER()

static ByteParserPtr Lucene::FieldCache::DEFAULT_BYTE_PARSER | ( |  | ) |

static

The default parser for byte values, which are encoded by StringUtils::toInt.

## ◆ DEFAULT_DOUBLE_PARSER()

static DoubleParserPtr Lucene::FieldCache::DEFAULT_DOUBLE_PARSER | ( |  | ) |

static

The default parser for double values, which are encoded by StringUtils::toDouble.

## ◆ DEFAULT_INT_PARSER()

static IntParserPtr Lucene::FieldCache::DEFAULT_INT_PARSER | ( |  | ) |

static

The default parser for int values, which are encoded by StringUtils::toInt.

## ◆ DEFAULT_LONG_PARSER()

static LongParserPtr Lucene::FieldCache::DEFAULT_LONG_PARSER | ( |  | ) |

static

The default parser for int values, which are encoded by StringUtils::toLong.

## ◆ getBytes() [1/2]

virtual Collection<uint8_t> Lucene::FieldCache::getBytes | ( | const IndexReaderPtr & | reader,
|  | const String & | field
| ) |  |

virtual

Checks the internal cache for an appropriate entry, and if none are found, reads the terms in field as a single byte and returns an array of size reader.maxDoc() of the value each document has in the given field.

Parameters

  reader | Used to get field values.
  field | Which field contains the single byte values.

Returns
  The values in the given field for each document.

Reimplemented in Lucene::FieldCacheImpl.

## ◆ getBytes() [2/2]

virtual Collection<uint8_t> Lucene::FieldCache::getBytes | ( | const IndexReaderPtr & | reader,
|  | const String & | field,
|  | const ByteParserPtr & | parser
| ) |  |

virtual

Checks the internal cache for an appropriate entry, and if none are found, reads the terms in field as bytes and returns an array of size reader.maxDoc() of the value each document has in the given field.

Parameters

  reader | Used to get field values.
  field | Which field contains the bytes.
  parser | Computes byte for string values.

Returns
  The values in the given field for each document.

Reimplemented in Lucene::FieldCacheImpl.

## ◆ getCacheEntries()

virtual Collection<FieldCacheEntryPtr> Lucene::FieldCache::getCacheEntries | ( |  | ) |

pure virtual

Generates an array of CacheEntry objects representing all items currently in the FieldCache.

Implemented in Lucene::FieldCacheImpl.

## ◆ getClassName()

virtual String Lucene::FieldCache::getClassName | ( |  | ) |

inline virtual

Reimplemented in Lucene::FieldCacheImpl.

## ◆ getDoubles() [1/2]

virtual Collection<double> Lucene::FieldCache::getDoubles | ( | const IndexReaderPtr & | reader,
|  | const String & | field
| ) |  |

virtual

Checks the internal cache for an appropriate entry, and if none are found, reads the terms in field as integers and returns an array of size reader.maxDoc() of the value each document has in the given field.

Parameters

  reader | Used to get field values.
  field | Which field contains the doubles.

Returns
  The values in the given field for each document.

Reimplemented in Lucene::FieldCacheImpl.

## ◆ getDoubles() [2/2]

virtual Collection<double> Lucene::FieldCache::getDoubles | ( | const IndexReaderPtr & | reader,
|  | const String & | field,
|  | const DoubleParserPtr & | parser
| ) |  |

virtual

Checks the internal cache for an appropriate entry, and if none are found, reads the terms in field as doubles and returns an array of size reader.maxDoc() of the value each document has in the given field.

Parameters

  reader | Used to get field values.
  field | Which field contains the doubles.
  parser | Computes double for string values.

Returns
  The values in the given field for each document.

Reimplemented in Lucene::FieldCacheImpl.

## ◆ getInfoStream()

virtual InfoStreamPtr Lucene::FieldCache::getInfoStream | ( |  | ) |

virtual

See also
  setInfoStream

Reimplemented in Lucene::FieldCacheImpl.

## ◆ getInts() [1/2]

virtual Collection<int32_t> Lucene::FieldCache::getInts | ( | const IndexReaderPtr & | reader,
|  | const String & | field
| ) |  |

virtual

Checks the internal cache for an appropriate entry, and if none are found, reads the terms in field as integers and returns an array of size reader.maxDoc() of the value each document has in the given field.

Parameters

  reader | Used to get field values.
  field | Which field contains the integers.

Returns
  The values in the given field for each document.

Reimplemented in Lucene::FieldCacheImpl.

## ◆ getInts() [2/2]

virtual Collection<int32_t> Lucene::FieldCache::getInts | ( | const IndexReaderPtr & | reader,
|  | const String & | field,
|  | const IntParserPtr & | parser
| ) |  |

virtual

Checks the internal cache for an appropriate entry, and if none are found, reads the terms in field as integers and returns an array of size reader.maxDoc() of the value each document has in the given field.

Parameters

  reader | Used to get field values.
  field | Which field contains the integers.
  parser | Computes integer for string values.

Returns
  The values in the given field for each document.

Reimplemented in Lucene::FieldCacheImpl.

## ◆ getLongs() [1/2]

virtual Collection<int64_t> Lucene::FieldCache::getLongs | ( | const IndexReaderPtr & | reader,
|  | const String & | field
| ) |  |

virtual

Checks the internal cache for an appropriate entry, and if none are found, reads the terms in field as longs and returns an array of size reader.maxDoc() of the value each document has in the given field.

Parameters

  reader | Used to get field values.
  field | Which field contains the longs.

Returns
  The values in the given field for each document.

Reimplemented in Lucene::FieldCacheImpl.

## ◆ getLongs() [2/2]

virtual Collection<int64_t> Lucene::FieldCache::getLongs | ( | const IndexReaderPtr & | reader,
|  | const String & | field,
|  | const LongParserPtr & | parser
| ) |  |

virtual

Checks the internal cache for an appropriate entry, and if none are found, reads the terms in field as longs and returns an array of size reader.maxDoc() of the value each document has in the given field.

Parameters

  reader | Used to get field values.
  field | Which field contains the longs.
  parser | Computes long for string values.

Returns
  The values in the given field for each document.

Reimplemented in Lucene::FieldCacheImpl.

## ◆ getStringIndex()

virtual StringIndexPtr Lucene::FieldCache::getStringIndex | ( | const IndexReaderPtr & | reader,
|  | const String & | field
| ) |  |

virtual

Checks the internal cache for an appropriate entry, and if none are found reads the term values in field and returns an array of them in natural order, along with an array telling which element in the term array each document uses.

Parameters

  reader | Used to get field values.
  field | Which field contains the strings.

Returns
  Array of terms and index into the array for each document.

Reimplemented in Lucene::FieldCacheImpl.

## ◆ getStrings()

virtual Collection<String> Lucene::FieldCache::getStrings | ( | const IndexReaderPtr & | reader,
|  | const String & | field
| ) |  |

virtual

Checks the internal cache for an appropriate entry, and if none are found, reads the term values in field and returns an array of size reader.maxDoc() containing the value each document has in the given field.

Parameters

  reader | Used to get field values.
  field | Which field contains the strings.

Returns
  The values in the given field for each document.

Reimplemented in Lucene::FieldCacheImpl.

## ◆ NUMERIC_UTILS_DOUBLE_PARSER()

static DoubleParserPtr Lucene::FieldCache::NUMERIC_UTILS_DOUBLE_PARSER | ( |  | ) |

static

A parser instance for double values encoded by NumericUtils, eg. when indexed via NumericField/NumericTokenStream.

## ◆ NUMERIC_UTILS_INT_PARSER()

static IntParserPtr Lucene::FieldCache::NUMERIC_UTILS_INT_PARSER | ( |  | ) |

static

A parser instance for int values encoded by NumericUtils#prefixCodedToInt(String), eg. when indexed via NumericField/NumericTokenStream.

## ◆ NUMERIC_UTILS_LONG_PARSER()

static LongParserPtr Lucene::FieldCache::NUMERIC_UTILS_LONG_PARSER | ( |  | ) |

static

A parser instance for long values encoded by NumericUtils#prefixCodedToLong(String), eg. when indexed via NumericField/NumericTokenStream.

## ◆ purge()

virtual void Lucene::FieldCache::purge | ( | const IndexReaderPtr & | r | ) |

pure virtual

Drops all cache entries associated with this reader. NOTE: this reader must precisely match the reader that the cache entry is keyed on. If you pass a top-level reader, it usually will have no effect as Lucene now caches at the segment reader level.

Implemented in Lucene::FieldCacheImpl.

## ◆ purgeAllCaches()

virtual void Lucene::FieldCache::purgeAllCaches | ( |  | ) |

pure virtual

Instructs the FieldCache to forcibly expunge all entries from the underlying caches. This is intended only to be used for test methods as a way to ensure a known base state of the Cache. It should not be relied on for "Cache maintenance" in general application code.

Implemented in Lucene::FieldCacheImpl.

## ◆ setInfoStream()

virtual void Lucene::FieldCache::setInfoStream | ( | const InfoStreamPtr & | stream | ) |

virtual

If non-null, FieldCacheImpl will warn whenever entries are created that are not sane according to FieldCacheSanityChecker.

Reimplemented in Lucene::FieldCacheImpl.

## Field Documentation

## ◆ STRING_INDEX

const int32_t Lucene::FieldCache::STRING_INDEX

static

Indicator for StringIndex values in the cache. NOTE: the value assigned to this constant must not be the same as any of those in SortField.

The documentation for this class was generated from the following file:

- FieldCache.h

clucene.sourceforge.net