Class IndexAccessorImpl
- java.lang.Object
-
- org.hibernate.search.backend.lucene.lowlevel.index.impl.IndexAccessorImpl
-
- All Implemented Interfaces:
AutoCloseable,IndexAccessor
public class IndexAccessorImpl extends Object implements AutoCloseable, IndexAccessor
- Author:
- Sanne Grinovero (C) 2011 Red Hat Inc.
-
-
Constructor Summary
Constructors Constructor Description IndexAccessorImpl(EventContext eventContext, DirectoryHolder directoryHolder, IndexWriterProvider indexWriterProvider, IndexReaderProvider indexReaderProvider)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcleanUpAfterFailure(Throwable throwable, Object failingOperation)Closes, drops and re-creates any cached resources: index writers, index readers.voidclose()voidcommit()Commits the underlying index writer, if any.voidcommitOrDelay()Commits the underlying index writer, if any, or delay the commit if a commit happened recently and configuration requires to wait longer between two commits.longcomputeSizeInBytes()voidcreateIndexIfMissing()Checks whether the index exists (on disk, ...), and creates it if necessary.voiddropIndexIfExisting()Checks whether the index exists (on disk, ...), and drops it if it exists.org.apache.lucene.store.DirectorygetDirectoryForTests()org.apache.lucene.index.DirectoryReadergetIndexReader()IndexWriterDelegatorgetIndexWriterDelegator()org.apache.lucene.index.IndexWritergetWriterForTests()voidmergeSegments()Merge segments files.voidrefresh()Refreshes the underlying index readers.voidvalidateIndexExists()Checks whether the index exists (on disk, ...), and throws an exception if it doesn't.
-
-
-
Constructor Detail
-
IndexAccessorImpl
public IndexAccessorImpl(EventContext eventContext, DirectoryHolder directoryHolder, IndexWriterProvider indexWriterProvider, IndexReaderProvider indexReaderProvider)
-
-
Method Detail
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Throws:
IOException
-
createIndexIfMissing
public void createIndexIfMissing()
Description copied from interface:IndexAccessorChecks whether the index exists (on disk, ...), and creates it if necessary.- Specified by:
createIndexIfMissingin interfaceIndexAccessor
-
validateIndexExists
public void validateIndexExists()
Description copied from interface:IndexAccessorChecks whether the index exists (on disk, ...), and throws an exception if it doesn't.- Specified by:
validateIndexExistsin interfaceIndexAccessor
-
dropIndexIfExisting
public void dropIndexIfExisting()
Description copied from interface:IndexAccessorChecks whether the index exists (on disk, ...), and drops it if it exists.- Specified by:
dropIndexIfExistingin interfaceIndexAccessor
-
commit
public void commit()
Description copied from interface:IndexAccessorCommits the underlying index writer, if any.- Specified by:
commitin interfaceIndexAccessor
-
commitOrDelay
public void commitOrDelay()
Description copied from interface:IndexAccessorCommits the underlying index writer, if any, or delay the commit if a commit happened recently and configuration requires to wait longer between two commits.- Specified by:
commitOrDelayin interfaceIndexAccessor
-
refresh
public void refresh()
Description copied from interface:IndexAccessorRefreshes the underlying index readers.- Specified by:
refreshin interfaceIndexAccessor
-
mergeSegments
public void mergeSegments()
Description copied from interface:IndexAccessorMerge segments files.- Specified by:
mergeSegmentsin interfaceIndexAccessor
-
getIndexWriterDelegator
public IndexWriterDelegator getIndexWriterDelegator() throws IOException
- Specified by:
getIndexWriterDelegatorin interfaceIndexAccessor- Returns:
- The index writer delegator.
- Throws:
IOException
-
getIndexReader
public org.apache.lucene.index.DirectoryReader getIndexReader() throws IOException- Specified by:
getIndexReaderin interfaceIndexAccessor- Returns:
- The most up-to-date index reader available.
- Throws:
IOException
-
cleanUpAfterFailure
public void cleanUpAfterFailure(Throwable throwable, Object failingOperation)
Description copied from interface:IndexAccessorCloses, drops and re-creates any cached resources: index writers, index readers.Should be used to clean up the accessor upon write or commit failure, passing an exception with as much information as possible (operation, document ID, ...).
- Specified by:
cleanUpAfterFailurein interfaceIndexAccessor- Parameters:
throwable- The failure.failingOperation- The operation that failed.
-
computeSizeInBytes
public long computeSizeInBytes()
- Specified by:
computeSizeInBytesin interfaceIndexAccessor- Returns:
- The size of the index on its storage support, in bytes.
-
getDirectoryForTests
public org.apache.lucene.store.Directory getDirectoryForTests()
-
getWriterForTests
public org.apache.lucene.index.IndexWriter getWriterForTests() throws IOException- Throws:
IOException
-
-