mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 12:02:42 +01:00
3600d09ab4
The main idea is to exploit the fact that key scans for "key=const" return ordered sequences of rowids. include/my_base.h: Added HA_EXTRA_KEYREAD_PRESERVE_FIELDS flag include/my_bitmap.h: Added a couple of utility functions include/my_sys.h: Added my_conunt_bits_ushort function innobase/include/row0mysql.h: Added support for HA_EXTRA_KEYREAD_PRESERVE_FIELDS innobase/row/row0sel.c: Added support for HA_EXTRA_KEYREAD_PRESERVE_FIELDS mysys/my_bit.c: Added my_count_bits_ushort function mysys/my_bitmap.c: Added a couple of utility functions sql/ha_berkeley.cc: Added cmp_ref rowid comparison function. sql/ha_berkeley.h: Added cmp_ref rowid comparison function. sql/ha_heap.h: Added cmp_ref rowid comparison function. sql/ha_innodb.cc: Added cmp_ref rowid comparison function and support from HA_EXTRA_KEYREAD_PRESERVE_FIELDS sql/ha_innodb.h: Added cmp_ref rowid comparison function. sql/handler.h: Added cmp_ref rowid comparison function. sql/opt_range.cc: Added QUICK_ROR_{INTERSECT,UNION}_SELECT classes and related optimizer code sql/opt_range.h: Added QUICK_ROR_{INTERSECT,UNION}_SELECT classes sql/sql_delete.cc: Changed to use new ROWID comparison function also always call quick->reset() for quick selects sql/sql_select.cc: Account for new quick select types sql/sql_select.h: New, proper rowid ordering/comparison function to be used with Unique class etc. sql/sql_test.cc: Account for new quick select types sql/sql_update.cc: Account for new quick select types
78 lines
2.7 KiB
C
78 lines
2.7 KiB
C
/* 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,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
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 */
|
|
|
|
/* Some useful bit functions */
|
|
|
|
#include "mysys_priv.h"
|
|
|
|
/*
|
|
Find smallest X in 2^X >= value
|
|
This can be used to divide a number with value by doing a shift instead
|
|
*/
|
|
|
|
uint my_bit_log2(ulong value)
|
|
{
|
|
uint bit;
|
|
for (bit=0 ; value > 1 ; value>>=1, bit++) ;
|
|
return bit;
|
|
}
|
|
|
|
static char nbits[256] = {
|
|
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
|
|
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
|
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
|
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
|
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
|
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
|
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
|
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
|
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
|
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
|
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
|
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
|
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
|
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
|
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
|
4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8,
|
|
};
|
|
|
|
uint my_count_bits(ulonglong v)
|
|
{
|
|
#if SIZEOF_LONG_LONG > 4
|
|
/* The following code is a bit faster on 16 bit machines than if we would
|
|
only shift v */
|
|
ulong v2=(ulong) (v >> 32);
|
|
return (uint) (uchar) (nbits[(uchar) v] +
|
|
nbits[(uchar) (v >> 8)] +
|
|
nbits[(uchar) (v >> 16)] +
|
|
nbits[(uchar) (v >> 24)] +
|
|
nbits[(uchar) (v2)] +
|
|
nbits[(uchar) (v2 >> 8)] +
|
|
nbits[(uchar) (v2 >> 16)] +
|
|
nbits[(uchar) (v2 >> 24)]);
|
|
#else
|
|
return (uint) (uchar) (nbits[(uchar) v] +
|
|
nbits[(uchar) (v >> 8)] +
|
|
nbits[(uchar) (v >> 16)] +
|
|
nbits[(uchar) (v >> 24)]);
|
|
#endif
|
|
}
|
|
|
|
uint my_count_bits_ushort(ushort v)
|
|
{
|
|
return nbits[v];
|
|
}
|
|
|