mirror of
https://github.com/querydsl/querydsl.git
synced 2026-07-12 21:20:19 +08:00
This commit is contained in:
parent
3544eeab5e
commit
83691b078b
@ -91,13 +91,13 @@ public class LuceneSessionImpl implements LuceneSession {
|
||||
@Override
|
||||
public LuceneQuery createQuery() {
|
||||
try {
|
||||
final IndexSearcher searcher = getSearcher();
|
||||
searcher.getIndexReader().incRef();
|
||||
return new LuceneQuery(serializer, searcher){
|
||||
final IndexSearcher is = getSearcher();
|
||||
is.getIndexReader().incRef();
|
||||
return new LuceneQuery(serializer, is){
|
||||
@Override
|
||||
public void close(){
|
||||
try {
|
||||
searcher.getIndexReader().decRef();
|
||||
is.getIndexReader().decRef();
|
||||
} catch (IOException e) {
|
||||
throw new QueryException(e);
|
||||
}
|
||||
@ -108,25 +108,6 @@ public class LuceneSessionImpl implements LuceneSession {
|
||||
}
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public <T> T query(QueryCallback<T> callback) {
|
||||
// try {
|
||||
// IndexSearcher is = getSearcher();
|
||||
// try {
|
||||
// // Incrementing the reference count
|
||||
// is.getIndexReader().incRef();
|
||||
// return callback.query(new LuceneQuery(serializer, is));
|
||||
// } finally {
|
||||
// // Releasing the reference count
|
||||
// // This can be the last to actually close the reader
|
||||
// is.getIndexReader().decRef();
|
||||
// }
|
||||
// } catch (IOException e) {
|
||||
// throw new QueryException(e);
|
||||
// }
|
||||
//
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void update(WriteCallback callback) {
|
||||
try {
|
||||
@ -136,10 +117,18 @@ public class LuceneSessionImpl implements LuceneSession {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNew(WriteCallback callback) {
|
||||
try {
|
||||
update(callback, true);
|
||||
} catch (IOException e) {
|
||||
throw new QueryException(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void update(WriteCallback callback, boolean create) throws IOException {
|
||||
IndexWriter writer = new IndexWriter(directory, new StandardAnalyzer(
|
||||
Version.LUCENE_CURRENT), create, MaxFieldLength.LIMITED);
|
||||
|
||||
try {
|
||||
callback.write(writer);
|
||||
} finally {
|
||||
@ -156,17 +145,6 @@ public class LuceneSessionImpl implements LuceneSession {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateNew(WriteCallback callback) {
|
||||
try {
|
||||
update(callback, true);
|
||||
} catch (IOException e) {
|
||||
throw new QueryException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,14 +0,0 @@
|
||||
package com.mysema.query.lucene.session;
|
||||
|
||||
import com.mysema.query.lucene.LuceneQuery;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author laimw
|
||||
*
|
||||
*/
|
||||
public interface QueryCallback<T> {
|
||||
|
||||
T query(LuceneQuery query);
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user