Skip to content
Snippets Groups Projects
Commit ddddd65d authored by Bingyi Sun 【孙秉义】's avatar Bingyi Sun 【孙秉义】 Committed by yefu.chen
Browse files

Delete internal/errors package


Signed-off-by: default avatarsunby <bingyi.sun@zilliz.com>
parent 447a1520
No related branches found
No related tags found
No related merge requests found
Showing
with 69 additions and 53 deletions
package util
import (
"github.com/zilliztech/milvus-distributed/internal/errors"
"errors"
"github.com/zilliztech/milvus-distributed/internal/msgstream"
"github.com/zilliztech/milvus-distributed/internal/proto/commonpb"
"github.com/zilliztech/milvus-distributed/internal/proto/internalpb2"
......
......@@ -3,7 +3,7 @@ package proxynode
import (
"context"
"github.com/zilliztech/milvus-distributed/internal/errors"
"errors"
)
type Condition interface {
......
......@@ -6,7 +6,8 @@ import (
"strconv"
"time"
"github.com/zilliztech/milvus-distributed/internal/errors"
"errors"
"github.com/zilliztech/milvus-distributed/internal/msgstream"
"github.com/zilliztech/milvus-distributed/internal/proto/commonpb"
"github.com/zilliztech/milvus-distributed/internal/proto/datapb"
......
......@@ -2,13 +2,13 @@ package proxynode
import (
"context"
"fmt"
"log"
"reflect"
"sort"
"strconv"
"sync"
"github.com/zilliztech/milvus-distributed/internal/errors"
"errors"
"github.com/zilliztech/milvus-distributed/internal/msgstream"
)
......@@ -120,7 +120,7 @@ func (m *InsertChannelsMap) closeInsertMsgStream(collID UniqueID) error {
loc, ok := m.collectionID2InsertChannels[collID]
if !ok {
return errors.New("cannot find collection with id: " + strconv.Itoa(int(collID)))
return fmt.Errorf("cannot find collection with id %d", collID)
}
if m.droppedBitMap[loc] != 0 {
return errors.New("insert message stream already closed")
......@@ -145,7 +145,7 @@ func (m *InsertChannelsMap) getInsertChannels(collID UniqueID) ([]string, error)
loc, ok := m.collectionID2InsertChannels[collID]
if !ok {
return nil, errors.New("cannot find collection with id: " + strconv.Itoa(int(collID)))
return nil, fmt.Errorf("cannot find collection with id: %d", collID)
}
if m.droppedBitMap[loc] != 0 {
......@@ -161,7 +161,7 @@ func (m *InsertChannelsMap) getInsertMsgStream(collID UniqueID) (msgstream.MsgSt
loc, ok := m.collectionID2InsertChannels[collID]
if !ok {
return nil, errors.New("cannot find collection with id: " + strconv.Itoa(int(collID)))
return nil, fmt.Errorf("cannot find collection with id: %d", collID)
}
if m.droppedBitMap[loc] != 0 {
......
......@@ -2,9 +2,10 @@ package proxynode
import (
"context"
"errors"
"fmt"
"sync"
"github.com/zilliztech/milvus-distributed/internal/errors"
"github.com/zilliztech/milvus-distributed/internal/proto/commonpb"
"github.com/zilliztech/milvus-distributed/internal/proto/milvuspb"
"github.com/zilliztech/milvus-distributed/internal/proto/schemapb"
......@@ -61,7 +62,7 @@ func (m *MetaCache) readCollectionID(ctx context.Context, collectionName string)
collInfo, ok := m.collInfo[collectionName]
if !ok {
return 0, errors.Errorf("can't find collection name:%s", collectionName)
return 0, fmt.Errorf("can't find collection name:%s", collectionName)
}
return collInfo.collID, nil
}
......@@ -72,7 +73,7 @@ func (m *MetaCache) readCollectionSchema(ctx context.Context, collectionName str
collInfo, ok := m.collInfo[collectionName]
if !ok {
return nil, errors.Errorf("can't find collection name:%s", collectionName)
return nil, fmt.Errorf("can't find collection name:%s", collectionName)
}
return collInfo.schema, nil
}
......@@ -83,12 +84,12 @@ func (m *MetaCache) readPartitionID(ctx context.Context, collectionName string,
collInfo, ok := m.collInfo[collectionName]
if !ok {
return 0, errors.Errorf("can't find collection name:%s", collectionName)
return 0, fmt.Errorf("can't find collection name:%s", collectionName)
}
partitionID, ok := collInfo.partInfo[partitionName]
if !ok {
return 0, errors.Errorf("can't find partition name:%s", partitionName)
return 0, fmt.Errorf("can't find partition name:%s", partitionName)
}
return partitionID, nil
}
......@@ -112,7 +113,7 @@ func (m *MetaCache) GetCollectionID(ctx context.Context, collectionName string)
return 0, err
}
if coll.Status.ErrorCode != commonpb.ErrorCode_SUCCESS {
return 0, errors.Errorf("%s", coll.Status.Reason)
return 0, errors.New(coll.Status.Reason)
}
_, ok := m.collInfo[collectionName]
......@@ -143,7 +144,7 @@ func (m *MetaCache) GetCollectionSchema(ctx context.Context, collectionName stri
return nil, err
}
if coll.Status.ErrorCode != commonpb.ErrorCode_SUCCESS {
return nil, errors.Errorf("%s", coll.Status.Reason)
return nil, errors.New(coll.Status.Reason)
}
_, ok := m.collInfo[collectionName]
......@@ -175,10 +176,10 @@ func (m *MetaCache) GetPartitionID(ctx context.Context, collectionName string, p
return 0, err
}
if partitions.Status.ErrorCode != commonpb.ErrorCode_SUCCESS {
return 0, errors.Errorf("%s", partitions.Status.Reason)
return 0, fmt.Errorf("%s", partitions.Status.Reason)
}
if len(partitions.PartitionIDs) != len(partitions.PartitionNames) {
return 0, errors.Errorf("partition ids len: %d doesn't equal Partition name len %d",
return 0, fmt.Errorf("partition ids len: %d doesn't equal Partition name len %d",
len(partitions.PartitionIDs), len(partitions.PartitionNames))
}
......@@ -201,7 +202,7 @@ func (m *MetaCache) GetPartitionID(ctx context.Context, collectionName string, p
}
_, ok = partInfo[partitionName]
if !ok {
return 0, errors.Errorf("partitionID of partitionName:%s can not be find", partitionName)
return 0, fmt.Errorf("partitionID of partitionName:%s can not be find", partitionName)
}
return partInfo[partitionName], nil
......
......@@ -12,7 +12,8 @@ import (
"github.com/zilliztech/milvus-distributed/internal/proto/proxypb"
"github.com/zilliztech/milvus-distributed/internal/util/retry"
"github.com/zilliztech/milvus-distributed/internal/errors"
"errors"
"github.com/zilliztech/milvus-distributed/internal/proto/commonpb"
"github.com/zilliztech/milvus-distributed/internal/proto/internalpb2"
......
......@@ -4,11 +4,12 @@ import (
"log"
"sort"
"errors"
"github.com/zilliztech/milvus-distributed/internal/proto/internalpb2"
"github.com/zilliztech/milvus-distributed/internal/util/typeutil"
"github.com/zilliztech/milvus-distributed/internal/errors"
"github.com/zilliztech/milvus-distributed/internal/msgstream"
"github.com/zilliztech/milvus-distributed/internal/proto/commonpb"
)
......@@ -27,11 +28,11 @@ func insertRepackFunc(tsMsgs []msgstream.TsMsg,
for i, request := range tsMsgs {
if request.Type() != commonpb.MsgType_kInsert {
return nil, errors.New(string("msg's must be Insert"))
return nil, errors.New("msg's must be Insert")
}
insertRequest, ok := request.(*msgstream.InsertMsg)
if !ok {
return nil, errors.New(string("msg's must be Insert"))
return nil, errors.New("msg's must be Insert")
}
keys := hashKeys[i]
......@@ -41,7 +42,7 @@ func insertRepackFunc(tsMsgs []msgstream.TsMsg,
keysLen := len(keys)
if keysLen != timestampLen || keysLen != rowIDLen || keysLen != rowDataLen {
return nil, errors.New(string("the length of hashValue, timestamps, rowIDs, RowData are not equal"))
return nil, errors.New("the length of hashValue, timestamps, rowIDs, RowData are not equal")
}
reqID := insertRequest.Base.MsgID
......
......@@ -7,9 +7,10 @@ import (
"log"
"time"
"errors"
"github.com/zilliztech/milvus-distributed/internal/allocator"
"github.com/zilliztech/milvus-distributed/internal/errors"
"github.com/zilliztech/milvus-distributed/internal/proto/commonpb"
"github.com/zilliztech/milvus-distributed/internal/proto/datapb"
"github.com/zilliztech/milvus-distributed/internal/util/typeutil"
......
......@@ -2,12 +2,13 @@ package proxynode
import (
"context"
"errors"
"fmt"
"log"
"math"
"strconv"
"errors"
"github.com/golang/protobuf/proto"
"github.com/zilliztech/milvus-distributed/internal/allocator"
"github.com/zilliztech/milvus-distributed/internal/msgstream"
......@@ -296,7 +297,7 @@ func (cct *CreateCollectionTask) PreExecute(ctx context.Context) error {
}
if int64(len(cct.schema.Fields)) > Params.MaxFieldNum {
return errors.New("maximum field's number should be limited to " + strconv.FormatInt(Params.MaxFieldNum, 10))
return fmt.Errorf("maximum field's number should be limited to %d", Params.MaxFieldNum)
}
// validate collection name
......@@ -590,7 +591,7 @@ func (st *SearchTask) PostExecute(ctx context.Context) error {
select {
case <-st.Ctx().Done():
log.Print("SearchTask: wait to finish failed, timeout!, taskID:", st.ID())
return errors.New("SearchTask:wait to finish failed, timeout:" + strconv.FormatInt(st.ID(), 10))
return fmt.Errorf("SearchTask:wait to finish failed, timeout: %d", st.ID())
case searchResults := <-st.resultBuf:
// fmt.Println("searchResults: ", searchResults)
filterSearchResult := make([]*internalpb2.SearchResults, 0)
......
......@@ -3,12 +3,13 @@ package proxynode
import (
"container/list"
"context"
"errors"
"fmt"
"log"
"strconv"
"sync"
"errors"
"github.com/opentracing/opentracing-go"
oplog "github.com/opentracing/opentracing-go/log"
"github.com/zilliztech/milvus-distributed/internal/allocator"
......
package proxynode
import (
"fmt"
"strconv"
"strings"
"github.com/zilliztech/milvus-distributed/internal/errors"
"errors"
"github.com/zilliztech/milvus-distributed/internal/proto/schemapb"
)
......@@ -120,11 +122,10 @@ func ValidateFieldName(fieldName string) error {
func ValidateDimension(dim int64, isBinary bool) error {
if dim <= 0 || dim > Params.MaxDimension {
return errors.New("invalid dimension: " + strconv.FormatInt(dim, 10) + ". should be in range 1 ~ " +
strconv.FormatInt(Params.MaxDimension, 10) + ".")
return fmt.Errorf("invalid dimension: %d. should be in range 1 ~ %d", dim, Params.MaxDimension)
}
if isBinary && dim%8 != 0 {
return errors.New("invalid dimension: " + strconv.FormatInt(dim, 10) + ". should be multiple of 8.")
return fmt.Errorf("invalid dimension: %d. should be multiple of 8. ", dim)
}
return nil
}
......@@ -158,7 +159,7 @@ func ValidatePrimaryKey(coll *schemapb.CollectionSchema) error {
if coll.AutoID {
for _, field := range coll.Fields {
if field.IsPrimaryKey {
return errors.Errorf("collection %s is auto id, so filed %s should not defined as primary key", coll.Name, field.Name)
return fmt.Errorf("collection %s is auto id, so filed %s should not defined as primary key", coll.Name, field.Name)
}
}
return nil
......@@ -167,16 +168,16 @@ func ValidatePrimaryKey(coll *schemapb.CollectionSchema) error {
for i, field := range coll.Fields {
if field.IsPrimaryKey {
if idx != -1 {
return errors.Errorf("there are more than one primary key, filed name = %s, %s", coll.Fields[idx].Name, field.Name)
return fmt.Errorf("there are more than one primary key, filed name = %s, %s", coll.Fields[idx].Name, field.Name)
}
if field.DataType != schemapb.DataType_INT64 {
return errors.Errorf("the data type of primary key should be int64")
return errors.New("the data type of primary key should be int64")
}
idx = i
}
}
if idx == -1 {
return errors.Errorf("primay key is undefined")
return errors.New("primay key is undefined")
}
return nil
}
......@@ -12,7 +12,7 @@ import (
grpcproxynodeclient "github.com/zilliztech/milvus-distributed/internal/distributed/proxynode/client"
"github.com/zilliztech/milvus-distributed/internal/errors"
"errors"
"github.com/zilliztech/milvus-distributed/internal/proto/proxypb"
)
......
......@@ -3,7 +3,8 @@ package proxyservice
import (
"context"
"github.com/zilliztech/milvus-distributed/internal/errors"
"errors"
"github.com/zilliztech/milvus-distributed/internal/proto/commonpb"
"github.com/zilliztech/milvus-distributed/internal/proto/internalpb2"
"github.com/zilliztech/milvus-distributed/internal/proto/milvuspb"
......
......@@ -5,7 +5,7 @@ import (
"log"
"sync"
"github.com/zilliztech/milvus-distributed/internal/errors"
"errors"
)
type TaskQueue interface {
......
......@@ -2,12 +2,12 @@ package proxyservice
import (
"context"
"errors"
"log"
"math"
"sync"
"sync/atomic"
"github.com/zilliztech/milvus-distributed/internal/errors"
ms "github.com/zilliztech/milvus-distributed/internal/msgstream"
)
......@@ -54,16 +54,16 @@ func (ttBarrier *softTimeTickBarrier) AddPeer(peerID UniqueID) error {
func (ttBarrier *softTimeTickBarrier) GetTimeTick() (Timestamp, error) {
select {
case <-ttBarrier.ctx.Done():
return 0, errors.Errorf("[GetTimeTick] closed.")
return 0, errors.New("getTimeTick closed")
case ts, ok := <-ttBarrier.outTt:
if !ok {
return 0, errors.Errorf("[GetTimeTick] closed.")
return 0, errors.New("getTimeTick closed")
}
num := len(ttBarrier.outTt)
for i := 0; i < num; i++ {
ts, ok = <-ttBarrier.outTt
if !ok {
return 0, errors.Errorf("[GetTimeTick] closed.")
return 0, errors.New("getTimeTick closed")
}
}
atomic.StoreInt64(&(ttBarrier.lastTt), int64(ts))
......
......@@ -12,12 +12,14 @@ package querynode
*/
import "C"
import (
"fmt"
"strconv"
"sync"
"errors"
"go.uber.org/zap"
"github.com/zilliztech/milvus-distributed/internal/errors"
"github.com/zilliztech/milvus-distributed/internal/log"
"github.com/zilliztech/milvus-distributed/internal/proto/internalpb2"
"github.com/zilliztech/milvus-distributed/internal/proto/schemapb"
......@@ -96,7 +98,7 @@ func (colReplica *collectionReplicaImpl) addCollection(collectionID UniqueID, sc
defer colReplica.mu.Unlock()
if ok := colReplica.hasCollectionPrivate(collectionID); ok {
return errors.New("collection has been existed, id = " + strconv.FormatInt(collectionID, 10))
return fmt.Errorf("collection has been existed, id %d", collectionID)
}
var newCollection = newCollection(collectionID, schema)
......@@ -138,7 +140,7 @@ func (colReplica *collectionReplicaImpl) getCollectionByID(collectionID UniqueID
func (colReplica *collectionReplicaImpl) getCollectionByIDPrivate(collectionID UniqueID) (*Collection, error) {
collection, ok := colReplica.collections[collectionID]
if !ok {
return nil, errors.New("cannot find collection, id = " + strconv.FormatInt(collectionID, 10))
return nil, fmt.Errorf("cannot find collection, id = %d", collectionID)
}
return collection, nil
......@@ -190,7 +192,7 @@ func (colReplica *collectionReplicaImpl) getVecFieldIDsByCollectionID(collection
}
if len(vecFields) <= 0 {
return nil, errors.New("no vector field in collection " + strconv.FormatInt(collectionID, 10))
return nil, fmt.Errorf("no vector field in collection %d", collectionID)
}
return vecFields, nil
......@@ -223,7 +225,7 @@ func (colReplica *collectionReplicaImpl) getFieldsByCollectionIDPrivate(collecti
}
if len(collection.Schema().Fields) <= 0 {
return nil, errors.New("no field in collection " + strconv.FormatInt(collectionID, 10))
return nil, fmt.Errorf("no field in collection %d", collectionID)
}
return collection.Schema().Fields, nil
......@@ -286,7 +288,7 @@ func (colReplica *collectionReplicaImpl) getPartitionByID(partitionID UniqueID)
func (colReplica *collectionReplicaImpl) getPartitionByIDPrivate(partitionID UniqueID) (*Partition, error) {
partition, ok := colReplica.partitions[partitionID]
if !ok {
return nil, errors.New("cannot find partition, id = " + strconv.FormatInt(partitionID, 10))
return nil, fmt.Errorf("cannot find partition, id = %d", partitionID)
}
return partition, nil
......
......@@ -2,7 +2,6 @@ package querynode
import (
"context"
"errors"
"fmt"
"path"
"sort"
......@@ -11,6 +10,8 @@ import (
"sync"
"time"
"errors"
"go.uber.org/zap"
"github.com/zilliztech/milvus-distributed/internal/kv"
......
......@@ -9,11 +9,12 @@ package querynode
*/
import "C"
import (
"errors"
"path/filepath"
"strconv"
"unsafe"
"errors"
"go.uber.org/zap"
"github.com/zilliztech/milvus-distributed/internal/log"
......
......@@ -6,9 +6,10 @@ import (
"sync"
"time"
"errors"
"go.uber.org/zap"
"github.com/zilliztech/milvus-distributed/internal/errors"
"github.com/zilliztech/milvus-distributed/internal/log"
"github.com/zilliztech/milvus-distributed/internal/msgstream"
"github.com/zilliztech/milvus-distributed/internal/proto/commonpb"
......
......@@ -10,9 +10,10 @@ package querynode
*/
import "C"
import (
"errors"
"strconv"
"unsafe"
"errors"
)
type Plan struct {
......
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