Skip to content

Commit

Permalink
Added reading data paralelization for comparision
Browse files Browse the repository at this point in the history
  • Loading branch information
adranwit committed Dec 30, 2018
1 parent 8347ffa commit f76d254
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
## Dec 29 2018 - v0.4.1
* Added reading data paralizattion for comparision

## Dec 28 2018 - v0.4.0
* Added Expect attribute in Query operation for optional valiation (SQL based validation)

Expand Down
26 changes: 22 additions & 4 deletions service.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/viant/toolbox/url"
"io"
"strings"
"sync"
"time"
)

Expand Down Expand Up @@ -811,11 +812,28 @@ func (s *service) compare(manager1 dsc.Manager, manager2 dsc.Manager, request *C
data1 := data.NewCompactedSlice(false, true)
data2 := data.NewCompactedSlice(false, true)

if err = manager1.ReadAllWithHandler(request.Source1.SQL, nil, compactedSliceReader(data1)); err == nil {
err = manager1.ReadAllWithHandler(request.Source2.SQL, nil, compactedSliceReader(data2))
waitGroup := &sync.WaitGroup{}
waitGroup.Add(2)
go func() {
defer waitGroup.Done()
if e := manager1.ReadAllWithHandler(request.Source1.SQL, nil, compactedSliceReader(data1)); e != nil {
err = e
}
response.Dataset1Count = data1.Size()
}()
go func() {
defer waitGroup.Done()
if e := manager2.ReadAllWithHandler(request.Source2.SQL, nil, compactedSliceReader(data2)); e != nil {
err = e
}
response.Dataset2Count = data2.Size()
}()
waitGroup.Wait()
if err != nil {
response.SetError(err)
return
}
response.Dataset1Count = data1.Size()
response.Dataset2Count = data2.Size()

var iter1, iter2 toolbox.Iterator
indexBy := request.IndexBy()
if len(indexBy) == 0 {
Expand Down

0 comments on commit f76d254

Please sign in to comment.