CUBRID Engine  latest
log_compress.h
Go to the documentation of this file.
1 /*
2  * Copyright 2008 Search Solution Corporation
3  * Copyright 2016 CUBRID Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  */
18 
19 
20 /*
21  * log_compress.h - log compression functions
22  *
23  * Note: Using lz4 library
24  */
25 
26 #ifndef _LOG_COMPRESS_H_
27 #define _LOG_COMPRESS_H_
28 
29 #ident "$Id$"
30 
31 #include "lz4.h"
32 
33 #define MAKE_ZIP_LEN(length) \
34  ((length) | 0x80000000)
35 
36 #define GET_ZIP_LEN(length) \
37  ((length) & ~(0x80000000))
38 
39 #define ZIP_CHECK(length) \
40  (((length) & 0x80000000) ? true : false)
41 
42 /* plus lz4 overhead to log_zip data size */
43 #define LOG_ZIP_BUF_SIZE(length) \
44  (LZ4_compressBound(length) + sizeof(LOG_ZIP_SIZE_T))
45 
46 #define LOG_ZIP_SIZE_T int
47 
48 /*
49  * Compressed(zipped) log structure
50  */
51 typedef struct log_zip LOG_ZIP;
52 
53 struct log_zip
54 {
55  LOG_ZIP_SIZE_T data_length; /* length of stored (compressed/uncompressed)log_zip data */
56  LOG_ZIP_SIZE_T buf_size; /* size of log_zip data buffer */
57  char *log_data; /* compressed/uncompressed log_zip data (used as data buffer) */
58 };
59 
60 extern LOG_ZIP *log_zip_alloc (LOG_ZIP_SIZE_T size);
61 extern void log_zip_free (LOG_ZIP * log_zip);
62 
63 extern bool log_zip (LOG_ZIP * log_zip, LOG_ZIP_SIZE_T length, const void *data);
64 extern bool log_unzip (LOG_ZIP * log_unzip, LOG_ZIP_SIZE_T length, void *data);
65 extern bool log_diff (LOG_ZIP_SIZE_T undo_length, const void *undo_data, LOG_ZIP_SIZE_T redo_length, void *redo_data);
66 
67 #endif /* _LOG_COMPRESS_H_ */
#define LOG_ZIP_SIZE_T
Definition: log_compress.h:46
bool log_diff(LOG_ZIP_SIZE_T undo_length, const void *undo_data, LOG_ZIP_SIZE_T redo_length, void *redo_data)
Definition: log_compress.c:201
LOG_ZIP * log_zip_alloc(LOG_ZIP_SIZE_T size)
Definition: log_compress.c:230
bool log_zip(LOG_ZIP *log_zip, LOG_ZIP_SIZE_T length, const void *data)
Definition: log_compress.c:43
LOG_ZIP_SIZE_T data_length
Definition: log_compress.h:55
char * log_data
Definition: log_compress.h:57
bool log_unzip(LOG_ZIP *log_unzip, LOG_ZIP_SIZE_T length, void *data)
Definition: log_compress.c:123
void log_zip_free(LOG_ZIP *log_zip)
Definition: log_compress.c:265
LOG_ZIP_SIZE_T buf_size
Definition: log_compress.h:56