Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

panic in collectStoreSlice.Final #453

Closed
dtylman opened this issue Sep 28, 2016 · 0 comments
Closed

panic in collectStoreSlice.Final #453

dtylman opened this issue Sep 28, 2016 · 0 comments

Comments

@dtylman
Copy link
Contributor

dtylman commented Sep 28, 2016

Used the following code example:

package main

import (
    "fmt"

    "github.com/blevesearch/bleve"
    "os"
)

type Person struct {
    ID   string `json:"id"`
    Name string `json:"name"`
}

func worky(from int) error{
    fileName:="/tmp/lala"
    idx, err := bleve.New(fileName, bleve.NewIndexMapping())
    if err != nil {
        return  err
    }
    defer idx.Close()
    defer os.RemoveAll(fileName)

    for i := 0; i < 10; i++ {
        p := &Person{ID: fmt.Sprintf("%d", i), Name: "lala"}
        idx.Index(p.ID, p)
    }
    sr := bleve.NewSearchRequestOptions(bleve.NewMatchAllQuery(), 10, from, false)
    sr.Fields = []string{"*"}
    res, err := idx.Search(sr)
    if err != nil {
        return err
    }
    fmt.Println(res)
    return nil
}

func main() {
    err := worky(10)
    fmt.Println("Worky done with: ", err)
    err = worky(100)
    fmt.Println("Worky done with: ", err)
}

Got panic:

panic: runtime error: slice bounds out of range

goroutine 1 [running]:
panic(0x2ba8a0, 0xc42000c0e0)
    /usr/local/go/src/runtime/panic.go:500 +0x1a1
github.com/blevesearch/bleve/search/collectors.(*collectStoreSlice).Final(0xc4201decc0, 0x64, 0xc4201deee0, 0xaf57d, 0xecf7d8f98, 0xc42c9e3f1b, 0x4a8620, 0xecf7d8f98)
    /Users/danny/src/go/src/github.com/blevesearch/bleve/search/collectors/slice.go:55 +0xf1
github.com/blevesearch/bleve/search/collectors.(*TopNCollector).finalizeResults(0xc4200d8240, 0x45b200, 0xc4201ded20, 0x8990, 0x0)
    /Users/danny/src/go/src/github.com/blevesearch/bleve/search/collectors/topn.go:233 +0x85
github.com/blevesearch/bleve/search/collectors.(*TopNCollector).Collect(0xc4200d8240, 0xe08028, 0xc42000c488, 0x45a480, 0xc4201c5da0, 0x45b200, 0xc4201ded20, 0x0, 0x0)
    /Users/danny/src/go/src/github.com/blevesearch/bleve/search/collectors/topn.go:132 +0x2a4
github.com/blevesearch/bleve.(*indexImpl).SearchInContext(0xc42013ba40, 0xe08028, 0xc42000c488, 0xc4201daf50, 0x0, 0x0, 0x0)
    /Users/danny/src/go/src/github.com/blevesearch/bleve/index_impl.go:405 +0x306
github.com/blevesearch/bleve.(*indexImpl).Search(0xc42013ba40, 0xc4201daf50, 0x1, 0x293020, 0xc4201de6e0)
    /Users/danny/src/go/src/github.com/blevesearch/bleve/index_impl.go:339 +0x75
main.worky(0x64, 0x0, 0x0)
    /Users/danny/src/go/src/github.com/demisto/installer/tester/blevental/mana.go:30 +0x3e0
main.main()
    /Users/danny/src/go/src/github.com/demisto/installer/tester/blevental/mana.go:41 +0x134
exit status 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant