MCPcopy
hub / github.com/grafana/tempo / Run

Method Run

cmd/tempo-cli/cmd-gen-attrindex.go:37–82  ·  view source on GitHub ↗
(_ *globalOptions)

Source from the content-addressed store, hash-verified

35}
36
37func (cmd *attrIndexCmd) Run(_ *globalOptions) error {
38 cmd.In = getPathToBlockDir(cmd.In)
39 fmt.Printf("Analyzing parquet block from %s\n", cmd.In)
40
41 meta, err := readBlockMeta(cmd.In)
42 if err != nil {
43 return err
44 }
45 if meta.Version != vp4.VersionString {
46 return fmt.Errorf("unsupported parquet version %s", meta.Version)
47 }
48
49 cmd.readDedicatedAttributes(meta)
50
51 stats, err := cmd.collectAttributeStats()
52 if err != nil {
53 return err
54 }
55 stats.printStats()
56
57 if len(cmd.IndexTypes) == 0 || len(cmd.IndexTypes) == 2 {
58 fmt.Println("Generating combined index with inverted index and key/value codes")
59
60 index := generateCombinedIndex(stats)
61 err = writeAttributeIndex(cmd.In, index)
62 } else if len(cmd.IndexTypes) == 1 {
63 switch cmd.IndexTypes[0] {
64 case "rows":
65 fmt.Println("Generating inverted index with rows")
66
67 index := generateRowsIndex(stats)
68 err = writeAttributeIndex(cmd.In, index)
69 case "codes":
70 fmt.Println("Generating index with key/value codes")
71
72 index := generateCodesIndex(stats)
73 err = writeAttributeIndex(cmd.In, index)
74 }
75 }
76 if err != nil {
77 return err
78 }
79
80 fmt.Printf("\nSuccessfully generated attribute index in %s/index.parquet\n", cmd.In)
81 return nil
82}
83
84func (cmd *attrIndexCmd) readDedicatedAttributes(meta *backend.BlockMeta) {
85 for _, ded := range meta.DedicatedColumns {

Callers

nothing calls this directly

Calls 9

collectAttributeStatsMethod · 0.95
getPathToBlockDirFunction · 0.85
readBlockMetaFunction · 0.85
generateCombinedIndexFunction · 0.85
writeAttributeIndexFunction · 0.85
generateRowsIndexFunction · 0.85
generateCodesIndexFunction · 0.85
printStatsMethod · 0.80

Tested by

no test coverage detected