Scalable Algorithms
ScalableAlgorithms
Source code in engines/contentFilterEngine/performance_scalability/scalable_algorithms.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
__init__(num_workers=None)
Initializes the ScalableAlgorithms with a specified number of worker processes.
- num_workers (int, optional): The number of worker processes to use. Defaults to the number of CPU cores available.
Source code in engines/contentFilterEngine/performance_scalability/scalable_algorithms.py
11 12 13 14 15 16 17 18 19 20 21 22 23 |
|
chunkify(data, n_chunks)
Splits data into specified number of chunks.
Parameters: - data (list): The data to split. - n_chunks (int): The number of chunks to create.
Returns: - list of lists: A list containing the data chunks.
Source code in engines/contentFilterEngine/performance_scalability/scalable_algorithms.py
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
map_async(function, data)
Asynchronously maps a function over data using multiprocessing.
Parameters: - function (callable): The function to apply to each data item. - data (iterable): The data to process.
Returns: - list: A list of results after applying the function.
Source code in engines/contentFilterEngine/performance_scalability/scalable_algorithms.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
|
parallel_process(function, data, chunksize=1)
Processes data in parallel using a specified function.
Parameters: - function (callable): The function to apply to each data chunk. - data (iterable): The data to process. - chunksize (int): The size of each data chunk.
Returns: - list: A list of results after applying the function.
Source code in engines/contentFilterEngine/performance_scalability/scalable_algorithms.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|