Skip to content

tool: add value pretty-printing facility #630

@petermattis

Description

@petermattis

Keys can be pretty-printed using the Comparer.Format facility. We should add something similar for values. This is particularly useful for CRDB post-mortem debugging where values have rich structure. For CRDB, decoding of the value is dependent on the key, so the interface here will need to take both a key and value. Something like:

type PrettyValue func(key, value []byte) fmt.Formatter

For CRDB this would look something like:

PrettyValue = func(key, value []byte) string {
  decoded, err := storage.DecodeMVCCKey(key)
  if err != nil {
    return err.Error()
  }
  return kvserver.SprintKeyValue(storage.MVCCKeyValue{Key: decoded, Value: value}, false)
}

Open question is how to associate this PrettyValue function with the comparer. Should RegisterComparer take an optional PrettyValue?

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions