MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / FetchValIdx

Method FetchValIdx

pkg/util/json/encoded.go:384–408  ·  view source on GitHub ↗
(idx int)

Source from the content-addressed store, hash-verified

382}
383
384func (j *jsonEncoded) FetchValIdx(idx int) (JSON, error) {
385 if dec := j.alreadyDecoded(); dec != nil {
386 return dec.FetchValIdx(idx)
387 }
388
389 if j.Type() == ArrayJSONType {
390 if idx < 0 {
391 idx = j.containerLen + idx
392 }
393 if idx < 0 || idx >= j.containerLen {
394 return nil, nil
395 }
396
397 // We need to find the bounds for a given index, but this is nontrivial,
398 // since some headers store an offset and some store a length.
399
400 begin, end, entry, err := j.getNthEntryBounds(idx)
401 if err != nil {
402 return nil, err
403 }
404
405 return newEncoded(entry, j.arrayGetDataRange(begin, end))
406 }
407 return nil, nil
408}
409
410func (j *jsonEncoded) FetchValKey(key string) (JSON, error) {
411 if dec := j.alreadyDecoded(); dec != nil {

Callers 1

FetchValKeyOrIdxMethod · 0.95

Calls 6

alreadyDecodedMethod · 0.95
TypeMethod · 0.95
getNthEntryBoundsMethod · 0.95
arrayGetDataRangeMethod · 0.95
newEncodedFunction · 0.85
FetchValIdxMethod · 0.65

Tested by

no test coverage detected