Exemple #1
0
func (I fmiworker) Analyze(message []byte) []byte {
	element := strings.Split(string(message), " ")
	if element[0] != filename {
		sequencename := strings.TrimRight(element[0], ".fm")
		if _, err := os.Stat(element[0]); os.IsNotExist(err) {
			if _, err := os.Stat(sequencename); os.IsNotExist(err) {
				return []byte(fmt.Sprintf("No such index: %s, need to build it first. But no such sequence: %s!", filename, sequencename))
				// log.Fatal("Exit!")
			} else {
				filename = element[0]
				fmt.Printf("No such index: %s, build it now!\n", filename)
				idx = fmi.Build(sequencename)
			}
		} else {
			filename = element[0]
			idx = fmi.Load(element[0])
			fmt.Println("Download the index file.")
		}
	}
	result := fmi.Search(idx, []byte(element[2]))
	return format_result(element[1], result)
}
Exemple #2
0
func (m *MyWorker) ProcessQuery(qid int, query string) string {
	result := fmi.Search(m.idx, []byte(query))
	fmt.Println(format_result(query, result))
	return string(format_result(query, result))
}