org.alfresco.repo.search.impl.lucene
Class AVMLuceneIndexerImpl

java.lang.Object
  extended by org.alfresco.repo.search.impl.lucene.AbstractLuceneBase
      extended by org.alfresco.repo.search.impl.lucene.AbstractLuceneIndexerImpl
          extended by org.alfresco.repo.search.impl.lucene.AVMLuceneIndexerImpl
All Implemented Interfaces:
BackgroundIndexerAware, AVMLuceneIndexer, LuceneIndexer, Indexer, SupportsBackgroundIndexing, TransactionSynchronisationAwareIndexer

public class AVMLuceneIndexerImpl
extends AbstractLuceneIndexerImpl
implements AVMLuceneIndexer

Update the index after a snap shot to an AVM store. (Revert is dealt with as a new snap shot is created)


Nested Class Summary
protected static class AVMLuceneIndexerImpl.IndexDeleteMode
           
 
Nested classes/interfaces inherited from class org.alfresco.repo.search.impl.lucene.AbstractLuceneIndexerImpl
AbstractLuceneIndexerImpl.Action, AbstractLuceneIndexerImpl.Command, AbstractLuceneIndexerImpl.FTSStatus, AbstractLuceneIndexerImpl.IndexUpdateStatus
 
Field Summary
protected  java.util.Set deletionsSinceFlush
          A list of deletions associated with the changes to nodes in the current flush
 
Fields inherited from class org.alfresco.repo.search.impl.lucene.AbstractLuceneIndexerImpl
commandList, containerDeletions, deletions, docs, indexUpdateStatus, maxAtomicTransformationTime, NOT_INDEXED_CONTENT_MISSING, NOT_INDEXED_NO_TRANSFORMATION, NOT_INDEXED_NO_TYPE_CONVERSION, NOT_INDEXED_TRANSFORMATION_FAILED, transactionService
 
Fields inherited from class org.alfresco.repo.search.impl.lucene.AbstractLuceneBase
deltaId, store
 
Constructor Summary
AVMLuceneIndexerImpl()
           
 
Method Summary
 void asyncronousCreateIndex(java.lang.String store)
          Asyn create index
 void asyncronousDeleteIndex(java.lang.String store)
          Support to delete all entries frmo the idnex in the background
 void createChildRelationship(org.alfresco.service.cmr.repository.ChildAssociationRef relationshipRef)
          Create a refernce link between a parent and child.
protected  java.util.List createDocuments(java.lang.String stringNodeRef, AbstractLuceneIndexerImpl.FTSStatus ftsStatus, boolean indexAllProperties, boolean includeDirectoryDocuments)
           
 void createIndex(java.lang.String store, IndexMode mode)
          Create an index for the specified store.
 void createNode(org.alfresco.service.cmr.repository.ChildAssociationRef relationshipRef)
          Create an index entry when a new node is created.
 void deleteAll()
          Delete all entries from the index.
 void deleteAll(java.lang.String prefix)
          Delete all index entries which do not start with the given prefix
 void deleteChildRelationship(org.alfresco.service.cmr.repository.ChildAssociationRef relationshipRef)
          Delete a relationship between a parent and child.
protected  java.util.Set deleteImpl(java.lang.String nodeRef, AVMLuceneIndexerImpl.IndexDeleteMode mode, boolean cascade, org.apache.lucene.index.IndexReader mainReader)
           
 void deleteIndex(org.alfresco.service.cmr.repository.StoreRef storeRef)
          Delete the index for a store
 void deleteIndex(java.lang.String store, IndexMode mode)
          Delete the index for the specified store.
 void deleteNode(org.alfresco.service.cmr.repository.ChildAssociationRef relationshipRef)
          Delete a node entry from an index.
protected  void doCommit()
           
protected  void doPrepare()
           
protected  void doRollBack()
           
protected  void doSetRollbackOnly()
           
 void flushPending()
           
 boolean getDeleteOnlyNodes()
          Are we deleting leaves only (not meta data)
 long getIndexedDocCount()
          Get the number of docs this indexer has indexed so far
 int getLastIndexedSnapshot(java.lang.String store)
          Get the last snapshot in the index - this does not mean that all snapshots before it have been indexed.
static AVMLuceneIndexerImpl getUpdateIndexer(org.alfresco.service.cmr.repository.StoreRef storeRef, java.lang.String deltaId, LuceneConfig config)
          Generate an indexer
 boolean hasIndexBeenCreated(java.lang.String store)
          Has the index been ceated
 boolean hasIndexBeenCreatedimpl(java.lang.String store, org.alfresco.repo.search.impl.lucene.AVMLuceneIndexerImpl.IndexChannel channel)
           
 void index(java.lang.String store, int srcVersion, int dstVersion, IndexMode mode)
          Index a specified change to a store
