Append a value to our buffers and return the view pointing to it
(&mut self, value: &[u8])
| 428 | |
| 429 | /// Append a value to our buffers and return the view pointing to it |
| 430 | fn append_value(&mut self, value: &[u8]) -> u128 { |
| 431 | let len = value.len(); |
| 432 | let view = if len <= 12 { |
| 433 | make_view(value, 0, 0) |
| 434 | } else { |
| 435 | // Ensure buffer is big enough |
| 436 | if self.in_progress.len() + len > BYTE_VIEW_MAX_BLOCK_SIZE { |
| 437 | let flushed = std::mem::replace( |
| 438 | &mut self.in_progress, |
| 439 | Vec::with_capacity(BYTE_VIEW_MAX_BLOCK_SIZE), |
| 440 | ); |
| 441 | self.completed.push(Buffer::from_vec(flushed)); |
| 442 | } |
| 443 | |
| 444 | let buffer_index = self.completed.len() as u32; |
| 445 | let offset = self.in_progress.len() as u32; |
| 446 | self.in_progress.extend_from_slice(value); |
| 447 | |
| 448 | make_view(value, buffer_index, offset) |
| 449 | }; |
| 450 | |
| 451 | self.views.push(view); |
| 452 | self.nulls.append_non_null(); |
| 453 | view |
| 454 | } |
| 455 | |
| 456 | /// Total number of entries (including null, if present) |
| 457 | pub fn len(&self) -> usize { |