1 /* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 // vim: ft=cpp:expandtab:ts=8:sw=4:softtabstop=4:
3 #ident "$Id$"
4 /*======
5 This file is part of PerconaFT.
6
7
8 Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved.
9
10 PerconaFT is free software: you can redistribute it and/or modify
11 it under the terms of the GNU General Public License, version 2,
12 as published by the Free Software Foundation.
13
14 PerconaFT is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with PerconaFT. If not, see <http://www.gnu.org/licenses/>.
21
22 ----------------------------------------
23
24 PerconaFT is free software: you can redistribute it and/or modify
25 it under the terms of the GNU Affero General Public License, version 3,
26 as published by the Free Software Foundation.
27
28 PerconaFT is distributed in the hope that it will be useful,
29 but WITHOUT ANY WARRANTY; without even the implied warranty of
30 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
31 GNU Affero General Public License for more details.
32
33 You should have received a copy of the GNU Affero General Public License
34 along with PerconaFT. If not, see <http://www.gnu.org/licenses/>.
35 ======= */
36
37 #ident "Copyright (c) 2006, 2015, Percona and/or its affiliates. All rights reserved."
38
39 #include "test.h"
40
41 static TOKUTXN const null_txn = 0;
42
test2(int limit)43 static void test2 (int limit) {
44 FT_HANDLE t;
45 int r;
46 int i;
47 CACHETABLE ct;
48 const char *fname = TOKU_TEST_FILENAME;
49 if (verbose) printf("%s:%d checking\n", __FILE__, __LINE__);
50
51 toku_cachetable_create(&ct, 0, ZERO_LSN, nullptr);
52 unlink(fname);
53 r = toku_open_ft_handle(fname, 1, &t, 1024, 256, TOKU_DEFAULT_COMPRESSION_METHOD, ct, null_txn, toku_builtin_compare_fun);
54 if (verbose) printf("%s:%d did setup\n", __FILE__, __LINE__);
55 assert(r==0);
56 for (i=0; i<limit; i++) { // 4096
57 DBT k,v;
58 char key[100],val[100];
59 snprintf(key,100,"hello%d",i);
60 snprintf(val,100,"there%d",i);
61 toku_ft_insert(t, toku_fill_dbt(&k, key, 1+strlen(key)), toku_fill_dbt(&v, val, 1+strlen(val)), null_txn);
62 assert(r==0);
63 r = toku_verify_ft(t); assert(r==0);
64 //printf("%s:%d did insert %d\n", __FILE__, __LINE__, i);
65 }
66 if (verbose) printf("%s:%d inserted\n", __FILE__, __LINE__);
67 r = toku_verify_ft(t); assert(r==0);
68 r = toku_close_ft_handle_nolsn(t, 0); assert(r==0);
69 toku_cachetable_close(&ct);
70
71 if (verbose) printf("test2 ok\n");
72 }
73
74 int
test_main(int argc,const char * argv[])75 test_main (int argc , const char *argv[]) {
76 default_parse_args(argc, argv);
77 if (verbose) printf("test2 faster\n");
78 test2(2);
79 test2(27);
80 test2(212);
81 test2(4096);
82
83 if (verbose) printf("test1 ok\n");
84 return 0;
85 }
86