本文整理汇总了Golang中C.DBGet函数的典型用法代码示例。如果您正苦于以下问题:Golang DBGet函数的具体用法?Golang DBGet怎么用?Golang DBGet使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DBGet函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: dbGetProto
func dbGetProto(rdb *C.DBEngine, key MVCCKey,
msg proto.Message) (ok bool, keyBytes, valBytes int64, err error) {
if len(key.Key) == 0 {
err = emptyKeyError()
return
}
var result C.DBString
if err = statusToError(C.DBGet(rdb, goToCKey(key), &result)); err != nil {
return
}
if result.len <= 0 {
msg.Reset()
return
}
ok = true
if msg != nil {
// Make a byte slice that is backed by result.data. This slice
// cannot live past the lifetime of this method, but we're only
// using it to unmarshal the roachpb.
data := cSliceToUnsafeGoBytes(C.DBSlice(result))
err = proto.Unmarshal(data, msg)
}
C.free(unsafe.Pointer(result.data))
keyBytes = int64(key.EncodedSize())
valBytes = int64(result.len)
return
}
示例2: getProtoInternal
func (r *RocksDB) getProtoInternal(key proto.EncodedKey, msg gogoproto.Message,
snapshotHandle *C.DBSnapshot) (ok bool, keyBytes, valBytes int64, err error) {
if len(key) == 0 {
err = emptyKeyError()
return
}
var result C.DBString
if err = statusToError(C.DBGet(r.rdb, snapshotHandle, goToCSlice(key), &result)); err != nil {
return
}
if result.len <= 0 {
msg.Reset()
return
}
ok = true
if msg != nil {
// Make a byte slice that is backed by result.data. This slice
// cannot live past the lifetime of this method, but we're only
// using it to unmarshal the proto.
data := cSliceToUnsafeGoBytes(C.DBSlice(result))
err = gogoproto.Unmarshal(data, msg)
}
C.free(unsafe.Pointer(result.data))
keyBytes = int64(len(key))
valBytes = int64(result.len)
return
}
示例3: dbGet
// dbGet returns the value for the given key.
func dbGet(rdb *C.DBEngine, key MVCCKey) ([]byte, error) {
if len(key.Key) == 0 {
return nil, emptyKeyError()
}
var result C.DBString
err := statusToError(C.DBGet(rdb, goToCKey(key), &result))
if err != nil {
return nil, err
}
return cStringToGoBytes(result), nil
}
示例4: getInternal
// getInternal returns the value for the given key.
func (r *RocksDB) getInternal(key proto.EncodedKey, snapshotHandle *C.DBSnapshot) ([]byte, error) {
if len(key) == 0 {
return nil, emptyKeyError()
}
var result C.DBString
err := statusToError(C.DBGet(r.rdb, snapshotHandle, goToCSlice(key), &result))
if err != nil {
return nil, err
}
return cStringToGoBytes(result), nil
}