本文整理匯總了Golang中github.com/cockroachdb/cockroach/pkg/sql/sqlbase.RowFetcher.Key方法的典型用法代碼示例。如果您正苦於以下問題:Golang RowFetcher.Key方法的具體用法?Golang RowFetcher.Key怎麽用?Golang RowFetcher.Key使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cockroachdb/cockroach/pkg/sql/sqlbase.RowFetcher
的用法示例。
在下文中一共展示了RowFetcher.Key方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: deleteAllRowsScan
func (td *tableDeleter) deleteAllRowsScan(
ctx context.Context, resume roachpb.Span, limit int64,
) (roachpb.Span, error) {
if resume.Key == nil {
tablePrefix := sqlbase.MakeIndexKeyPrefix(
td.rd.helper.tableDesc, td.rd.helper.tableDesc.PrimaryIndex.ID)
resume = roachpb.Span{Key: roachpb.Key(tablePrefix), EndKey: roachpb.Key(tablePrefix).PrefixEnd()}
}
valNeededForCol := make([]bool, len(td.rd.helper.tableDesc.Columns))
for _, idx := range td.rd.fetchColIDtoRowIndex {
valNeededForCol[idx] = true
}
var rf sqlbase.RowFetcher
err := rf.Init(
td.rd.helper.tableDesc, td.rd.fetchColIDtoRowIndex, &td.rd.helper.tableDesc.PrimaryIndex,
false, false, td.rd.fetchCols, valNeededForCol)
if err != nil {
return resume, err
}
if err := rf.StartScan(td.txn, roachpb.Spans{resume}, true /* limit batches */, 0); err != nil {
return resume, err
}
for i := int64(0); i < limit; i++ {
row, err := rf.NextRowDecoded()
if err != nil {
return resume, err
}
if row == nil {
// Done deleting all rows.
resume = roachpb.Span{}
break
}
_, err = td.row(ctx, row)
if err != nil {
return resume, err
}
}
if resume.Key != nil {
// Update the resume start key for the next iteration.
resume.Key = rf.Key()
}
return resume, td.finalize(ctx)
}