(buffer *bytes.Buffer, nsIndexStat map[string]interface{})
| 766 | } |
| 767 | |
| 768 | func massageStats(buffer *bytes.Buffer, nsIndexStat map[string]interface{}) error { |
| 769 | statsBytes := buffer.Bytes() |
| 770 | pointers, err := jsonpointer.ListPointers(statsBytes) |
| 771 | if err != nil { |
| 772 | return err |
| 773 | } |
| 774 | |
| 775 | countPointers := make([]string, 0) |
| 776 | for _, pointer := range pointers { |
| 777 | if strings.HasSuffix(pointer, "/count") || |
| 778 | strings.HasSuffix(pointer, "/DocCount") || |
| 779 | matchAnyFixedSuffixes(pointer) { |
| 780 | countPointers = append(countPointers, pointer) |
| 781 | } |
| 782 | } |
| 783 | |
| 784 | countValueMap, err := jsonpointer.FindMany(statsBytes, countPointers) |
| 785 | if err != nil { |
| 786 | return err |
| 787 | } |
| 788 | |
| 789 | for k, v := range countValueMap { |
| 790 | statName := convertStatName(k) |
| 791 | var statValue float64 |
| 792 | err := json.Unmarshal(v, &statValue) |
| 793 | if err != nil { |
| 794 | return err |
| 795 | } |
| 796 | oldValue, ok := nsIndexStat[statName] |
| 797 | if ok { |
| 798 | switch oldValue := oldValue.(type) { |
| 799 | case float64: |
| 800 | oldValue += statValue |
| 801 | nsIndexStat[statName] = oldValue |
| 802 | } |
| 803 | } |
| 804 | } |
| 805 | |
| 806 | return nil |
| 807 | } |
| 808 | |
| 809 | var fixedSuffixToStatNameMapping = map[string]string{ |
| 810 | "compacts": "total_compactions", |
no test coverage detected