Reset implements the Batch interface.
(typs []*types.T, length int, factory ColumnFactory)
| 407 | |
| 408 | // Reset implements the Batch interface. |
| 409 | func (m *MemBatch) Reset(typs []*types.T, length int, factory ColumnFactory) { |
| 410 | cannotReuse := m == nil || m.Capacity() < length || m.Width() < len(typs) |
| 411 | for i := 0; i < len(typs) && !cannotReuse; i++ { |
| 412 | // TODO(yuzefovich): change this when DatumVec is introduced. |
| 413 | // TODO(yuzefovich): requiring that types are "identical" might be an |
| 414 | // overkill - the vectors could have the same physical representation |
| 415 | // but non-identical types. Think through this more. |
| 416 | if v := m.ColVec(i); !v.Type().Identical(typs[i]) { |
| 417 | cannotReuse = true |
| 418 | break |
| 419 | } |
| 420 | } |
| 421 | if cannotReuse { |
| 422 | *m = *NewMemBatchWithCapacity(typs, length, factory).(*MemBatch) |
| 423 | m.SetLength(length) |
| 424 | return |
| 425 | } |
| 426 | // Yay! We can reuse m. NB It's not specified in the Reset contract, but |
| 427 | // probably a good idea to keep all modifications below this line. |
| 428 | // |
| 429 | // Note that we're intentionally not calling m.SetLength() here because |
| 430 | // that would update offsets in the bytes vectors which is not necessary |
| 431 | // since those will get reset in ResetInternalBatch anyway. |
| 432 | m.b = m.b[:len(typs)] |
| 433 | m.sel = m.sel[:length] |
| 434 | m.ResetInternalBatch() |
| 435 | m.SetLength(length) |
| 436 | } |
| 437 | |
| 438 | // ResetInternalBatch implements the Batch interface. |
| 439 | func (m *MemBatch) ResetInternalBatch() { |
nothing calls this directly
no test coverage detected