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

java.lang.Object
  extended by org.alfresco.repo.search.impl.lucene.AbstractLuceneBase
      extended by org.alfresco.repo.search.impl.lucene.AbstractLuceneIndexerImpl
Direct Known Subclasses:
ADMLuceneIndexerImpl, AVMLuceneIndexerImpl

public abstract class AbstractLuceneIndexerImpl
extends AbstractLuceneBase

Common support for indexing across implementations


Nested Class Summary
protected static class AbstractLuceneIndexerImpl.Action
          Enum for indexing actions against a node
protected static class AbstractLuceneIndexerImpl.Command
           
protected static class AbstractLuceneIndexerImpl.IndexDeleteMode
           
protected static class AbstractLuceneIndexerImpl.IndexUpdateStatus
           
 
Field Summary
protected  java.util.List commandList
          List of pending indexing commands.
protected  java.util.Set deletions
          A list of all deletions we have made - at merge these deletions need to be made against the main index.
protected  long docs
           
protected  AbstractLuceneIndexerImpl.IndexUpdateStatus indexUpdateStatus
          Flag to indicte if we are doing an in transactional delta or a batch update to the index.
protected  long maxAtomicTransformationTime
          the maximum transformation time to allow atomically, defaulting to 20ms
static java.lang.String NOT_INDEXED_CONTENT_MISSING
          No content
static java.lang.String NOT_INDEXED_NO_TRANSFORMATION
          No transform available
static java.lang.String NOT_INDEXED_NO_TYPE_CONVERSION
          No type conversion
static java.lang.String NOT_INDEXED_TRANSFORMATION_FAILED
          Tranfrom failed
 
Fields inherited from class org.alfresco.repo.search.impl.lucene.AbstractLuceneBase
deltaId, store
 
Constructor Summary
AbstractLuceneIndexerImpl()
           
 
Method Summary
protected  void checkAbleToDoWork(AbstractLuceneIndexerImpl.IndexUpdateStatus indexUpdateStatus)
          Utility method to check we are in the correct state to do work Also keeps track of the dirty flag.
 void commit()
          Commit this index
protected abstract  java.util.List createDocuments(java.lang.String stringNodeRef, boolean isNew, boolean indexAllProperties, boolean includeDirectoryDocuments)
           
protected  void delete(java.lang.Object ref)
           
 void deleteAll()
          Delete all entries from the index.
 void deleteAll(java.lang.String prefix)
          Delete all index entries which do not start with the goven prefix
protected static java.util.Set deleteContainerAndBelow(java.lang.String nodeRef, org.apache.lucene.index.IndexReader reader, boolean delete, boolean cascade)
           
protected  java.util.Set deleteImpl(java.lang.String nodeRef, AbstractLuceneIndexerImpl.IndexDeleteMode mode, boolean cascade, org.apache.lucene.index.IndexReader mainReader)
           
protected static java.util.Set deletePrimary(java.util.Collection nodeRefs, org.apache.lucene.index.IndexReader reader, boolean delete)
           
protected static java.util.Set deleteReference(java.util.Collection nodeRefs, org.apache.lucene.index.IndexReader reader, boolean delete)
           
protected abstract  void doCommit()
           
protected abstract  void doPrepare()
           
protected abstract  void doRollBack()
           
protected abstract  void doSetRollbackOnly()
           
 void flushPending()
           
 boolean getDeleteOnlyNodes()
          Are we deleting leaves only (not meta data)
 java.util.Set getDeletions()
          Get the deletions
protected  void index(java.lang.Object ref)
           
protected  void indexImpl(java.lang.String nodeRef, boolean isNew)
           
 boolean isModified()
          Has this index been modified?
protected  void move(java.lang.Object ref)
           
 int prepare()
          Prepare to commit At the moment this makes sure we have all the locks TODO: This is not doing proper serialisation against the index as would a data base transaction.
protected  void reindex(java.lang.Object ref, boolean cascadeReindexDirectories)
           
 void rollback()
          Roll back the index changes (this just means they are never added)
 void setMaxAtomicTransformationTime(long maxAtomicTransformationTime)
          Set the max time allowed to transform content atomically
 void setRollbackOnly()
          Mark this index for roll back only.
 
Methods inherited from class org.alfresco.repo.search.impl.lucene.AbstractLuceneBase
closeDeltaReader, closeDeltaWriter, deleteIndex, doWithWriteLock, 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
 

Field Detail

docs

protected long docs

NOT_INDEXED_NO_TRANSFORMATION

public static final java.lang.String NOT_INDEXED_NO_TRANSFORMATION
No transform available

See Also:
Constant Field Values

NOT_INDEXED_TRANSFORMATION_FAILED

