mirror of https://github.com/apache/lucene.git
LUCENE-4979: LiveFieldValues can work with any ReferenceManager
git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1479968 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
cc12d7e659
commit
e86dce4e9c
|
@ -153,6 +153,9 @@ New Features
|
||||||
* LUCENE-4965: Add dynamic (no taxonomy index used) numeric range
|
* LUCENE-4965: Add dynamic (no taxonomy index used) numeric range
|
||||||
faceting to Lucene's facet module (Mike McCandless, Shai Erera)
|
faceting to Lucene's facet module (Mike McCandless, Shai Erera)
|
||||||
|
|
||||||
|
* LUCENE-4979: LiveFieldFields can work with any ReferenceManager, not
|
||||||
|
just ReferenceManager<IndexSearcher> (Mike McCandless).
|
||||||
|
|
||||||
======================= Lucene 4.3.0 =======================
|
======================= Lucene 4.3.0 =======================
|
||||||
|
|
||||||
Changes in backwards compatibility policy
|
Changes in backwards compatibility policy
|
||||||
|
|
|
@ -33,14 +33,14 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||||
* the same time by two threads, because in this case you
|
* the same time by two threads, because in this case you
|
||||||
* cannot in general know which thread "won". */
|
* cannot in general know which thread "won". */
|
||||||
|
|
||||||
public abstract class LiveFieldValues<T> implements ReferenceManager.RefreshListener, Closeable {
|
public abstract class LiveFieldValues<S,T> implements ReferenceManager.RefreshListener, Closeable {
|
||||||
|
|
||||||
private volatile Map<String,T> current = new ConcurrentHashMap<String,T>();
|
private volatile Map<String,T> current = new ConcurrentHashMap<String,T>();
|
||||||
private volatile Map<String,T> old = new ConcurrentHashMap<String,T>();
|
private volatile Map<String,T> old = new ConcurrentHashMap<String,T>();
|
||||||
private final ReferenceManager<IndexSearcher> mgr;
|
private final ReferenceManager<S> mgr;
|
||||||
private final T missingValue;
|
private final T missingValue;
|
||||||
|
|
||||||
public LiveFieldValues(ReferenceManager<IndexSearcher> mgr, T missingValue) {
|
public LiveFieldValues(ReferenceManager<S> mgr, T missingValue) {
|
||||||
this.missingValue = missingValue;
|
this.missingValue = missingValue;
|
||||||
this.mgr = mgr;
|
this.mgr = mgr;
|
||||||
mgr.addListener(this);
|
mgr.addListener(this);
|
||||||
|
@ -114,7 +114,7 @@ public abstract class LiveFieldValues<T> implements ReferenceManager.RefreshList
|
||||||
// It either does not exist in the index, or, it was
|
// It either does not exist in the index, or, it was
|
||||||
// already flushed & NRT reader was opened on the
|
// already flushed & NRT reader was opened on the
|
||||||
// segment, so fallback to current searcher:
|
// segment, so fallback to current searcher:
|
||||||
IndexSearcher s = mgr.acquire();
|
S s = mgr.acquire();
|
||||||
try {
|
try {
|
||||||
return lookupFromSearcher(s, id);
|
return lookupFromSearcher(s, id);
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -128,6 +128,6 @@ public abstract class LiveFieldValues<T> implements ReferenceManager.RefreshList
|
||||||
* in an NRT IndexSearcher. You must implement this to
|
* in an NRT IndexSearcher. You must implement this to
|
||||||
* go look up the value (eg, via doc values, field cache,
|
* go look up the value (eg, via doc values, field cache,
|
||||||
* stored fields, etc.). */
|
* stored fields, etc.). */
|
||||||
protected abstract T lookupFromSearcher(IndexSearcher s, String id) throws IOException;
|
protected abstract T lookupFromSearcher(S s, String id) throws IOException;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ public class TestLiveFieldValues extends LuceneTestCase {
|
||||||
|
|
||||||
final Integer missing = -1;
|
final Integer missing = -1;
|
||||||
|
|
||||||
final LiveFieldValues<Integer> rt = new LiveFieldValues<Integer>(mgr, missing) {
|
final LiveFieldValues<IndexSearcher,Integer> rt = new LiveFieldValues<IndexSearcher,Integer>(mgr, missing) {
|
||||||
@Override
|
@Override
|
||||||
protected Integer lookupFromSearcher(IndexSearcher s, String id) throws IOException {
|
protected Integer lookupFromSearcher(IndexSearcher s, String id) throws IOException {
|
||||||
TermQuery tq = new TermQuery(new Term("id", id));
|
TermQuery tq = new TermQuery(new Term("id", id));
|
||||||
|
|
Loading…
Reference in New Issue