Skip to content

Commit

Permalink
fix based on comments
Browse files Browse the repository at this point in the history
Signed-off-by: Kosuke Morimoto <kou.morimoto@gmail.com>
  • Loading branch information
kmrmt committed Jul 30, 2020
1 parent 6b8c9d6 commit b541c1a
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions pkg/tools/cli/loadtest/assets/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (

"github.com/kpango/fuid"
"github.com/vdaas/vald/internal/errors"
"github.com/vdaas/vald/internal/log"
"gonum.org/v1/hdf5"
)

Expand Down Expand Up @@ -84,39 +83,34 @@ func loadDataset(file *hdf5.File, name string, f loaderFunc) (dim int, vec inter
func Load(path string) (train, test, distances [][]float32, neighbors [][]int, dim int, err error) {
f, err := hdf5.OpenFile(path, hdf5.F_ACC_RDONLY)
if err != nil {
log.Errorf("couldn't open file %s: %s", path, err)
return nil, nil, nil, nil, 0, err
return nil, nil, nil, nil, 0, errors.Wrapf(err, "couldn't open file %s", path)
}
defer func() {
err = f.Close()
}()
trainDim, v1, err := loadDataset(f, "train", loadFloat32)
if err != nil {
log.Errorf("couldn't load train dataset for path %s: %s", path, err)
return nil, nil, nil, nil, 0, err
return nil, nil, nil, nil, 0, errors.Wrapf(err, "couldn't load train dataset for path %s", path)
}
train = v1.([][]float32)
dim = trainDim
testDim, v2, err := loadDataset(f, "test", loadFloat32)
if err != nil {
log.Errorf("couldn't load test dataset for path %s: %s", path, err)
return train, nil, nil, nil, dim, err
return train, nil, nil, nil, dim, errors.Wrapf(err, "couldn't load test dataset for path %s", path)
}
test = v2.([][]float32)
if dim != testDim {
return train, test, nil, nil, 0, errors.Errorf("test has different dimension from train")
}
distancesDim, v3, err := loadDataset(f, "distances", loadFloat32)
if err != nil {
log.Errorf("couldn't load distances dataset for path %s: %s", path, err)
return train, test, nil, nil, dim, err
return train, test, nil, nil, dim, errors.Wrapf(err, "couldn't load distances dataset for path %s", path)
}
distances = v3.([][]float32)

neighborsDim, v4, err := loadDataset(f, "neighbors", loadInt)
if err != nil {
log.Errorf("couldn't load neighbors dataset for path %s: %s", path, err)
return train, test, distances, nil, trainDim, err
return train, test, distances, nil, trainDim, errors.Wrapf(err, "couldn't load neighbors dataset for path %s", path)
}
neighbors = v4.([][]int)
if distancesDim != neighborsDim {
Expand Down

0 comments on commit b541c1a

Please sign in to comment.