susumu.yata
null+****@clear*****
Tue Jun 4 21:33:45 JST 2013
susumu.yata 2013-06-04 21:33:45 +0900 (Tue, 04 Jun 2013) New Revision: a31db526229a540f02a437b2dd3651b95d0d9cdd https://github.com/groonga/grnxx/commit/a31db526229a540f02a437b2dd3651b95d0d9cdd Message: Update the implementation of grnxx::map::ArrayMap. Added files: lib/grnxx/map/array_map/Makefile.am Copied files: lib/grnxx/map/array_map/bit_array.hpp (from lib/grnxx/map/hash_table/key_array.hpp) lib/grnxx/map/array_map/dummy.cpp (from lib/grnxx/map/hash_table/dummy.cpp) lib/grnxx/map/array_map/key_array.hpp (from lib/grnxx/map/hash_table/key_array.hpp) Modified files: configure.ac lib/grnxx/map/Makefile.am lib/grnxx/map/array_map.cpp lib/grnxx/map/array_map.hpp lib/grnxx/map/hash_table/dummy.cpp lib/grnxx/map/hash_table/key_array.hpp lib/grnxx/map/helper.hpp Modified: configure.ac (+1 -0) =================================================================== --- configure.ac 2013-06-04 18:23:12 +0900 (6243117) +++ configure.ac 2013-06-04 21:33:45 +0900 (1736eac) @@ -66,6 +66,7 @@ AC_CONFIG_FILES([Makefile lib/grnxx/db/Makefile lib/grnxx/io/Makefile lib/grnxx/map/Makefile + lib/grnxx/map/array_map/Makefile lib/grnxx/map/hash_table/Makefile lib/grnxx/storage/Makefile src/Makefile Modified: lib/grnxx/map/Makefile.am (+2 -0) =================================================================== --- lib/grnxx/map/Makefile.am 2013-06-04 18:23:12 +0900 (d5066f0) +++ lib/grnxx/map/Makefile.am 2013-06-04 21:33:45 +0900 (4edca2e) @@ -1,9 +1,11 @@ SUBDIRS = \ + array_map \ hash_table noinst_LTLIBRARIES = libgrnxx_map.la libgrnxx_map_la_LIBADD = \ + array_map/libgrnxx_map_array_map.la \ hash_table/libgrnxx_map_hash_table.la libgrnxx_map_la_LDFLAGS = @AM_LTLDFLAGS@ Modified: lib/grnxx/map/array_map.cpp (+1 -0) =================================================================== --- lib/grnxx/map/array_map.cpp 2013-06-04 18:23:12 +0900 (dc84361) +++ lib/grnxx/map/array_map.cpp 2013-06-04 21:33:45 +0900 (decdc5d) @@ -22,6 +22,7 @@ #include "grnxx/bytes.hpp" #include "grnxx/geo_point.hpp" #include "grnxx/logger.hpp" +#include "grnxx/map/helper.hpp" #include "grnxx/storage.hpp" namespace grnxx { Modified: lib/grnxx/map/array_map.hpp (+5 -4) =================================================================== --- lib/grnxx/map/array_map.hpp 2013-06-04 18:23:12 +0900 (7d44c10) +++ lib/grnxx/map/array_map.hpp 2013-06-04 21:33:45 +0900 (ba680bd) @@ -23,7 +23,8 @@ #include <memory> #include "grnxx/map.hpp" -#include "grnxx/map/helper.hpp" +#include "grnxx/map/array_map/bit_array.hpp" +#include "grnxx/map/array_map/key_array.hpp" #include "grnxx/types.hpp" namespace grnxx { @@ -36,14 +37,14 @@ struct ArrayMapHeader; template <typename T> class ArrayMap : public Map<T> { + using Bitmap = typename array_map::BitArray<T>::Type; + using KeyArray = typename array_map::KeyArray<T>::Type; + public: using Key = typename Map<T>::Key; using KeyArg = typename Map<T>::KeyArg; using Cursor = typename Map<T>::Cursor; - using Bitmap = typename Helper<T>::Bitmap; - using KeyArray = typename Helper<T>::KeyArray; - ArrayMap(); ~ArrayMap(); Added: lib/grnxx/map/array_map/Makefile.am (+11 -0) 100644 =================================================================== --- /dev/null +++ lib/grnxx/map/array_map/Makefile.am 2013-06-04 21:33:45 +0900 (2148059) @@ -0,0 +1,11 @@ +noinst_LTLIBRARIES = libgrnxx_map_array_map.la + +libgrnxx_map_array_map_la_LDFLAGS = @AM_LTLDFLAGS@ + +libgrnxx_map_array_map_la_SOURCES = \ + dummy.cpp + +libgrnxx_map_array_map_includedir = ${includedir}/grnxx/map/array_map +libgrnxx_map_array_map_include_HEADERS = \ + bit_array.hpp \ + key_array.hpp Copied: lib/grnxx/map/array_map/bit_array.hpp (+15 -23) 66% =================================================================== --- lib/grnxx/map/hash_table/key_array.hpp 2013-06-04 18:23:12 +0900 (4c96009) +++ lib/grnxx/map/array_map/bit_array.hpp 2013-06-04 21:33:45 +0900 (ab7cd3f) @@ -15,56 +15,48 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef GRNXX_MAP_HASH_TABLE_KEY_ARRAY_HPP -#define GRNXX_MAP_HASH_TABLE_KEY_ARRAY_HPP +#ifndef GRNXX_MAP_ARRAY_MAP_BIT_ARRAY_HPP +#define GRNXX_MAP_ARRAY_MAP_BIT_ARRAY_HPP #include "grnxx/features.hpp" #include "grnxx/array.hpp" -#include "grnxx/bytes.hpp" -#include "grnxx/map/bytes_array.hpp" #include "grnxx/types.hpp" namespace grnxx { namespace map { -namespace hash_table { +namespace array_map { -// Change the array size based on "T". +// Change the array size based on the size of "T". template <typename T, size_t T_SIZE = sizeof(T)> -struct KeyArray; +struct BitArray; // Map<T> has at most 2^40 different keys. template <typename T, size_t T_SIZE> -struct KeyArray { - using Type = Array<T>; +struct BitArray { + using Type = Array<bool, 65536, 4096, 4096>; }; // Map<T> has at most 2^8 different keys. template <typename T> -struct KeyArray<T, 1> { - using Type = Array<T, 256, 1, 1>; +struct BitArray<T, 1> { + using Type = Array<bool, 256, 1, 1>; }; // Map<T> has at most 2^16 different keys. template <typename T> -struct KeyArray<T, 2> { - using Type = Array<T, 256, 256, 1>; +struct BitArray<T, 2> { + using Type = Array<bool, 256, 256, 1>; }; // Map<T> has at most 2^32 different keys. template <typename T> -struct KeyArray<T, 4> { - using Type = Array<T, 65536, 256, 256>; +struct BitArray<T, 4> { + using Type = Array<bool, 16384, 512, 512>; }; -// Map<T> has at most 2^40 different keys. -template <> -struct KeyArray<Bytes> { - using Type = BytesArray; -}; - -} // namespace hash_table +} // namespace array_map } // namespace map } // namespace grnxx -#endif // GRNXX_MAP_HASH_TABLE_KEY_ARRAY_HPP +#endif // GRNXX_MAP_ARRAY_MAP_BIT_ARRAY_HPP Copied: lib/grnxx/map/array_map/dummy.cpp (+4 -14) 66% =================================================================== --- lib/grnxx/map/hash_table/dummy.cpp 2013-06-04 18:23:12 +0900 (43a92c7) +++ lib/grnxx/map/array_map/dummy.cpp 2013-06-04 21:33:45 +0900 (4a29140) @@ -15,23 +15,13 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef GRNXX_MAP_HASH_TABLE_DUMMY_HPP -#define GRNXX_MAP_HASH_TABLE_DUMMY_HPP - -#include "grnxx/features.hpp" - -#include "grnxx/map/hash_table/bit_array.hpp" -#include "grnxx/map/hash_table/hash.hpp" -#include "grnxx/map/hash_table/key_array.hpp" -#include "grnxx/map/hash_table/key_id_array.hpp" -#include "grnxx/map/hash_table/link_array.hpp" +#include "grnxx/map/array_map/bit_array.hpp" +#include "grnxx/map/array_map/key_array.hpp" namespace grnxx { namespace map { -namespace hash_table { +namespace array_map { -} // namespace hash_table +} // namespace array_map } // namespace map } // namespace grnxx - -#endif // GRNXX_MAP_HASH_TABLE_DUMMY_HPP Copied: lib/grnxx/map/array_map/key_array.hpp (+6 -6) 88% =================================================================== --- lib/grnxx/map/hash_table/key_array.hpp 2013-06-04 18:23:12 +0900 (4c96009) +++ lib/grnxx/map/array_map/key_array.hpp 2013-06-04 21:33:45 +0900 (399fcb3) @@ -15,8 +15,8 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef GRNXX_MAP_HASH_TABLE_KEY_ARRAY_HPP -#define GRNXX_MAP_HASH_TABLE_KEY_ARRAY_HPP +#ifndef GRNXX_MAP_ARRAY_MAP_KEY_ARRAY_HPP +#define GRNXX_MAP_ARRAY_MAP_KEY_ARRAY_HPP #include "grnxx/features.hpp" @@ -27,7 +27,7 @@ namespace grnxx { namespace map { -namespace hash_table { +namespace array_map { // Change the array size based on "T". template <typename T, size_t T_SIZE = sizeof(T)> @@ -36,7 +36,7 @@ struct KeyArray; // Map<T> has at most 2^40 different keys. template <typename T, size_t T_SIZE> struct KeyArray { - using Type = Array<T>; + using Type = Array<T, 65536, 4096, 4096>; }; // Map<T> has at most 2^8 different keys. @@ -63,8 +63,8 @@ struct KeyArray<Bytes> { using Type = BytesArray; }; -} // namespace hash_table +} // namespace array_map } // namespace map } // namespace grnxx -#endif // GRNXX_MAP_HASH_TABLE_KEY_ARRAY_HPP +#endif // GRNXX_MAP_ARRAY_MAP_KEY_ARRAY_HPP Modified: lib/grnxx/map/hash_table/dummy.cpp (+0 -7) =================================================================== --- lib/grnxx/map/hash_table/dummy.cpp 2013-06-04 18:23:12 +0900 (43a92c7) +++ lib/grnxx/map/hash_table/dummy.cpp 2013-06-04 21:33:45 +0900 (f7ac17d) @@ -15,11 +15,6 @@ License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifndef GRNXX_MAP_HASH_TABLE_DUMMY_HPP -#define GRNXX_MAP_HASH_TABLE_DUMMY_HPP - -#include "grnxx/features.hpp" - #include "grnxx/map/hash_table/bit_array.hpp" #include "grnxx/map/hash_table/hash.hpp" #include "grnxx/map/hash_table/key_array.hpp" @@ -33,5 +28,3 @@ namespace hash_table { } // namespace hash_table } // namespace map } // namespace grnxx - -#endif // GRNXX_MAP_HASH_TABLE_DUMMY_HPP Modified: lib/grnxx/map/hash_table/key_array.hpp (+1 -1) =================================================================== --- lib/grnxx/map/hash_table/key_array.hpp 2013-06-04 18:23:12 +0900 (4c96009) +++ lib/grnxx/map/hash_table/key_array.hpp 2013-06-04 21:33:45 +0900 (bacec40) @@ -36,7 +36,7 @@ struct KeyArray; // Map<T> has at most 2^40 different keys. template <typename T, size_t T_SIZE> struct KeyArray { - using Type = Array<T>; + using Type = Array<T, 65536, 4096, 4096>; }; // Map<T> has at most 2^8 different keys. Modified: lib/grnxx/map/helper.hpp (+0 -52) =================================================================== --- lib/grnxx/map/helper.hpp 2013-06-04 18:23:12 +0900 (e6d9fb5) +++ lib/grnxx/map/helper.hpp 2013-06-04 21:33:45 +0900 (5914f21) @@ -33,55 +33,6 @@ namespace grnxx { namespace map { -// Change the settings based on the key type. -template <typename T, size_t T_SIZE = sizeof(T)> -struct BitmapHelper { - // Map<T> has at most 2^40 different keys. - using Type = Array<bool>; -}; -template <typename T> -struct BitmapHelper<T, 1> { - // Map<T> has at most 2^8 different keys. - using Type = Array<bool, 256, 1, 1>; -}; -template <typename T> -struct BitmapHelper<T, 2> { - // Map<T> has at most 2^16 different keys. - using Type = Array<bool, 256, 256, 1>; -}; -template <typename T> -struct BitmapHelper<T, 4> { - // Map<T> has at most 2^32 different keys. - using Type = Array<bool, 65536, 256, 256>; -}; - -// Change the settings based on the key type. -template <typename T, size_t T_SIZE = sizeof(T)> -struct KeyArrayHelper { - // Map<T> has at most 2^40 different keys. - using Type = Array<T>; -}; -template <typename T> -struct KeyArrayHelper<T, 1> { - // Map<T> has at most 2^8 different keys. - using Type = Array<T, 256, 1, 1>; -}; -template <typename T> -struct KeyArrayHelper<T, 2> { - // Map<T> has at most 2^16 different keys. - using Type = Array<T, 256, 256, 1>; -}; -template <typename T> -struct KeyArrayHelper<T, 4> { - // Map<T> has at most 2^32 different keys. - using Type = Array<T, 65536, 256, 256>; -}; -template <> -struct KeyArrayHelper<Bytes> { - // Map<T> has at most 2^40 different keys. - using Type = BytesArray; -}; - // Normalize a key. template <typename T, bool IS_FLOATING_POINT = std::is_floating_point<T>::value> @@ -142,9 +93,6 @@ struct Helper { using Key = typename Traits<T>::Type; using KeyArg = typename Traits<T>::ArgumentType; - using Bitmap = typename BitmapHelper<T>::Type; - using KeyArray = typename KeyArrayHelper<T>::Type; - static Key normalize(KeyArg key) { return NormalizeHelper<T>::normalize(key); } -------------- next part -------------- HTML����������������������������...Download