Capacity returns the capacity of the Golang's slice that is underlying this Vec. Note that if there is no "slice" (like in case of flat bytes), then "capacity" of such object is equal to the number of elements.
()
| 290 | // this Vec. Note that if there is no "slice" (like in case of flat bytes), |
| 291 | // then "capacity" of such object is equal to the number of elements. |
| 292 | func (v *Vec) Capacity() int { |
| 293 | switch v.CanonicalTypeFamily() { |
| 294 | case types.BoolFamily: |
| 295 | return cap(v.col.(Bools)) |
| 296 | case types.BytesFamily: |
| 297 | return v.Bytes().Len() |
| 298 | case types.IntFamily: |
| 299 | switch v.t.Width() { |
| 300 | case 16: |
| 301 | return cap(v.col.(Int16s)) |
| 302 | case 32: |
| 303 | return cap(v.col.(Int32s)) |
| 304 | case 0, 64: |
| 305 | return cap(v.col.(Int64s)) |
| 306 | default: |
| 307 | panic(fmt.Sprintf("unexpected int width: %d", v.t.Width())) |
| 308 | } |
| 309 | case types.FloatFamily: |
| 310 | return cap(v.col.(Float64s)) |
| 311 | case types.DecimalFamily: |
| 312 | return cap(v.col.(Decimals)) |
| 313 | case types.TimestampTZFamily: |
| 314 | return cap(v.col.(Times)) |
| 315 | case types.IntervalFamily: |
| 316 | return cap(v.col.(Durations)) |
| 317 | case types.JsonFamily: |
| 318 | return v.JSON().Len() |
| 319 | case typeconv.DatumVecCanonicalTypeFamily: |
| 320 | return v.col.(DatumVec).Cap() |
| 321 | default: |
| 322 | panic(fmt.Sprintf("unhandled type %s", v.t)) |
| 323 | } |
| 324 | } |