org.teiid.internal.core.index
Class MergeFactory

java.lang.Object
  extended by org.teiid.internal.core.index.MergeFactory

public class MergeFactory
extends java.lang.Object

A mergeFactory is used to merge 2 indexes into one. One of the indexes (oldIndex) is on the disk and the other(addsIndex) is in memory. The merge respects the following rules:
- The files are sorted in alphabetical order;
- if a file is in oldIndex and addsIndex, the one which is added is the one in the addsIndex.


Field Summary
static int ADDS_INDEX
           
protected  IndexInput addsInput
          Input on the addsIndex.
protected  int[] mappingAdds
           
protected  int[] mappingOld
           
protected  BlocksIndexOutput mergeOutput
          Output to write the result of the merge in.
static int OLD_INDEX
           
protected  IndexInput oldInput
          Input on the oldIndex.
protected  java.util.Map removedInAdds
          Files removed from addsIndex.
protected  java.util.Map removedInOld
          Files removed from oldIndex.
 
Constructor Summary
MergeFactory(IndexInput oldIndexInput, IndexInput addsIndexInput, BlocksIndexOutput mergeIndexOutput, java.util.Map removedInOld, java.util.Map removedInAdds)
          MergeFactory constructor comment.
 
Method Summary
protected  void init()
          Initialise the merge.
 void merge()
          Merges the 2 indexes into a new one on the disk.
protected  void mergeFiles()
          Merges the files of the 2 indexes in the new index, removes the files to be removed, and records the changes made to propagate them to the word references.
protected  void mergeReferences()
          Merges the files of the 2 indexes in the new index, according to the changes recorded during mergeFiles().
protected  void removeFile(IndexedFile file, int index)
          Records the deletion of one file.
protected  boolean wasRemoved(IndexedFile indexedFile, int index)
          Returns whether the given file has to be removed from the given index (ADDS_INDEX or OLD_INDEX).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

addsInput

protected IndexInput addsInput
Input on the addsIndex.


oldInput

protected IndexInput oldInput
Input on the oldIndex.


mergeOutput

protected BlocksIndexOutput mergeOutput
Output to write the result of the merge in.


removedInOld

protected java.util.Map removedInOld
Files removed from oldIndex.


removedInAdds

protected java.util.Map removedInAdds
Files removed from addsIndex.


mappingOld

protected int[] mappingOld

mappingAdds

protected int[] mappingAdds

ADDS_INDEX

public static final int ADDS_INDEX
See Also:
Constant Field Values

OLD_INDEX

public static final int OLD_INDEX
See Also:
Constant Field Values
Constructor Detail

MergeFactory

public MergeFactory(IndexInput oldIndexInput,
                    IndexInput addsIndexInput,
                    BlocksIndexOutput mergeIndexOutput,
                    java.util.Map removedInOld,
                    java.util.Map removedInAdds)
MergeFactory constructor comment.

Parameters:
directory - java.io.File
Method Detail

init

protected void init()
Initialise the merge.


merge

public void merge()
           throws java.io.IOException
Merges the 2 indexes into a new one on the disk.

Throws:
java.io.IOException

mergeFiles

protected void mergeFiles()
                   throws java.io.IOException
Merges the files of the 2 indexes in the new index, removes the files to be removed, and records the changes made to propagate them to the word references.

Throws:
java.io.IOException

mergeReferences

protected void mergeReferences()
                        throws java.io.IOException
Merges the files of the 2 indexes in the new index, according to the changes recorded during mergeFiles().

Throws:
java.io.IOException

removeFile

protected void removeFile(IndexedFile file,
                          int index)
Records the deletion of one file.


wasRemoved

protected boolean wasRemoved(IndexedFile indexedFile,
                             int index)
Returns whether the given file has to be removed from the given index (ADDS_INDEX or OLD_INDEX). If it has to be removed, the mergeFactory deletes it and records the changes.



Copyright © 2011. All Rights Reserved.