[Groonga-commit] groonga/grnxx at d936a9e [master] Add grnxx::map::Helper::HashArray.

Back to archive index

susumu.yata null+****@clear*****
Fri May 31 11:38:04 JST 2013


susumu.yata	2013-05-31 11:38:04 +0900 (Fri, 31 May 2013)

  New Revision: d936a9ef03533db6c1985c727afb39fc6ff5a9aa
  https://github.com/groonga/grnxx/commit/d936a9ef03533db6c1985c727afb39fc6ff5a9aa

  Message:
    Add grnxx::map::Helper::HashArray.

  Modified files:
    lib/grnxx/map/helper.hpp

  Modified: lib/grnxx/map/helper.hpp (+25 -0)
===================================================================
--- lib/grnxx/map/helper.hpp    2013-05-31 11:36:59 +0900 (e6d9fb5)
+++ lib/grnxx/map/helper.hpp    2013-05-31 11:38:04 +0900 (cc5aee6)
@@ -82,6 +82,30 @@ struct KeyArrayHelper<Bytes> {
   using Type = BytesArray;
 };
 
+// Change the settings based on the key type.
+template <typename T, size_t T_SIZE = sizeof(T)>
+struct HashArrayHelper {
+  // Map<T> has at most 2^40 different keys.
+  using Type = Array<uint64_t, 65536, 4096, 8192>;
+};
+template <typename T>
+struct HashArrayHelper<T, 1> {
+  // Map<T> has at most 2^8 different keys.
+  // Assume a perfect hash function.
+  using Type = Array<uint8_t, 256, 1, 1>;
+};
+template <typename T>
+struct HashArrayHelper<T, 2> {
+  // Map<T> has at most 2^16 different keys.
+  // Assume a perfect hash function.
+  using Type = Array<uint16_t, 65536, 1, 1>;
+};
+template <typename T>
+struct HashArrayHelper<T, 4> {
+  // Map<T> has at most 2^32 different keys.
+  using Type = Array<uint32_t, 65536, 256, 512>;
+};
+
 // Normalize a key.
 template <typename T,
           bool IS_FLOATING_POINT = std::is_floating_point<T>::value>
@@ -144,6 +168,7 @@ struct Helper {
 
   using Bitmap = typename BitmapHelper<T>::Type;
   using KeyArray = typename KeyArrayHelper<T>::Type;
+  using HashArray = typename HashArrayHelper<T>::Type;
 
   static Key normalize(KeyArg key) {
     return NormalizeHelper<T>::normalize(key);
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index