satyr 0.43
Loading...
Searching...
No Matches
distance.h File Reference

Distance between stack trace threads. More...

#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>

Go to the source code of this file.

Data Structures

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...

Enumerations

enum  sr_distance_type {
  SR_DISTANCE_JARO_WINKLER , SR_DISTANCE_JACCARD , SR_DISTANCE_LEVENSHTEIN , SR_DISTANCE_DAMERAU_LEVENSHTEIN ,
  SR_DISTANCE_NUM
}

Functions

float sr_distance (enum sr_distance_type distance_type, struct sr_thread *thread1, struct sr_thread *thread2)
struct sr_distancessr_distances_new (int m, int n)
struct sr_distancessr_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_distancessr_threads_compare (struct sr_thread **threads, int m, int n, enum sr_distance_type dist_type)
struct sr_distances_partsr_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_partsr_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_distancessr_distances_part_merge (struct sr_distances_part *parts)
void sr_distances_part_free (struct sr_distances_part *part, bool follow_links)

Detailed Description

Distance between stack trace threads.

Definition in file distance.h.

Enumeration Type Documentation

◆ sr_distance_type

enum sr_distance_type

Definition at line 38 of file distance.h.

Function Documentation

◆ sr_distances_dup()

struct sr_distances * sr_distances_dup ( struct sr_distances * distances)

Creates a duplicate of the distances structure.

Parameters
distancesIt must be non-NULL pointer. The structure is not modified by calling this function.
Returns
This function never returns NULL.

◆ sr_distances_free()

void sr_distances_free ( struct sr_distances * distances)

Releases the memory held by the distances structure.

Parameters
distancesIf 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
distancesIt must be non-NULL pointer.
iRow in the matrix.
jColumn 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()

struct sr_distances * sr_distances_new ( int m,
int n )

Creates and initializes a new distances structure.

Parameters
mNumber of rows.
nNumber of columns.
Returns
It never returns NULL. The returned pointer must be released by calling the function sr_distances_free().

◆ sr_distances_part_compute()

void sr_distances_part_compute ( struct sr_distances_part * part,
struct sr_thread ** threads )

Perform the distance computation on the matrix part.

Parameters
partPart of the matrix previously returned by sr_distances_part_create.
threadsArray 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
mSame as for sr_threads_compare
nSame as for sr_threads_compare
dist_typeSame as for sr_threads_compare
npartsDivide the computation into nparts parts. Use something like number of your CPU cores here.

◆ sr_distances_part_free()

void sr_distances_part_free ( struct sr_distances_part * part,
bool follow_links )

Free the distance matrix part.

Parameters
partWill be freed.
follow_linksIf true, part is treated as a linked list and all the elements are freed.

◆ sr_distances_part_merge()

struct sr_distances * sr_distances_part_merge ( struct sr_distances_part * parts)

Merge the matrix part into full distance matrix.

Parameters
partLinked 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
distancesIt must be non-NULL pointer.
iRow in the matrix.
jColumn in the matrix.
dDistance.

◆ 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
threadsArray of threads. They are not modified by calling this function.
mCompare first m threads from the array with other threads.
nNumber of threads in the passed array.
dist_typeType of distance to compute.
Returns
This function never returns NULL.