milvus-io / milvus-sdk-go

Go SDK for Milvus.
Apache License 2.0
326 stars 105 forks source link

[Bug]: NewColumnBinaryVector wrongly counts rows during Insert #774

Closed mzurawek closed 2 months ago

mzurawek commented 2 months ago

Is there an existing issue for this?

Current Behavior

NewColumnBinaryVector counts each binary element as separate vector during Insert

dataVector := make([][]byte, 0, 1)
var byteArray [5]byte = [5]byte{1, 1, 1, 1, 1}
dataVector = append(dataVector, byteArray)

dataColumn := entity.NewColumnBinaryVector("vector", 5, dataVector)

_, err = mClient.Insert(
        context.Background(), // ctx
        "coll",             // CollectionName
        "",                   // partitionName
        dataColumn
    )

returns error:

the num_rows (5) of field (vector) is not equal to passed num_rows (1): invalid parameter[expected=5][actual=1]

Expected Behavior

Item should be inserted without errors

Steps To Reproduce

dataVector := make([][]byte, 0, 1)
var byteArray [5]byte = [5]byte{1, 1, 1, 1, 1}
dataVector = append(dataVector, byteArray)

dataColumn := entity.NewColumnBinaryVector("vector", 5, dataVector)

_, err = mClient.Insert(
        context.Background(), // ctx
        "coll",             // CollectionName
        "",                   // partitionName
        dataColumn
    )

Environment

go version go1.22.4 darwin/arm64

Anything else?

No response

congqixia commented 2 months ago

@mzurawek thanks for the feedback, some quick question: what was the dimension of the vector? from the code it could be 5 or 40:

dataColumn := entity.NewColumnBinaryVector("vector", 5, dataVector) // set insert data as 5

the data is actually in dimension of 40: 5 bytes = 40bits

var byteArray [5]byte = [5]byte{1, 1, 1, 1, 1}

The error message cannot be reproduce with the code you provide since the dimension check failed first

mzurawek commented 2 months ago

Sorry I should know that if the variable is 256 bits there should be 256 dimensions in binary vector, it wasn't clear on the documentation