Skip to content

Commit

Permalink
TestKeyDuplicateBTreePrallelTxnStrideVarchar(no strange giant lock, f…
Browse files Browse the repository at this point in the history
…ixed length) really passed
  • Loading branch information
ryogrid committed Sep 12, 2024
1 parent a2c3b4e commit 0a62886
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions lib/storage/index/btree_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ func (btidx *BTreeIndex) insertEntryInner(key *tuple.Tuple, rid page.RID, txn in
convedKeyVal := samehada_util.EncodeValueAndRIDToDicOrderComparableVarchar(&orgKeyVal, &rid)

if isNoLock == false {
if orgKeyVal.ValueType() == types.Varchar {
btidx.rwMtx.Lock()
defer btidx.rwMtx.Unlock()
} else {
btidx.rwMtx.RLock()
defer btidx.rwMtx.RUnlock()
}
//if orgKeyVal.ValueType() == types.Varchar {
// btidx.rwMtx.Lock()
// defer btidx.rwMtx.Unlock()
//} else {
btidx.rwMtx.RLock()
defer btidx.rwMtx.RUnlock()
//}
}

ridBytes := samehada_util.PackRIDto8bytes(&rid)
Expand All @@ -129,13 +129,13 @@ func (btidx *BTreeIndex) deleteEntryInner(key *tuple.Tuple, rid page.RID, txn in
convedKeyVal := samehada_util.EncodeValueAndRIDToDicOrderComparableVarchar(&orgKeyVal, &rid)

if isNoLock == false {
if orgKeyVal.ValueType() == types.Varchar {
btidx.rwMtx.Lock()
defer btidx.rwMtx.Unlock()
} else {
btidx.rwMtx.RLock()
defer btidx.rwMtx.RUnlock()
}
//if orgKeyVal.ValueType() == types.Varchar {
// btidx.rwMtx.Lock()
// defer btidx.rwMtx.Unlock()
//} else {
btidx.rwMtx.RLock()
defer btidx.rwMtx.RUnlock()
//}
}
btidx.container.DeleteKey(convedKeyVal.SerializeOnlyVal(), 0)
}
Expand All @@ -150,11 +150,11 @@ func (btidx *BTreeIndex) ScanKey(key *tuple.Tuple, txn interface{}) []page.RID {
smallestKeyVal := samehada_util.EncodeValueAndRIDToDicOrderComparableVarchar(&orgKeyVal, &page.RID{0, 0})
biggestKeyVal := samehada_util.EncodeValueAndRIDToDicOrderComparableVarchar(&orgKeyVal, &page.RID{math.MaxInt32, math.MaxUint32})

if orgKeyVal.ValueType() == types.Varchar {
btidx.rwMtx.Lock()
} else {
btidx.rwMtx.RLock()
}
//if orgKeyVal.ValueType() == types.Varchar {
// btidx.rwMtx.Lock()
//} else {
btidx.rwMtx.RLock()
//}
// Attention: returned itr's containing keys are string type Value which is constructed with byte arr of concatenated original key and value
rangeItr := btidx.container.GetRangeItr(smallestKeyVal.SerializeOnlyVal(), biggestKeyVal.SerializeOnlyVal())

Expand All @@ -166,11 +166,11 @@ func (btidx *BTreeIndex) ScanKey(key *tuple.Tuple, txn interface{}) []page.RID {
//uintRID := binary.BigEndian.Uint64(eightBytesRID[:])
retArr = append(retArr, samehada_util.Unpack8BytesToRID(eightBytesRID[:]))
}
if orgKeyVal.ValueType() == types.Varchar {
btidx.rwMtx.Unlock()
} else {
btidx.rwMtx.RUnlock()
}
//if orgKeyVal.ValueType() == types.Varchar {
// btidx.rwMtx.Unlock()
//} else {
btidx.rwMtx.RUnlock()
//}

return retArr
}
Expand Down Expand Up @@ -200,13 +200,13 @@ func (btidx *BTreeIndex) GetRangeScanIterator(start_key *tuple.Tuple, end_key *t
biggestKeyVal = samehada_util.EncodeValueAndRIDToDicOrderComparableVarchar(&orgEndKeyVal, &page.RID{math.MaxInt32, math.MaxUint32})
}

if tupleSchema_.GetColumns()[btidx.col_idx].GetType() == types.Varchar {
btidx.rwMtx.Lock()
defer btidx.rwMtx.Unlock()
} else {
btidx.rwMtx.RLock()
defer btidx.rwMtx.RUnlock()
}
//if tupleSchema_.GetColumns()[btidx.col_idx].GetType() == types.Varchar {
// btidx.rwMtx.Lock()
// defer btidx.rwMtx.Unlock()
//} else {
btidx.rwMtx.RLock()
defer btidx.rwMtx.RUnlock()
//}
var smalledKeyBytes []byte
var biggestKeyBytes []byte

Expand Down

0 comments on commit 0a62886

Please sign in to comment.