Use: "stats <index>", Short: "Outputs the stats of a bitindex.", Run: func(cmd *cobra.Command, args []string) { if len(args) != 1 { cmd.Println("An index file is required.") os.Exit(1) } f, err := os.Open(args[0]) if err != nil { cmd.Println("Error opening file:", err) os.Exit(1) } var idx *bitindex.Index if idx, err = bitindex.LoadIndex(f); err != nil { cmd.Println("Error loading index file:", err) os.Exit(1) } cmd.Println("Statistics") cmd.Println("* Domain size:", idx.Domain.Size()) cmd.Println("* Table size:", idx.Table.Size()) cmd.Println("* Sparsity:", idx.Sparsity()*100) }, }
Use: "http <index>", Run: func(cmd *cobra.Command, args []string) { if len(args) != 1 { cmd.Println("An index file is required.") os.Exit(1) } f, err := os.Open(args[0]) if err != nil { cmd.Println("Error opening file:", err) os.Exit(1) } var idx *bitindex.Index if idx, err = bitindex.LoadIndex(f); err != nil { cmd.Println("Error loading index file:", err) os.Exit(1) } http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) { w.Header().Set("content-type", "application/json") v := map[string]interface{}{ "domain_size": idx.Domain.Size(), "table_size": idx.Table.Size(), "index_sparsity": idx.Sparsity(), }
os.Exit(1) } if len(any) == 0 && len(all) == 0 && len(nany) == 0 && len(nall) == 0 { cmd.Println("At least one operation must be specified.") os.Exit(1) } f, err := os.Open(args[0]) if err != nil { cmd.Println("Error opening file:", err) os.Exit(1) } var idx *bitindex.Index if idx, err = bitindex.LoadIndex(f); err != nil { cmd.Println("Error loading index file:", err) os.Exit(1) } // Query time. t0 := time.Now() res, err := idx.Query(any, all, nany, nall) if err != nil { cmd.Println("Error with query:", err) os.Exit(1) }