~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/blitzdb/blitzindex.cc

Merge Joe, plus I updated the tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
 
20
#include <config.h>
21
21
#include "ha_blitz.h"
22
22
 
23
23
/* Unlike the data dictionary, don't tune the btree by default
28
28
  char buf[FN_REFLEN];
29
29
 
30
30
  if ((btree = tcbdbnew()) == NULL)
31
 
    return drizzled::HA_ERR_OUT_OF_MEM;
 
31
    return HA_ERR_OUT_OF_MEM;
32
32
 
33
33
  if (!tcbdbsetmutex(btree)) {
34
34
    tcbdbdel(btree);
35
 
    return drizzled::HA_ERR_GENERIC;
36
 
  }
37
 
 
38
 
  if (blitz_estimated_rows != 0) {
39
 
    uint64_t tree_buckets = blitz_estimated_rows / 10;
40
 
    if (!tcbdbtune(btree, 0, 0, tree_buckets, -1, -1, 0)) {
41
 
      tcbdbdel(btree);
42
 
      return drizzled::HA_ERR_GENERIC;
43
 
    }
 
35
    return HA_ERR_CRASHED_ON_USAGE;
44
36
  }
45
37
 
46
38
  if (!tcbdbsetcmpfunc(btree, blitz_keycmp_cb, this)) {
47
39
    tcbdbdel(btree);
48
 
    return drizzled::HA_ERR_GENERIC;
 
40
    return HA_ERR_CRASHED_ON_USAGE;
49
41
  }
50
42
 
51
43
  snprintf(buf, FN_REFLEN, "%s_%02d%s", path, key_num, BLITZ_INDEX_EXT);
52
44
 
53
45
  if (!tcbdbopen(btree, buf, mode)) {
54
46
    tcbdbdel(btree);
55
 
    return drizzled::HA_ERR_CRASHED_ON_USAGE;
 
47
    return HA_ERR_CRASHED_ON_USAGE;
56
48
  }
57
49
 
58
50
  return 0;
92
84
 
93
85
  if (!tcbdbclose(btree)) {
94
86
    tcbdbdel(btree);
95
 
    return drizzled::HA_ERR_CRASHED_ON_USAGE;
 
87
    return HA_ERR_CRASHED_ON_USAGE;
96
88
  }
97
89
 
98
90
  tcbdbdel(btree);
127
119
int BlitzTree::write_unique(const char *key, const size_t klen) {
128
120
  if (!tcbdbputkeep(btree, key, klen, "", 0)) {
129
121
    if (tcbdbecode(btree) == TCEKEEP) {
130
 
      errno = drizzled::HA_ERR_FOUND_DUPP_KEY;
131
 
      return drizzled::HA_ERR_FOUND_DUPP_KEY;
 
122
      errno = HA_ERR_FOUND_DUPP_KEY;
 
123
      return HA_ERR_FOUND_DUPP_KEY;
132
124
    }
133
125
  }
134
126
  return 0;