Skip to content

Commit

Permalink
[WIP] sql: use GetRequest for point lookups
Browse files Browse the repository at this point in the history
  • Loading branch information
nvanbenschoten committed Mar 30, 2020
1 parent b0f33f8 commit 8bce292
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
28 changes: 22 additions & 6 deletions pkg/sql/row/kv_batch_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,12 +283,20 @@ func (f *txnKVFetcher) fetch(ctx context.Context) error {
ba.Requests[i].MustSetInner(&scans[i])
}
} else {
scans := make([]roachpb.ScanRequest, len(f.spans))
for i := range f.spans {
scans[i].SetSpan(f.spans[i])
scans[i].ScanFormat = roachpb.BATCH_RESPONSE
scans[i].KeyLocking = keyLocking
ba.Requests[i].MustSetInner(&scans[i])
if f.lockStr == sqlbase.ScanLockingStrength_FOR_SHARE {
scans := make([]roachpb.GetRequest, len(f.spans))
for i := range f.spans {
scans[i].Key = f.spans[i].Key
ba.Requests[i].MustSetInner(&scans[i])
}
} else {
scans := make([]roachpb.ScanRequest, len(f.spans))
for i := range f.spans {
scans[i].SetSpan(f.spans[i])
scans[i].ScanFormat = roachpb.BATCH_RESPONSE
scans[i].KeyLocking = keyLocking
ba.Requests[i].MustSetInner(&scans[i])
}
}
}
if cap(f.requestSpans) < len(f.spans) {
Expand Down Expand Up @@ -391,6 +399,14 @@ func (f *txnKVFetcher) nextBatch(
f.remainingBatches = t.BatchResponses[1:]
}
return true, t.Rows, batchResp, origSpan, nil
case *roachpb.GetResponse:
if t.Value != nil {
kvs = []roachpb.KeyValue{{
Key: origSpan.Key,
Value: *t.Value,
}}
}
return true, kvs, batchResp, origSpan, nil
}
}
if f.fetchEnd {
Expand Down
2 changes: 1 addition & 1 deletion pkg/workload/kv/kv.go
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ func (w *kv) Ops(urls []string, reg *histogram.Registry) (workload.QueryLoad, er
fmt.Fprintf(&buf, `(mod($%d, %d), $%d)`, i+1, w.shards, i+1)
}
}
buf.WriteString(`)`)
buf.WriteString(`) FOR SHARE`)
readStmtStr := buf.String()

// Write statement
Expand Down

0 comments on commit 8bce292

Please sign in to comment.