MapReduce
1.0.0
MapReduce con Delphi.
Gbearray es una implementación de MapReduce. Es un Tarray genérico con algunos métodos:
function Add (aValue : T): integer; // Add a value to the end of the array and return the new length
function Any (Lambda: TPredicate<T>): boolean; // any : is there at least one element that corresponds to the request
function Concat (anArray: TGBEArray<T>): TGBEArray<T>; // Concat : concat this TGBEArray<T> with another TGBEArray<T> into a new one
function Every ( const Lambda: TPredicate<T>): Boolean; // Each element respects the lambda
function Extract (fromElement : integer = 0 ; toElement : integer = 0 ): TGBEArray<T>; // Extract element from an TGBEArray from fromElement indice to toElement indice to a new TGBEArray
// if fromElement or toElement are negative, it's indicate an offset from the end of the TGBEArray
function Fill (aValue : T; iStart : integer = 0 ; iEnd : integer = - 1 ): TGBEArray<T>; // Fill an TGBEArray<T> with aValue. If the TGBEArray is empty and the iStart at 0, then iEnd parameter specify also the length of the TGBEArray<T>
function Filter (Lambda: TPredicate<T>): TGBEArray<T>; // filter
function FilterEvenItems (Lambda: TPredicate<T>): TGBEArray<T>; // filter on even items only
function FilterOddItems (Lambda: TPredicate<T>): TGBEArray<T>; // filter on odd items only
function FindIndex (Lambda: TPredicate<T>):integer; // Return first index of element that match with the predicate
function FirstOrDefault ( const Lambda: TPredicate<T> = nil ): T; // Return first element or first element from a predicate (if predicate set) or the default value of T
procedure ForEach (Lambda: TProc<T>; fromElement : integer = 0 ; toElement : integer = - 1 ); // execute lambda for all elements don't return object
function Gather (Lambda: TFunc<T,string, string>; sep : string = ' ; ' ): TGBEArray<string>; // group the keys/values and return a TGBEArray<string>
function Includes (aValue: T; lambda: TFunc<T, string> = nil ): boolean; // aValue is included in the array ?
function Insert (aValue : T; index : integer = 0 ): TGBEArray<T>; // Insert aValue at index position and return a new TGBEArray
function IntersectionWith (anotherArray: TGBEArray<T>; lambda: TFunc<T, string> = nil ): TGBEArray<T>; // Return a new TGBEArray which is intersection of original arrya and anotherArray
function Join (sep: string = ' , ' ; lambda: TFunc<T, string> = nil ): String; // Join elements of array in a string with sep as separator
function KeepDuplicates : TGBEArray<T>; // Return a new TGBEArray with only duplicates elements
function LastOrDefault ( const Lambda: TPredicate<T> = nil ): T; // Return first element or first element from a predicate (if predicate set) or the default value of T
function Map <S>(Lambda: TFunc<T, S>): TGBEArray<S>; // map
function MapParallel <S>(Lambda: TFunc<T, S>): TGBEArray<S>; // mapParallel
function AbsoluteMajorityElement (Lambda: TFunc<T, String> = nil ;
noAbsoluteMajority : string = ' No absolute majority ' ): String; // returns a string which indicates the element of the array which is present in an absolute majority, returns noAbsoluteMajority if no element has an absolute majority
function Pop :T; // return the last item of the array and remove it from the array
function Print (Lambda: TFunc<T, T>): TGBEArray<T>; // print the data
function Reduce <S>(Lambda: TFunc<S, T, S>; const Init: S): S; // reduce
function ReduceRight <S>(Lambda: TFunc<S, T, S>; const Init: S): S;
function Remove (anotherArray: TGBEArray<T>; lambda: TFunc<T, string> = nil ): TGBEArray<T>; // return a new TGBEArray<T> without element of anotherArray
function Reverse :TGBEArray<T>; // Reverse the array
function Shift : T; // return the first item of the array and remove it from the array
function Swap (index1, index2 : integer): TGBEArray<T>; // Return new TGBEArra<T> with swap item1 and item2
function Sort ( const Comparer: IComparer<T> = nil ): TGBEArray<T>; // sort
function ParallelSort ( const Comparer: IComparer<T> = nil ): TGBEArray<T>; // sort using TParallelArray (Delphi 12.2 or higher)
function SuchAs (index : integer; aValue : T): TGBEArray<T>; // Generate a new Array with the same datas but with aValue at index position
function SymmetricalDifferenceWith (anotherArray: TGBEArray<T>; lambda: TFunc<T, string> = nil ): TGBEArray<T>; // Return a new TGBEArray<T> symetrical difference of original array and anotherArray
function ToArray : TArray<T>; // convert TGBEArry to TArray
function ToDictionary (iStartKey : integer = 0 ): TDictionary<integer, T>; // convert to TDictionary with an optional paramter to specify the start index of key
function ToString (Lambda: TFunc<T, String>; sep : string = ' , ' ): String; // convert to string
function UnionWith (anotherArray: TGBEArray<T>; lambda: TFunc<T, string> = nil ): TGBEArray<T>; // Return a new TGBEArray<T> which is union between original array and anotherArray
function Unique ( const Comparer: IComparer<T> = nil ): TGBEArray<T>; // Return a new TGBEArray<T> without duplicatesEl proyecto es una aplicación de muestra para explicar cómo usarlo.
En el rectángulo azul, debe hacer clic en el botón Inicializar para generar un conjunto de datos aleatorio de 20 enteros. Los otros botones en el rectángulo azul usan este conjunto de datos.
En el rectángulo morado, el clic en el botón muestra una secuencia de tratamientos en objeto complejo (Tpersonne).
Finalmente, en el rectángulo amarillo, hay un tmemo donde puedes escribir algún texto. Si hace clic en el botón, el proceso extraerá cada palabra y calculará para cada palabra su número de ocurrencias.
(Haga clic en la imagen para ver el video de YouTube)