MCPcopy Create free account
hub / github.com/nutsdb/nutsdb / GetRawKey

Method GetRawKey

internal/core/entry.go:309–341  ·  view source on GitHub ↗

** * decode the key of the entry * 1. in the case of list flag is DataLPushFlag or DataRPushFlag, the key is transformed from seq + user_key to user_key * so we need to decode the key to get the raw key * 2. in the case of sorted set flag is DataZAddFlag, the key is transformed from score + user

()

Source from the content-addressed store, hash-verified

307 * 3. All other cases, the key is the raw key
308 */
309func (entry *Entry) GetRawKey() ([]byte, error) {
310 key := entry.Key
311
312 switch entry.Meta.Ds {
313 case DataStructureList:
314 if entry.Meta.Flag != DataLPushFlag && entry.Meta.Flag != DataRPushFlag {
315 return key, nil
316 }
317
318 if len(key) < 8 {
319 return key, ErrInvalidKey
320 }
321
322 return key[8:], nil
323 case DataStructureSortedSet:
324 if entry.Meta.Flag != DataZAddFlag {
325 return key, nil
326 }
327
328 strList := bytes.Split(key, []byte(SeparatorForZSetKey))
329 if len(strList) != 2 {
330 return key, ErrInvalidKey
331 }
332
333 return []byte(strList[0]), nil
334 case DataStructureSet:
335 return key, nil
336 case DataStructureBTree:
337 return key, nil
338 default:
339 return key, ErrDataStructureNotSupported
340 }
341}

Callers 2

sendUpdatedEntriesMethod · 0.80
Test_EntryMostFunctionsFunction · 0.80

Calls

no outgoing calls

Tested by 1

Test_EntryMostFunctionsFunction · 0.64