Commit 15ca553a authored by unknown's avatar unknown

bitmap bug fixes and interface change

parent a46f4cf4
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
typedef struct st_bitmap typedef struct st_bitmap
{ {
uchar *bitmap; uint32 *bitmap;
uint bitmap_size; /* number of bits occupied by the above */ uint bitmap_size; /* number of bits occupied by the above */
uint32 last_word_mask; uint32 last_word_mask;
uint32 *last_word_ptr; uint32 *last_word_ptr;
...@@ -41,7 +41,7 @@ typedef struct st_bitmap ...@@ -41,7 +41,7 @@ typedef struct st_bitmap
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
extern my_bool bitmap_init(MY_BITMAP *map, uchar *buf, uint bitmap_size, my_bool thread_safe); extern my_bool bitmap_init(MY_BITMAP *map, uint32 *buf, uint bitmap_size, my_bool thread_safe);
extern my_bool bitmap_is_clear_all(const MY_BITMAP *map); extern my_bool bitmap_is_clear_all(const MY_BITMAP *map);
extern my_bool bitmap_is_prefix(const MY_BITMAP *map, uint prefix_size); extern my_bool bitmap_is_prefix(const MY_BITMAP *map, uint prefix_size);
extern my_bool bitmap_is_set_all(const MY_BITMAP *map); extern my_bool bitmap_is_set_all(const MY_BITMAP *map);
...@@ -84,10 +84,10 @@ extern void bitmap_lock_invert(MY_BITMAP *map); ...@@ -84,10 +84,10 @@ extern void bitmap_lock_invert(MY_BITMAP *map);
#define no_bytes_in_map(map) ((map->bitmap_size + 7)/8) #define no_bytes_in_map(map) ((map->bitmap_size + 7)/8)
#define no_words_in_map(map) ((map->bitmap_size + 31)/32) #define no_words_in_map(map) ((map->bitmap_size + 31)/32)
#define bytes_word_aligned(bytes) (4*((bytes + 3)/4)) #define bytes_word_aligned(bytes) (4*((bytes + 3)/4))
#define bitmap_set_bit(MAP, BIT) ((MAP)->bitmap[(BIT) / 8] |= (1 << ((BIT) & 7))) #define bitmap_set_bit(MAP, BIT) ((MAP)->bitmap[(BIT) / 32] |= (1 << ((BIT) & 31)))
#define bitmap_flip_bit(MAP, BIT) ((MAP)->bitmap[(BIT) / 8] ^= (1 << ((BIT) & 7))) #define bitmap_flip_bit(MAP, BIT) ((MAP)->bitmap[(BIT) / 32] ^= (1 << ((BIT) & 31)))
#define bitmap_clear_bit(MAP, BIT) ((MAP)->bitmap[(BIT) / 8] &= ~ (1 << ((BIT) & 7))) #define bitmap_clear_bit(MAP, BIT) ((MAP)->bitmap[(BIT) / 32] &= ~ (1 << ((BIT) & 31)))
#define bitmap_is_set(MAP, BIT) ((MAP)->bitmap[(BIT) / 8] & (1 << ((BIT) & 7))) #define bitmap_is_set(MAP, BIT) ((MAP)->bitmap[(BIT) / 32] & (1 << ((BIT) & 31)))
#define bitmap_cmp(MAP1, MAP2) \ #define bitmap_cmp(MAP1, MAP2) \
(memcmp((MAP1)->bitmap, (MAP2)->bitmap, 4*no_words_in_map((MAP1)))==0) (memcmp((MAP1)->bitmap, (MAP2)->bitmap, 4*no_words_in_map((MAP1)))==0)
#define bitmap_clear_all(MAP) \ #define bitmap_clear_all(MAP) \
......
...@@ -80,6 +80,9 @@ FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) @NOINST_LDFLAGS@ ...@@ -80,6 +80,9 @@ FLAGS=$(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) @NOINST_LDFLAGS@
# which automaticly removes the object files you use to compile a final program # which automaticly removes the object files you use to compile a final program
# #
test_bitmap$(EXEEXT): my_bitmap.c $(LIBRARIES)
$(LINK) $(FLAGS) -DMAIN ./my_bitmap.c $(LDADD) $(LIBS)
test_thr_alarm$(EXEEXT): thr_alarm.c $(LIBRARIES) test_thr_alarm$(EXEEXT): thr_alarm.c $(LIBRARIES)
$(CP) $(srcdir)/thr_alarm.c ./test_thr_alarm.c $(CP) $(srcdir)/thr_alarm.c ./test_thr_alarm.c
$(LINK) $(FLAGS) -DMAIN ./test_thr_alarm.c $(LDADD) $(LIBS) $(LINK) $(FLAGS) -DMAIN ./test_thr_alarm.c $(LDADD) $(LIBS)
......
This diff is collapsed.
...@@ -1360,20 +1360,31 @@ int handler::ha_initialise() ...@@ -1360,20 +1360,31 @@ int handler::ha_initialise()
int handler::ha_allocate_read_write_set(ulong no_fields) int handler::ha_allocate_read_write_set(ulong no_fields)
{ {
uint bitmap_size= 4*(((no_fields+1)+31)/32); uint bitmap_size= 4*(((no_fields+1)+31)/32);
uchar *read_buf, *write_buf; uint32 *read_buf, *write_buf;
#ifndef DEBUG_OFF
my_bool r;
#endif
DBUG_ENTER("ha_allocate_read_write_set"); DBUG_ENTER("ha_allocate_read_write_set");
DBUG_PRINT("info", ("no_fields = %d", no_fields)); DBUG_PRINT("info", ("no_fields = %d", no_fields));
read_set= (MY_BITMAP*)sql_alloc(sizeof(MY_BITMAP)); read_set= (MY_BITMAP*)sql_alloc(sizeof(MY_BITMAP));
write_set= (MY_BITMAP*)sql_alloc(sizeof(MY_BITMAP)); write_set= (MY_BITMAP*)sql_alloc(sizeof(MY_BITMAP));
read_buf= (uchar*)sql_alloc(bitmap_size); read_buf= (uint32*)sql_alloc(bitmap_size);
write_buf= (uchar*)sql_alloc(bitmap_size); write_buf= (uint32*)sql_alloc(bitmap_size);
DBUG_ASSERT(!bitmap_init(read_set, read_buf, (no_fields+1), FALSE));
DBUG_ASSERT(!bitmap_init(write_set, write_buf, (no_fields+1), FALSE));
if (!read_set || !write_set || !read_buf || !write_buf) if (!read_set || !write_set || !read_buf || !write_buf)
{ {
ha_deallocate_read_write_set(); ha_deallocate_read_write_set();
DBUG_RETURN(TRUE); DBUG_RETURN(TRUE);
} }
#ifndef DEBUG_OFF
r =
#endif
bitmap_init(read_set, read_buf, no_fields+1, FALSE);
DBUG_ASSERT(!r /*bitmap_init(read_set...)*/);
#ifndef DEBUG_OFF
r =
#endif
bitmap_init(write_set, write_buf, no_fields+1, FALSE);
DBUG_ASSERT(!r /*bitmap_init(write_set...)*/);
ha_clear_all_set(); ha_clear_all_set();
DBUG_RETURN(FALSE); DBUG_RETURN(FALSE);
} }
......
...@@ -1566,9 +1566,9 @@ static int fill_used_fields_bitmap(PARAM *param) ...@@ -1566,9 +1566,9 @@ static int fill_used_fields_bitmap(PARAM *param)
{ {
TABLE *table= param->table; TABLE *table= param->table;
param->fields_bitmap_size= (table->s->fields/8 + 1); param->fields_bitmap_size= (table->s->fields/8 + 1);
uchar *tmp; uint32 *tmp;
uint pk; uint pk;
if (!(tmp= (uchar*)alloc_root(param->mem_root, if (!(tmp= (uint32*)alloc_root(param->mem_root,
bytes_word_aligned(param->fields_bitmap_size))) || bytes_word_aligned(param->fields_bitmap_size))) ||
bitmap_init(&param->needed_fields, tmp, param->fields_bitmap_size*8, bitmap_init(&param->needed_fields, tmp, param->fields_bitmap_size*8,
FALSE)) FALSE))
...@@ -2309,7 +2309,7 @@ static ...@@ -2309,7 +2309,7 @@ static
ROR_SCAN_INFO *make_ror_scan(const PARAM *param, int idx, SEL_ARG *sel_arg) ROR_SCAN_INFO *make_ror_scan(const PARAM *param, int idx, SEL_ARG *sel_arg)
{ {
ROR_SCAN_INFO *ror_scan; ROR_SCAN_INFO *ror_scan;
uchar *bitmap_buf; uint32 *bitmap_buf;
uint keynr; uint keynr;
DBUG_ENTER("make_ror_scan"); DBUG_ENTER("make_ror_scan");
if (!(ror_scan= (ROR_SCAN_INFO*)alloc_root(param->mem_root, if (!(ror_scan= (ROR_SCAN_INFO*)alloc_root(param->mem_root,
...@@ -2323,7 +2323,7 @@ ROR_SCAN_INFO *make_ror_scan(const PARAM *param, int idx, SEL_ARG *sel_arg) ...@@ -2323,7 +2323,7 @@ ROR_SCAN_INFO *make_ror_scan(const PARAM *param, int idx, SEL_ARG *sel_arg)
ror_scan->sel_arg= sel_arg; ror_scan->sel_arg= sel_arg;
ror_scan->records= param->table->quick_rows[keynr]; ror_scan->records= param->table->quick_rows[keynr];
if (!(bitmap_buf= (uchar*)alloc_root(param->mem_root, if (!(bitmap_buf= (uint32*)alloc_root(param->mem_root,
bytes_word_aligned(param->fields_bitmap_size)))) bytes_word_aligned(param->fields_bitmap_size))))
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
...@@ -2439,12 +2439,12 @@ static ...@@ -2439,12 +2439,12 @@ static
ROR_INTERSECT_INFO* ror_intersect_init(const PARAM *param) ROR_INTERSECT_INFO* ror_intersect_init(const PARAM *param)
{ {
ROR_INTERSECT_INFO *info; ROR_INTERSECT_INFO *info;
uchar* buf; uint32* buf;
if (!(info= (ROR_INTERSECT_INFO*)alloc_root(param->mem_root, if (!(info= (ROR_INTERSECT_INFO*)alloc_root(param->mem_root,
sizeof(ROR_INTERSECT_INFO)))) sizeof(ROR_INTERSECT_INFO))))
return NULL; return NULL;
info->param= param; info->param= param;
if (!(buf= (uchar*)alloc_root(param->mem_root, if (!(buf= (uint32*)alloc_root(param->mem_root,
bytes_word_aligned(param->fields_bitmap_size)))) bytes_word_aligned(param->fields_bitmap_size))))
return NULL; return NULL;
if (bitmap_init(&info->covered_fields, buf, param->fields_bitmap_size*8, if (bitmap_init(&info->covered_fields, buf, param->fields_bitmap_size*8,
...@@ -3003,9 +3003,8 @@ TRP_ROR_INTERSECT *get_best_covering_ror_intersect(PARAM *param, ...@@ -3003,9 +3003,8 @@ TRP_ROR_INTERSECT *get_best_covering_ror_intersect(PARAM *param,
ror_scan_mark= tree->ror_scans; ror_scan_mark= tree->ror_scans;
uint32 int_buf[MAX_KEY/32+1]; uint32 int_buf[MAX_KEY/32+1];
uchar *buf= (uchar*)&int_buf;
MY_BITMAP covered_fields; MY_BITMAP covered_fields;
if (bitmap_init(&covered_fields, buf, nbits, FALSE)) if (bitmap_init(&covered_fields, int_buf, nbits, FALSE))
DBUG_RETURN(0); DBUG_RETURN(0);
bitmap_clear_all(&covered_fields); bitmap_clear_all(&covered_fields);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment