Skip to content

Commit

Permalink
Integer and Varchar testcase passed. Varchar(all writes and reads get…
Browse files Browse the repository at this point in the history
… giant exclusive lock, 50bytes fixed size key)
  • Loading branch information
ryogrid committed Sep 12, 2024
1 parent b4abaab commit a2c3b4e
Showing 1 changed file with 17 additions and 4 deletions.
21 changes: 17 additions & 4 deletions lib/storage/index/btree_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +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})

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 @@ -162,7 +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[:]))
}
btidx.rwMtx.RUnlock()
if orgKeyVal.ValueType() == types.Varchar {
btidx.rwMtx.Unlock()
} else {
btidx.rwMtx.RUnlock()
}

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

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 a2c3b4e

Please sign in to comment.