org.hibernate.search.indexes.impl
Class SharingBufferReaderProvider

java.lang.Object
  extended by org.hibernate.search.indexes.impl.SharingBufferReaderProvider
All Implemented Interfaces:
DirectoryBasedReaderProvider, ReaderProvider

public class SharingBufferReaderProvider
extends Object
implements DirectoryBasedReaderProvider

This ReaderProvider shares IndexReaders as long as they are "current"; It 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 (C) 2011 Red Hat Inc.

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  Map<IndexReader,SharingBufferReaderProvider.ReaderUsagePair> allReaders
          contains all Readers (most current per Directory and all unclosed old readers)
protected  Map<Directory,SharingBufferReaderProvider.PerDirectoryLatestReader> currentReaders
          contains last updated Reader; protected by lockOnOpenLatest (in the values)
 
Constructor Summary
SharingBufferReaderProvider()
           
 
Method Summary
 void closeIndexReader(IndexReader reader)
           
 void initialize(DirectoryBasedIndexManager indexManager, Properties props)
           
 IndexReader openIndexReader()
           
protected  IndexReader readerFactory(Directory directory)
           
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

allReaders

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


currentReaders

protected final Map<Directory,SharingBufferReaderProvider.PerDirectoryLatestReader> currentReaders
contains last updated Reader; protected by lockOnOpenLatest (in the values)

Constructor Detail

SharingBufferReaderProvider

public SharingBufferReaderProvider()
Method Detail

openIndexReader

public IndexReader openIndexReader()
Specified by:
openIndexReader in interface ReaderProvider

closeIndexReader

public void closeIndexReader(IndexReader reader)
Specified by:
closeIndexReader in interface ReaderProvider

initialize

public void initialize(DirectoryBasedIndexManager indexManager,
                       Properties props)
Specified by:
initialize in interface DirectoryBasedReaderProvider

stop

public void stop()
Specified by:
stop in interface DirectoryBasedReaderProvider

readerFactory

protected IndexReader readerFactory(Directory directory)
                             throws IOException
Throws:
IOException


Copyright © 2006-2013 Red Hat, Inc. All Rights Reserved