MCPcopy Create free account
hub / github.com/distributedio/titan / Keys

Function Keys

command/keys.go:248–266  ·  view source on GitHub ↗

Keys returns all keys matching pattern

(ctx *Context, txn *db.Transaction)

Source from the content-addressed store, hash-verified

246
247// Keys returns all keys matching pattern
248func Keys(ctx *Context, txn *db.Transaction) (OnCommit, error) {
249 list := make([][]byte, 0)
250 pattern := []byte(ctx.Args[0])
251 all := (pattern[0] == '*' && len(pattern) == 1)
252 prefix := globMatchPrefix(pattern)
253
254 kv := txn.Kv()
255 f := func(key []byte) bool {
256 if all || globMatch(pattern, key, false) {
257 list = append(list, key)
258 }
259 return true
260 }
261
262 if err := kv.Keys(prefix, f); err != nil {
263 return nil, errors.New("ERR " + err.Error())
264 }
265 return BytesArray(ctx.Out, list), nil
266}
267
268// Scan incrementally iterates the key space
269func Scan(ctx *Context, txn *db.Transaction) (OnCommit, error) {

Callers

nothing calls this directly

Calls 6

globMatchPrefixFunction · 0.85
globMatchFunction · 0.85
BytesArrayFunction · 0.85
KvMethod · 0.80
KeysMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected