LALPulsar  6.1.0.1-89842e6
CrossCorrToplist.c File Reference

Prototypes

int finite (double)
 
static void reduce_crossCorr_toplist_precision (toplist_t *l)
 
static int _atomic_write_crossCorr_toplist_to_file (toplist_t *l, const char *filename, UINT4 *checksum, int write_done)
 
static int _atomic_write_crossCorrBinary_toplist_to_file (toplist_t *l, const char *filename, UINT4 *checksum, int write_done)
 
static int print_crossCorrline_to_str (CrossCorrOutputEntry fline, char *buf, int buflen)
 
static int print_crossCorrBinaryline_to_str (CrossCorrBinaryOutputEntry fline, char *buf, int buflen)
 
static int crossCorr_toplist_qsort_function (const void *a, const void *b)
 
static int crossCorrBinary_toplist_qsort_function (const void *a, const void *b)
 
static int crossCorr_smaller (const void *a, const void *b)
 
static int crossCorrBinary_smaller (const void *a, const void *b)
 
int create_crossCorr_toplist (toplist_t **tl, UINT8 length)
 creates a toplist with length elements, returns -1 on error (usually out of memory), else 0 More...
 
int create_crossCorrBinary_toplist (toplist_t **tl, UINT8 length)
 
void free_crossCorr_toplist (toplist_t **l)
 frees the space occupied by the toplist More...
 
int insert_into_crossCorr_toplist (toplist_t *tl, CrossCorrOutputEntry elem)
 Inserts an element in to the toplist either if there is space left or the element is larger than the smallest element in the toplist. More...
 
int insert_into_crossCorrBinary_toplist (toplist_t *tl, CrossCorrBinaryOutputEntry elem)
 
void sort_crossCorr_toplist (toplist_t *l)
 reads a (created!) toplist from an open filepointer sets the checksum if non-NULL reads maximum maxbytes, all that is there if maxbytes is 0 returns the number of bytes read, 0 if we found a DONE marker at the end, -1 if the file contained a syntax error, -2 if given an improper toplist More...
 
void sort_crossCorrBinary_toplist (toplist_t *l)
 
int write_crossCorr_toplist_item_to_fp (CrossCorrOutputEntry fline, FILE *fp, UINT4 *checksum)
 File IO. More...
 
int write_crossCorrBinary_toplist_item_to_fp (CrossCorrBinaryOutputEntry fline, FILE *fp, UINT4 *checksum)
 
static void reduce_crossCorrline_precision (void *line)
 
static void reduce_crossCorrBinaryline_precision (void *line)
 
static void reduce_crossCorrBinary_toplist_precision (toplist_t *l)
 
int write_crossCorr_toplist_to_fp (toplist_t *tl, FILE *fp, UINT4 *checksum)
 Writes the toplist to an (already open) filepointer Returns the number of written charactes sets the checksum if non-NULL Returns something <0 on error. More...
 
int write_crossCorrBinary_toplist_to_fp (toplist_t *tl, FILE *fp, UINT4 *checksum)
 
int atomic_write_crossCorr_toplist_to_file (toplist_t *l, const char *filename, UINT4 *checksum)
 writes the given toplitst to a temporary file, then renames the temporary file to filename. More...
 
int atomic_write_crossCorrBinary_toplist_to_file (toplist_t *l, const char *filename, UINT4 *checksum)
 
int final_write_crossCorr_toplist_to_file (toplist_t *l, const char *filename, UINT4 *checksum)
 meant for the final writing of the toplist More...
 
int final_write_crossCorrBinary_toplist_to_file (toplist_t *l, const char *filename, UINT4 *checksum)
 
int write_cc_checkpoint (const char *filename, toplist_t *tl, UINT4 counter, BOOLEAN do_sync)
 writes a checkpoint: More...
 
int read_cc_checkpoint (const char *filename, toplist_t *tl, UINT4 *counter)
 tries to read a checkpoint More...
 
int write_cc_output (const char *filename, toplist_t *tl)
 write the final output file: More...
 

Go to the source code of this file.

Macros

#define min(a, b)   ((a)<(b)?(a):(b))
 
#define SYNC_FAIL_LIMIT   5
 
#define TEMP_EXT   ".tmp"
 
#define TEMP_EXT   ".tmp"
 
#define __func__   ""
 log an I/O error, i.e. More...
 
#define LOGIOERROR(mess, filename)
 
#define TMP_EXT   ".tmp"
 

Macro Definition Documentation

◆ min

#define min (   a,
 
)    ((a)<(b)?(a):(b))

Definition at line 71 of file CrossCorrToplist.c.

◆ SYNC_FAIL_LIMIT

#define SYNC_FAIL_LIMIT   5

Definition at line 75 of file CrossCorrToplist.c.

◆ TEMP_EXT [1/2]

#define TEMP_EXT   ".tmp"

◆ TEMP_EXT [2/2]

#define TEMP_EXT   ".tmp"

◆ __func__

#define __func__   ""

log an I/O error, i.e.

source code line no., ferror, errno and strerror, and doserrno on Windows, too

Definition at line 872 of file CrossCorrToplist.c.

◆ LOGIOERROR

#define LOGIOERROR (   mess,
  filename 
)
Value:
LogPrintf(LOG_CRITICAL, "ERROR: %s %s: %s (%s:%d): errno:%d: %s\n",\
mess,filename,__func__,__FILE__,__LINE__,errno,strerror(errno))
#define __func__
log an I/O error, i.e.
void LogPrintf(LogLevel_t, const char *format,...) _LAL_GCC_PRINTF_FORMAT_(2
LOG_CRITICAL

Definition at line 881 of file CrossCorrToplist.c.

◆ TMP_EXT

#define TMP_EXT   ".tmp"

Function Documentation

◆ finite()

int finite ( double  )

◆ reduce_crossCorr_toplist_precision()

static void reduce_crossCorr_toplist_precision ( toplist_t l)
static

Definition at line 632 of file CrossCorrToplist.c.

◆ _atomic_write_crossCorr_toplist_to_file()

static int _atomic_write_crossCorr_toplist_to_file ( toplist_t l,
const char filename,
UINT4 checksum,
int  write_done 
)
static

Definition at line 708 of file CrossCorrToplist.c.

◆ _atomic_write_crossCorrBinary_toplist_to_file()

static int _atomic_write_crossCorrBinary_toplist_to_file ( toplist_t l,
const char filename,
UINT4 checksum,
int  write_done 
)
static

Definition at line 774 of file CrossCorrToplist.c.

◆ print_crossCorrline_to_str()

static int print_crossCorrline_to_str ( CrossCorrOutputEntry  fline,
char buf,
int  buflen 
)
static

Definition at line 505 of file CrossCorrToplist.c.

◆ print_crossCorrBinaryline_to_str()

static int print_crossCorrBinaryline_to_str ( CrossCorrBinaryOutputEntry  fline,
char buf,
int  buflen 
)
static

Definition at line 525 of file CrossCorrToplist.c.

◆ crossCorr_toplist_qsort_function()

static int crossCorr_toplist_qsort_function ( const void *  a,
const void *  b 
)
static

Definition at line 87 of file CrossCorrToplist.c.

◆ crossCorrBinary_toplist_qsort_function()

static int crossCorrBinary_toplist_qsort_function ( const void *  a,
const void *  b 
)
static

Definition at line 123 of file CrossCorrToplist.c.

◆ crossCorr_smaller()

static int crossCorr_smaller ( const void *  a,
const void *  b 
)
static

Definition at line 159 of file CrossCorrToplist.c.

◆ crossCorrBinary_smaller()

static int crossCorrBinary_smaller ( const void *  a,
const void *  b 
)
static

Definition at line 171 of file CrossCorrToplist.c.

◆ create_crossCorr_toplist()

int create_crossCorr_toplist ( toplist_t **  tl,
UINT8  length 
)

creates a toplist with length elements, returns -1 on error (usually out of memory), else 0

Definition at line 186 of file CrossCorrToplist.c.

◆ create_crossCorrBinary_toplist()

int create_crossCorrBinary_toplist ( toplist_t **  tl,
UINT8  length 
)

Definition at line 191 of file CrossCorrToplist.c.

◆ free_crossCorr_toplist()

void free_crossCorr_toplist ( toplist_t **  l)

frees the space occupied by the toplist

Definition at line 198 of file CrossCorrToplist.c.

◆ insert_into_crossCorr_toplist()

int insert_into_crossCorr_toplist ( toplist_t list,
CrossCorrOutputEntry  line 
)

Inserts an element in to the toplist either if there is space left or the element is larger than the smallest element in the toplist.

In the latter case, remove the smallest element from the toplist Returns 1 if the element was actually inserted, 0 if not.

Definition at line 209 of file CrossCorrToplist.c.

◆ insert_into_crossCorrBinary_toplist()

int insert_into_crossCorrBinary_toplist ( toplist_t tl,
CrossCorrBinaryOutputEntry  elem 
)

Definition at line 219 of file CrossCorrToplist.c.

◆ sort_crossCorr_toplist()

void sort_crossCorr_toplist ( toplist_t list)

reads a (created!) toplist from an open filepointer sets the checksum if non-NULL reads maximum maxbytes, all that is there if maxbytes is 0 returns the number of bytes read, 0 if we found a DONE marker at the end, -1 if the file contained a syntax error, -2 if given an improper toplist

sorts the toplist with an internal sorting function, used before finally writing it

Definition at line 232 of file CrossCorrToplist.c.

◆ sort_crossCorrBinary_toplist()

void sort_crossCorrBinary_toplist ( toplist_t l)

Definition at line 238 of file CrossCorrToplist.c.

◆ write_crossCorr_toplist_item_to_fp()

int write_crossCorr_toplist_item_to_fp ( CrossCorrOutputEntry  line,
FILE *  fp,
UINT4 checksum 
)

File IO.

writes a CrossCorrOutputEntry line to an open filepointer. Returns the number of chars written, -1 if in error Updates checksum if given (i.e. not NULL)

Definition at line 546 of file CrossCorrToplist.c.

◆ write_crossCorrBinary_toplist_item_to_fp()

int write_crossCorrBinary_toplist_item_to_fp ( CrossCorrBinaryOutputEntry  fline,
FILE *  fp,
UINT4 checksum 
)

Definition at line 568 of file CrossCorrToplist.c.

◆ reduce_crossCorrline_precision()

static void reduce_crossCorrline_precision ( void *  line)
static

Definition at line 591 of file CrossCorrToplist.c.

◆ reduce_crossCorrBinaryline_precision()

static void reduce_crossCorrBinaryline_precision ( void *  line)
static

Definition at line 611 of file CrossCorrToplist.c.

◆ reduce_crossCorrBinary_toplist_precision()

static void reduce_crossCorrBinary_toplist_precision ( toplist_t l)
static

Definition at line 638 of file CrossCorrToplist.c.

◆ write_crossCorr_toplist_to_fp()

int write_crossCorr_toplist_to_fp ( toplist_t tl,
FILE *  fp,
UINT4 checksum 
)

Writes the toplist to an (already open) filepointer Returns the number of written charactes sets the checksum if non-NULL Returns something <0 on error.

Definition at line 647 of file CrossCorrToplist.c.

◆ write_crossCorrBinary_toplist_to_fp()

int write_crossCorrBinary_toplist_to_fp ( toplist_t tl,
FILE *  fp,
UINT4 checksum 
)

Definition at line 669 of file CrossCorrToplist.c.

◆ atomic_write_crossCorr_toplist_to_file()

int atomic_write_crossCorr_toplist_to_file ( toplist_t list,
const char filename,
UINT4 checksum 
)

writes the given toplitst to a temporary file, then renames the temporary file to filename.

The name of the temporary file is derived from the filename by appending ".tmp". Returns the number of chars written or -1 if the temp file could not be opened.

Definition at line 695 of file CrossCorrToplist.c.

◆ atomic_write_crossCorrBinary_toplist_to_file()

int atomic_write_crossCorrBinary_toplist_to_file ( toplist_t l,
const char filename,
UINT4 checksum 
)

Definition at line 700 of file CrossCorrToplist.c.

◆ final_write_crossCorr_toplist_to_file()

int final_write_crossCorr_toplist_to_file ( toplist_t list,
const char filename,
UINT4 checksum 
)

meant for the final writing of the toplist

Definition at line 845 of file CrossCorrToplist.c.

◆ final_write_crossCorrBinary_toplist_to_file()

int final_write_crossCorrBinary_toplist_to_file ( toplist_t l,
const char filename,
UINT4 checksum 
)

Definition at line 853 of file CrossCorrToplist.c.

◆ write_cc_checkpoint()

int write_cc_checkpoint ( const char filename,
toplist_t tl,
UINT4  counter,
BOOLEAN  do_sync 
)

writes a checkpoint:

  • constructs temporary filename (by appending .TMP)
  • writes number of elements ("elems") in toplist to tempfile
  • dumps data to tempfile
  • appends counter
  • appends checksum (of elems, data and counter)
  • renames tempfile to final name returns -1 in case of an I/O error, -2 if out of memory, 0 otherwise (successful)

Definition at line 887 of file CrossCorrToplist.c.

◆ read_cc_checkpoint()

int read_cc_checkpoint ( const char filename,
toplist_t tl,
UINT4 counter 
)

tries to read a checkpoint

  • tries to open the file, returns 1 if no file found
  • reads elems, data, counter and checksum
  • verifies checksum
  • restores the heap by sorting returns 0 if successfully read a checkpoint 1 if no checkpoint was found -1 in case of an I/O error -2 if the checksum was wrong or elems was unreasonable

Definition at line 999 of file CrossCorrToplist.c.

◆ write_cc_output()

int write_cc_output ( const char filename,
toplist_t tl 
)

write the final output file:

  • re-sort the toplist into freq/alpha/delta/fdot order
  • write out the toplist in ASCII format with end marker to a temporary file
  • rename the file to the final name

Definition at line 1115 of file CrossCorrToplist.c.