Meshbeyn / Projects

Namespace FastBWT

public abstract void ADesorter.GenerateVector

This method generates the desorting vector for source bytes.

Syntax

public abstract void GenerateVector(
    byte[] SourceBlock,
    ICollection Vector,
    long DataSize = 0
)

Parameters

byte[] SourceBlock

Array with source bytes.

ICollection Index

Array for desorting vector. The type of this array depends on concrete desorter. 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.

OutOfMemoryException

This exception is thrown if the desorter needs more memory than the system has or if you try to sort a too big source array with the desorter, that doesn't support this. You may try to use a system with more (virtual) memory or use other desorter.

Remarks

This method performs the actual BWT desorting. Its result is the Desorting Vector, that will be applyed later to SourceBlock to calculate desorted bytes. Consider to use this method with the method FillDesortedBlock to desort multiple blocks. You may reuse Desorting Vector for desorting the next block. Method Desort creates and cleares the desorting vector during each invocation. 

The capabilities and memory usage of method GenerateVector depend on concrete implementation. Read the description of concrete Desorter classes for this information.

Example

static void DesortPages(byte[][] Source, byte[][] Target, int[] Idx)
{
    uint BlockSize = (uint)Source[0].Length;
    ADesorter UnBWT = new BWT_Small_Desorter();
    //Desorting vector
    uint[] Vector = new uint[BlockSize];
    //Variable for target blocks
    byte[] Res = new byte[BlockSize];
    for (int i = 0; i < Source.Length; i++)
    {
        UnBWT.GenerateVector(Source[i], Vector);
        Idx[i] = (int)ADesorter.FillDesortedBlock(Source[i], Idx[i], Res, Vector);
        Target[i] = Res;
        //Take source block for the next target
        Res = Source[i];
        Source[i] = null;
    }
}

This example desorts a collection of pages (same-sized blocks). It reuses arrays from Source collection for target blocks (usually you don't need source block after desorting). After you call this method, Source array has nulls as its members, and the corresponding elements of Target have desorted blocks. You may use this method like that:

byte[][] Source;
int[] Idx;
GetSourceBlocks(out Source, out Idx);
byte[][] Target = new byte[Source.Length][];
SortPages(Source, Target, Idx);

See also

ADesorter.FillDesortedBlock method

ADesorter class

BWT_Small_Desorter class

Project FastBWT