MCPcopy Index your code
hub / github.com/ByteStorage/FlyDB / Get

Method Get

engine/db.go:250–269  ·  view source on GitHub ↗

Get Read data according to the key

(key []byte)

Source from the content-addressed store, hash-verified

248
249// Get Read data according to the key
250func (db *DB) Get(key []byte) ([]byte, error) {
251 zap.L().Info("get", zap.ByteString("key", key))
252 db.lock.RLock()
253 defer db.lock.RUnlock()
254
255 // Determine the validity of the key
256 if len(key) == 0 {
257 return nil, _const.ErrKeyIsEmpty
258 }
259
260 // Retrieves the index of the key from the memory data structure
261 logRecordPst := db.index.Get(key)
262 // If key is not in the memory index, it does not exist
263 if logRecordPst == nil {
264 return nil, _const.ErrKeyNotFound
265 }
266
267 // Gets the value from the data file
268 return db.getValueByPosition(logRecordPst)
269}
270
271// GetListKeys Gets all the keys in the database
272func (db *DB) GetListKeys() [][]byte {

Callers 8

TestDB_WriteBatchFunction · 0.95
TestDB_WriteBatchRestartFunction · 0.95
TestPutAndGetFunction · 0.95
TestDB_PutFunction · 0.95
TestDB_ConcurrentPutFunction · 0.95
TestDB_GetFunction · 0.95
TestDB_DeleteFunction · 0.95
TestDB_Merge2Function · 0.95

Calls 2

getValueByPositionMethod · 0.95
GetMethod · 0.65

Tested by 8

TestDB_WriteBatchFunction · 0.76
TestDB_WriteBatchRestartFunction · 0.76
TestPutAndGetFunction · 0.76
TestDB_PutFunction · 0.76
TestDB_ConcurrentPutFunction · 0.76
TestDB_GetFunction · 0.76
TestDB_DeleteFunction · 0.76
TestDB_Merge2Function · 0.76