本文整理匯總了Golang中github.com/pingcap/tidb/kv.RetrieverMutator.Set方法的典型用法代碼示例。如果您正苦於以下問題:Golang RetrieverMutator.Set方法的具體用法?Golang RetrieverMutator.Set怎麽用?Golang RetrieverMutator.Set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/pingcap/tidb/kv.RetrieverMutator
的用法示例。
在下文中一共展示了RetrieverMutator.Set方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: SetColValue
// SetColValue implements table.Table SetColValue interface.
func SetColValue(rm kv.RetrieverMutator, key []byte, data types.Datum) error {
v, err := EncodeValue(data)
if err != nil {
return errors.Trace(err)
}
if err := rm.Set(key, v); err != nil {
return errors.Trace(err)
}
return nil
}
示例2: SetColValue
// SetColValue implements table.Table SetColValue interface.
func (t *Table) SetColValue(rm kv.RetrieverMutator, key []byte, data interface{}) error {
v, err := t.EncodeValue(data)
if err != nil {
return errors.Trace(err)
}
if err := rm.Set(key, v); err != nil {
return errors.Trace(err)
}
return nil
}
示例3: Create
// Create creates a new entry in the kvIndex data.
// If the index is unique and there is an existing entry with the same key, Create will return ErrKeyExists.
func (c *index) Create(rm kv.RetrieverMutator, indexedValues []types.Datum, h int64) error {
key, distinct, err := c.GenIndexKey(indexedValues, h)
if err != nil {
return errors.Trace(err)
}
if !distinct {
// TODO: reconsider value
err = rm.Set(key, []byte("timestamp?"))
return errors.Trace(err)
}
_, err = rm.Get(key)
if kv.IsErrNotFound(err) {
err = rm.Set(key, encodeHandle(h))
return errors.Trace(err)
}
return errors.Trace(kv.ErrKeyExists)
}
示例4: Create
// Create creates a new entry in the kvIndex data.
// If the index is unique and there is an existing entry with the same key,
// Create will return the existing entry's handle as the first return value, ErrKeyExists as the second return value.
func (c *index) Create(rm kv.RetrieverMutator, indexedValues []types.Datum, h int64) (int64, error) {
key, distinct, err := c.GenIndexKey(indexedValues, h)
if err != nil {
return 0, errors.Trace(err)
}
if !distinct {
// non-unique index doesn't need store value, write a '0' to reduce space
err = rm.Set(key, []byte{'0'})
return 0, errors.Trace(err)
}
value, err := rm.Get(key)
if kv.IsErrNotFound(err) {
err = rm.Set(key, encodeHandle(h))
return 0, errors.Trace(err)
}
handle, err := decodeHandle(value)
if err != nil {
return 0, errors.Trace(err)
}
return handle, errors.Trace(kv.ErrKeyExists)
}