Commit 85cba2da authored by Jeromy Johnson's avatar Jeromy Johnson Committed by GitHub

Merge pull request #43 from ipfs/kevina/128

Set the channel buffer size to 128 for KeysOnly queries.
parents dcac9354 c33fc953
......@@ -309,7 +309,7 @@ func (fs *Datastore) Query(q query.Query) (query.Results, error) {
return nil, errors.New("flatfs only supports listing all keys in random order")
}
reschan := make(chan query.Result)
reschan := make(chan query.Result, query.KeysOnlyBufSize)
go func() {
defer close(reschan)
err := filepath.Walk(fs.path, func(path string, info os.FileInfo, err error) error {
......
......@@ -179,10 +179,16 @@ func (rb *ResultBuilder) Results() Results {
}
}
const KeysOnlyBufSize = 128
func NewResultBuilder(q Query) *ResultBuilder {
bufSize := 1
if q.KeysOnly {
bufSize = KeysOnlyBufSize
}
b := &ResultBuilder{
Query: q,
Output: make(chan Result),
Output: make(chan Result, bufSize),
}
b.Process = goprocess.WithTeardown(func() error {
close(b.Output)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment