Skip to content

Commit

Permalink
fix error
Browse files Browse the repository at this point in the history
Signed-off-by: aknishid <[email protected]>
  • Loading branch information
aknishid committed Apr 25, 2023
1 parent 95a8dc8 commit 9858128
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 87 deletions.
83 changes: 1 addition & 82 deletions internal/errors/ngt.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,91 +18,10 @@
package errors

var (
// ErrCreateIndexingIsInProgress represents an error that the indexing is in progress but search request received
ErrCreateIndexingIsInProgress = New("create indexing is in progress")

// ErrFlushingIsInProgress represents an error that the flushing is in progress but any request received
ErrFlushingIsInProgress = New("flush is in progress")

// ErrCreateProperty represents a function to generate an error that the property creation failed.
ErrCreateProperty = func(err error) error {
return Wrap(err, "failed to create property")
}

// ErrIndexFileNotFound represents an error that the index file is not found.
ErrIndexFileNotFound = New("index file not found")

// ErrIndicesAreTooFewComparedToMetadata represents an error that the index count is not enough to be compared by metadata.
ErrIndicesAreTooFewComparedToMetadata = New("indices are too few compared to Metadata")

// ErrIndexLoadTimeout represents an error that the index loading timeout.
ErrIndexLoadTimeout = New("index load timeout")

// ErrInvalidDimensionSize represents a function to generate an error that the dimension size is invalid.
ErrInvalidDimensionSize = func(current, limit int) error {
if limit == 0 {
return Errorf("dimension size %d is invalid, the supporting dimension size must be bigger than 2", current)
}
return Errorf("dimension size %d is invalid, the supporting dimension size must be between 2 ~ %d", current, limit)
}

// ErrInvalidUUID represents a function to generate an error that the uuid is invalid.
ErrInvalidUUID = func(uuid string) error {
return Errorf("uuid \"%s\" is invalid", uuid)
}

// ErrDimensionLimitExceed represents a function to generate an error that the supported dimension limit exceeded.
ErrDimensionLimitExceed = func(current, limit int) error {
return Errorf("supported dimension limit exceed:\trequired = %d,\tlimit = %d", current, limit)
}

// ErrIncompatibleDimensionSize represents a function to generate an error that the incompatible dimension size detected.
ErrIncompatibleDimensionSize = func(current, expected int) error {
return Errorf("incompatible dimension size detected\trequested: %d,\tconfigured: %d", current, expected)
}

// ErrUnsupportedObjectType represents an error that the object type is unsupported.
ErrUnsupportedObjectType = New("unsupported ObjectType")

// ErrUnsupportedDistanceType represents an error that the distance type is unsupported.
ErrUnsupportedDistanceType = New("unsupported DistanceType")

// ErrFailedToSetDistanceType represents a function to generate an error that the set of distance type failed.
ErrFailedToSetDistanceType = func(err error, distance string) error {
return Wrap(err, "failed to set distance type "+distance)
}

// ErrFailedToSetObjectType represents a function to generate an error that the set of object type failed.
ErrFailedToSetObjectType = func(err error, t string) error {
return Wrap(err, "failed to set object type "+t)
}

// ErrFailedToSetDimension represents a function to generate an error that the set of dimension failed.
ErrFailedToSetDimension = func(err error) error {
return Wrap(err, "failed to set dimension")
}

// ErrFailedToSetCreationEdgeSize represents a function to generate an error that the set of creation edge size failed.
ErrFailedToSetCreationEdgeSize = func(err error) error {
return Wrap(err, "failed to set creation edge size")
}

// ErrFailedToSetSearchEdgeSize represents a function to generate an error that the set of search edge size failed.
ErrFailedToSetSearchEdgeSize = func(err error) error {
return Wrap(err, "failed to set search edge size")
}

// ErrUncommittedIndexExists represents a function to generate an error that the uncommitted indexes exist.
ErrUncommittedIndexExists = func(num uint64) error {
return Errorf("%d indexes are not committed", num)
}

// ErrUncommittedIndexNotFound represents an error that the uncommitted indexes are not found.
ErrUncommittedIndexNotFound = New("uncommitted indexes are not found")

// ErrCAPINotImplemented represents an error that the function is not implemented in C API.
ErrCAPINotImplemented = New("not implemented in C API")

// ErrUUIDAlreadyExists represents a function to generate an error that the uuid already exists.
ErrUUIDAlreadyExists = func(uuid string) error {
return Errorf("ngt uuid %s index already exists", uuid)
Expand Down Expand Up @@ -139,4 +58,4 @@ func NewNGTError(msg string) error {

func (n NGTError) Error() string {
return n.Msg
}
}
3 changes: 1 addition & 2 deletions internal/file/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import (
"github.com/vdaas/vald/internal/errors"
"github.com/vdaas/vald/internal/io"
"github.com/vdaas/vald/internal/log"
"github.com/vdaas/vald/internal/safety"
"github.com/vdaas/vald/internal/slices"
"github.com/vdaas/vald/internal/strings"
)
Expand Down Expand Up @@ -502,7 +501,7 @@ func DeleteDir(ctx context.Context, path string) (err error) {
return err
}
eg.Go(safety.RecoverFunc(func() (err error) {
_, err = os.Remove(childPath)
err = os.Remove(childPath)
return err
}))
return nil
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/core/ngt/handler/grpc/flush.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func (s *server) Flush(ctx context.Context, req *payload.Flush_Request) (*payloa
err := s.ngt.RegenerateIndex(ctx)
if err != nil {
var attrs []attribute.KeyValue
if errors.Is(err, errors.ErrFlushingIsInProgress()) {
if errors.Is(err, errors.ErrFlushingIsInProgress) {
err = status.WrapWithAborted("Flush API aborted to process search request due to flushing indices is in progress", err,
&errdetails.RequestInfo{
ServingData: errdetails.Serialize(req),
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/core/ngt/handler/grpc/insert.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (s *server) Insert(ctx context.Context, req *payload.Insert_Request) (res *
})
log.Warn(err)
attrs = trace.StatusCodeAlreadyExists(err.Error())
} else if errors.Is(err, errors.ErrFlushingIsInProgress()) {
} else if errors.Is(err, errors.ErrFlushingIsInProgress) {
err = status.WrapWithAborted("Insert API aborted to process search request due to flushing indices is in progress", err,
&errdetails.RequestInfo{
RequestId: req.GetVector().GetId(),
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/core/ngt/service/ngt.go
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,7 @@ func (n *ngt) mktmp() (err error) {
func (n *ngt) Exists(uuid string) (oid uint32, ok bool) {
if n.IsFlushing() {
log.Debugf("Exists\tuuid: %s's data will be delete soon\terror: %v",
uuid, errors.ErrFlushingIsInProgress())
uuid, errors.ErrFlushingIsInProgress)
return 0, false
}
ok = n.vq.IVExists(uuid)
Expand Down

0 comments on commit 9858128

Please sign in to comment.