Commit b25cbdba authored by mronstrom@mysql.com's avatar mronstrom@mysql.com

Fixed test cases for hash and linear hash and fixed guess in NDB API

for this as well
parent d931417c
...@@ -505,19 +505,37 @@ NdbTableImpl::buildColumnHash(){ ...@@ -505,19 +505,37 @@ NdbTableImpl::buildColumnHash(){
Uint32 Uint32
NdbTableImpl::get_nodes(Uint32 hashValue, const Uint16 ** nodes) const NdbTableImpl::get_nodes(Uint32 hashValue, const Uint16 ** nodes) const
{ {
if(m_replicaCount > 0) Uint32 fragmentId;
if(m_replicaCount == 0)
return 0;
switch (m_fragmentType)
{ {
Uint32 fragmentId = hashValue & m_hashValueMask; case AllNodesSmallTable:
if(fragmentId < m_hashpointerValue) case AllNodesMediumTable:
case AllNodesLargeTable:
case SingleFragment:
case DistrKeyLin:
{ {
fragmentId = hashValue & ((m_hashValueMask << 1) + 1); Uint32 fragmentId = hashValue & m_hashValueMask;
if(fragmentId < m_hashpointerValue)
{
fragmentId = hashValue & ((m_hashValueMask << 1) + 1);
}
break;
} }
Uint32 pos = fragmentId * m_replicaCount; case DistrKeyHash:
if(pos + m_replicaCount <= m_fragments.size())
{ {
* nodes = m_fragments.getBase()+pos; fragmentId = hashValue % m_fragmentCount;
return m_replicaCount; break;
} }
default:
return 0;
}
Uint32 pos = fragmentId * m_replicaCount;
if (pos + m_replicaCount <= m_fragments.size())
{
*nodes = m_fragments.getBase()+pos;
return m_replicaCount;
} }
return 0; return 0;
} }
......
...@@ -94,6 +94,15 @@ add_distribution_key(Ndb*, NdbDictionary::Table& tab, int when) ...@@ -94,6 +94,15 @@ add_distribution_key(Ndb*, NdbDictionary::Table& tab, int when)
} }
} }
} }
Uint32 linear_hash_ind = rand() & 1;
NdbDictionary::Table::FragmentType ftype;
if (linear_hash_ind)
ftype = NdbDictionary::Table::DistrKeyLin;
else
ftype = NdbDictionary::Table::DistrKeyHash;
tab.setFragmentType(ftype);
ndbout << (NDBT_Table&)tab << endl; ndbout << (NDBT_Table&)tab << endl;
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment