LALPulsar 7.1.1.1-eeff03c
FstatToplist.h File Reference

Prototypes

int create_fstat_toplist (toplist_t **list, UINT8 length)
 creates a toplist with length elements, returns -1 on error (usually out of memory), else 0 More...
 
void free_fstat_toplist (toplist_t **list)
 frees the space occupied by the toplist More...
 
int insert_into_fstat_toplist (toplist_t *list, FstatOutputEntry 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. More...
 
int write_fstat_toplist_to_fp (toplist_t *list, 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 read_fstat_toplist_from_fp (toplist_t *list, FILE *fp, UINT4 *checksum, UINT4 maxbytes)
 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_fstat_toplist (toplist_t *list)
 sorts the toplist with an internal sorting function, used before finally writing it More...
 
int write_fstat_toplist_item_to_fp (FstatOutputEntry line, FILE *fp, UINT4 *checksum)
 File IO. More...
 
int atomic_write_fstat_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. More...
 
int final_write_fstat_toplist_to_file (toplist_t *list, const char *filename, UINT4 *checksum)
 meant for the final writing of the toplist More...
 
int fstat_cpt_file_create (FstatCheckpointFile **cptf, CHAR *filename, UINT4 bufsize, UINT4 maxsize, toplist_t *tl)
 creates a FstatCheckpointFile More...
 
int fstat_cpt_file_destroy (FstatCheckpointFile **cptf)
 destroys a FstatCheckpointFile More...
 
int fstat_cpt_file_open (FstatCheckpointFile *cptf)
 opens a file for checkpointing the desired toplist More...
 
int fstat_cpt_file_flush (FstatCheckpointFile *cptf)
 flushes the checkpoint file (only useful if buffered) More...
 
int fstat_cpt_file_info (FstatCheckpointFile *cptf, CHAR **filename, UINT4 *bytes, UINT4 *checksum)
 returns information for checkpointing More...
 
int fstat_cpt_file_add (FstatCheckpointFile *cptf, FstatOutputEntry line)
 adds an item to the toplist and keeps the file consistent, i.e. More...
 
int fstat_cpt_file_close (FstatCheckpointFile *cptf)
 closes the file, reduces the precision, sorts the toplist, finally rewrites the file (sorted and compact) with end marker More...
 
int fstat_cpt_file_read (FstatCheckpointFile *cptf, UINT4 checksum, UINT4 maxbytes)
 reads a written checkpointed toplist back into memory More...
 
int fstat_cpt_file_compact (FstatCheckpointFile *cptf)
 compact a toplist file if the length has reached maxbytes More...
 
int write_hs_checkpoint (const char *filename, toplist_t *tl, UINT4 counter, BOOLEAN do_sync)
 new, simpler checkpointing for HierarchicalSearch More...
 
int read_hs_checkpoint (const char *filename, toplist_t *tl, UINT4 *counter)
 tries to read a checkpoint More...
 
int write_hs_oputput (const char *filename, toplist_t *tl)
 write the final output file: More...
 

Go to the source code of this file.

Data Structures

struct  FstatOutputEntry
 Type to hold the fields that will be output in unclustered output file
More...
 
struct  FstatCheckpointFile
 a toplist as a checkpointed file More...
 

Macros

#define MAXFILENAMELENGTH   256 /* Maximum # of characters of a filename */
 

Macro Definition Documentation

◆ MAXFILENAMELENGTH

#define MAXFILENAMELENGTH   256 /* Maximum # of characters of a filename */

Definition at line 30 of file FstatToplist.h.

Function Documentation

◆ create_fstat_toplist()

int create_fstat_toplist ( toplist_t **  list,
UINT8  length 
)

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

Definition at line 111 of file FstatToplist.c.

◆ free_fstat_toplist()

void free_fstat_toplist ( toplist_t **  list)

frees the space occupied by the toplist

Definition at line 118 of file FstatToplist.c.

◆ insert_into_fstat_toplist()

int insert_into_fstat_toplist ( toplist_t list,
FstatOutputEntry  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 129 of file FstatToplist.c.

◆ write_fstat_toplist_to_fp()

int write_fstat_toplist_to_fp ( toplist_t list,
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 352 of file FstatToplist.c.

◆ read_fstat_toplist_from_fp()

int read_fstat_toplist_from_fp ( toplist_t list,
FILE *  fp,
UINT4 checksum,
UINT4  maxbytes 
)

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

Definition at line 151 of file FstatToplist.c.

◆ sort_fstat_toplist()

void sort_fstat_toplist ( toplist_t list)

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

Definition at line 140 of file FstatToplist.c.

◆ write_fstat_toplist_item_to_fp()

int write_fstat_toplist_item_to_fp ( FstatOutputEntry  line,
FILE *  fp,
UINT4 checksum 
)

File IO.

writes an FstatOutputEntry 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 303 of file FstatToplist.c.

◆ atomic_write_fstat_toplist_to_file()

int atomic_write_fstat_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 378 of file FstatToplist.c.

◆ final_write_fstat_toplist_to_file()

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

meant for the final writing of the toplist

Definition at line 456 of file FstatToplist.c.

◆ fstat_cpt_file_create()

int fstat_cpt_file_create ( FstatCheckpointFile **  cptf,
CHAR filename,
UINT4  bufsize,
UINT4  maxsize,
toplist_t tl 
)

creates a FstatCheckpointFile

Definition at line 467 of file FstatToplist.c.

◆ fstat_cpt_file_destroy()

int fstat_cpt_file_destroy ( FstatCheckpointFile **  cptf)

destroys a FstatCheckpointFile

Definition at line 525 of file FstatToplist.c.

◆ fstat_cpt_file_open()

int fstat_cpt_file_open ( FstatCheckpointFile cptf)

opens a file for checkpointing the desired toplist

Definition at line 545 of file FstatToplist.c.

◆ fstat_cpt_file_flush()

int fstat_cpt_file_flush ( FstatCheckpointFile cptf)

flushes the checkpoint file (only useful if buffered)

Definition at line 574 of file FstatToplist.c.

◆ fstat_cpt_file_info()

int fstat_cpt_file_info ( FstatCheckpointFile cptf,
CHAR **  filename,
UINT4 bytes,
UINT4 checksum 
)

returns information for checkpointing

Definition at line 590 of file FstatToplist.c.

◆ fstat_cpt_file_add()

int fstat_cpt_file_add ( FstatCheckpointFile cptf,
FstatOutputEntry  line 
)

adds an item to the toplist and keeps the file consistent, i.e.

adds the entry to the file if it was really inserted and compacts the file if necessary

Definition at line 637 of file FstatToplist.c.

◆ fstat_cpt_file_close()

int fstat_cpt_file_close ( FstatCheckpointFile cptf)

closes the file, reduces the precision, sorts the toplist, finally rewrites the file (sorted and compact) with end marker

Definition at line 611 of file FstatToplist.c.

◆ fstat_cpt_file_read()

int fstat_cpt_file_read ( FstatCheckpointFile cptf,
UINT4  checksum,
UINT4  maxbytes 
)

reads a written checkpointed toplist back into memory

Definition at line 668 of file FstatToplist.c.

◆ fstat_cpt_file_compact()

int fstat_cpt_file_compact ( FstatCheckpointFile cptf)

compact a toplist file if the length has reached maxbytes

Definition at line 721 of file FstatToplist.c.

◆ write_hs_checkpoint()

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

new, simpler checkpointing for HierarchicalSearch

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 766 of file FstatToplist.c.

◆ read_hs_checkpoint()

int read_hs_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 878 of file FstatToplist.c.

◆ write_hs_oputput()

int write_hs_oputput ( 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 988 of file FstatToplist.c.