`INSERT ... ON CONFLICT DO NOTHING` semantics: append only if the PK is absent; silently skip on duplicate. Returns `Ok(MutationResult { wal_records })` with an empty vector when the row was skipped, so callers that batch WAL appends can detect no-ops by checking `wal_records.is_empty()`.
(&mut self, values: &[Value])
| 120 | /// when the row was skipped, so callers that batch WAL appends can |
| 121 | /// detect no-ops by checking `wal_records.is_empty()`. |
| 122 | pub fn insert_if_absent(&mut self, values: &[Value]) -> Result<MutationResult, ColumnarError> { |
| 123 | let pk_bytes = self.extract_pk_bytes(values)?; |
| 124 | if self.pk_index.contains(&pk_bytes) { |
| 125 | return Ok(MutationResult { |
| 126 | wal_records: Vec::new(), |
| 127 | }); |
| 128 | } |
| 129 | |
| 130 | let row_data = encode_row_for_wal(values)?; |
| 131 | let wal = ColumnarWalRecord::InsertRow { |
| 132 | collection: self.collection.clone(), |
| 133 | row_data, |
| 134 | }; |
| 135 | self.memtable.append_row(values)?; |
| 136 | let location = RowLocation { |
| 137 | segment_id: self.memtable_segment_id, |
| 138 | row_index: self.memtable_row_counter, |
| 139 | }; |
| 140 | self.pk_index.upsert(pk_bytes, location); |
| 141 | self.memtable_surrogates.push(None); |
| 142 | self.memtable_row_counter += 1; |
| 143 | |
| 144 | Ok(MutationResult { |
| 145 | wal_records: vec![wal], |
| 146 | }) |
| 147 | } |
| 148 | |
| 149 | /// Look up the current row for a PK in the memtable, if present. |
| 150 | /// |
no test coverage detected