00001 // Copyright (C) 2001, Compaq Computer Corporation 00002 00003 // This file is part of Vesta. 00004 00005 // Vesta is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU Lesser General Public 00007 // License as published by the Free Software Foundation; either 00008 // version 2.1 of the License, or (at your option) any later version. 00009 00010 // Vesta is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 // Lesser General Public License for more details. 00014 00015 // You should have received a copy of the GNU Lesser General Public 00016 // License along with Vesta; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00018 00019 // Last modified on Mon Jul 25 17:00:54 EDT 2005 by ken@xorian.net 00020 00021 // Constants used by both Table.C and SharedTable.C. 00022 00023 #ifndef _TABLECONSTS_H 00024 #define _TABLECONSTS_H 00025 00026 #include <Basics.H> 00027 00028 namespace TableConsts 00029 { 00030 // Since initialization order is not defined, initialization of one 00031 // global constant from another won't always work. So, we use a 00032 // bunch of macros to repeat things. 00033 00034 // ---------- Table ---------- 00035 00036 static const int BitsPerWd = sizeof(Word) * 8; 00037 #define ONE_32_U 1U 00038 static const Bit32 One32U = ONE_32_U; 00039 00040 // the Multiplier is (2^BitsPerWd) / Phi, where Phi = (1 + Sqrt(5)) / 2 00041 static const Word Multiplier = CONST_INT_64(0x9e3779b97f4a7c15); 00042 00043 // bounds on number of buckets 00044 #define MAX_LOG_BUCKETS ((sizeof(Bit32) * 8) - 4) 00045 static const Bit16 MaxLogBuckets = MAX_LOG_BUCKETS; 00046 static const Bit32 MaxBuckets = (ONE_32_U << MAX_LOG_BUCKETS); 00047 #define MIN_LOG_BUCKETS 4 00048 static const Bit16 MinLogBuckets = MIN_LOG_BUCKETS; 00049 static const Bit32 MinBuckets = (ONE_32_U << MIN_LOG_BUCKETS); 00050 00051 // density = (#entries)/(#buckets) 00052 #define IDEAL_DENSITY 0.5 00053 static const float IdealDensity = IDEAL_DENSITY; 00054 static const float MaxDensity = IDEAL_DENSITY * 1.7; 00055 static const float MinDensity = IDEAL_DENSITY * 0.3; 00056 00057 // Mask for storing "doDeletions" in "maxEntries" field 00058 static const Bit32 DoDeletions = ONE_32_U; 00059 static const Bit32 DoDeletionsBar = ~ONE_32_U; 00060 00061 // ---------- SharedTable ---------- 00062 00063 // initial size of a MultiBucket (must be >= 2) 00064 static const Bit32 InitBucketSize = 2; 00065 00066 // factor by which to grow a bucket (must be > 1.0) 00067 static const float BucketGrowFactor = 3.0; 00068 00069 // Constants used for overloading the meaning of the "buckets" 00070 // pointers (single KVPair or MultiBucket) 00071 #define LSB_MASK 0x1UL 00072 static const PointerInt LSBMask = LSB_MASK; 00073 static const PointerInt LSBMaskBar = ~LSB_MASK; 00074 00075 } 00076 00077 #endif // _TABLECONSTS_H