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

Function HGetAll

command/hashes.go:99–120  ·  view source on GitHub ↗

HGetAll returns all fields and values of the hash stored at key

(ctx *Context, txn *db.Transaction)

Source from the content-addressed store, hash-verified

97
98// HGetAll returns all fields and values of the hash stored at key
99func HGetAll(ctx *Context, txn *db.Transaction) (OnCommit, error) {
100 key := []byte(ctx.Args[0])
101 hash, err := txn.Hash(key)
102 if err != nil {
103 if err == db.ErrTypeMismatch {
104 return nil, ErrTypeMismatch
105 }
106 return nil, errors.New("ERR " + err.Error())
107 }
108 fields, vals, err := hash.HGetAll()
109 if err != nil {
110 return nil, errors.New("ERR " + err.Error())
111 }
112
113 results := make([][]byte, len(fields)*2)
114 for i := range fields {
115 results[i*2] = fields[i]
116 results[i*2+1] = vals[i]
117 }
118
119 return BytesArray(ctx.Out, results), nil
120}
121
122// HExists returns if field is an existing field in the hash stored at key
123func HExists(ctx *Context, txn *db.Transaction) (OnCommit, error) {

Callers

nothing calls this directly

Calls 4

BytesArrayFunction · 0.85
HashMethod · 0.80
HGetAllMethod · 0.80
ErrorMethod · 0.65

Tested by

no test coverage detected