CWB
Macros | Functions | Variables
cwb-compress-rdx.c File Reference
#include <math.h>
#include "../cl/cl.h"
#include "../cl/globals.h"
#include "../cl/corpus.h"
#include "../cl/attributes.h"
#include "../cl/storage.h"
#include "../cl/bitio.h"
#include "../cl/compression.h"

Macros

#define log2(x)   (log(x)/log(2.0))
 

Functions

void compressrdx_usage (char *msg, int error_code)
 Prints a usage message and exits the program. More...
 
void compressrdx_cleanup (int error_code)
 Cleans up memory prior to an (error-prompted or normal) exit. More...
 
void compress_reversed_index (Attribute *attr, char *output_fn)
 Compresses the reversed index of a p-attribute. More...
 
void decompress_check_reversed_index (Attribute *attr, char *output_fn)
 Checks a compressed reversed index for errors by decompressing it. More...
 
int main (int argc, char **argv)
 Main function for cwb-compress-rdx. More...
 

Variables

char * progname = NULL
 Name of the program. More...
 
char * corpus_id = NULL
 CWB id of the corpus we are working on. More...
 
Corpuscorpus
 Record for the corpus we are working on. More...
 
int debug = 0
 debug level More...
 
FILE * debug_output
 where debug messages are to be sent to (stderr) More...
 
int codepos = 0
 stores current position in a bit-write-file More...
 

Macro Definition Documentation

#define log2 (   x)    (log(x)/log(2.0))

Function Documentation

void compress_reversed_index ( Attribute attr,
char *  output_fn 
)

Compresses the reversed index of a p-attribute.

Parameters
attrThe attribute to compress the index of.
output_fnBase name for the compressed RDX files to be written (if this is null, filenames will be taken from the attribute).

References _Attribute::any, BFclose(), BFflush(), BFopen(), BFposition(), CDA_OK, cl_delete_stream(), cl_errno, cl_error(), cl_id2freq(), cl_max_cpos(), CL_MAX_FILENAME_LENGTH, cl_max_id(), cl_new_stream(), cl_read_stream(), codepos, CompCompRF, CompCompRFX, component_full_name(), compressrdx_cleanup(), CompRevCorpus, CompRevCorpusIdx, compute_ba(), corpus_id, debug, debug_output, ensure_component(), NwriteInt(), and write_golomb_code().

Referenced by main().

void compressrdx_cleanup ( int  error_code)

Cleans up memory prior to an (error-prompted or normal) exit.

Parameters
error_codeValue to be returned by the program when it exits.

References cl_delete_corpus(), and debug_output.

Referenced by compress_reversed_index(), compressrdx_usage(), decompress_check_reversed_index(), and main().

void compressrdx_usage ( char *  msg,
int  error_code 
)

Prints a usage message and exits the program.

Parameters
msgA message about the error.
error_codeValue to be returned by the program when it exits.

References compressrdx_cleanup(), progname, and VERSION.

Referenced by main().

void decompress_check_reversed_index ( Attribute attr,
char *  output_fn 
)

Checks a compressed reversed index for errors by decompressing it.

This function this assumes that compress_reversed_index() has been called beforehand and made sure that the uncompressed index is usable by CL access functions.

Parameters
attrThe attribute to check the index of.
output_fnBase name for the compressed RDX files to be read (if this is null, filenames will be taken from the attribute).

References _Attribute::any, BFclose(), BFflush(), BFopen(), CDA_OK, cl_delete_stream(), cl_errno, cl_error(), cl_id2freq(), cl_max_cpos(), CL_MAX_FILENAME_LENGTH, cl_max_id(), cl_new_stream(), cl_read_stream(), CompCompRF, CompCompRFX, component_full_name(), compressrdx_cleanup(), CompRevCorpus, CompRevCorpusIdx, compute_ba(), corpus_id, debug, debug_output, and read_golomb_code_bf().

Referenced by main().

int main ( int  argc,
char **  argv 
)

Variable Documentation

int codepos = 0

stores current position in a bit-write-file

Referenced by compress_reversed_index().

Corpus* corpus
char* corpus_id = NULL

CWB id of the corpus we are working on.

Referenced by compress_reversed_index(), decompress_check_reversed_index(), and main().

int debug = 0
FILE* debug_output

where debug messages are to be sent to (stderr)

Referenced by compress_reversed_index(), compressrdx_cleanup(), decompress_check_reversed_index(), and main().

char* progname = NULL

Name of the program.

Referenced by compressrdx_usage(), and main().