~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/blitzdb/blitzindex.cc

  • Committer: Brian Aker
  • Date: 2011-01-06 05:17:09 UTC
  • Revision ID: brian@tangent.org-20110106051709-oa0se8ur02uc6i9o
Added native functions into the function table.

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;
 
35
    return HA_ERR_GENERIC;
36
36
  }
37
37
 
38
38
  if (blitz_estimated_rows != 0) {
39
39
    uint64_t tree_buckets = blitz_estimated_rows / 10;
40
40
    if (!tcbdbtune(btree, 0, 0, tree_buckets, -1, -1, 0)) {
41
41
      tcbdbdel(btree);
42
 
      return drizzled::HA_ERR_GENERIC;
 
42
      return HA_ERR_GENERIC;
43
43
    }
44
44
  }
45
45
 
46
46
  if (!tcbdbsetcmpfunc(btree, blitz_keycmp_cb, this)) {
47
47
    tcbdbdel(btree);
48
 
    return drizzled::HA_ERR_GENERIC;
 
48
    return HA_ERR_GENERIC;
49
49
  }
50
50
 
51
51
  snprintf(buf, FN_REFLEN, "%s_%02d%s", path, key_num, BLITZ_INDEX_EXT);
52
52
 
53
53
  if (!tcbdbopen(btree, buf, mode)) {
54
54
    tcbdbdel(btree);
55
 
    return drizzled::HA_ERR_CRASHED_ON_USAGE;
 
55
    return HA_ERR_CRASHED_ON_USAGE;
56
56
  }
57
57
 
58
58
  return 0;
92
92
 
93
93
  if (!tcbdbclose(btree)) {
94
94
    tcbdbdel(btree);
95
 
    return drizzled::HA_ERR_CRASHED_ON_USAGE;
 
95
    return HA_ERR_CRASHED_ON_USAGE;
96
96
  }
97
97
 
98
98
  tcbdbdel(btree);
127
127
int BlitzTree::write_unique(const char *key, const size_t klen) {
128
128
  if (!tcbdbputkeep(btree, key, klen, "", 0)) {
129
129
    if (tcbdbecode(btree) == TCEKEEP) {
130
 
      errno = drizzled::HA_ERR_FOUND_DUPP_KEY;
131
 
      return drizzled::HA_ERR_FOUND_DUPP_KEY;
 
130
      errno = HA_ERR_FOUND_DUPP_KEY;
 
131
      return HA_ERR_FOUND_DUPP_KEY;
132
132
    }
133
133
  }
134
134
  return 0;