Пример #1
0
//GetStrings gets thread tags from the disk
func GetStrings(thread string) []string {
	var r []string
	err := db.DB.View(func(tx *bolt.Tx) error {
		var err error
		r, err = db.MapKeys(tx, "usertag", []byte(thread))
		return err
	})
	if err != nil {
		log.Print(err, thread)
		return nil
	}
	return r
}
Пример #2
0
//GetNodestrSliceInTable returns Nodestr slice of nodes associated datfile thread.
func GetNodestrSliceInTable(datfile string) []string {
	var r []string
	err := db.DB.View(func(tx *bolt.Tx) error {
		var err error
		r, err = db.MapKeys(tx, "lookupT", []byte(datfile))
		return err
	})
	if err != nil {
		log.Print(err, datfile)
		return nil
	}
	return r
}
Пример #3
0
//Get returns copy of Slice associated with datfile or returns def if not exists.
func Get(datfile string, def tag.Slice) tag.Slice {
	var r []string
	err := db.DB.View(func(tx *bolt.Tx) error {
		var err error
		r, err = db.MapKeys(tx, "sugtag", []byte(datfile))
		return err
	})
	if err != nil {
		log.Print(err, datfile)
		return def
	}
	tags := make([]*tag.Tag, len(r))
	for i, rr := range r {
		tags[i] = &tag.Tag{
			Tagstr: rr,
		}
	}
	if len(tags) > cfg.TagSize {
		tags = tags[:cfg.TagSize]
	}
	return tag.Slice(tags)
}