org.hibernate.search.reader
Class SharingBufferReaderProvider

java.lang.Object
  extended by org.hibernate.search.reader.SharingBufferReaderProvider
All Implemented Interfaces:
ReaderProvider

public class SharingBufferReaderProvider
extends java.lang.Object
implements ReaderProvider

This ReaderProvider shares IndexReaders as long as they are "current"; main difference with SharedReaderProvider is the way to update the Readers when needed: this uses IndexReader.reopen() which should improve performance on larger indexes as it shares buffers with previous IndexReader generation for the segments which didn't change.

Author:
Sanne Grinovero

Nested Class Summary
protected  class SharingBufferReaderProvider.PerDirectoryLatestReader
          An instance for each DirectoryProvider, establishing the association between "current" ReaderUsagePair for a DirectoryProvider and it's lock.
protected  class SharingBufferReaderProvider.ReaderUsagePair
          Container for the couple IndexReader,UsageCounter.
 
Field Summary
protected  java.util.Map<org.apache.lucene.index.IndexReader,SharingBufferReaderProvider.ReaderUsagePair> allReaders
          contains all Readers (most current per Directory and all unclosed old readers)
protected  java.util.Map<org.apache.lucene.store.Directory,SharingBufferReaderProvider.PerDirectoryLatestReader> currentReaders
          contains last updated Reader; protected by lockOnOpenLatest (in the values)
 
Constructor Summary
SharingBufferReaderProvider()
           
 
Method Summary
 void closeReader(org.apache.lucene.index.IndexReader multiReader)
          Close a reader previously opened by ReaderProvider.openReader(org.hibernate.search.store.DirectoryProvider...).
 void destroy()
          Called when a SearchFactory is destroyed.
 void initialize(java.util.Properties props, SearchFactoryImplementor searchFactoryImplementor)
          Inialize the reader provider before its use.
 org.apache.lucene.index.IndexReader openReader(DirectoryProvider... directoryProviders)
          Open a read-only reader on all the listed directory providers.
protected  org.apache.lucene.index.IndexReader readerFactory(org.apache.lucene.store.Directory directory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

allReaders

protected final java.util.Map<org.apache.lucene.index.IndexReader,SharingBufferReaderProvider.ReaderUsagePair> allReaders
contains all Readers (most current per Directory and all unclosed old readers)


currentReaders

protected final java.util.Map<org.apache.lucene.store.Directory,SharingBufferReaderProvider.PerDirectoryLatestReader> currentReaders
contains last updated Reader; protected by lockOnOpenLatest (in the values)

Constructor Detail

SharingBufferReaderProvider

public SharingBufferReaderProvider()
Method Detail

closeReader

public void closeReader(org.apache.lucene.index.IndexReader multiReader)
Description copied from interface: ReaderProvider
Close a reader previously opened by ReaderProvider.openReader(org.hibernate.search.store.DirectoryProvider...). The closing can be virtual.

Specified by:
closeReader in interface ReaderProvider

initialize

public void initialize(java.util.Properties props,
                       SearchFactoryImplementor searchFactoryImplementor)
Description copied from interface: ReaderProvider
Inialize the reader provider before its use.

Specified by:
initialize in interface ReaderProvider

destroy

public void destroy()
Description copied from interface: ReaderProvider
Called when a SearchFactory is destroyed. This method typically releases resources. It is guaranteed to be executed after readers are released by queries (assuming no user error).

Specified by:
destroy in interface ReaderProvider

openReader

public org.apache.lucene.index.IndexReader openReader(DirectoryProvider... directoryProviders)
Description copied from interface: ReaderProvider
Open a read-only reader on all the listed directory providers. The opened reader has to be closed through ReaderProvider.closeReader(IndexReader). The opening can be virtual.

Specified by:
openReader in interface ReaderProvider

readerFactory

protected org.apache.lucene.index.IndexReader readerFactory(org.apache.lucene.store.Directory directory)
                                                     throws java.io.IOException
Throws:
java.io.IOException


Copyright © 2006-2010 Hibernate. All Rights Reserved.