Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes14kdownloads
toast_compression.h74 linesDownload Raw Back to access
1/*-------------------------------------------------------------------------2 *3 * toast_compression.h4 *	  Functions for toast compression.5 *6 * Copyright (c) 2021-2023, PostgreSQL Global Development Group7 *8 * src/include/access/toast_compression.h9 *10 *-------------------------------------------------------------------------11 */12 13#ifndef TOAST_COMPRESSION_H14#define TOAST_COMPRESSION_H15 16/*17 * GUC support.18 *19 * default_toast_compression is an integer for purposes of the GUC machinery,20 * but the value is one of the char values defined below, as they appear in21 * pg_attribute.attcompression, e.g. TOAST_PGLZ_COMPRESSION.22 */23extern PGDLLIMPORT int default_toast_compression;24 25/*26 * Built-in compression method ID.  The toast compression header will store27 * this in the first 2 bits of the raw length.  These built-in compression28 * method IDs are directly mapped to the built-in compression methods.29 *30 * Don't use these values for anything other than understanding the meaning31 * of the raw bits from a varlena; in particular, if the goal is to identify32 * a compression method, use the constants TOAST_PGLZ_COMPRESSION, etc.33 * below. We might someday support more than 4 compression methods, but34 * we can never have more than 4 values in this enum, because there are35 * only 2 bits available in the places where this is stored.36 */37typedef enum ToastCompressionId38{39	TOAST_PGLZ_COMPRESSION_ID = 0,40	TOAST_LZ4_COMPRESSION_ID = 1,41	TOAST_INVALID_COMPRESSION_ID = 242} ToastCompressionId;43 44/*45 * Built-in compression methods.  pg_attribute will store these in the46 * attcompression column.  In attcompression, InvalidCompressionMethod47 * denotes the default behavior.48 */49#define TOAST_PGLZ_COMPRESSION			'p'50#define TOAST_LZ4_COMPRESSION			'l'51#define InvalidCompressionMethod		'\0'52 53#define CompressionMethodIsValid(cm)  ((cm) != InvalidCompressionMethod)54 55 56/* pglz compression/decompression routines */57extern struct varlena *pglz_compress_datum(const struct varlena *value);58extern struct varlena *pglz_decompress_datum(const struct varlena *value);59extern struct varlena *pglz_decompress_datum_slice(const struct varlena *value,60												   int32 slicelength);61 62/* lz4 compression/decompression routines */63extern struct varlena *lz4_compress_datum(const struct varlena *value);64extern struct varlena *lz4_decompress_datum(const struct varlena *value);65extern struct varlena *lz4_decompress_datum_slice(const struct varlena *value,66												  int32 slicelength);67 68/* other stuff */69extern ToastCompressionId toast_get_compression_id(struct varlena *attr);70extern char CompressionNameToMethod(const char *compression);71extern const char *GetCompressionMethodName(char method);72 73#endif							/* TOAST_COMPRESSION_H */74 
codekingpro/portable-devtools · Team Ai