2001-12-06 14:10:51 +02:00
|
|
|
/* Copyright (C) 2000 MySQL AB
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
2001-01-27 03:24:05 -06:00
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2001-12-06 14:10:51 +02:00
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
2001-01-27 03:24:05 -06:00
|
|
|
|
|
|
|
#ifndef _my_bitmap_h_
|
|
|
|
#define _my_bitmap_h_
|
|
|
|
|
2006-01-01 22:18:02 +01:00
|
|
|
#ifdef THREAD
|
2001-02-07 17:42:20 +02:00
|
|
|
#include <my_pthread.h>
|
2006-01-01 22:18:02 +01:00
|
|
|
#endif
|
2001-02-07 17:42:20 +02:00
|
|
|
|
|
|
|
#define MY_BIT_NONE (~(uint) 0)
|
|
|
|
|
2005-05-12 11:20:50 +02:00
|
|
|
|
2001-02-07 17:42:20 +02:00
|
|
|
typedef struct st_bitmap
|
|
|
|
{
|
2005-06-02 18:40:25 +02:00
|
|
|
uint32 *bitmap;
|
2005-06-02 22:10:57 +02:00
|
|
|
uint n_bits; /* number of bits occupied by the above */
|
2005-05-12 11:20:50 +02:00
|
|
|
uint32 last_word_mask;
|
|
|
|
uint32 *last_word_ptr;
|
2001-12-13 17:21:04 -07:00
|
|
|
/*
|
|
|
|
mutex will be acquired for the duration of each bitmap operation if
|
2003-10-24 22:44:48 +02:00
|
|
|
thread_safe flag in bitmap_init was set. Otherwise, we optimize by not
|
|
|
|
acquiring the mutex
|
2001-12-13 17:21:04 -07:00
|
|
|
*/
|
2001-02-07 17:42:20 +02:00
|
|
|
#ifdef THREAD
|
2003-10-24 22:44:48 +02:00
|
|
|
pthread_mutex_t *mutex;
|
2001-02-07 17:42:20 +02:00
|
|
|
#endif
|
2001-02-07 23:27:19 +02:00
|
|
|
} MY_BITMAP;
|
2001-01-27 03:24:05 -06:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
2005-06-02 22:10:57 +02:00
|
|
|
extern my_bool bitmap_init(MY_BITMAP *map, uint32 *buf, uint n_bits, my_bool thread_safe);
|
2003-10-30 19:17:57 +01:00
|
|
|
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_set_all(const MY_BITMAP *map);
|
|
|
|
extern my_bool bitmap_is_subset(const MY_BITMAP *map1, const MY_BITMAP *map2);
|
2005-07-01 07:05:42 +03:00
|
|
|
extern my_bool bitmap_test_and_set(MY_BITMAP *map, uint bitmap_bit);
|
|
|
|
extern my_bool bitmap_fast_test_and_set(MY_BITMAP *map, uint bitmap_bit);
|
2003-10-11 13:06:55 +02:00
|
|
|
extern uint bitmap_set_next(MY_BITMAP *map);
|
2004-05-13 01:38:40 +04:00
|
|
|
extern uint bitmap_get_first(const MY_BITMAP *map);
|
2005-05-12 11:20:50 +02:00
|
|
|
extern uint bitmap_get_first_set(const MY_BITMAP *map);
|
2004-05-13 01:38:40 +04:00
|
|
|
extern uint bitmap_bits_set(const MY_BITMAP *map);
|
2003-10-11 13:06:55 +02:00
|
|
|
extern void bitmap_free(MY_BITMAP *map);
|
Bug#10932 - Building server with key limit of 128, makes test cases fail
This patch allows to configure MyISAM for 128 indexes per table.
The main problem is the key_map, wich is implemented as an ulonglong.
To get rid of the limit and keep the efficient and flexible
implementation, the highest bit is now used for all upper keys.
This means that the lower keys can be disabled and enabled
individually as usual and the high keys can only be disabled and
enabled as a block. That way the existing test suite is still
applicable, while more keys work, though slightly less efficient.
To really get more than 64 keys, some defines need to be changed.
Another patch will address this.
include/my_bitmap.h:
Bug#10932 - Building server with key limit of 128, makes test cases fail
Added the declaration for a function that extends the highest bit value
to all upper bits of a bigger bitmap.
include/myisam.h:
Bug#10932 - Building server with key limit of 128, makes test cases fail
Changed MI_MAX_POSSIBLE_KEY to what it was meant for.
Added a bunch of macros to handle the MyISAM key_map.
myisam/mi_check.c:
Bug#10932 - Building server with key limit of 128, makes test cases fail
Changed key_map access to use the new macros.
myisam/mi_create.c:
Bug#10932 - Building server with key limit of 128, makes test cases fail
Changed key_map access to use the new macros.
myisam/mi_delete.c:
Bug#10932 - Building server with key limit of 128, makes test cases fail
Changed key_map access to use the new macros.
myisam/mi_extra.c:
Bug#10932 - Building server with key limit of 128, makes test cases fail
Changed key_map access to use the new macros.
myisam/mi_open.c:
Bug#10932 - Building server with key limit of 128, makes test cases fail
Changed key_map access to use the new macros.
Changed pointer types from signed char* to unsigned char*.
myisam/mi_preload.c:
Bug#10932 - Building server with key limit of 128, makes test cases fail
Changed key_map access to use the new macros.
myisam/mi_rsame.c:
Bug#10932 - Building server with key limit of 128, makes test cases fail
Changed key_map access to use the new macros.
myisam/mi_rsamepos.c:
Bug#10932 - Building server with key limit of 128, makes test cases fail
Changed key_map access to use the new macros.
myisam/mi_search.c:
Bug#10932 - Building server with key limit of 128, makes test cases fail
Changed key_map access to use the new macros.
myisam/mi_update.c:
Bug#10932 - Building server with key limit of 128, makes test cases fail
Changed key_map access to use the new macros.
myisam/mi_write.c:
Bug#10932 - Building server with key limit of 128, makes test cases fail
Changed key_map access to use the new macros.
myisam/myisamchk.c:
Bug#10932 - Building server with key limit of 128, makes test cases fail
Changed key_map access to use the new macros.
myisam/myisamdef.h:
Bug#10932 - Building server with key limit of 128, makes test cases fail
Changed pointer types from signed char* to unsigned char*.
myisam/myisamlog.c:
Bug#10932 - Building server with key limit of 128, makes test cases fail
Changed key_map access to use the new macros.
myisam/myisampack.c:
Bug#10932 - Building server with key limit of 128, makes test cases fail
Changed key_map access to use the new macros.
myisam/sort.c:
Bug#10932 - Building server with key limit of 128, makes test cases fail
Changed key_map access to use the new macros.
mysys/my_bitmap.c:
Bug#10932 - Building server with key limit of 128, makes test cases fail
Added a function that extends the highest bit value
to all upper bits of a bigger bitmap.
sql/ha_myisam.cc:
Bug#10932 - Building server with key limit of 128, makes test cases fail
Changed key_map access to use the new macros.
sql/sql_bitmap.h:
Bug#10932 - Building server with key limit of 128, makes test cases fail
Added a method that extends the highest bit value
to all upper bits of a bigger bitmap.
2005-07-19 14:13:56 +02:00
|
|
|
extern void bitmap_set_above(MY_BITMAP *map, uint from_byte, uint use_bit);
|
2003-10-11 13:06:55 +02:00
|
|
|
extern void bitmap_set_prefix(MY_BITMAP *map, uint prefix_size);
|
2005-05-12 11:20:50 +02:00
|
|
|
extern void bitmap_intersect(MY_BITMAP *map, const MY_BITMAP *map2);
|
2003-10-30 19:17:57 +01:00
|
|
|
extern void bitmap_subtract(MY_BITMAP *map, const MY_BITMAP *map2);
|
|
|
|
extern void bitmap_union(MY_BITMAP *map, const MY_BITMAP *map2);
|
2004-05-16 14:48:32 +03:00
|
|
|
|
2005-05-12 11:20:50 +02:00
|
|
|
extern uint bitmap_lock_set_next(MY_BITMAP *map);
|
|
|
|
extern void bitmap_lock_clear_bit(MY_BITMAP *map, uint bitmap_bit);
|
|
|
|
#ifdef NOT_USED
|
|
|
|
extern uint bitmap_lock_bits_set(const MY_BITMAP *map);
|
|
|
|
extern my_bool bitmap_lock_is_set_all(const MY_BITMAP *map);
|
|
|
|
extern uint bitmap_lock_get_first(const MY_BITMAP *map);
|
|
|
|
extern uint bitmap_lock_get_first_set(const MY_BITMAP *map);
|
|
|
|
extern my_bool bitmap_lock_is_subset(const MY_BITMAP *map1,
|
|
|
|
const MY_BITMAP *map2);
|
|
|
|
extern my_bool bitmap_lock_is_prefix(const MY_BITMAP *map, uint prefix_size);
|
|
|
|
extern my_bool bitmap_lock_is_set(const MY_BITMAP *map, uint bitmap_bit);
|
|
|
|
extern my_bool bitmap_lock_is_clear_all(const MY_BITMAP *map);
|
|
|
|
extern my_bool bitmap_lock_cmp(const MY_BITMAP *map1, const MY_BITMAP *map2);
|
|
|
|
extern void bitmap_lock_set_all(MY_BITMAP *map);
|
|
|
|
extern void bitmap_lock_clear_all(MY_BITMAP *map);
|
|
|
|
extern void bitmap_lock_set_bit(MY_BITMAP *map, uint bitmap_bit);
|
|
|
|
extern void bitmap_lock_flip_bit(MY_BITMAP *map, uint bitmap_bit);
|
|
|
|
extern void bitmap_lock_set_prefix(MY_BITMAP *map, uint prefix_size);
|
|
|
|
extern void bitmap_lock_intersect(MY_BITMAP *map, const MY_BITMAP *map2);
|
|
|
|
extern void bitmap_lock_subtract(MY_BITMAP *map, const MY_BITMAP *map2);
|
|
|
|
extern void bitmap_lock_union(MY_BITMAP *map, const MY_BITMAP *map2);
|
|
|
|
extern void bitmap_lock_xor(MY_BITMAP *map, const MY_BITMAP *map2);
|
|
|
|
extern void bitmap_lock_invert(MY_BITMAP *map);
|
|
|
|
#endif
|
2004-05-16 14:48:32 +03:00
|
|
|
/* Fast, not thread safe, bitmap functions */
|
2005-11-24 06:15:35 +02:00
|
|
|
#define bitmap_buffer_size(bits) 4*(((bits)+31)/32);
|
2005-06-02 22:10:57 +02:00
|
|
|
#define no_bytes_in_map(map) (((map)->n_bits + 7)/8)
|
|
|
|
#define no_words_in_map(map) (((map)->n_bits + 31)/32)
|
2005-05-12 11:20:50 +02:00
|
|
|
#define bytes_word_aligned(bytes) (4*((bytes + 3)/4))
|
2005-06-06 08:59:00 +02:00
|
|
|
#define _bitmap_set_bit(MAP, BIT) (((uchar*)(MAP)->bitmap)[(BIT) / 8] \
|
|
|
|
|= (1 << ((BIT) & 7)))
|
|
|
|
#define _bitmap_flip_bit(MAP, BIT) (((uchar*)(MAP)->bitmap)[(BIT) / 8] \
|
|
|
|
^= (1 << ((BIT) & 7)))
|
|
|
|
#define _bitmap_clear_bit(MAP, BIT) (((uchar*)(MAP)->bitmap)[(BIT) / 8] \
|
|
|
|
&= ~ (1 << ((BIT) & 7)))
|
|
|
|
#define _bitmap_is_set(MAP, BIT) (((uchar*)(MAP)->bitmap)[(BIT) / 8] \
|
|
|
|
& (1 << ((BIT) & 7)))
|
|
|
|
#ifndef DBUG_OFF
|
2005-11-06 02:19:51 +01:00
|
|
|
static inline uint32
|
2005-06-06 08:59:00 +02:00
|
|
|
bitmap_set_bit(MY_BITMAP *map,uint bit)
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(bit < (map)->n_bits);
|
|
|
|
return _bitmap_set_bit(map,bit);
|
|
|
|
}
|
2005-11-06 02:19:51 +01:00
|
|
|
static inline uint32
|
2005-06-06 08:59:00 +02:00
|
|
|
bitmap_flip_bit(MY_BITMAP *map,uint bit)
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(bit < (map)->n_bits);
|
|
|
|
return _bitmap_flip_bit(map,bit);
|
|
|
|
}
|
2005-11-06 02:19:51 +01:00
|
|
|
static inline uint32
|
2005-06-06 08:59:00 +02:00
|
|
|
bitmap_clear_bit(MY_BITMAP *map,uint bit)
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(bit < (map)->n_bits);
|
|
|
|
return _bitmap_clear_bit(map,bit);
|
|
|
|
}
|
2005-11-06 02:19:51 +01:00
|
|
|
static inline uint32
|
2005-06-06 08:59:00 +02:00
|
|
|
bitmap_is_set(const MY_BITMAP *map,uint bit)
|
|
|
|
{
|
|
|
|
DBUG_ASSERT(bit < (map)->n_bits);
|
|
|
|
return _bitmap_is_set(map,bit);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define bitmap_set_bit(MAP, BIT) _bitmap_set_bit(MAP, BIT)
|
|
|
|
#define bitmap_flip_bit(MAP, BIT) _bitmap_flip_bit(MAP, BIT)
|
|
|
|
#define bitmap_clear_bit(MAP, BIT) _bitmap_clear_bit(MAP, BIT)
|
|
|
|
#define bitmap_is_set(MAP, BIT) _bitmap_is_set(MAP, BIT)
|
|
|
|
#endif
|
2005-05-12 11:20:50 +02:00
|
|
|
#define bitmap_cmp(MAP1, MAP2) \
|
|
|
|
(memcmp((MAP1)->bitmap, (MAP2)->bitmap, 4*no_words_in_map((MAP1)))==0)
|
|
|
|
#define bitmap_clear_all(MAP) \
|
2005-06-06 08:59:00 +02:00
|
|
|
{ memset((MAP)->bitmap, 0, 4*no_words_in_map((MAP))); \
|
|
|
|
*(MAP)->last_word_ptr|= (MAP)->last_word_mask; }
|
2005-05-12 11:20:50 +02:00
|
|
|
#define bitmap_set_all(MAP) \
|
|
|
|
(memset((MAP)->bitmap, 0xFF, 4*no_words_in_map((MAP))))
|
2004-05-16 14:48:32 +03:00
|
|
|
|
2001-01-27 03:24:05 -06:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2001-02-07 17:42:20 +02:00
|
|
|
#endif /* _my_bitmap_h_ */
|