本文整理了Java中proj.zoie.api.ZoieMultiReader
类的一些代码示例,展示了ZoieMultiReader
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZoieMultiReader
类的具体详情如下:
包路径:proj.zoie.api.ZoieMultiReader
类名称:ZoieMultiReader
暂无
代码示例来源:origin: com.linkedin.zoie/zoie-core
protected ZoieMultiReader<R> newInstance(IndexReader inner,IndexReader[] subReaders) throws IOException{
return new ZoieMultiReader<R>(inner, subReaders ,_decorator);
}
代码示例来源:origin: senseidb/zoie
@SuppressWarnings("unchecked")
private ZoieMultiReader(DirectoryReader in, IndexReaderDecorator<R> decorator,
ZoieSubReaderWrapper<R> wrapper) throws IOException {
super(in, wrapper);
_subZoieReaders = (List<ZoieSegmentReader<R>>) getSequentialSubReaders();
_decorator = decorator;
_readerMap = new HashMap<String, ZoieSegmentReader<R>>();
_decoratedReaders = null;
init();
}
代码示例来源:origin: senseidb/zoie
public UIDFilter(long[] filteredIDs, ZoieMultiReader<?> reader) {
_filteredIDs = filteredIDs;
_subZoieReaders = reader.getSubReaders();
}
代码示例来源:origin: senseidb/zoie
public void commitDeletes() throws IOException {
ZoieMultiReader<R> reader = null;
synchronized (this) {
reader = openIndexReader();
if (reader == null) {
return;
}
reader.incZoieRef();
reader.commitDeletes();
reader.decZoieRef();
}
}
代码示例来源:origin: senseidb/zoie
/**
* swap the disk IndexReader cached in mem. In order to count the reference properly,
* we need to lock the access to _mem so that it is safe to compare whether the old
* and new disk IndexReader are different. decZoieRef the old IndexReader only when they
* differ.
* @param diskIndexReader the new disk IndexReader
* @param oldDiskReader the old disk IndexReader from old mem
* @param mem the new mem
*/
private void lockAndSwapMem(ZoieMultiReader<R> diskIndexReader, ZoieMultiReader<R> oldDiskReader,
Mem<R> mem) {
synchronized (_memLock) {
if (oldDiskReader != diskIndexReader) {
if (oldDiskReader != null) {
oldDiskReader.decZoieRef();
}
diskIndexReader.incZoieRef();
}
_mem = mem;
}
}
代码示例来源:origin: senseidb/zoie
protected List<ZoieMultiReader<R>> loadArchives() {
List<ZoieMultiReader<R>> archives = new ArrayList<ZoieMultiReader<R>>();
long t0 = System.currentTimeMillis();
List<Directory> dirs = _dirMgrFactory.getAllArchivedDirectories();
for (Directory dir : dirs) {
DirectoryReader reader;
try {
reader = DirectoryReader.open(dir);
ZoieMultiReader<R> zoiereader = new ZoieMultiReader<R>(reader, _decorator);
// Initialize docIdMapper
DocIDMapper mapper = _zConfig.getDocidMapperFactory().getDocIDMapper(zoiereader);
zoiereader.setDocIDMapper(mapper);
archives.add(zoiereader);
} catch (CorruptIndexException e) {
log.error("corruptedIndex", e);
} catch (IOException e) {
log.error("IOException", e);
}
}
log.info("load " + dirs.size() + " archived indices of " + getSizeBytes() + " bytes in "
+ (System.currentTimeMillis() - t0) + "ms");
return archives;
}
代码示例来源:origin: senseidb/zoie
@Override
public void refresh() throws IOException {
synchronized (this) {
ZoieMultiReader<R> reader = null;
if (_currentReader == null) {
reader = openIndexReaderInternal();
} else {
reader = _currentReader.reopen();
if (reader != _currentReader) {
DocIDMapper mapper = _idxMgr._docIDMapperFactory.getDocIDMapper(reader);
reader.setDocIDMapper(mapper);
}
}
if (_currentReader != reader) {
ZoieMultiReader<R> oldReader = _currentReader;
_currentReader = reader;
if (oldReader != null) {
oldReader.decZoieRef();
}
}
LongSet delDocs = _delDocs;
clearDeletes();
markDeletes(delDocs); // re-mark deletes
commitDeletes();
}
}
代码示例来源:origin: senseidb/zoie
/**
* The readers removed will also be decZoieRef(). But the readers to be added will NOT get incZoieRef(),
* which means we assume the newly added ones have already been incRef().
* remove and add should be <b>disjoint</b>
* @param remove the readers to be remove. This has to be disjoint from add.
* @param add
*/
public synchronized void swapArchives(List<ZoieMultiReader<R>> remove,
List<ZoieMultiReader<R>> add) {
List<ZoieMultiReader<R>> archives = new LinkedList<ZoieMultiReader<R>>(add);
if (!box._archives.containsAll(remove)) {
log.error("swapArchives: potential sync issue. ");
}
archives.addAll(box._archives);
archives.removeAll(remove);
for (ZoieMultiReader<R> r : remove) {
r.decZoieRef();
if (log.isDebugEnabled()) {
log.debug("remove time " + r.directory() + " refCount: " + r.getInnerRefCount());
}
}
Box<R, D> newbox = new Box<R, D>(archives, box._archiveZoies, box._retiree, box._actives,
_decorator);
box = newbox;
}
代码示例来源:origin: senseidb/zoie
public boolean isDeleted(int docid) {
int idx = readerIndex(docid);
ZoieSegmentReader<R> subReader = _subZoieReaders.get(idx);
return subReader.isDeleted(docid - readerBase(idx));
}
代码示例来源:origin: com.linkedin.zoie/zoie-core
int docCount = reader.maxDoc();
final ZoieSegmentReader<?>[] subreaders = (ZoieSegmentReader<?>[]) (reader
.getSequentialSubReaders());
final int[] starts = reader.getStarts();
代码示例来源:origin: com.linkedin.zoie/zoie-core
@Override
public void setDelDocIds()
{
ZoieIndexReader<R>[] subReaders = getSequentialSubReaders();
for(ZoieIndexReader<R> subReader : subReaders)
{
subReader.setDelDocIds();
}
}
代码示例来源:origin: senseidb/zoie
@Override
public int getNumdocs() {
ZoieMultiReader<R> reader = null;
synchronized (this) {
reader = openIndexReader();
if (reader == null) {
return 0;
}
reader.incZoieRef();
}
int numDocs = reader.numDocs();
reader.decZoieRef();
return numDocs;
}
代码示例来源:origin: com.senseidb.zoie/zoie-core
public void markDeletes(LongSet delDocs) throws IOException {
if (delDocs != null && delDocs.size() > 0) {
ZoieMultiReader<R> reader = null;
synchronized (this) {
reader = openIndexReader();
if (reader == null) {
return;
}
reader.incZoieRef();
reader.markDeletes(delDocs, _delDocs);
reader.decZoieRef();
}
}
}
代码示例来源:origin: com.linkedin.zoie/zoie-core
@Override
public byte[] getStoredValue(long uid) throws IOException {
int docid = this.getDocIDMaper().getDocID(uid);
if (docid < 0) return null;
int idx = readerIndex(docid);
if (idx < 0) return null;
ZoieIndexReader<R> subReader = _subZoieReaders.get(idx);
return subReader.getStoredValue(uid);
}
代码示例来源:origin: com.linkedin.zoie/zoie-core
private int readerIndex(int n){
return readerIndex(n,_starts,_starts.length);
}
代码示例来源:origin: com.linkedin.zoie/zoie-core
public DocIDMapper<?> getDocIDMapper(ZoieMultiReader<?> multireader) {
final ZoieSegmentReader<?>[] subreaders =(ZoieSegmentReader<?>[])(multireader.getSequentialSubReaders());
final int[] starts = multireader.getStarts();
for (int i = 0; i < subreaders.length; ++i){
ZoieSegmentReader<?> subReader = subreaders[i];
DocIDMapper<?> mapper = subReader.getDocIDMaper();
if (mapper == null){
mapper = new DocIDMapperImpl(subReader.getUIDArray());
}
subReader.setDocIDMapper(mapper);
}
final DocIDMapper[] mappers = new DocIDMapper[subreaders.length];
for(int i=0; i< subreaders.length; i++)
{
mappers[i] = subreaders[i].getDocIDMaper();
}
final int bound = subreaders.length-1;
return new DefaultDocIDMapper(bound, mappers, starts);
}
代码示例来源:origin: com.linkedin.zoie/zoie-core
public ZoieMultiReader(IndexReader in,IndexReader[] subReaders,IndexReaderDecorator<R> decorator) throws IOException {
super(in,decorator);
_readerMap = new HashMap<String,ZoieSegmentReader<R>>();
_decoratedReaders = null;
init(subReaders);
}
代码示例来源:origin: senseidb/zoie
/**
* Closes the index reader
*/
public void closeReader() {
if (_currentReader != null) {
_currentReader.decZoieRef();
int count = _currentReader.getInnerRefCount();
log.info("final closeReader in dispenser and current refCount: " + count);
if (count > 0) {
log.warn("final closeReader call with reference count == " + count
+ " greater than 0. Potentially, "
+ "the IndexReaders are not properly return to ZoieSystem.");
}
_currentReader = null;
}
}
}
代码示例来源:origin: com.senseidb.zoie/zoie-core
@Override
public void returnIndexReaders(List<ZoieMultiReader<R>> readers) {
for (ZoieMultiReader<R> r : readers) {
r.decZoieRef();
}
}
代码示例来源:origin: senseidb/zoie
reader = memIndexB.openIndexReader();
if (reader != null) {
reader = reader.copy();
readers.add(reader);
reader = memIndexA.openIndexReader();
if (reader != null) {
reader = reader.copy();
readers.add(reader);
reader = reader.copy();
readers.add(reader);
内容来源于网络,如有侵权,请联系作者删除!