milvus-sdk-go icon indicating copy to clipboard operation
milvus-sdk-go copied to clipboard

[Bug]: reflectValueCandi array error

Open extrame opened this issue 10 months ago • 1 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current Behavior

https://github.com/milvus-io/milvus-sdk-go/blob/626c1fece76114d1d7e6abcfbf759cd1f7bc5d62/entity/rows.go#L552

reflectValueCandi reflect array of wrong length, it trim the last byte.

If I define a struct like:

type PromptTemplate struct {
	Id int64 `xorm:"pk autoincr" json:"id" milvus:"primary_key;name:id"`
	CreatedAt time.Time `json:"created_at" xorm:"created" milvus:"-"`
	ActionType  int32        `json:"action_type" milvus:"name:action_type"`
	ProcessCode string       `json:"process_code" milvus:"name:process_code"`
	Vectors     [384]float32 `milvus:"name:prompt_vector" json:"-" xorm:"-"` //用于存储向量
}

It will reflect Vectors to 383 lengths slice.

remove -1 in https://github.com/milvus-io/milvus-sdk-go/blob/626c1fece76114d1d7e6abcfbf759cd1f7bc5d62/entity/rows.go#L552 will fix the bug

Expected Behavior

It should reflect Vectors to 384 lengths slice.

Steps To Reproduce

Define a type with array like:

type PromptTemplate struct {
	Id int64 `xorm:"pk autoincr" json:"id" milvus:"primary_key;name:id"`
	CreatedAt time.Time `json:"created_at" xorm:"created" milvus:"-"`
	ActionType  int32        `json:"action_type" milvus:"name:action_type"`
	ProcessCode string       `json:"process_code" milvus:"name:process_code"`
	Vectors     [384]float32 `milvus:"name:prompt_vector" json:"-" xorm:"-"` //用于存储向量
}

call InsertRows to insert objects of the test type like:

_, err = mclient.InsertRows(
		context.Background(), // ctx
		"cpzx_rag_prompt",    // CollectionName
		"",                   // partitionName
		interfaces,           // rows
	)
	return err

It will show a error like

the length(383) of float data should divide the dim(384)


### Environment

_No response_

### Anything else?

_No response_

extrame avatar Apr 24 '24 01:04 extrame

Thanks for pointing this out! I'll fix this asap

congqixia avatar Apr 24 '24 03:04 congqixia