All Downloads are FREE. Search and download functionalities are using the official Maven repository.

proj.zoie.impl.indexing.SimpleReaderCache Maven / Gradle / Ivy

There is a newer version: 3.3.0
Show newest version
package proj.zoie.impl.indexing;

import java.io.IOException;
import java.util.List;
import java.util.ArrayList;

import org.apache.log4j.Logger;
import org.apache.lucene.index.IndexReader;

import proj.zoie.api.IndexReaderFactory;
import proj.zoie.api.ZoieException;
import proj.zoie.api.ZoieIndexReader;

public class SimpleReaderCache extends AbstractReaderCache{

	private static final Logger logger = Logger.getLogger(SimpleReaderCache.class);
	
	private final IndexReaderFactory> _readerFactory;
	
	public SimpleReaderCache(IndexReaderFactory> readerfactory){
	  _readerFactory = readerfactory;
	}
	
	@Override
	public List> getIndexReaders() {
	  try {
		return _readerFactory.getIndexReaders();
	  } catch (IOException e) {
		logger.error(e.getMessage(),e);
		return new ArrayList>();
	  }
	}

	@Override
	public void returnIndexReaders(List> readers) {
		_readerFactory.returnIndexReaders(readers);
	}

	@Override
	public void refreshCache(long timeout) throws ZoieException {
		
	}

	@Override
	public void start() {

	}

	@Override
	public void shutdown() {
		
	}

	@Override
	public void setFreshness(long freshness) {
		
	}

	@Override
	public long getFreshness() {
		return 0;
	}
	
	public static ReaderCacheFactory FACTORY = new ReaderCacheFactory(){

	@Override
	public  AbstractReaderCache newInstance(IndexReaderFactory> readerfactory)
	{
	      return new SimpleReaderCache(readerfactory);
	}};

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy