MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / NewFixedKeysObjectBuilder

Function NewFixedKeysObjectBuilder

pkg/util/json/json.go:421–438  ·  view source on GitHub ↗

NewFixedKeysObjectBuilder creates JSON object builder for the specified set of fixed, unique keys.

(keys []string)

Source from the content-addressed store, hash-verified

419// NewFixedKeysObjectBuilder creates JSON object builder for the specified
420// set of fixed, unique keys.
421func NewFixedKeysObjectBuilder(keys []string) (*FixedKeysObjectBuilder, error) {
422 sort.Strings(keys)
423 pairs := make([]jsonKeyValuePair, len(keys))
424 keyOrd := make(map[string]int, len(keys))
425
426 for i, k := range keys {
427 if _, exists := keyOrd[k]; exists {
428 return nil, errors.AssertionFailedf("expected unique keys, found %v", keys)
429 }
430 pairs[i] = jsonKeyValuePair{k: jsonString(keys[i])}
431 keyOrd[k] = i
432 }
433
434 return &FixedKeysObjectBuilder{
435 pairs: pairs,
436 keyOrd: keyOrd,
437 }, nil
438}
439
440// Set sets the value for the specified key.
441// All previously configured keys must be set before calling Build.

Callers

nothing calls this directly

Calls 1

jsonStringTypeAlias · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…