PostgreSQL Source Code  git master
pg_lzcompress.h
Go to the documentation of this file.
1 /* ----------
2  * pg_lzcompress.h -
3  *
4  * Definitions for the builtin LZ compressor
5  *
6  * src/include/common/pg_lzcompress.h
7  * ----------
8  */
9 
10 #ifndef _PG_LZCOMPRESS_H_
11 #define _PG_LZCOMPRESS_H_
12 
13 
14 /* ----------
15  * PGLZ_MAX_OUTPUT -
16  *
17  * Macro to compute the buffer size required by pglz_compress().
18  * We allow 4 bytes for overrun before detecting compression failure.
19  * ----------
20  */
21 #define PGLZ_MAX_OUTPUT(_dlen) ((_dlen) + 4)
22 
23 
24 /* ----------
25  * PGLZ_Strategy -
26  *
27  * Some values that control the compression algorithm.
28  *
29  * min_input_size Minimum input data size to consider compression.
30  *
31  * max_input_size Maximum input data size to consider compression.
32  *
33  * min_comp_rate Minimum compression rate (0-99%) to require.
34  * Regardless of min_comp_rate, the output must be
35  * smaller than the input, else we don't store
36  * compressed.
37  *
38  * first_success_by Abandon compression if we find no compressible
39  * data within the first this-many bytes.
40  *
41  * match_size_good The initial GOOD match size when starting history
42  * lookup. When looking up the history to find a
43  * match that could be expressed as a tag, the
44  * algorithm does not always walk back entirely.
45  * A good match fast is usually better than the
46  * best possible one very late. For each iteration
47  * in the lookup, this value is lowered so the
48  * longer the lookup takes, the smaller matches
49  * are considered good.
50  *
51  * match_size_drop The percentage by which match_size_good is lowered
52  * after each history check. Allowed values are
53  * 0 (no change until end) to 100 (only check
54  * latest history entry at all).
55  * ----------
56  */
57 typedef struct PGLZ_Strategy
58 {
66 
67 
68 /* ----------
69  * The standard strategies
70  *
71  * PGLZ_strategy_default Recommended default strategy for TOAST.
72  *
73  * PGLZ_strategy_always Try to compress inputs of any length.
74  * Fallback to uncompressed storage only if
75  * output would be larger than input.
76  * ----------
77  */
80 
81 
82 /* ----------
83  * Global function declarations
84  * ----------
85  */
86 extern int32 pglz_compress(const char *source, int32 slen, char *dest,
87  const PGLZ_Strategy *strategy);
88 extern int32 pglz_decompress(const char *source, int32 slen, char *dest,
89  int32 rawsize, bool check_complete);
91  int32 total_compressed_size);
92 
93 #endif /* _PG_LZCOMPRESS_H_ */
#define PGDLLIMPORT
Definition: c.h:1316
signed int int32
Definition: c.h:494
PGDLLIMPORT const PGLZ_Strategy *const PGLZ_strategy_always
PGDLLIMPORT const PGLZ_Strategy *const PGLZ_strategy_default
struct PGLZ_Strategy PGLZ_Strategy
int32 pglz_decompress(const char *source, int32 slen, char *dest, int32 rawsize, bool check_complete)
int32 pglz_compress(const char *source, int32 slen, char *dest, const PGLZ_Strategy *strategy)
int32 pglz_maximum_compressed_size(int32 rawsize, int32 total_compressed_size)
static rewind_source * source
Definition: pg_rewind.c:89
int32 first_success_by
Definition: pg_lzcompress.h:62
int32 match_size_drop
Definition: pg_lzcompress.h:64
int32 match_size_good
Definition: pg_lzcompress.h:63
int32 min_comp_rate
Definition: pg_lzcompress.h:61
int32 min_input_size
Definition: pg_lzcompress.h:59
int32 max_input_size
Definition: pg_lzcompress.h:60