@@ -1792,7 +1792,7 @@ func unmarshalVector(info VectorType, data []byte, value interface{}) error {
17921792 for i := 0 ; i < info .Dimensions ; i ++ {
17931793 offset := 0
17941794 if isVectorVariableLengthType (info .SubType ) {
1795- m , p , err := readUnsignedVInt (data , 0 )
1795+ m , p , err := readUnsignedVInt (data )
17961796 if err != nil {
17971797 return err
17981798 }
@@ -1858,24 +1858,24 @@ func writeUnsignedVInt(buf *bytes.Buffer, v uint64) {
18581858 buf .Write (tmp )
18591859}
18601860
1861- func readUnsignedVInt (data []byte , start int ) (uint64 , int , error ) {
1862- if len (data ) <= start {
1861+ func readUnsignedVInt (data []byte ) (uint64 , int , error ) {
1862+ if len (data ) <= 0 {
18631863 return 0 , 0 , errors .New ("unexpected eof" )
18641864 }
1865- firstByte := data [start ]
1865+ firstByte := data [0 ]
18661866 if firstByte & 0x80 == 0 {
1867- return uint64 (firstByte ), start + 1 , nil
1867+ return uint64 (firstByte ), 1 , nil
18681868 }
18691869 numBytes := bits .LeadingZeros32 (uint32 (^ firstByte )) - 24
18701870 ret := uint64 (firstByte & (0xff >> uint (numBytes )))
1871- if len (data ) < start + numBytes + 1 {
1872- return 0 , 0 , fmt .Errorf ("data expect to have %d bytes, but it has only %d" , start + numBytes + 1 , len (data ))
1871+ if len (data ) < numBytes + 1 {
1872+ return 0 , 0 , fmt .Errorf ("data expect to have %d bytes, but it has only %d" , numBytes + 1 , len (data ))
18731873 }
1874- for i := start ; i < start + numBytes ; i ++ {
1874+ for i := 0 ; i < numBytes ; i ++ {
18751875 ret <<= 8
18761876 ret |= uint64 (data [i + 1 ] & 0xff )
18771877 }
1878- return ret , start + numBytes + 1 , nil
1878+ return ret , numBytes + 1 , nil
18791879}
18801880
18811881func computeUnsignedVIntSize (v uint64 ) int {
0 commit comments