(b []byte)
| 711 | return [][]byte{encoding.EncodeDecimalAscending(b, &dec)}, nil |
| 712 | } |
| 713 | func (j jsonArray) encodeInvertedIndexKeys(b []byte) ([][]byte, error) { |
| 714 | // Checking for an empty array. |
| 715 | if len(j) == 0 { |
| 716 | return [][]byte{encoding.EncodeJSONEmptyArray(b)}, nil |
| 717 | } |
| 718 | |
| 719 | prefix := encoding.EncodeArrayAscending(b) |
| 720 | var outKeys [][]byte |
| 721 | for i := range j { |
| 722 | children, err := j[i].encodeInvertedIndexKeys(prefix[:len(prefix):len(prefix)]) |
| 723 | if err != nil { |
| 724 | return nil, err |
| 725 | } |
| 726 | outKeys = append(outKeys, children...) |
| 727 | } |
| 728 | |
| 729 | // Deduplicate the entries, since arrays can have duplicates - we don't want |
| 730 | // to emit duplicate keys from this method, as it's more expensive to |
| 731 | // deduplicate keys via KV (which will actually write the keys) than via SQL |
| 732 | // (just an in-memory sort and distinct). |
| 733 | outKeys = unique.UniquifyByteSlices(outKeys) |
| 734 | return outKeys, nil |
| 735 | } |
| 736 | |
| 737 | func (j jsonObject) encodeInvertedIndexKeys(b []byte) ([][]byte, error) { |
| 738 | // Checking for an empty object. |
no test coverage detected