Meshbeyn / Projects

Namespace FastBWT

public static void ADesorter.FillDesortedBlock

This method fills the target block using source block and desorting vector.

Syntax

public static void FillDesortedBlock(
    byte[] SourceBlock,
    long StartIndex,
    byte[] TargetBlock,
    uint[] Vector,
    long DataSize = 0
)

Parameters

byte[] SourceBlock

Array with source bytes.

long StartIndex

BWT starting index

byte[] TargetBlock

Array for sorted bytes.

uint[] Vector

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 TargetBlock is too small.

Remarks

This method applies the calculated desorting vector on the source bytes and calculates target bytes. Consider to use this method with the method GenerateVector to desort multiple blocks. You may reuse Desorting Vector for sorting the next block. Method Sort creates and clears the desorting vector during each invocation.

Method FillDesortedBlock is static and shall be called from ADesorter class.

Example

static long SortHugeBlock(byte[] Source, long StartIndex, out byte[] Target)
{
    uint BlockSize = (uint)Source[0].Length;
    ADeSorter UnBWT = new BWT_Small_Desorter(BlockSize);
    //Sorting vector
    uint[] Vector = new uint[BlockSize];
    UnBWT.GenerateVector(Source, Vector);
    //Create the target block
    Target = new byte[BlockSize];
    return ADesorter.FillDesortedBlock(Source, StartIndex, Res, Vector);
}

This example uses less memory than normal Sort method. You may use this strategy if the size of block is threateningly big.

See also

ASorter.GenerateVector method

ASorter class

BWT_Small_Sorter class

BWT_Medium_Sorter class

ADesorter class

Project FastBWT