(_ *globalOptions)
| 35 | } |
| 36 | |
| 37 | func (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 | |
| 84 | func (cmd *attrIndexCmd) readDedicatedAttributes(meta *backend.BlockMeta) { |
| 85 | for _, ded := range meta.DedicatedColumns { |
nothing calls this directly
no test coverage detected