| 200 | } |
| 201 | |
| 202 | func (fs *fileStats) printStats() { |
| 203 | fmt.Println("File stats:") |
| 204 | |
| 205 | w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', tabwriter.DiscardEmptyColumns) |
| 206 | tmpl := "%s\t%d\n" |
| 207 | _, _ = fmt.Fprintf(w, tmpl, "Traces", fs.Traces) |
| 208 | _, _ = fmt.Fprintf(w, tmpl, "Resources", fs.Resources) |
| 209 | _, _ = fmt.Fprintf(w, tmpl, "Spans", fs.Spans) |
| 210 | _, _ = fmt.Fprintf(w, tmpl, "Events", fs.Events) |
| 211 | _, _ = fmt.Fprintf(w, tmpl, "Links", fs.Links) |
| 212 | _, _ = fmt.Fprintf(w, tmpl, "Arrays", fs.Arrays) |
| 213 | _ = w.Flush() |
| 214 | |
| 215 | // sort attributes by scope and count |
| 216 | attrs := make([]attributeInfo, 0, len(fs.Attributes)) |
| 217 | for _, attr := range fs.Attributes { |
| 218 | attrs = append(attrs, attr) |
| 219 | } |
| 220 | sort.Slice(attrs, func(i, j int) bool { |
| 221 | if n := cmp.Compare(attrs[i].ScopeMask, attrs[j].ScopeMask); n != 0 { |
| 222 | return n < 0 |
| 223 | } |
| 224 | return attrs[i].Count > attrs[j].Count |
| 225 | }) |
| 226 | |
| 227 | fmt.Println("\nAttribute stats:") |
| 228 | w = tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', tabwriter.DiscardEmptyColumns) |
| 229 | _, _ = fmt.Fprintf(w, "%s\t%s\t%s\t%s\n", "Name", "Scopes", "Count", "Cardinality") |
| 230 | tmpl = "%s\t%s\t%d\t%d\n" |
| 231 | for _, attr := range attrs { |
| 232 | _, _ = fmt.Fprintf(w, tmpl, attr.Key, attr.ScopeMask.String(), attr.Count, len(attr.ValuesString)+len(attr.ValuesInt)+len(attr.ValuesFloat)+len(attr.ValuesBool)) |
| 233 | } |
| 234 | _ = w.Flush() |
| 235 | |
| 236 | fmt.Printf("\n\n") |
| 237 | } |
| 238 | |
| 239 | func generateCombinedIndex(stats *fileStats) []indexedAttrCombined { |
| 240 | var ( |