public static final java.lang.String NOT_INDEXED_TRANSFORMATION_FAILED
Tranfrom failed

See Also:
Constant Field Values

NOT_INDEXED_CONTENT_MISSING

public static final java.lang.String NOT_INDEXED_CONTENT_MISSING
No content

See Also:
Constant Field Values

NOT_INDEXED_NO_TYPE_CONVERSION

public static final java.lang.String NOT_INDEXED_NO_TYPE_CONVERSION
No type conversion

See Also:
Constant Field Values

maxAtomicTransformationTime

protected long maxAtomicTransformationTime
the maximum transformation time to allow atomically, defaulting to 20ms


deletions

protected java.util.Set deletions
A list of all deletions we have made - at merge these deletions need to be made against the main index. TODO: Consider if this information needs to be persisted for recovery


commandList

protected java.util.List commandList
List of pending indexing commands.


indexUpdateStatus

protected AbstractLuceneIndexerImpl.IndexUpdateStatus indexUpdateStatus
Flag to indicte if we are doing an in transactional delta or a batch update to the index. If true, we are just fixing up non atomically indexed things from one or more other updates.

Constructor Detail

AbstractLuceneIndexerImpl

public AbstractLuceneIndexerImpl()
Method Detail

deletePrimary

protected static java.util.Set deletePrimary(java.util.Collection nodeRefs,
                                             org.apache.lucene.index.IndexReader reader,
                                             boolean delete)
                                      throws LuceneIndexException
Throws:
LuceneIndexException

deleteReference

protected static java.util.Set deleteReference(java.util.Collection nodeRefs,
                                               org.apache.lucene.index.IndexReader reader,
                                               boolean delete)
                                        throws LuceneIndexException
Throws:
LuceneIndexException

deleteContainerAndBelow

protected static java.util.Set deleteContainerAndBelow(java.lang.String nodeRef,
                                                       org.apache.lucene.index.IndexReader reader,
                                                       boolean delete,
                                                       boolean cascade)
                                                throws LuceneIndexException
Throws:
LuceneIndexException

setMaxAtomicTransformationTime

public void setMaxAtomicTransformationTime(long maxAtomicTransformationTime)
Set the max time allowed to transform content atomically

Parameters:
maxAtomicTransformationTime -

checkAbleToDoWork

protected void checkAbleToDoWork(AbstractLuceneIndexerImpl.IndexUpdateStatus indexUpdateStatus)
Utility method to check we are in the correct state to do work Also keeps track of the dirty flag.

Throws:
java.io.IOException

commit

public void commit()
            throws LuceneIndexException
Commit this index

Throws:
LuceneIndexException

prepare

public int prepare()
            throws LuceneIndexException
Prepare to commit At the moment this makes sure we have all the locks TODO: This is not doing proper serialisation against the index as would a data base transaction.

Returns:
the tx state
Throws:
LuceneIndexException

isModified

public boolean isModified()
Has this index been modified?

Returns:
true if modified

rollback

public void rollback()
              throws LuceneIndexException
Roll back the index changes (this just means they are never added)

Throws:
LuceneIndexException

setRollbackOnly

public void setRollbackOnly()
Mark this index for roll back only. This action can not be reversed. It will reject all other work and only allow roll back.


doPrepare

protected abstract void doPrepare()
                           throws java.io.IOException
Throws:
java.io.IOException

doCommit

protected abstract void doCommit()
                          throws java.io.IOException
Throws:
java.io.IOException

doRollBack

protected abstract void doRollBack()
                            throws java.io.IOException
Throws:
java.io.IOException

doSetRollbackOnly

protected abstract void doSetRollbackOnly()
                                   throws java.io.IOException
Throws:
java.io.IOException

createDocuments

protected abstract java.util.List createDocuments(java.lang.String stringNodeRef,
                                                  boolean isNew,
                                                  boolean indexAllProperties,
                                                  boolean includeDirectoryDocuments)

deleteImpl

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

indexImpl

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

index

protected void index(java.lang.Object ref)
              throws LuceneIndexException
Throws:
LuceneIndexException

reindex

protected void reindex(java.lang.Object ref,
                       boolean cascadeReindexDirectories)
                throws LuceneIndexException
Throws:
LuceneIndexException

delete

protected void delete(java.lang.Object ref)
               throws LuceneIndexException
Throws:
LuceneIndexException

move

protected void move(java.lang.Object ref)
             throws LuceneIndexException
Throws:
LuceneIndexException

flushPending

public void flushPending()
                  throws LuceneIndexException
Throws:
LuceneIndexException

getDeleteOnlyNodes

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

Returns:
- deleting only nodes.

getDeletions

public java.util.Set getDeletions()
Get the deletions

Returns:
- the ids to delete

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 goven prefix

Parameters:
prefix -


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