Namespace FastBWT
public static void ASorter.FillSortedBlock
This method fills the target block using source block and sorting vector.
Syntax
public abstract void FillSortedBock(
byte[] SourceBlock,
byte[] TargetBlock,
int[] or uint[] or long[] Index,
long DataSize = 0
)
Parameters
byte[] SourceBlock
Array with source bytes.
byte[] TargetBlock
Array for sorted bytes.
int[] or uint[] or long[] Index
Array with sorting vector. The type of this array depends on concrete sorter. Read the documentation of concrete sorter.
long DataSize
Source data length. If source block is not filled completely, set the amount of source bytes using this parameter. Default value 0 means DataSize = SourceBlock.length.
Exceptions
- IndexOutOfRangeException
This exception is thrown if DataSize is too big or if the Index is too small.
Remarks
This method applies the calculated sorting vector on the source bytes and calculates target bytes. During this process it finds starting BWT index. Consider to use this method with the method GenerateVector to sort multiple blocks. You may reuse Sorting Vector for sorting the next block. Method Sort creates and clears the sorting vector during each invocation.
Method FillSortedBlock is static and shall be called from ASorter class. You don't need a sorter to apply sorting vector. You may use this to slightly reduce memory usage during a sorting of a very large block. The algorithm of FastBWT uses normally 10 times of source block's size: Source Block (1), Target Block (1), Sorting Vector (4) and internal Marking Block (4). Target Block and Marking Block do not need to exist at the same time. So, you may clear the reference to Sorter before you call this method. Using this strategy, you need 9 times of block size during sorting and 6 times of block size during filling.
Example
static long SortHugeBlock(byte[] Source, out byte[] Target)
{
uint BlockSize = (uint)Source[0].Length;
ASorter BWT = new BWT_Medium_Sorter(BlockSize);
//Sorting vector
uint[] Vector = new uint[BlockSize];
BWT.GenerateVector(Source, Vector);
//Forget the sorter
BWT = null;
//Create the target block
Target = new byte[BlockSize];
return ASorter.FillSortedBlock(Source[i], Res, Vector);
}
This example uses less memory than normal Sort method. You may use this strategy if the size of block is threateningly big.