Overview | Package | Class | Use | Tree | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.lucene.search
Class LiveFieldValues<T>

    java.lang.Object
      org.apache.lucene.search.LiveFieldValues<T>

All Implemented Interfaces:
  Closeable, ReferenceManager.RefreshListener

    public abstract class LiveFieldValues<T>

extends Object
implements ReferenceManager.RefreshListener, Closeable

Tracks live field values across NRT reader reopens. This holds a map for all updated ids since the last reader reopen. Once the NRT reader is reopened, it prunes the map. This means you must reopen your NRT reader periodically otherwise the RAM consumption of this class will grow unbounded!

NOTE: you must ensure the same id is never updated at the same time by two threads, because in this case you cannot in general know which thread "won".

Constructor Summary
`LiveFieldValues(ReferenceManager<IndexSearcher> mgr, T missingValue)`

Method Summary
`void` | `add(String id, T value)` Call this after you've successfully added a document to the index, to record what value you just set the field to.
`void` | `afterRefresh(boolean didRefresh)` Called after the attempted refresh; if the refresh did open a new reference then didRefresh will be true and `ReferenceManager.acquire()` is guaranteed to return the new reference.
`void` | `beforeRefresh()` Called right before a refresh attempt starts.
`void` | `close()`
`void` | `delete(String id)` Call this after you've successfully deleted a document from the index.
`T` | `get(String id)` Returns the current value for this id, or null if the id isn't in the index or was deleted.
`protected abstract T` | `lookupFromSearcher(IndexSearcher s, String id)` This is called when the id/value was already flushed & opened in an NRT IndexSearcher.
`int` | `size()` Returns the [approximate] number of id/value pairs buffered in RAM.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### LiveFieldValues

    public LiveFieldValues(ReferenceManager<IndexSearcher> mgr,
                           T missingValue)

Method Detail

### close

    public void close()

  Specified by:
    `close` in interface `Closeable`

### beforeRefresh

    public void beforeRefresh()
                       throws IOException

  Description copied from interface: `ReferenceManager.RefreshListener`
  Called right before a refresh attempt starts.

  Specified by:
    `beforeRefresh` in interface `ReferenceManager.RefreshListener`
  Throws:
    `IOException`

### afterRefresh

    public void afterRefresh(boolean didRefresh)
                      throws IOException

  Description copied from interface: `ReferenceManager.RefreshListener`
  Called after the attempted refresh; if the refresh did open a new reference then didRefresh will be true and `ReferenceManager.acquire()` is guaranteed to return the new reference.

  Specified by:
    `afterRefresh` in interface `ReferenceManager.RefreshListener`
  Throws:
    `IOException`

### add

    public void add(String id,
                    T value)

  Call this after you've successfully added a document to the index, to record what value you just set the field to.

### delete

    public void delete(String id)

  Call this after you've successfully deleted a document from the index.

### size

    public int size()

  Returns the [approximate] number of id/value pairs buffered in RAM.

### get

    public T get(String id)
          throws IOException

  Returns the current value for this id, or null if the id isn't in the index or was deleted.

  Throws:
    `IOException`

### lookupFromSearcher

    protected abstract T lookupFromSearcher(IndexSearcher s,
                                            String id)
                                     throws IOException

  This is called when the id/value was already flushed & opened in an NRT IndexSearcher. You must implement this to go look up the value (eg, via doc values, field cache, stored fields, etc.).

  Throws:
    `IOException`

Overview | Package | Class | Use | Tree | Deprecated | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.