Skip to content

Commit

Permalink
Set the channel buffer size to 128 for KeysOnly queries.
Browse files Browse the repository at this point in the history
  • Loading branch information
kevina committed Jun 30, 2016
1 parent dcac935 commit c33fc95
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion flatfs/flatfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 7 additions & 1 deletion query/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit c33fc95

Please sign in to comment.