~ubuntu-branches/ubuntu/trusty/mariadb-5.5/trusty-proposed

« back to all changes in this revision

Viewing changes to storage/tokudb/ft-index/ft/sub_block.h

  • Committer: Package Import Robot
  • Author(s): James Page, Otto Kekäläinen
  • Date: 2014-02-17 16:51:52 UTC
  • mfrom: (2.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20140217165152-k315d3175g865kkx
Tags: 5.5.35-1
[ Otto Kekäläinen ]
* New upstream release, fixing the following security issues:
  - Buffer overflow in client/mysql.cc (Closes: #737597).
    - CVE-2014-0001
  - http://www.oracle.com/technetwork/topics/security/cpujan2014-1972949.html
    - CVE-2013-5891
    - CVE-2013-5908
    - CVE-2014-0386
    - CVE-2014-0393
    - CVE-2014-0401
    - CVE-2014-0402
    - CVE-2014-0412
    - CVE-2014-0420
    - CVE-2014-0437
* Upstream https://mariadb.atlassian.net/browse/MDEV-4902
  fixes compatibility with Bison 3.0 (Closes: #733002)
* Updated Russian debconf translation (Closes: #734426)
* Updated Japanese debconf translation (Closes: #735284)
* Updated French debconf translation (Closes: #736480)
* Renamed SONAME properly (Closes: #732967)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
 
2
// vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
 
3
#ifndef TOKU_SUB_BLOCK_H
 
4
#define TOKU_SUB_BLOCK_H
 
5
 
 
6
#ident "$Id$"
 
7
/*
 
8
COPYING CONDITIONS NOTICE:
 
9
 
 
10
  This program is free software; you can redistribute it and/or modify
 
11
  it under the terms of version 2 of the GNU General Public License as
 
12
  published by the Free Software Foundation, and provided that the
 
13
  following conditions are met:
 
14
 
 
15
      * Redistributions of source code must retain this COPYING
 
16
        CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
 
17
        DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
 
18
        PATENT MARKING NOTICE (below), and the PATENT RIGHTS
 
19
        GRANT (below).
 
20
 
 
21
      * Redistributions in binary form must reproduce this COPYING
 
22
        CONDITIONS NOTICE, the COPYRIGHT NOTICE (below), the
 
23
        DISCLAIMER (below), the UNIVERSITY PATENT NOTICE (below), the
 
24
        PATENT MARKING NOTICE (below), and the PATENT RIGHTS
 
25
        GRANT (below) in the documentation and/or other materials
 
26
        provided with the distribution.
 
27
 
 
28
  You should have received a copy of the GNU General Public License
 
29
  along with this program; if not, write to the Free Software
 
30
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 
31
  02110-1301, USA.
 
32
 
 
33
COPYRIGHT NOTICE:
 
34
 
 
35
  TokuDB, Tokutek Fractal Tree Indexing Library.
 
36
  Copyright (C) 2007-2013 Tokutek, Inc.
 
37
 
 
38
DISCLAIMER:
 
39
 
 
40
  This program is distributed in the hope that it will be useful, but
 
41
  WITHOUT ANY WARRANTY; without even the implied warranty of
 
42
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
43
  General Public License for more details.
 
44
 
 
45
UNIVERSITY PATENT NOTICE:
 
46
 
 
47
  The technology is licensed by the Massachusetts Institute of
 
48
  Technology, Rutgers State University of New Jersey, and the Research
 
49
  Foundation of State University of New York at Stony Brook under
 
50
  United States of America Serial No. 11/760379 and to the patents
 
51
  and/or patent applications resulting from it.
 
52
 
 
53
PATENT MARKING NOTICE:
 
54
 
 
55
  This software is covered by US Patent No. 8,185,551.
 
56
  This software is covered by US Patent No. 8,489,638.
 
57
 
 
58
PATENT RIGHTS GRANT:
 
59
 
 
60
  "THIS IMPLEMENTATION" means the copyrightable works distributed by
 
61
  Tokutek as part of the Fractal Tree project.
 
62
 
 
63
  "PATENT CLAIMS" means the claims of patents that are owned or
 
64
  licensable by Tokutek, both currently or in the future; and that in
 
65
  the absence of this license would be infringed by THIS
 
66
  IMPLEMENTATION or by using or running THIS IMPLEMENTATION.
 
67
 
 
68
  "PATENT CHALLENGE" shall mean a challenge to the validity,
 
69
  patentability, enforceability and/or non-infringement of any of the
 
70
  PATENT CLAIMS or otherwise opposing any of the PATENT CLAIMS.
 
71
 
 
72
  Tokutek hereby grants to you, for the term and geographical scope of
 
73
  the PATENT CLAIMS, a non-exclusive, no-charge, royalty-free,
 
74
  irrevocable (except as stated in this section) patent license to
 
75
  make, have made, use, offer to sell, sell, import, transfer, and
 
76
  otherwise run, modify, and propagate the contents of THIS
 
77
  IMPLEMENTATION, where such license applies only to the PATENT
 
78
  CLAIMS.  This grant does not include claims that would be infringed
 
79
  only as a consequence of further modifications of THIS
 
80
  IMPLEMENTATION.  If you or your agent or licensee institute or order
 
81
  or agree to the institution of patent litigation against any entity
 
82
  (including a cross-claim or counterclaim in a lawsuit) alleging that
 
83
  THIS IMPLEMENTATION constitutes direct or contributory patent
 
84
  infringement, or inducement of patent infringement, then any rights
 
85
  granted to you under this License shall terminate as of the date
 
86
  such litigation is filed.  If you or your agent or exclusive
 
87
  licensee institute or order or agree to the institution of a PATENT
 
88
  CHALLENGE, then Tokutek may terminate any rights granted to you
 
89
  under this License.
 
90
*/
 
91
 
 
92
#ident "Copyright (c) 2007-2013 Tokutek Inc.  All rights reserved."
 
93
#ident "The technology is licensed by the Massachusetts Institute of Technology, Rutgers State University of New Jersey, and the Research Foundation of State University of New York at Stony Brook under United States of America Serial No. 11/760379 and to the patents and/or patent applications resulting from it."
 
94
 
 
95
#include "compress.h"
 
96
#include "fttypes.h"
 
97
 
 
98
 
 
99
static const int max_sub_blocks = 8;
 
100
static const int target_sub_block_size = 512*1024;
 
101
static const int max_basement_nodes = 32;
 
102
static const int max_basement_node_uncompressed_size = 256*1024;
 
103
static const int max_basement_node_compressed_size = 64*1024;
 
104
 
 
105
struct sub_block {
 
106
    void *uncompressed_ptr;
 
107
    uint32_t uncompressed_size;
 
108
 
 
109
    void *compressed_ptr;
 
110
    uint32_t compressed_size;         // real compressed size
 
111
    uint32_t compressed_size_bound;   // estimated compressed size
 
112
 
 
113
    uint32_t xsum;                    // sub block checksum
 
114
};
 
115
 
 
116
struct stored_sub_block {
 
117
    uint32_t uncompressed_size;
 
118
    uint32_t compressed_size;
 
119
    uint32_t xsum;
 
120
};
 
121
 
 
122
void sub_block_init(SUB_BLOCK);
 
123
SUB_BLOCK sub_block_creat(void);
 
124
 
 
125
// get the size of the compression header
 
126
size_t 
 
127
sub_block_header_size(int n_sub_blocks);
 
128
 
 
129
void
 
130
set_compressed_size_bound(struct sub_block *se, enum toku_compression_method method);
 
131
 
 
132
// get the sum of the sub block compressed bound sizes 
 
133
size_t 
 
134
get_sum_compressed_size_bound(int n_sub_blocks, struct sub_block sub_block[], enum toku_compression_method method);
 
135
 
 
136
// get the sum of the sub block uncompressed sizes 
 
137
size_t 
 
138
get_sum_uncompressed_size(int n_sub_blocks, struct sub_block sub_block[]);
 
139
 
 
140
// Choose n_sub_blocks and sub_block_size such that the product is >= total_size and the sub_block_size is at
 
141
// least >= the target_sub_block_size.
 
142
int
 
143
choose_sub_block_size(int total_size, int n_sub_blocks_limit, int *sub_block_size_ret, int *n_sub_blocks_ret);
 
144
 
 
145
int
 
146
choose_basement_node_size(int total_size, int *sub_block_size_ret, int *n_sub_blocks_ret);
 
147
 
 
148
void
 
149
set_all_sub_block_sizes(int total_size, int sub_block_size, int n_sub_blocks, struct sub_block sub_block[]);
 
150
 
 
151
// find the index of the first sub block that contains the offset
 
152
// Returns the index if found, else returns -1
 
153
int
 
154
get_sub_block_index(int n_sub_blocks, struct sub_block sub_block[], size_t offset);
 
155
 
 
156
#include "workset.h"
 
157
 
 
158
struct compress_work {
 
159
    struct work base;
 
160
    enum toku_compression_method method;
 
161
    struct sub_block *sub_block;
 
162
};
 
163
 
 
164
void
 
165
compress_work_init(struct compress_work *w, enum toku_compression_method method, struct sub_block *sub_block);
 
166
 
 
167
uint32_t
 
168
compress_nocrc_sub_block(
 
169
    struct sub_block *sub_block,
 
170
    void* sb_compressed_ptr,
 
171
    uint32_t cs_bound,
 
172
    enum toku_compression_method method
 
173
    );
 
174
 
 
175
void
 
176
compress_sub_block(struct sub_block *sub_block, enum toku_compression_method method);
 
177
 
 
178
void *
 
179
compress_worker(void *arg);
 
180
 
 
181
size_t
 
182
compress_all_sub_blocks(int n_sub_blocks, struct sub_block sub_block[], char *uncompressed_ptr, char *compressed_ptr, int num_cores, struct toku_thread_pool *pool, enum toku_compression_method method);
 
183
 
 
184
struct decompress_work {
 
185
    struct work base;
 
186
    void *compress_ptr;
 
187
    void *uncompress_ptr;
 
188
    uint32_t compress_size;
 
189
    uint32_t uncompress_size;
 
190
    uint32_t xsum;
 
191
    int error;
 
192
};
 
193
 
 
194
// initialize the decompression work
 
195
void 
 
196
decompress_work_init(struct decompress_work *dw,
 
197
                     void *compress_ptr, uint32_t compress_size,
 
198
                     void *uncompress_ptr, uint32_t uncompress_size,
 
199
                     uint32_t xsum);
 
200
 
 
201
// decompress one block
 
202
int
 
203
decompress_sub_block(void *compress_ptr, uint32_t compress_size, void *uncompress_ptr, uint32_t uncompress_size, uint32_t expected_xsum);
 
204
 
 
205
// decompress blocks until there is no more work to do
 
206
void *
 
207
decompress_worker(void *arg);
 
208
 
 
209
// decompress all sub blocks from the compressed_data buffer to the uncompressed_data buffer
 
210
// Returns 0 if success, otherwise an error
 
211
int
 
212
decompress_all_sub_blocks(int n_sub_blocks, struct sub_block sub_block[], unsigned char *compressed_data, unsigned char *uncompressed_data, int num_cores, struct toku_thread_pool *pool);
 
213
 
 
214
extern int verbose_decompress_sub_block;
 
215
 
 
216
 
 
217
#endif