protected  void indexImpl(java.lang.String nodeRef, boolean isNew)
           
protected  boolean indexProperty(org.alfresco.service.cmr.repository.NodeRef banana, org.alfresco.service.namespace.QName propertyName, java.io.Serializable value, org.apache.lucene.document.Document doc, boolean indexAtomicPropertiesOnly, java.util.Map properties, boolean isContentIndexedForNode)
           
 boolean isSnapshotIndexed(java.lang.String store, int id)
          Is the snapshot applied to the index? Is there an entry for any node that was added OR have all the nodes in the transaction been deleted as expected?
 boolean isSnapshotSearchable(java.lang.String store, int id)
          Is snapshot searchable
protected  java.io.Serializable makeSerializableValue(org.alfresco.service.cmr.dictionary.PropertyDefinition propertyDef, PropertyValue propertyValue)
           
protected  java.util.List readDocuments(java.lang.String stringNodeRef, AbstractLuceneIndexerImpl.FTSStatus ftsStatus, boolean indexAllProperties, boolean includeDirectoryDocuments)
           
 void registerCallBack(FTSIndexerAware callBack)
          Register call back handler when the indexing chunk is done
 void setAvmService(AVMService avmService)
          Set the AVM Service
 void setAvmSyncService(AVMSyncService avmSyncService)
          Set the AVM sync service
 void setContentService(ContentService contentService)
           
 void setContentStore(ContentStore contentStore)
          Set the content service
 void setFullTextSearchIndexer(FullTextSearchIndexer fullTextSearchIndexer)
          Set the back ground indexer manager
 void syncronousCreateIndex(java.lang.String store)
          Sync create index
 void syncronousDeleteIndex(java.lang.String store)
          Sync delete of this index
 void updateChildRelationship(org.alfresco.service.cmr.repository.ChildAssociationRef relationshipBeforeRef, org.alfresco.service.cmr.repository.ChildAssociationRef relationshipAfterRef)
          Alter the relationship between parent and child nodes in the index.
 int updateFullTextSearch(int size)
          Peform a chunk of background FTS (and other non atomic property) indexing
 void updateNode(org.alfresco.service.cmr.repository.NodeRef nodeRef)
          Update an index entry due to property changes on a node.
 
Methods inherited from class org.alfresco.repo.search.impl.lucene.AbstractLuceneIndexerImpl
checkAbleToDoWork, commit, delete, deleteContainerAndBelow, deleteLeafOnly, deletePrimary, deleteReference, doInReadthroughTransaction, getContainerDeletions, getDeletions, index, isModified, locateContainer, prepare, reindex, rollback, setMaxAtomicTransformationTime, setReadThrough, setRollbackOnly, setTransactionService
 
Methods inherited from class org.alfresco.repo.search.impl.lucene.AbstractLuceneBase
closeDeltaReader, closeDeltaWriter, deleteIndex, doReadOnly, getDeltaId, getDeltaReader, getDeltaWriter, getDictionaryService, getLuceneConfig, getReader, getSearcher, getSearcher, getStatus, initialise, saveDelta, setDictionaryService, setInfo, setLuceneConfig, setStatus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.alfresco.repo.search.impl.lucene.LuceneIndexer
doReadOnly, getContainerDeletions, getDeletions, getDeltaId
 
Methods inherited from interface org.alfresco.repo.search.Indexer
setReadThrough
 
Methods inherited from interface org.alfresco.repo.search.TransactionSynchronisationAwareIndexer
commit, isModified, prepare, rollback
 

Field Detail

deletionsSinceFlush

protected java.util.Set deletionsSinceFlush
A list of deletions associated with the changes to nodes in the current flush

Constructor Detail

AVMLuceneIndexerImpl

public AVMLuceneIndexerImpl()
Method Detail

setAvmService

public void setAvmService(AVMService avmService)
Set the AVM Service

Parameters:
avmService -

setAvmSyncService

public void setAvmSyncService(AVMSyncService avmSyncService)
Set the AVM sync service

Parameters:
avmSyncService -

setContentStore

public void setContentStore(ContentStore contentStore)
Set the content service

Parameters:
contentStore -

setContentService

public void setContentService(ContentService contentService)
Parameters:
contentService -

getDeleteOnlyNodes

public boolean getDeleteOnlyNodes()
Are we deleting leaves only (not meta data)

Specified by:
getDeleteOnlyNodes in interface LuceneIndexer
Returns:
- deleting only nodes.

getUpdateIndexer

public static AVMLuceneIndexerImpl getUpdateIndexer(org.alfresco.service.cmr.repository.StoreRef storeRef,
                                                    java.lang.String deltaId,
                                                    LuceneConfig config)
                                             throws LuceneIndexException
