Skip to content

Commit

Permalink
Integer and Varchar testcase passed. Varchar(all writes get giantlock…
Browse files Browse the repository at this point in the history
…, 50bytes fixed size key)
  • Loading branch information
ryogrid committed Sep 12, 2024
1 parent 689575c commit b4abaab
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ func testBTreeParallelTxnStrideRoot[T int32 | float32 | string](t *testing.T, ke

//InnerTestParallelTxnsQueryingIndexUsedColumns[T](t, keyType, 800, 3000, 17, 0, bpoolSize, index_constants.INDEX_KIND_BTREE, SERIAL_EXEC, 1)
InnerTestParallelTxnsQueryingIndexUsedColumns[T](t, keyType, 800, 30000, 17, 0, bpoolSize, index_constants.INDEX_KIND_BTREE, PARALLEL_EXEC, 20)
//InnerTestParallelTxnsQueryingIndexUsedColumns[T](t, keyType, 800, 30000, 17, 0, bpoolSize, index_constants.INDEX_KIND_BTREE, SERIAL_EXEC, 1)
default:
panic("not implemented!")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1071,18 +1071,16 @@ func InnerTestParallelTxnsQueryingIndexUsedColumns[T int32 | float32 | string](t
return
}
common.ShPrintf(common.DEBUGGING, "Select(success) op start.\n")
//diffToMakeNoExist := int32(10)
diffToMakeNoExist := int32(10)
rangeSelectRetry:
var rangeStartKey = samehada_util.ChoiceKeyFromMap(insVals)
var rangeEndKey = samehada_util.ChoiceKeyFromMap(insVals)
for rangeEndKey < rangeStartKey {
goto rangeSelectRetry
}
insValsMutex.RUnlock()
//// get 0-8 value
//tmpRand := rand.Intn(9)
// get 0-3 value
tmpRand := rand.Intn(4)
// get 0-8 value
tmpRand := rand.Intn(9)
var rangeScanPlan plans.Plan
switch tmpRand {
case 0: // start only
Expand All @@ -1093,22 +1091,22 @@ func InnerTestParallelTxnsQueryingIndexUsedColumns[T int32 | float32 | string](t
rangeScanPlan = createSpecifiedRangeScanPlanNode[T](c, tableMetadata, keyType, 0, &rangeStartKey, &rangeEndKey, indexKind)
case 3: // not specified both
rangeScanPlan = createSpecifiedRangeScanPlanNode[T](c, tableMetadata, keyType, 0, nil, nil, indexKind)
//case 4: // start only (not exisiting val)
// tmpStartKey := samehada_util.StrideAdd(rangeStartKey, diffToMakeNoExist).(T)
// rangeScanPlan = createSpecifiedRangeScanPlanNode[T](c, tableMetadata, keyType, 0, &tmpStartKey, nil, indexKind)
//case 5: // end only (not existing val)
// tmpEndKey := samehada_util.StrideAdd(rangeEndKey, diffToMakeNoExist).(T)
// rangeScanPlan = createSpecifiedRangeScanPlanNode[T](c, tableMetadata, keyType, 0, nil, &tmpEndKey, indexKind)
//case 6: // start and end (start val is not existing one)
// tmpStartKey := samehada_util.StrideAdd(rangeStartKey, diffToMakeNoExist).(T)
// rangeScanPlan = createSpecifiedRangeScanPlanNode[T](c, tableMetadata, keyType, 0, &tmpStartKey, &rangeEndKey, indexKind)
//case 7: // start and end (start val is not existing one)
// tmpEndKey := samehada_util.StrideAdd(rangeEndKey, diffToMakeNoExist).(T)
// rangeScanPlan = createSpecifiedRangeScanPlanNode[T](c, tableMetadata, keyType, 0, &rangeStartKey, &tmpEndKey, indexKind)
//case 8: // start and end (end val is not existing one)
// tmpStartKey := samehada_util.StrideAdd(rangeStartKey, diffToMakeNoExist).(T)
// tmpEndKey := samehada_util.StrideAdd(rangeEndKey, diffToMakeNoExist).(T)
// rangeScanPlan = createSpecifiedRangeScanPlanNode[T](c, tableMetadata, keyType, 0, &tmpStartKey, &tmpEndKey, indexKind)
case 4: // start only (not exisiting val)
tmpStartKey := samehada_util.StrideAdd(rangeStartKey, diffToMakeNoExist).(T)
rangeScanPlan = createSpecifiedRangeScanPlanNode[T](c, tableMetadata, keyType, 0, &tmpStartKey, nil, indexKind)
case 5: // end only (not existing val)
tmpEndKey := samehada_util.StrideAdd(rangeEndKey, diffToMakeNoExist).(T)
rangeScanPlan = createSpecifiedRangeScanPlanNode[T](c, tableMetadata, keyType, 0, nil, &tmpEndKey, indexKind)
case 6: // start and end (start val is not existing one)
tmpStartKey := samehada_util.StrideAdd(rangeStartKey, diffToMakeNoExist).(T)
rangeScanPlan = createSpecifiedRangeScanPlanNode[T](c, tableMetadata, keyType, 0, &tmpStartKey, &rangeEndKey, indexKind)
case 7: // start and end (start val is not existing one)
tmpEndKey := samehada_util.StrideAdd(rangeEndKey, diffToMakeNoExist).(T)
rangeScanPlan = createSpecifiedRangeScanPlanNode[T](c, tableMetadata, keyType, 0, &rangeStartKey, &tmpEndKey, indexKind)
case 8: // start and end (end val is not existing one)
tmpStartKey := samehada_util.StrideAdd(rangeStartKey, diffToMakeNoExist).(T)
tmpEndKey := samehada_util.StrideAdd(rangeEndKey, diffToMakeNoExist).(T)
rangeScanPlan = createSpecifiedRangeScanPlanNode[T](c, tableMetadata, keyType, 0, &tmpStartKey, &tmpEndKey, indexKind)
}

txn_ := txnMgr.Begin(nil)
Expand Down
18 changes: 14 additions & 4 deletions lib/storage/index/btree_index.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,13 @@ func (btidx *BTreeIndex) insertEntryInner(key *tuple.Tuple, rid page.RID, txn in
convedKeyVal := samehada_util.EncodeValueAndRIDToDicOrderComparableVarchar(&orgKeyVal, &rid)

if isNoLock == false {
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 @@ -124,8 +129,13 @@ func (btidx *BTreeIndex) deleteEntryInner(key *tuple.Tuple, rid page.RID, txn in
convedKeyVal := samehada_util.EncodeValueAndRIDToDicOrderComparableVarchar(&orgKeyVal, &rid)

if isNoLock == false {
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 Down

0 comments on commit b4abaab

Please sign in to comment.