Commit 1eabb412 authored by unknown's avatar unknown
Browse files

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

for this as well


storage/ndb/src/ndbapi/NdbDictionaryImpl.cpp:
  Fixed guess of proper transaction coordinator for NDB API users
storage/ndb/test/ndbapi/testPartitioning.cpp:
  Test case for both hash and linear hash
parent 5805fd26
Loading
Loading
Loading
Loading
+26 −8
Original line number Diff line number Diff line
@@ -505,20 +505,38 @@ NdbTableImpl::buildColumnHash(){
Uint32
NdbTableImpl::get_nodes(Uint32 hashValue, const Uint16 ** nodes) const
{
  if(m_replicaCount > 0)
  Uint32 fragmentId;
  if(m_replicaCount == 0)
    return 0;
  switch (m_fragmentType)
  {
    case AllNodesSmallTable:
    case AllNodesMediumTable:
    case AllNodesLargeTable:
    case SingleFragment:
    case DistrKeyLin:
    {
      Uint32 fragmentId = hashValue & m_hashValueMask;
      if(fragmentId < m_hashpointerValue) 
      {
        fragmentId = hashValue & ((m_hashValueMask << 1) + 1);
      }
      break;
    }
    case DistrKeyHash:
    {
      fragmentId = hashValue % m_fragmentCount;
      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;
}
  
+9 −0
Original line number Diff line number Diff line
@@ -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;

  return 0;