Generate an indexer

Parameters:
storeRef -
deltaId -
config -
Returns:
- the indexer instance
Throws:
LuceneIndexException

index

public void index(java.lang.String store,
                  int srcVersion,
                  int dstVersion,
                  IndexMode mode)
Index a specified change to a store

Specified by:
index in interface AVMLuceneIndexer
Parameters:
store -
srcVersion -
dstVersion -

deleteImpl

protected java.util.Set deleteImpl(java.lang.String nodeRef,
                                   AVMLuceneIndexerImpl.IndexDeleteMode mode,
                                   boolean cascade,
                                   org.apache.lucene.index.IndexReader mainReader)
                            throws LuceneIndexException,
                                   java.io.IOException
Throws:
LuceneIndexException
java.io.IOException

createDocuments

protected java.util.List createDocuments(java.lang.String stringNodeRef,
                                         AbstractLuceneIndexerImpl.FTSStatus ftsStatus,
                                         boolean indexAllProperties,
                                         boolean includeDirectoryDocuments)

readDocuments

protected java.util.List readDocuments(java.lang.String stringNodeRef,
                                       AbstractLuceneIndexerImpl.FTSStatus ftsStatus,
                                       boolean indexAllProperties,
                                       boolean includeDirectoryDocuments)

indexImpl

protected void indexImpl(java.lang.String nodeRef,
                         boolean isNew)
                  throws LuceneIndexException,
                         java.io.IOException
Throws:
LuceneIndexException
java.io.IOException

flushPending

public void flushPending()
                  throws LuceneIndexException
Specified by:
flushPending in interface Indexer
Throws:
LuceneIndexException

makeSerializableValue

protected java.io.Serializable makeSerializableValue(org.alfresco.service.cmr.dictionary.PropertyDefinition propertyDef,
                                                     PropertyValue propertyValue)

indexProperty

protected boolean indexProperty(org.alfresco.service.cmr.repository.NodeRef banana,
                                org.alfresco.service.namespace.QName propertyName,
                                java.io.Serializable value,
                                org.apache.lucene.document.Document doc,
                                boolean indexAtomicPropertiesOnly,
                                java.util.Map properties,
                                boolean isContentIndexedForNode)

doPrepare

protected void doPrepare()
                  throws java.io.IOException
Specified by:
doPrepare in class AbstractLuceneIndexerImpl
Throws:
java.io.IOException

doCommit

protected void doCommit()
                 throws java.io.IOException
Specified by:
doCommit in class AbstractLuceneIndexerImpl
Throws:
java.io.IOException

doRollBack

protected void doRollBack()
                   throws java.io.IOException
Specified by:
doRollBack in class AbstractLuceneIndexerImpl
Throws:
java.io.IOException

doSetRollbackOnly

protected void doSetRollbackOnly()
                          throws java.io.IOException
Specified by:
doSetRollbackOnly in class AbstractLuceneIndexerImpl
Throws:
java.io.IOException

createNode

public void createNode(org.alfresco.service.cmr.repository.ChildAssociationRef relationshipRef)
Description copied from interface: Indexer
Create an index entry when a new node is created. A node is always created with a name in a given parent and so a relationship ref is required.

Specified by:
createNode in interface Indexer

updateNode

public void updateNode(org.alfresco.service.cmr.repository.NodeRef nodeRef)
Description copied from interface: Indexer
Update an index entry due to property changes on a node. There are no strucural impications from such a change.

Specified by:
updateNode in interface Indexer

deleteNode

public void deleteNode(org.alfresco.service.cmr.repository.ChildAssociationRef relationshipRef)
Description copied from interface: Indexer
Delete a node entry from an index. This implies structural change. The node will be deleted from the index. This will also remove any remaining refernces to the node from the index. The index has no idea of the primary link.

Specified by:
deleteNode in interface Indexer

createChildRelationship

public void createChildRelationship(org.alfresco.service.cmr.repository.ChildAssociationRef relationshipRef)
Description copied from interface: Indexer
Create a refernce link between a parent and child. Implies only (potential) structural changes

Specified by:
createChildRelationship in interface Indexer

updateChildRelationship

public void updateChildRelationship(org.alfresco.service.cmr.repository.ChildAssociationRef relationshipBeforeRef,
                                    org.alfresco.service.cmr.repository.ChildAssociationRef relationshipAfterRef)
Description copied from interface: Indexer
Alter the relationship between parent and child nodes in the index. This can be used for:
  1. rename,
  2. move,
  3. move and rename,
  4. replace
This could be implemented as a delete and add but some implementations may be able to optimise this operation.

Specified by:
updateChildRelationship in interface Indexer

deleteChildRelationship

public void deleteChildRelationship(org.alfresco.service.cmr.repository.ChildAssociationRef relationshipRef)
Description copied from interface: Indexer
Delete a relationship between a parent and child. This will remove a structural route through the index. The index has no idea of reference and primary relationships and will happily remove the primary relationship before refernces which could remain. Use delete to ensure all strctural references are removed or call this sure you are doing an unlink (remove a hard link in the unix file system world).

Specified by:
deleteChildRelationship in interface Indexer

deleteIndex

public void deleteIndex(java.lang.String store,
                        IndexMode mode)
Description copied from interface: AVMLuceneIndexer
Delete the index for the specified store.

Specified by:
deleteIndex in interface AVMLuceneIndexer

syncronousDeleteIndex

public void syncronousDeleteIndex(java.lang.String store)
Sync delete of this index

Parameters:
store -

asyncronousDeleteIndex

public void asyncronousDeleteIndex(java.lang.String store)
Support to delete all entries frmo the idnex in the background

Parameters:
store -

createIndex

public void createIndex(java.lang.String store,
                        IndexMode mode)
Description copied from interface: AVMLuceneIndexer
Create an index for the specified store. This makes sure that the root node for the store is indexed correctly.

Specified by:
createIndex in interface AVMLuceneIndexer

syncronousCreateIndex

public void syncronousCreateIndex(java.lang.String store)
Sync create index

Parameters:
store -

asyncronousCreateIndex

public void asyncronousCreateIndex(java.lang.String store)
Asyn create index

Parameters:
store -

registerCallBack

public void registerCallBack(FTSIndexerAware callBack)
Description copied from interface: BackgroundIndexerAware
Register call back handler when the indexing chunk is done

Specified by:
registerCallBack in interface BackgroundIndexerAware

updateFullTextSearch

public int updateFullTextSearch(int size)
Description copied from interface: BackgroundIndexerAware
Peform a chunk of background FTS (and other non atomic property) indexing

Specified by:
updateFullTextSearch in interface BackgroundIndexerAware
Returns:
- the number of docs updates

setFullTextSearchIndexer

public void setFullTextSearchIndexer(FullTextSearchIndexer fullTextSearchIndexer)
Description copied from interface: SupportsBackgroundIndexing
Set the back ground indexer manager

Specified by:
setFullTextSearchIndexer in interface SupportsBackgroundIndexing

isSnapshotIndexed

public boolean isSnapshotIndexed(java.lang.String store,
                                 int id)
Description copied from interface: AVMLuceneIndexer
Is the snapshot applied to the index? Is there an entry for any node that was added OR have all the nodes in the transaction been deleted as expected?

Specified by:
isSnapshotIndexed in interface AVMLuceneIndexer
Returns:
- true if applied, false if not

isSnapshotSearchable

public boolean isSnapshotSearchable(java.lang.String store,
                                    int id)
Description copied from interface: AVMLuceneIndexer
Is snapshot searchable

Specified by:
isSnapshotSearchable in interface AVMLuceneIndexer
Returns:
- true if snapshot has been fully indexed, false if pending or unindexed.

hasIndexBeenCreated

public boolean hasIndexBeenCreated(java.lang.String store)
Description copied from interface: AVMLuceneIndexer
Has the index been ceated

Specified by:
hasIndexBeenCreated in interface AVMLuceneIndexer
Returns:

hasIndexBeenCreatedimpl

public boolean hasIndexBeenCreatedimpl(java.lang.String store,
                                       org.alfresco.repo.search.impl.lucene.AVMLuceneIndexerImpl.IndexChannel channel)

getIndexedDocCount

public long getIndexedDocCount()
Description copied from interface: AVMLuceneIndexer
Get the number of docs this indexer has indexed so far

Specified by:
getIndexedDocCount in interface AVMLuceneIndexer
Returns:

getLastIndexedSnapshot

public int getLastIndexedSnapshot(java.lang.String store)
Description copied from interface: AVMLuceneIndexer
Get the last snapshot in the index - this does not mean that all snapshots before it have been indexed.

Specified by:
getLastIndexedSnapshot in interface AVMLuceneIndexer
Returns:

deleteIndex

public void deleteIndex(org.alfresco.service.cmr.repository.StoreRef storeRef)
Description copied from interface: Indexer
Delete the index for a store

Specified by:
deleteIndex in interface Indexer

deleteAll

public void deleteAll()
Delete all entries from the index.


deleteAll

public void deleteAll(java.lang.String prefix)
Delete all index entries which do not start with the given prefix

Parameters:
prefix -


Copyright © 2005 - 2010 Alfresco Software, Inc. All Rights Reserved.