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 66 additions and 51 deletions
......@@ -17,9 +17,10 @@ import (
"fmt"
"sync/atomic"
"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/msgstream/pulsarms"
......@@ -144,7 +145,7 @@ func (node *QueryNode) Init() error {
case "QueryResultChannelName":
Params.SearchResultChannelNames = append(Params.SearchResultChannelNames, kv.Value)
default:
return errors.Errorf("Invalid key: %v", kv.Key)
return fmt.Errorf("Invalid key: %v", kv.Key)
}
}
......
......@@ -10,9 +10,10 @@ package querynode
*/
import "C"
import (
"errors"
"strconv"
"unsafe"
"errors"
)
type SearchResult struct {
......
......@@ -19,7 +19,8 @@ import (
"github.com/stretchr/testify/assert"
"go.uber.org/zap"
"github.com/zilliztech/milvus-distributed/internal/errors"
"errors"
"github.com/zilliztech/milvus-distributed/internal/log"
"github.com/zilliztech/milvus-distributed/internal/proto/commonpb"
)
......
......@@ -2,9 +2,10 @@ package querynode
import (
"context"
"errors"
"strconv"
"errors"
"github.com/zilliztech/milvus-distributed/internal/kv"
minioKV "github.com/zilliztech/milvus-distributed/internal/kv/minio"
"github.com/zilliztech/milvus-distributed/internal/msgstream"
......
......@@ -3,7 +3,8 @@ package queryservice
import (
"strconv"
"github.com/zilliztech/milvus-distributed/internal/errors"
"errors"
"github.com/zilliztech/milvus-distributed/internal/proto/querypb"
"github.com/zilliztech/milvus-distributed/internal/proto/schemapb"
)
......
......@@ -2,9 +2,10 @@ package queryservice
import (
"context"
"errors"
"strconv"
"errors"
"github.com/zilliztech/milvus-distributed/internal/proto/commonpb"
"github.com/zilliztech/milvus-distributed/internal/proto/datapb"
"github.com/zilliztech/milvus-distributed/internal/proto/internalpb2"
......
......@@ -14,8 +14,9 @@ import (
"github.com/uber/jaeger-client-go/config"
"go.uber.org/zap"
"errors"
nodeclient "github.com/zilliztech/milvus-distributed/internal/distributed/querynode/client"
"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"
......
......@@ -3,9 +3,10 @@ package storage
import (
"bytes"
"encoding/binary"
"fmt"
"strconv"
"github.com/zilliztech/milvus-distributed/internal/errors"
"errors"
)
type BinlogReader struct {
......@@ -36,8 +37,7 @@ func (reader *BinlogReader) readMagicNumber() (int32, error) {
return -1, err
}
if reader.magicNumber != MagicNumber {
return -1, errors.New("parse magic number failed, expected: " + strconv.Itoa(int(MagicNumber)) +
", actual: " + strconv.Itoa(int(reader.magicNumber)))
return -1, fmt.Errorf("parse magic number failed, expected: %s, actual: %s", strconv.Itoa(int(MagicNumber)), strconv.Itoa(int(reader.magicNumber)))
}
return reader.magicNumber, nil
......
......@@ -4,7 +4,8 @@ import (
"bytes"
"encoding/binary"
"github.com/zilliztech/milvus-distributed/internal/errors"
"errors"
"github.com/zilliztech/milvus-distributed/internal/proto/schemapb"
)
......
......@@ -7,7 +7,8 @@ import (
"strconv"
"strings"
"github.com/zilliztech/milvus-distributed/internal/errors"
"errors"
ms "github.com/zilliztech/milvus-distributed/internal/masterservice"
"github.com/zilliztech/milvus-distributed/internal/proto/etcdpb"
"github.com/zilliztech/milvus-distributed/internal/proto/schemapb"
......@@ -179,7 +180,7 @@ func (insertCodec *InsertCodec) Serialize(partitionID UniqueID, segmentID Unique
case schemapb.DataType_VECTOR_FLOAT:
err = eventWriter.AddFloatVectorToPayload(singleData.(*FloatVectorFieldData).Data, singleData.(*FloatVectorFieldData).Dim)
default:
return nil, errors.Errorf("undefined data type %d", field.DataType)
return nil, fmt.Errorf("undefined data type %d", field.DataType)
}
if err != nil {
return nil, err
......@@ -409,7 +410,7 @@ func (insertCodec *InsertCodec) Deserialize(blobs []*Blob) (partitionID UniqueID
floatVectorFieldData.NumRows += length
resultData.Data[fieldID] = floatVectorFieldData
default:
return -1, -1, nil, errors.Errorf("undefined data type %d", dataType)
return -1, -1, nil, fmt.Errorf("undefined data type %d", dataType)
}
}
insertCodec.readerCloseFunc = append(insertCodec.readerCloseFunc, readerClose(binlogReader))
......@@ -671,7 +672,7 @@ func (indexCodec *IndexCodec) Deserialize(blobs []*Blob) ([]*Blob, map[string]st
IndexID UniqueID
}{}
if err := json.Unmarshal(file.Value, &info); err != nil {
return nil, nil, "", -1, errors.New("json unmarshal error: " + err.Error())
return nil, nil, "", -1, fmt.Errorf("json unmarshal error: %s", err.Error())
}
return blobs, info.Params, info.IndexName, info.IndexID, nil
......
......@@ -2,9 +2,11 @@ package storage
import (
"encoding/binary"
"fmt"
"io"
"github.com/zilliztech/milvus-distributed/internal/errors"
"errors"
"github.com/zilliztech/milvus-distributed/internal/proto/schemapb"
"github.com/zilliztech/milvus-distributed/internal/util/typeutil"
)
......@@ -277,7 +279,7 @@ func newDescriptorEventData() (*descriptorEventData, error) {
for i := DescriptorEventType; i < EventTypeEnd; i++ {
size := getEventFixPartSize(i)
if size == -1 {
return nil, errors.Errorf("undefined event type %d", i)
return nil, fmt.Errorf("undefined event type %d", i)
}
data.PostHeaderLengths = append(data.PostHeaderLengths, uint8(size))
}
......
......@@ -3,7 +3,7 @@ package storage
import (
"bytes"
"errors"
"strconv"
"fmt"
"github.com/zilliztech/milvus-distributed/internal/proto/schemapb"
)
......@@ -55,7 +55,7 @@ func (reader *EventReader) readData() (eventData, error) {
case DropPartitionEventType:
data, err = readDropPartitionEventDataFixPart(reader.buffer)
default:
return nil, errors.New("unknown header type code: " + strconv.Itoa(int(reader.TypeCode)))
return nil, fmt.Errorf("unknown header type code: %d", reader.TypeCode)
}
if err != nil {
......
......@@ -5,7 +5,8 @@ import (
"encoding/binary"
"io"
"github.com/zilliztech/milvus-distributed/internal/errors"
"errors"
"github.com/zilliztech/milvus-distributed/internal/proto/schemapb"
)
......
......@@ -11,7 +11,8 @@ import "C"
import (
"unsafe"
"github.com/zilliztech/milvus-distributed/internal/errors"
"errors"
"github.com/zilliztech/milvus-distributed/internal/proto/commonpb"
"github.com/zilliztech/milvus-distributed/internal/proto/schemapb"
)
......@@ -158,7 +159,7 @@ func (w *PayloadWriter) AddDataToPayload(msgs interface{}, dim ...int) error {
func (w *PayloadWriter) AddBoolToPayload(msgs []bool) error {
length := len(msgs)
if length <= 0 {
return errors.Errorf("can't add empty msgs into payload")
return errors.New("can't add empty msgs into payload")
}
cMsgs := (*C.bool)(unsafe.Pointer(&msgs[0]))
......@@ -178,7 +179,7 @@ func (w *PayloadWriter) AddBoolToPayload(msgs []bool) error {
func (w *PayloadWriter) AddInt8ToPayload(msgs []int8) error {
length := len(msgs)
if length <= 0 {
return errors.Errorf("can't add empty msgs into payload")
return errors.New("can't add empty msgs into payload")
}
cMsgs := (*C.int8_t)(unsafe.Pointer(&msgs[0]))
cLength := C.int(length)
......@@ -197,7 +198,7 @@ func (w *PayloadWriter) AddInt8ToPayload(msgs []int8) error {
func (w *PayloadWriter) AddInt16ToPayload(msgs []int16) error {
length := len(msgs)
if length <= 0 {
return errors.Errorf("can't add empty msgs into payload")
return errors.New("can't add empty msgs into payload")
}
cMsgs := (*C.int16_t)(unsafe.Pointer(&msgs[0]))
......@@ -217,7 +218,7 @@ func (w *PayloadWriter) AddInt16ToPayload(msgs []int16) error {
func (w *PayloadWriter) AddInt32ToPayload(msgs []int32) error {
length := len(msgs)
if length <= 0 {
return errors.Errorf("can't add empty msgs into payload")
return errors.New("can't add empty msgs into payload")
}
cMsgs := (*C.int32_t)(unsafe.Pointer(&msgs[0]))
......@@ -237,7 +238,7 @@ func (w *PayloadWriter) AddInt32ToPayload(msgs []int32) error {
func (w *PayloadWriter) AddInt64ToPayload(msgs []int64) error {
length := len(msgs)
if length <= 0 {
return errors.Errorf("can't add empty msgs into payload")
return errors.New("can't add empty msgs into payload")
}
cMsgs := (*C.int64_t)(unsafe.Pointer(&msgs[0]))
......@@ -257,7 +258,7 @@ func (w *PayloadWriter) AddInt64ToPayload(msgs []int64) error {
func (w *PayloadWriter) AddFloatToPayload(msgs []float32) error {
length := len(msgs)
if length <= 0 {
return errors.Errorf("can't add empty msgs into payload")
return errors.New("can't add empty msgs into payload")
}
cMsgs := (*C.float)(unsafe.Pointer(&msgs[0]))
......@@ -277,7 +278,7 @@ func (w *PayloadWriter) AddFloatToPayload(msgs []float32) error {
func (w *PayloadWriter) AddDoubleToPayload(msgs []float64) error {
length := len(msgs)
if length <= 0 {
return errors.Errorf("can't add empty msgs into payload")
return errors.New("can't add empty msgs into payload")
}
cMsgs := (*C.double)(unsafe.Pointer(&msgs[0]))
......
package storage
import (
"errors"
"fmt"
"os"
"syscall"
"github.com/golang/protobuf/proto"
"github.com/zilliztech/milvus-distributed/internal/errors"
"github.com/zilliztech/milvus-distributed/internal/proto/milvuspb"
"github.com/zilliztech/milvus-distributed/internal/proto/schemapb"
"github.com/zilliztech/milvus-distributed/internal/util/tsoutil"
......@@ -71,7 +71,7 @@ func printBinlogFile(filename string) error {
fmt.Printf("\tEndTimestamp: %v\n", physical)
dataTypeName, ok := schemapb.DataType_name[int32(r.descriptorEvent.descriptorEventData.PayloadDataType)]
if !ok {
return errors.Errorf("undefine data type %d", r.descriptorEvent.descriptorEventData.PayloadDataType)
return fmt.Errorf("undefine data type %d", r.descriptorEvent.descriptorEventData.PayloadDataType)
}
fmt.Printf("\tPayloadDataType: %v\n", dataTypeName)
fmt.Printf("\tPostHeaderLengths: %v\n", r.descriptorEvent.descriptorEventData.PostHeaderLengths)
......@@ -95,7 +95,7 @@ func printBinlogFile(filename string) error {
case InsertEventType:
evd, ok := event.eventData.(*insertEventData)
if !ok {
return errors.Errorf("incorrect event data type")
return errors.New("incorrect event data type")
}
fmt.Printf("event %d insert event:\n", eventNum)
physical, _ = tsoutil.ParseTS(evd.StartTimestamp)
......@@ -108,7 +108,7 @@ func printBinlogFile(filename string) error {
case DeleteEventType:
evd, ok := event.eventData.(*deleteEventData)
if !ok {
return errors.Errorf("incorrect event data type")
return errors.New("incorrect event data type")
}
fmt.Printf("event %d delete event:\n", eventNum)
physical, _ = tsoutil.ParseTS(evd.StartTimestamp)
......@@ -121,7 +121,7 @@ func printBinlogFile(filename string) error {
case CreateCollectionEventType:
evd, ok := event.eventData.(*createCollectionEventData)
if !ok {
return errors.Errorf("incorrect event data type")
return errors.New("incorrect event data type")
}
fmt.Printf("event %d create collection event:\n", eventNum)
physical, _ = tsoutil.ParseTS(evd.StartTimestamp)
......@@ -134,7 +134,7 @@ func printBinlogFile(filename string) error {
case DropCollectionEventType:
evd, ok := event.eventData.(*dropCollectionEventData)
if !ok {
return errors.Errorf("incorrect event data type")
return errors.New("incorrect event data type")
}
fmt.Printf("event %d drop collection event:\n", eventNum)
physical, _ = tsoutil.ParseTS(evd.StartTimestamp)
......@@ -147,7 +147,7 @@ func printBinlogFile(filename string) error {
case CreatePartitionEventType:
evd, ok := event.eventData.(*createPartitionEventData)
if !ok {
return errors.Errorf("incorrect event data type")
return errors.New("incorrect event data type")
}
fmt.Printf("event %d create partition event:\n", eventNum)
physical, _ = tsoutil.ParseTS(evd.StartTimestamp)
......@@ -160,7 +160,7 @@ func printBinlogFile(filename string) error {
case DropPartitionEventType:
evd, ok := event.eventData.(*dropPartitionEventData)
if !ok {
return errors.Errorf("incorrect event data type")
return errors.New("incorrect event data type")
}
fmt.Printf("event %d drop partition event:\n", eventNum)
physical, _ = tsoutil.ParseTS(evd.StartTimestamp)
......@@ -171,7 +171,7 @@ func printBinlogFile(filename string) error {
return err
}
default:
return errors.Errorf("undefined event typd %d\n", event.eventHeader.TypeCode)
return fmt.Errorf("undefined event typd %d", event.eventHeader.TypeCode)
}
eventNum++
}
......@@ -280,7 +280,7 @@ func printPayloadValues(colType schemapb.DataType, reader PayloadReaderInterface
fmt.Println()
}
default:
return errors.Errorf("undefined data type")
return errors.New("undefined data type")
}
return nil
}
......@@ -333,11 +333,11 @@ func printDDLPayloadValues(eventType EventTypeCode, colType schemapb.DataType, r
}
fmt.Printf("\t\t%d : drop partition: %v\n", i, req)
default:
return errors.Errorf("undefined ddl event type %d", eventType)
return fmt.Errorf("undefined ddl event type %d", eventType)
}
}
default:
return errors.Errorf("undefined data type")
return errors.New("undefined data type")
}
return nil
}
......@@ -2,6 +2,7 @@ package timesync
import (
"context"
"errors"
"math"
"sync"
"sync/atomic"
......@@ -12,7 +13,6 @@ import (
"github.com/zilliztech/milvus-distributed/internal/util/typeutil"
"github.com/zilliztech/milvus-distributed/internal/errors"
"github.com/zilliztech/milvus-distributed/internal/log"
ms "github.com/zilliztech/milvus-distributed/internal/msgstream"
)
......@@ -72,16 +72,16 @@ func NewSoftTimeTickBarrier(ctx context.Context, ttStream ms.MsgStream, peerIds
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))
......@@ -137,10 +137,10 @@ func (ttBarrier *softTimeTickBarrier) minTimestamp() Timestamp {
func (ttBarrier *hardTimeTickBarrier) 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")
}
return ts, ttBarrier.ctx.Err()
}
......
......@@ -18,7 +18,8 @@ import (
"sync/atomic"
"time"
"github.com/zilliztech/milvus-distributed/internal/errors"
"errors"
"github.com/zilliztech/milvus-distributed/internal/kv"
"github.com/zilliztech/milvus-distributed/internal/util/tsoutil"
"github.com/zilliztech/milvus-distributed/internal/util/typeutil"
......
......@@ -21,7 +21,7 @@ import (
"go.uber.org/zap"
"github.com/zilliztech/milvus-distributed/internal/errors"
"github.com/pkg/errors"
"github.com/zilliztech/milvus-distributed/internal/kv"
"github.com/zilliztech/milvus-distributed/internal/util/tsoutil"
"github.com/zilliztech/milvus-distributed/internal/util/typeutil"
......
......@@ -5,7 +5,7 @@ import (
"log"
"sync"
"github.com/zilliztech/milvus-distributed/internal/errors"
"errors"
)
type TimeTickedFlowGraph struct {
......
......@@ -4,8 +4,9 @@ import (
"context"
"log"
"errors"
"github.com/opentracing/opentracing-go"
"github.com/zilliztech/milvus-distributed/internal/errors"
"github.com/zilliztech/milvus-distributed/internal/msgstream"
"github.com/zilliztech/milvus-distributed/internal/util/trace"
)
......
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