func RunCompact(dbpath string) { mystore, err := store.NewStore("leveldb", dbpath) check(err) defer mystore.Close() err = mystore.Compact() check(err) }
func RunSearch(dbpath string, args []string) { mystore, err := store.NewStore("leveldb", dbpath) check(err) defer mystore.Close() docs, err := mystore.QueryString(args[0]) check(err) for _, doc := range docs { fmt.Println(doc) } }
func RunExpandCIDR(dbpath string, args []string) { mystore, err := store.NewStore("leveldb", dbpath) check(err) defer mystore.Close() ips, err := mystore.ExpandCIDR(args[0]) check(err) for _, ip := range ips { fmt.Printf("%s\n", ip) } }
func startWeb() { var stores []store.IpStore matches, err := filepath.Glob("*.db") check(err) for _, db := range matches { log.Printf("Opening %s\n", db) mystore, err := store.NewStore("leveldb", db) check(err) stores = append(stores, mystore) } http.Handle("/search", &storeHandler{stores: stores}) log.Fatal(http.ListenAndServe(bind, nil)) }
func (i *Indexer) OpenOrCreateStore(filename string) (*store.IpStore, error) { s, alreadyExists := i.storeMap[filename] if alreadyExists { return &s, nil } log.Printf("Opening %s\n", filename) mystore, err := store.NewStore(i.config.Store, filename) if err != nil { return nil, err } i.storeMap[filename] = mystore i.stores = append(i.stores, mystore) return &mystore, nil }
func RunIndex(dbpath string, backend_type string, args []string) { runtime.GOMAXPROCS(runtime.NumCPU()) mystore, err := store.NewStore("leveldb", dbpath) check(err) defer mystore.Close() for _, path := range args { mybackend := backend.NewBackend(backend_type) matches, err := filepath.Glob(path) check(err) for _, fp := range matches { err = Index(mystore, mybackend, fp) check(err) } } }