Commit 76dd9aa2 authored by unknown's avatar unknown

Merge orca.ndb.mysql.com:/export/home/space/pekka/ndb/version/my50-ndb

into  orca.ndb.mysql.com:/export/home/space/pekka/ndb/version/my50-bug20446

parents d049ec4a eb97edf4
...@@ -121,41 +121,17 @@ private: ...@@ -121,41 +121,17 @@ private:
// forward declarations // forward declarations
struct DescEnt; struct DescEnt;
/* // Pointer to array of Uint32 represents attribute data and bounds
* Pointer to array of Uint32.
*/
struct Data {
private:
Uint32* m_data;
public:
Data();
Data(Uint32* data);
Data& operator=(Uint32* data);
operator Uint32*() const;
Data& operator+=(size_t n);
AttributeHeader& ah() const;
};
friend class Data;
/* typedef Uint32 *Data;
* Pointer to array of constant Uint32. inline AttributeHeader& ah(Data data) {
*/ return *reinterpret_cast<AttributeHeader*>(data);
struct ConstData; }
friend struct ConstData;
struct ConstData { typedef const Uint32* ConstData;
private: inline const AttributeHeader& ah(ConstData data) {
const Uint32* m_data; return *reinterpret_cast<const AttributeHeader*>(data);
public: }
ConstData();
ConstData(const Uint32* data);
ConstData& operator=(const Uint32* data);
operator const Uint32*() const;
ConstData& operator+=(size_t n);
const AttributeHeader& ah() const;
// non-const pointer can be cast to const pointer
ConstData(Data data);
ConstData& operator=(Data data);
};
// AttributeHeader size is assumed to be 1 word // AttributeHeader size is assumed to be 1 word
STATIC_CONST( AttributeHeaderSize = 1 ); STATIC_CONST( AttributeHeaderSize = 1 );
...@@ -212,6 +188,7 @@ private: ...@@ -212,6 +188,7 @@ private:
unsigned m_fragBit : 1; // which duplicated table fragment unsigned m_fragBit : 1; // which duplicated table fragment
TreeEnt(); TreeEnt();
// methods // methods
bool eqtuple(const TreeEnt ent) const;
bool eq(const TreeEnt ent) const; bool eq(const TreeEnt ent) const;
int cmp(const TreeEnt ent) const; int cmp(const TreeEnt ent) const;
}; };
...@@ -289,8 +266,7 @@ private: ...@@ -289,8 +266,7 @@ private:
struct TreePos { struct TreePos {
TupLoc m_loc; // physical node address TupLoc m_loc; // physical node address
Uint16 m_pos; // position 0 to m_occup Uint16 m_pos; // position 0 to m_occup
Uint8 m_match; // at an existing entry Uint8 m_dir; // see scanNext
Uint8 m_dir; // see scanNext()
TreePos(); TreePos();
}; };
...@@ -381,12 +357,13 @@ private: ...@@ -381,12 +357,13 @@ private:
enum { enum {
Undef = 0, Undef = 0,
First = 1, // before first entry First = 1, // before first entry
Current = 2, // at current before locking Current = 2, // at some entry
Blocked = 3, // at current waiting for ACC lock Found = 3, // return current as next scan result
Locked = 4, // at current and locked or no lock needed Blocked = 4, // found and waiting for ACC lock
Next = 5, // looking for next extry Locked = 5, // found and locked or no lock needed
Last = 6, // after last entry Next = 6, // looking for next extry
Aborting = 7, // lock wait at scan close Last = 7, // after last entry
Aborting = 8, // lock wait at scan close
Invalid = 9 // cannot return REF to LQH currently Invalid = 9 // cannot return REF to LQH currently
}; };
Uint16 m_state; Uint16 m_state;
...@@ -563,6 +540,7 @@ private: ...@@ -563,6 +540,7 @@ private:
void readKeyAttrs(const Frag& frag, TreeEnt ent, unsigned start, Data keyData); void readKeyAttrs(const Frag& frag, TreeEnt ent, unsigned start, Data keyData);
void readTablePk(const Frag& frag, TreeEnt ent, Data pkData, unsigned& pkSize); void readTablePk(const Frag& frag, TreeEnt ent, Data pkData, unsigned& pkSize);
void copyAttrs(const Frag& frag, ConstData data1, Data data2, unsigned maxlen2 = MaxAttrDataSize); void copyAttrs(const Frag& frag, ConstData data1, Data data2, unsigned maxlen2 = MaxAttrDataSize);
void unpackBound(const ScanBound& bound, Data data);
/* /*
* DbtuxMeta.cpp * DbtuxMeta.cpp
...@@ -637,7 +615,9 @@ private: ...@@ -637,7 +615,9 @@ private:
void execACCKEYREF(Signal* signal); void execACCKEYREF(Signal* signal);
void execACC_ABORTCONF(Signal* signal); void execACC_ABORTCONF(Signal* signal);
void scanFirst(ScanOpPtr scanPtr); void scanFirst(ScanOpPtr scanPtr);
void scanFind(ScanOpPtr scanPtr);
void scanNext(ScanOpPtr scanPtr, bool fromMaintReq); void scanNext(ScanOpPtr scanPtr, bool fromMaintReq);
bool scanCheck(ScanOpPtr scanPtr, TreeEnt ent);
bool scanVisible(ScanOpPtr scanPtr, TreeEnt ent); bool scanVisible(ScanOpPtr scanPtr, TreeEnt ent);
void scanClose(Signal* signal, ScanOpPtr scanPtr); void scanClose(Signal* signal, ScanOpPtr scanPtr);
void addAccLockOp(ScanOp& scan, Uint32 accLockOp); void addAccLockOp(ScanOp& scan, Uint32 accLockOp);
...@@ -647,8 +627,8 @@ private: ...@@ -647,8 +627,8 @@ private:
/* /*
* DbtuxSearch.cpp * DbtuxSearch.cpp
*/ */
void searchToAdd(Frag& frag, ConstData searchKey, TreeEnt searchEnt, TreePos& treePos); bool searchToAdd(Frag& frag, ConstData searchKey, TreeEnt searchEnt, TreePos& treePos);
void searchToRemove(Frag& frag, ConstData searchKey, TreeEnt searchEnt, TreePos& treePos); bool searchToRemove(Frag& frag, ConstData searchKey, TreeEnt searchEnt, TreePos& treePos);
void searchToScan(Frag& frag, ConstData boundInfo, unsigned boundCount, bool descending, TreePos& treePos); void searchToScan(Frag& frag, ConstData boundInfo, unsigned boundCount, bool descending, TreePos& treePos);
void searchToScanAscending(Frag& frag, ConstData boundInfo, unsigned boundCount, TreePos& treePos); void searchToScanAscending(Frag& frag, ConstData boundInfo, unsigned boundCount, TreePos& treePos);
void searchToScanDescending(Frag& frag, ConstData boundInfo, unsigned boundCount, TreePos& treePos); void searchToScanDescending(Frag& frag, ConstData boundInfo, unsigned boundCount, TreePos& treePos);
...@@ -737,99 +717,6 @@ private: ...@@ -737,99 +717,6 @@ private:
static unsigned max(unsigned x, unsigned y); static unsigned max(unsigned x, unsigned y);
}; };
// Dbtux::Data
inline
Dbtux::Data::Data() :
m_data(0)
{
}
inline
Dbtux::Data::Data(Uint32* data) :
m_data(data)
{
}
inline Dbtux::Data&
Dbtux::Data::operator=(Uint32* data)
{
m_data = data;
return *this;
}
inline
Dbtux::Data::operator Uint32*() const
{
return m_data;
}
inline Dbtux::Data&
Dbtux::Data::operator+=(size_t n)
{
m_data += n;
return *this;
}
inline AttributeHeader&
Dbtux::Data::ah() const
{
return *reinterpret_cast<AttributeHeader*>(m_data);
}
// Dbtux::ConstData
inline
Dbtux::ConstData::ConstData() :
m_data(0)
{
}
inline
Dbtux::ConstData::ConstData(const Uint32* data) :
m_data(data)
{
}
inline Dbtux::ConstData&
Dbtux::ConstData::operator=(const Uint32* data)
{
m_data = data;
return *this;
}
inline
Dbtux::ConstData::operator const Uint32*() const
{
return m_data;
}
inline Dbtux::ConstData&
Dbtux::ConstData::operator+=(size_t n)
{
m_data += n;
return *this;
}
inline const AttributeHeader&
Dbtux::ConstData::ah() const
{
return *reinterpret_cast<const AttributeHeader*>(m_data);
}
inline
Dbtux::ConstData::ConstData(Data data) :
m_data(static_cast<Uint32*>(data))
{
}
inline Dbtux::ConstData&
Dbtux::ConstData::operator=(Data data)
{
m_data = static_cast<Uint32*>(data);
return *this;
}
// Dbtux::TupLoc // Dbtux::TupLoc
inline inline
...@@ -898,6 +785,14 @@ Dbtux::TreeEnt::TreeEnt() : ...@@ -898,6 +785,14 @@ Dbtux::TreeEnt::TreeEnt() :
{ {
} }
inline bool
Dbtux::TreeEnt::eqtuple(const TreeEnt ent) const
{
return
m_tupLoc == ent.m_tupLoc &&
m_fragBit == ent.m_fragBit;
}
inline bool inline bool
Dbtux::TreeEnt::eq(const TreeEnt ent) const Dbtux::TreeEnt::eq(const TreeEnt ent) const
{ {
...@@ -910,6 +805,11 @@ Dbtux::TreeEnt::eq(const TreeEnt ent) const ...@@ -910,6 +805,11 @@ Dbtux::TreeEnt::eq(const TreeEnt ent) const
inline int inline int
Dbtux::TreeEnt::cmp(const TreeEnt ent) const Dbtux::TreeEnt::cmp(const TreeEnt ent) const
{ {
// compare frag first to improve cacheing in 5.0
if (m_fragBit < ent.m_fragBit)
return -1;
if (m_fragBit > ent.m_fragBit)
return +1;
if (m_tupLoc.getPageId() < ent.m_tupLoc.getPageId()) if (m_tupLoc.getPageId() < ent.m_tupLoc.getPageId())
return -1; return -1;
if (m_tupLoc.getPageId() > ent.m_tupLoc.getPageId()) if (m_tupLoc.getPageId() > ent.m_tupLoc.getPageId())
...@@ -918,14 +818,25 @@ Dbtux::TreeEnt::cmp(const TreeEnt ent) const ...@@ -918,14 +818,25 @@ Dbtux::TreeEnt::cmp(const TreeEnt ent) const
return -1; return -1;
if (m_tupLoc.getPageOffset() > ent.m_tupLoc.getPageOffset()) if (m_tupLoc.getPageOffset() > ent.m_tupLoc.getPageOffset())
return +1; return +1;
if (m_tupVersion < ent.m_tupVersion) /*
return -1; * Guess if one tuple version has wrapped around. This is well
if (m_tupVersion > ent.m_tupVersion) * defined ordering on existing versions since versions are assigned
return +1; * consecutively and different versions exists only on uncommitted
if (m_fragBit < ent.m_fragBit) * tuple. Assuming max 2**14 uncommitted ops on same tuple.
return -1; */
if (m_fragBit > ent.m_fragBit) const unsigned version_wrap_limit = (1 << (ZTUP_VERSION_BITS - 1));
return +1; if (m_tupVersion < ent.m_tupVersion) {
if (ent.m_tupVersion - m_tupVersion < version_wrap_limit)
return -1;
else
return +1;
}
if (m_tupVersion > ent.m_tupVersion) {
if (m_tupVersion - ent.m_tupVersion < version_wrap_limit)
return +1;
else
return -1;
}
return 0; return 0;
} }
...@@ -992,7 +903,6 @@ inline ...@@ -992,7 +903,6 @@ inline
Dbtux::TreePos::TreePos() : Dbtux::TreePos::TreePos() :
m_loc(), m_loc(),
m_pos(ZNIL), m_pos(ZNIL),
m_match(false),
m_dir(255) m_dir(255)
{ {
} }
......
...@@ -34,7 +34,7 @@ Dbtux::cmpSearchKey(const Frag& frag, unsigned& start, ConstData searchKey, Cons ...@@ -34,7 +34,7 @@ Dbtux::cmpSearchKey(const Frag& frag, unsigned& start, ConstData searchKey, Cons
// skip to right position in search key only // skip to right position in search key only
for (unsigned i = 0; i < start; i++) { for (unsigned i = 0; i < start; i++) {
jam(); jam();
searchKey += AttributeHeaderSize + searchKey.ah().getDataSize(); searchKey += AttributeHeaderSize + ah(searchKey).getDataSize();
} }
// number of words of entry data left // number of words of entry data left
unsigned len2 = maxlen; unsigned len2 = maxlen;
...@@ -46,16 +46,16 @@ Dbtux::cmpSearchKey(const Frag& frag, unsigned& start, ConstData searchKey, Cons ...@@ -46,16 +46,16 @@ Dbtux::cmpSearchKey(const Frag& frag, unsigned& start, ConstData searchKey, Cons
break; break;
} }
len2 -= AttributeHeaderSize; len2 -= AttributeHeaderSize;
if (! searchKey.ah().isNULL()) { if (! ah(searchKey).isNULL()) {
if (! entryData.ah().isNULL()) { if (! ah(entryData).isNULL()) {
jam(); jam();
// verify attribute id // verify attribute id
const DescAttr& descAttr = descEnt.m_descAttr[start]; const DescAttr& descAttr = descEnt.m_descAttr[start];
ndbrequire(searchKey.ah().getAttributeId() == descAttr.m_primaryAttrId); ndbrequire(ah(searchKey).getAttributeId() == descAttr.m_primaryAttrId);
ndbrequire(entryData.ah().getAttributeId() == descAttr.m_primaryAttrId); ndbrequire(ah(entryData).getAttributeId() == descAttr.m_primaryAttrId);
// sizes // sizes
const unsigned size1 = searchKey.ah().getDataSize(); const unsigned size1 = ah(searchKey).getDataSize();
const unsigned size2 = min(entryData.ah().getDataSize(), len2); const unsigned size2 = min(ah(entryData).getDataSize(), len2);
len2 -= size2; len2 -= size2;
// compare // compare
NdbSqlUtil::Cmp* const cmp = c_sqlCmp[start]; NdbSqlUtil::Cmp* const cmp = c_sqlCmp[start];
...@@ -74,15 +74,15 @@ Dbtux::cmpSearchKey(const Frag& frag, unsigned& start, ConstData searchKey, Cons ...@@ -74,15 +74,15 @@ Dbtux::cmpSearchKey(const Frag& frag, unsigned& start, ConstData searchKey, Cons
break; break;
} }
} else { } else {
if (! entryData.ah().isNULL()) { if (! ah(entryData).isNULL()) {
jam(); jam();
// NULL < not NULL // NULL < not NULL
ret = -1; ret = -1;
break; break;
} }
} }
searchKey += AttributeHeaderSize + searchKey.ah().getDataSize(); searchKey += AttributeHeaderSize + ah(searchKey).getDataSize();
entryData += AttributeHeaderSize + entryData.ah().getDataSize(); entryData += AttributeHeaderSize + ah(entryData).getDataSize();
start++; start++;
} }
return ret; return ret;
...@@ -130,17 +130,17 @@ Dbtux::cmpScanBound(const Frag& frag, unsigned idir, ConstData boundInfo, unsign ...@@ -130,17 +130,17 @@ Dbtux::cmpScanBound(const Frag& frag, unsigned idir, ConstData boundInfo, unsign
// get and skip bound type (it is used after the loop) // get and skip bound type (it is used after the loop)
type = boundInfo[0]; type = boundInfo[0];
boundInfo += 1; boundInfo += 1;
if (! boundInfo.ah().isNULL()) { if (! ah(boundInfo).isNULL()) {
if (! entryData.ah().isNULL()) { if (! ah(entryData).isNULL()) {
jam(); jam();
// verify attribute id // verify attribute id
const Uint32 index = boundInfo.ah().getAttributeId(); const Uint32 index = ah(boundInfo).getAttributeId();
ndbrequire(index < frag.m_numAttrs); ndbrequire(index < frag.m_numAttrs);
const DescAttr& descAttr = descEnt.m_descAttr[index]; const DescAttr& descAttr = descEnt.m_descAttr[index];
ndbrequire(entryData.ah().getAttributeId() == descAttr.m_primaryAttrId); ndbrequire(ah(entryData).getAttributeId() == descAttr.m_primaryAttrId);
// sizes // sizes
const unsigned size1 = boundInfo.ah().getDataSize(); const unsigned size1 = ah(boundInfo).getDataSize();
const unsigned size2 = min(entryData.ah().getDataSize(), len2); const unsigned size2 = min(ah(entryData).getDataSize(), len2);
len2 -= size2; len2 -= size2;
// compare // compare
NdbSqlUtil::Cmp* const cmp = c_sqlCmp[index]; NdbSqlUtil::Cmp* const cmp = c_sqlCmp[index];
...@@ -159,14 +159,14 @@ Dbtux::cmpScanBound(const Frag& frag, unsigned idir, ConstData boundInfo, unsign ...@@ -159,14 +159,14 @@ Dbtux::cmpScanBound(const Frag& frag, unsigned idir, ConstData boundInfo, unsign
} }
} else { } else {
jam(); jam();
if (! entryData.ah().isNULL()) { if (! ah(entryData).isNULL()) {
jam(); jam();
// NULL < not NULL // NULL < not NULL
return -1; return -1;
} }
} }
boundInfo += AttributeHeaderSize + boundInfo.ah().getDataSize(); boundInfo += AttributeHeaderSize + ah(boundInfo).getDataSize();
entryData += AttributeHeaderSize + entryData.ah().getDataSize(); entryData += AttributeHeaderSize + ah(entryData).getDataSize();
boundCount -= 1; boundCount -= 1;
} }
// all attributes were equal // all attributes were equal
......
...@@ -311,7 +311,6 @@ operator<<(NdbOut& out, const Dbtux::TreePos& pos) ...@@ -311,7 +311,6 @@ operator<<(NdbOut& out, const Dbtux::TreePos& pos)
out << "[TreePos " << hex << &pos; out << "[TreePos " << hex << &pos;
out << " [loc " << pos.m_loc << "]"; out << " [loc " << pos.m_loc << "]";
out << " [pos " << dec << pos.m_pos << "]"; out << " [pos " << dec << pos.m_pos << "]";
out << " [match " << dec << pos.m_match << "]";
out << " [dir " << dec << pos.m_dir << "]"; out << " [dir " << dec << pos.m_dir << "]";
out << "]"; out << "]";
return out; return out;
......
...@@ -221,7 +221,7 @@ Dbtux::setKeyAttrs(const Frag& frag) ...@@ -221,7 +221,7 @@ Dbtux::setKeyAttrs(const Frag& frag)
const DescAttr& descAttr = descEnt.m_descAttr[i]; const DescAttr& descAttr = descEnt.m_descAttr[i];
Uint32 size = AttributeDescriptor::getSizeInWords(descAttr.m_attrDesc); Uint32 size = AttributeDescriptor::getSizeInWords(descAttr.m_attrDesc);
// set attr id and fixed size // set attr id and fixed size
keyAttrs.ah() = AttributeHeader(descAttr.m_primaryAttrId, size); ah(keyAttrs) = AttributeHeader(descAttr.m_primaryAttrId, size);
keyAttrs += 1; keyAttrs += 1;
// set comparison method pointer // set comparison method pointer
const NdbSqlUtil::Type& sqlType = NdbSqlUtil::getTypeBinary(descAttr.m_typeId); const NdbSqlUtil::Type& sqlType = NdbSqlUtil::getTypeBinary(descAttr.m_typeId);
...@@ -251,8 +251,8 @@ Dbtux::readKeyAttrs(const Frag& frag, TreeEnt ent, unsigned start, Data keyData) ...@@ -251,8 +251,8 @@ Dbtux::readKeyAttrs(const Frag& frag, TreeEnt ent, unsigned start, Data keyData)
ConstData data = keyData; ConstData data = keyData;
Uint32 totalSize = 0; Uint32 totalSize = 0;
for (Uint32 i = start; i < frag.m_numAttrs; i++) { for (Uint32 i = start; i < frag.m_numAttrs; i++) {
Uint32 attrId = data.ah().getAttributeId(); Uint32 attrId = ah(data).getAttributeId();
Uint32 dataSize = data.ah().getDataSize(); Uint32 dataSize = ah(data).getDataSize();
debugOut << i << " attrId=" << attrId << " size=" << dataSize; debugOut << i << " attrId=" << attrId << " size=" << dataSize;
data += 1; data += 1;
for (Uint32 j = 0; j < dataSize; j++) { for (Uint32 j = 0; j < dataSize; j++) {
...@@ -290,7 +290,7 @@ Dbtux::copyAttrs(const Frag& frag, ConstData data1, Data data2, unsigned maxlen2 ...@@ -290,7 +290,7 @@ Dbtux::copyAttrs(const Frag& frag, ConstData data1, Data data2, unsigned maxlen2
unsigned len2 = maxlen2; unsigned len2 = maxlen2;
while (n != 0) { while (n != 0) {
jam(); jam();
const unsigned dataSize = data1.ah().getDataSize(); const unsigned dataSize = ah(data1).getDataSize();
// copy header // copy header
if (len2 == 0) if (len2 == 0)
return; return;
...@@ -314,4 +314,17 @@ Dbtux::copyAttrs(const Frag& frag, ConstData data1, Data data2, unsigned maxlen2 ...@@ -314,4 +314,17 @@ Dbtux::copyAttrs(const Frag& frag, ConstData data1, Data data2, unsigned maxlen2
#endif #endif
} }
void
Dbtux::unpackBound(const ScanBound& bound, Data dest)
{
ScanBoundIterator iter;
bound.first(iter);
const unsigned n = bound.getSize();
unsigned j;
for (j = 0; j < n; j++) {
dest[j] = *iter.data;
bound.next(iter);
}
}
BLOCK_FUNCTIONS(Dbtux) BLOCK_FUNCTIONS(Dbtux)
...@@ -113,16 +113,17 @@ Dbtux::execTUX_MAINT_REQ(Signal* signal) ...@@ -113,16 +113,17 @@ Dbtux::execTUX_MAINT_REQ(Signal* signal)
// do the operation // do the operation
req->errorCode = 0; req->errorCode = 0;
TreePos treePos; TreePos treePos;
bool ok;
switch (opCode) { switch (opCode) {
case TuxMaintReq::OpAdd: case TuxMaintReq::OpAdd:
jam(); jam();
searchToAdd(frag, c_searchKey, ent, treePos); ok = searchToAdd(frag, c_searchKey, ent, treePos);
#ifdef VM_TRACE #ifdef VM_TRACE
if (debugFlags & DebugMaint) { if (debugFlags & DebugMaint) {
debugOut << treePos << (treePos.m_match ? " - error" : "") << endl; debugOut << treePos << (! ok ? " - error" : "") << endl;
} }
#endif #endif
if (treePos.m_match) { if (! ok) {
jam(); jam();
// there is no "Building" state so this will have to do // there is no "Building" state so this will have to do
if (indexPtr.p->m_state == Index::Online) { if (indexPtr.p->m_state == Index::Online) {
...@@ -152,13 +153,13 @@ Dbtux::execTUX_MAINT_REQ(Signal* signal) ...@@ -152,13 +153,13 @@ Dbtux::execTUX_MAINT_REQ(Signal* signal)
break; break;
case TuxMaintReq::OpRemove: case TuxMaintReq::OpRemove:
jam(); jam();
searchToRemove(frag, c_searchKey, ent, treePos); ok = searchToRemove(frag, c_searchKey, ent, treePos);
#ifdef VM_TRACE #ifdef VM_TRACE
if (debugFlags & DebugMaint) { if (debugFlags & DebugMaint) {
debugOut << treePos << (! treePos.m_match ? " - error" : "") << endl; debugOut << treePos << (! ok ? " - error" : "") << endl;
} }
#endif #endif
if (! treePos.m_match) { if (! ok) {
jam(); jam();
// there is no "Building" state so this will have to do // there is no "Building" state so this will have to do
if (indexPtr.p->m_state == Index::Online) { if (indexPtr.p->m_state == Index::Online) {
......
This diff is collapsed.
...@@ -21,22 +21,18 @@ ...@@ -21,22 +21,18 @@
* Search for entry to add. * Search for entry to add.
* *
* Similar to searchToRemove (see below). * Similar to searchToRemove (see below).
*
* TODO optimize for initial equal attrs in node min/max
*/ */
void bool
Dbtux::searchToAdd(Frag& frag, ConstData searchKey, TreeEnt searchEnt, TreePos& treePos) Dbtux::searchToAdd(Frag& frag, ConstData searchKey, TreeEnt searchEnt, TreePos& treePos)
{ {
const TreeHead& tree = frag.m_tree; const TreeHead& tree = frag.m_tree;
const unsigned numAttrs = frag.m_numAttrs; const unsigned numAttrs = frag.m_numAttrs;
NodeHandle currNode(frag); NodeHandle currNode(frag);
currNode.m_loc = tree.m_root; currNode.m_loc = tree.m_root;
// assume success
treePos.m_match = false;
if (currNode.m_loc == NullTupLoc) { if (currNode.m_loc == NullTupLoc) {
// empty tree // empty tree
jam(); jam();
return; return true;
} }
NodeHandle glbNode(frag); // potential g.l.b of final node NodeHandle glbNode(frag); // potential g.l.b of final node
/* /*
...@@ -94,9 +90,8 @@ Dbtux::searchToAdd(Frag& frag, ConstData searchKey, TreeEnt searchEnt, TreePos& ...@@ -94,9 +90,8 @@ Dbtux::searchToAdd(Frag& frag, ConstData searchKey, TreeEnt searchEnt, TreePos&
jam(); jam();
treePos.m_loc = currNode.m_loc; treePos.m_loc = currNode.m_loc;
treePos.m_pos = 0; treePos.m_pos = 0;
// failed // entry found - error
treePos.m_match = true; return false;
return;
} }
break; break;
} }
...@@ -104,7 +99,7 @@ Dbtux::searchToAdd(Frag& frag, ConstData searchKey, TreeEnt searchEnt, TreePos& ...@@ -104,7 +99,7 @@ Dbtux::searchToAdd(Frag& frag, ConstData searchKey, TreeEnt searchEnt, TreePos&
treePos.m_loc = currNode.m_loc; treePos.m_loc = currNode.m_loc;
// binary search // binary search
int lo = -1; int lo = -1;
unsigned hi = currNode.getOccup(); int hi = currNode.getOccup();
int ret; int ret;
while (1) { while (1) {
jam(); jam();
...@@ -126,9 +121,8 @@ Dbtux::searchToAdd(Frag& frag, ConstData searchKey, TreeEnt searchEnt, TreePos& ...@@ -126,9 +121,8 @@ Dbtux::searchToAdd(Frag& frag, ConstData searchKey, TreeEnt searchEnt, TreePos&
lo = j; lo = j;
else { else {
treePos.m_pos = j; treePos.m_pos = j;
// failed // entry found - error
treePos.m_match = true; return false;
return;
} }
if (hi - lo == 1) if (hi - lo == 1)
break; break;
...@@ -136,22 +130,23 @@ Dbtux::searchToAdd(Frag& frag, ConstData searchKey, TreeEnt searchEnt, TreePos& ...@@ -136,22 +130,23 @@ Dbtux::searchToAdd(Frag& frag, ConstData searchKey, TreeEnt searchEnt, TreePos&
if (ret < 0) { if (ret < 0) {
jam(); jam();
treePos.m_pos = hi; treePos.m_pos = hi;
return; return true;
} }
if (hi < currNode.getOccup()) { if (hi < currNode.getOccup()) {
jam(); jam();
treePos.m_pos = hi; treePos.m_pos = hi;
return; return true;
} }
if (bottomNode.isNull()) { if (bottomNode.isNull()) {
jam(); jam();
treePos.m_pos = hi; treePos.m_pos = hi;
return; return true;
} }
jam(); jam();
// backwards compatible for now // backwards compatible for now
treePos.m_loc = bottomNode.m_loc; treePos.m_loc = bottomNode.m_loc;
treePos.m_pos = 0; treePos.m_pos = 0;
return true;
} }
/* /*
...@@ -163,21 +158,17 @@ Dbtux::searchToAdd(Frag& frag, ConstData searchKey, TreeEnt searchEnt, TreePos& ...@@ -163,21 +158,17 @@ Dbtux::searchToAdd(Frag& frag, ConstData searchKey, TreeEnt searchEnt, TreePos&
* then the saved node is the g.l.b of the final node and we move back * then the saved node is the g.l.b of the final node and we move back
* to it. * to it.
*/ */
void bool
Dbtux::searchToRemove(Frag& frag, ConstData searchKey, TreeEnt searchEnt, TreePos& treePos) Dbtux::searchToRemove(Frag& frag, ConstData searchKey, TreeEnt searchEnt, TreePos& treePos)
{ {
const TreeHead& tree = frag.m_tree; const TreeHead& tree = frag.m_tree;
const unsigned numAttrs = frag.m_numAttrs; const unsigned numAttrs = frag.m_numAttrs;
NodeHandle currNode(frag); NodeHandle currNode(frag);
currNode.m_loc = tree.m_root; currNode.m_loc = tree.m_root;
// assume success
treePos.m_match = true;
if (currNode.m_loc == NullTupLoc) { if (currNode.m_loc == NullTupLoc) {
// empty tree // empty tree - failed
jam(); jam();
// failed return false;
treePos.m_match = false;
return;
} }
NodeHandle glbNode(frag); // potential g.l.b of final node NodeHandle glbNode(frag); // potential g.l.b of final node
while (true) { while (true) {
...@@ -229,7 +220,7 @@ Dbtux::searchToRemove(Frag& frag, ConstData searchKey, TreeEnt searchEnt, TreePo ...@@ -229,7 +220,7 @@ Dbtux::searchToRemove(Frag& frag, ConstData searchKey, TreeEnt searchEnt, TreePo
jam(); jam();
treePos.m_loc = currNode.m_loc; treePos.m_loc = currNode.m_loc;
treePos.m_pos = 0; treePos.m_pos = 0;
return; return true;
} }
break; break;
} }
...@@ -242,12 +233,12 @@ Dbtux::searchToRemove(Frag& frag, ConstData searchKey, TreeEnt searchEnt, TreePo ...@@ -242,12 +233,12 @@ Dbtux::searchToRemove(Frag& frag, ConstData searchKey, TreeEnt searchEnt, TreePo
if (searchEnt.eq(currNode.getEnt(j))) { if (searchEnt.eq(currNode.getEnt(j))) {
jam(); jam();
treePos.m_pos = j; treePos.m_pos = j;
return; return true;
} }
} }
treePos.m_pos = currNode.getOccup(); treePos.m_pos = currNode.getOccup();
// failed // not found - failed
treePos.m_match = false; return false;
} }
/* /*
...@@ -278,8 +269,6 @@ Dbtux::searchToScanAscending(Frag& frag, ConstData boundInfo, unsigned boundCoun ...@@ -278,8 +269,6 @@ Dbtux::searchToScanAscending(Frag& frag, ConstData boundInfo, unsigned boundCoun
currNode.m_loc = tree.m_root; currNode.m_loc = tree.m_root;
NodeHandle glbNode(frag); // potential g.l.b of final node NodeHandle glbNode(frag); // potential g.l.b of final node
NodeHandle bottomNode(frag); NodeHandle bottomNode(frag);
// always before entry
treePos.m_match = false;
while (true) { while (true) {
jam(); jam();
selectNode(currNode, currNode.m_loc); selectNode(currNode, currNode.m_loc);
...@@ -315,7 +304,7 @@ Dbtux::searchToScanAscending(Frag& frag, ConstData boundInfo, unsigned boundCoun ...@@ -315,7 +304,7 @@ Dbtux::searchToScanAscending(Frag& frag, ConstData boundInfo, unsigned boundCoun
treePos.m_dir = 3; treePos.m_dir = 3;
return; return;
} }
} else if (ret > 0) { } else {
// bound is at or right of this node // bound is at or right of this node
jam(); jam();
const TupLoc loc = currNode.getLink(1); const TupLoc loc = currNode.getLink(1);
...@@ -327,8 +316,6 @@ Dbtux::searchToScanAscending(Frag& frag, ConstData boundInfo, unsigned boundCoun ...@@ -327,8 +316,6 @@ Dbtux::searchToScanAscending(Frag& frag, ConstData boundInfo, unsigned boundCoun
currNode.m_loc = loc; currNode.m_loc = loc;
continue; continue;
} }
} else {
ndbrequire(false);
} }
break; break;
} }
...@@ -369,8 +356,6 @@ Dbtux::searchToScanDescending(Frag& frag, ConstData boundInfo, unsigned boundCou ...@@ -369,8 +356,6 @@ Dbtux::searchToScanDescending(Frag& frag, ConstData boundInfo, unsigned boundCou
currNode.m_loc = tree.m_root; currNode.m_loc = tree.m_root;
NodeHandle glbNode(frag); // potential g.l.b of final node NodeHandle glbNode(frag); // potential g.l.b of final node
NodeHandle bottomNode(frag); NodeHandle bottomNode(frag);
// always before entry
treePos.m_match = false;
while (true) { while (true) {
jam(); jam();
selectNode(currNode, currNode.m_loc); selectNode(currNode, currNode.m_loc);
...@@ -403,7 +388,7 @@ Dbtux::searchToScanDescending(Frag& frag, ConstData boundInfo, unsigned boundCou ...@@ -403,7 +388,7 @@ Dbtux::searchToScanDescending(Frag& frag, ConstData boundInfo, unsigned boundCou
// empty result set // empty result set
return; return;
} }
} else if (ret > 0) { } else {
// bound is at or right of this node // bound is at or right of this node
jam(); jam();
const TupLoc loc = currNode.getLink(1); const TupLoc loc = currNode.getLink(1);
...@@ -415,8 +400,6 @@ Dbtux::searchToScanDescending(Frag& frag, ConstData boundInfo, unsigned boundCou ...@@ -415,8 +400,6 @@ Dbtux::searchToScanDescending(Frag& frag, ConstData boundInfo, unsigned boundCou
currNode.m_loc = loc; currNode.m_loc = loc;
continue; continue;
} }
} else {
ndbrequire(false);
} }
break; break;
} }
......
This diff is collapsed.
...@@ -607,7 +607,15 @@ args: ...@@ -607,7 +607,15 @@ args:
max-time: 5000 max-time: 5000
cmd: testOIBasic cmd: testOIBasic
args: args: -case abcdefz
max-time: 2000
cmd: testOIBasic
args: -case gz
max-time: 2000
cmd: testOIBasic
args: -case hz
max-time: 2500 max-time: 2500
cmd: testBitfield cmd: testBitfield
......
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