MCPcopy Create free account
hub / github.com/dolthub/doltgresql / FetchValIdx

Method FetchValIdx

postgres/parser/json/encoded.go:398–422  ·  view source on GitHub ↗
(idx int)

Source from the content-addressed store, hash-verified

396}
397
398func (j *jsonEncoded) FetchValIdx(idx int) (JSON, error) {
399 if dec := j.alreadyDecoded(); dec != nil {
400 return dec.FetchValIdx(idx)
401 }
402
403 if j.Type() == ArrayJSONType {
404 if idx < 0 {
405 idx = j.containerLen + idx
406 }
407 if idx < 0 || idx >= j.containerLen {
408 return nil, nil
409 }
410
411 // We need to find the bounds for a given index, but this is nontrivial,
412 // since some headers store an offset and some store a length.
413
414 begin, end, entry, err := j.getNthEntryBounds(idx)
415 if err != nil {
416 return nil, err
417 }
418
419 return newEncoded(entry, j.arrayGetDataRange(begin, end))
420 }
421 return nil, nil
422}
423
424func (j *jsonEncoded) FetchValKey(key string) (JSON, error) {
425 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