Distance between stack trace threads.
More...
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
Go to the source code of this file.
|
struct | sr_distances |
| A distance matrix of stack trace threads. More...
|
|
struct | sr_distances_part |
| A part of a distance matrix to be computed (possibly in different threads/processes and even different machines provided they have the same architecture and saytr version) and then merged with other parts into a full matrix. More...
|
|
|
enum | sr_distance_type {
SR_DISTANCE_JARO_WINKLER
, SR_DISTANCE_JACCARD
, SR_DISTANCE_LEVENSHTEIN
, SR_DISTANCE_DAMERAU_LEVENSHTEIN
,
SR_DISTANCE_NUM
} |
|
|
float | sr_distance (enum sr_distance_type distance_type, struct sr_thread *thread1, struct sr_thread *thread2) |
|
struct sr_distances * | sr_distances_new (int m, int n) |
|
struct sr_distances * | sr_distances_dup (struct sr_distances *distances) |
|
void | sr_distances_free (struct sr_distances *distances) |
|
float | sr_distances_get_distance (struct sr_distances *distances, int i, int j) |
|
void | sr_distances_set_distance (struct sr_distances *distances, int i, int j, float d) |
|
struct sr_distances * | sr_threads_compare (struct sr_thread **threads, int m, int n, enum sr_distance_type dist_type) |
|
struct sr_distances_part * | sr_distances_part_new (int m, int n, enum sr_distance_type dist_type, int m_begin, int n_begin, size_t len) |
|
struct sr_distances_part * | sr_distances_part_create (int m, int n, enum sr_distance_type dist_type, unsigned nparts) |
|
void | sr_distances_part_compute (struct sr_distances_part *part, struct sr_thread **threads) |
|
struct sr_distances * | sr_distances_part_merge (struct sr_distances_part *parts) |
|
void | sr_distances_part_free (struct sr_distances_part *part, bool follow_links) |
|
Distance between stack trace threads.
Definition in file distance.h.
◆ sr_distance_type
◆ sr_distances_dup()
Creates a duplicate of the distances structure.
- Parameters
-
distances | It must be non-NULL pointer. The structure is not modified by calling this function. |
- Returns
- This function never returns NULL.
◆ sr_distances_free()
Releases the memory held by the distances structure.
- Parameters
-
distances | If the distances is NULL, no operation is performed. |
◆ sr_distances_get_distance()
float sr_distances_get_distance |
( |
struct sr_distances * |
distances, |
|
|
int |
i, |
|
|
int |
j |
|
) |
| |
Gets the entry (i, j) from the distance matrix.
- Parameters
-
distances | It must be non-NULL pointer. |
i | Row in the matrix. |
j | Column in the matrix. |
- Returns
- For entries (i, i) zero distance is returned and values returned for entries (i, j) and (j, i) are the same.
◆ sr_distances_new()
Creates and initializes a new distances structure.
- Parameters
-
m | Number of rows. |
n | Number of columns. |
- Returns
- It never returns NULL. The returned pointer must be released by calling the function sr_distances_free().
◆ sr_distances_part_compute()
Perform the distance computation on the matrix part.
- Parameters
-
part | Part of the matrix previously returned by sr_distances_part_create. |
threads | Array of threads. They are not modified by calling this function. |
◆ sr_distances_part_create()
struct sr_distances_part * sr_distances_part_create |
( |
int |
m, |
|
|
int |
n, |
|
|
enum sr_distance_type |
dist_type, |
|
|
unsigned |
nparts |
|
) |
| |
Creates linked list of distance matrix parts suitable for parallel computation.
- Parameters
-
m | Same as for sr_threads_compare |
n | Same as for sr_threads_compare |
dist_type | Same as for sr_threads_compare |
nparts | Divide the computation into nparts parts. Use something like number of your CPU cores here. |
◆ sr_distances_part_free()
Free the distance matrix part.
- Parameters
-
part | Will be freed. |
follow_links | If true, part is treated as a linked list and all the elements are freed. |
◆ sr_distances_part_merge()
Merge the matrix part into full distance matrix.
- Parameters
-
part | Linked list of matrix part that have been computed using sr_distances_part_compute. |
- Returns
- The resulting distance matrix, or NULL on failure.
◆ sr_distances_part_new()
struct sr_distances_part * sr_distances_part_new |
( |
int |
m, |
|
|
int |
n, |
|
|
enum sr_distance_type |
dist_type, |
|
|
int |
m_begin, |
|
|
int |
n_begin, |
|
|
size_t |
len |
|
) |
| |
Creates new distance matrix part. You probably don't want to use this function directly, use sr_distances_part_create instead.
◆ sr_distances_set_distance()
void sr_distances_set_distance |
( |
struct sr_distances * |
distances, |
|
|
int |
i, |
|
|
int |
j, |
|
|
float |
d |
|
) |
| |
Sets the entry (i, j) from the distance matrix.
- Parameters
-
distances | It must be non-NULL pointer. |
i | Row in the matrix. |
j | Column in the matrix. |
d | Distance. |
◆ sr_threads_compare()
struct sr_distances * sr_threads_compare |
( |
struct sr_thread ** |
threads, |
|
|
int |
m, |
|
|
int |
n, |
|
|
enum sr_distance_type |
dist_type |
|
) |
| |
Creates a distances structure by comparing threads.
- Parameters
-
threads | Array of threads. They are not modified by calling this function. |
m | Compare first m threads from the array with other threads. |
n | Number of threads in the passed array. |
dist_type | Type of distance to compute. |
- Returns
- This function never returns NULL.