Write a key and its associated row id. If key is None, the row id is added to the null bitmap. Keys must be written in sorted order; entries with the same key are combined.
(&mut self, key: Option<&[u8]>, row_id: i64)
| 95 | /// If key is None, the row id is added to the null bitmap. |
| 96 | /// Keys must be written in sorted order; entries with the same key are combined. |
| 97 | pub async fn write(&mut self, key: Option<&[u8]>, row_id: i64) -> io::Result<()> { |
| 98 | self.row_count += 1; |
| 99 | |
| 100 | match key { |
| 101 | None => { |
| 102 | self.null_bitmap |
| 103 | .get_or_insert_with(RoaringTreemap::new) |
| 104 | .insert(row_id as u64); |
| 105 | } |
| 106 | Some(k) => { |
| 107 | if let Some(ref last) = self.last_key { |
| 108 | if (self.key_comparator)(k, last) != Ordering::Equal { |
| 109 | self.flush_row_ids().await?; |
| 110 | } |
| 111 | } |
| 112 | self.last_key = Some(k.to_vec()); |
| 113 | self.current_row_ids.push(row_id); |
| 114 | |
| 115 | if self.first_key.is_none() { |
| 116 | self.first_key = Some(k.to_vec()); |
| 117 | } |
| 118 | } |
| 119 | } |
| 120 | Ok(()) |
| 121 | } |
| 122 | |
| 123 | /// Flush accumulated row ids for the current key. |
| 124 | async fn flush_row_ids(&mut self) -> io::Result<()> { |