Merge pull request #91 from Kerollmops/warn-reused-document-id

Emit warnings when a document id is reused
This commit is contained in:
Clément Renault 2019-01-28 21:05:42 +01:00 committed by GitHub
commit 820f1f9ac6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,6 +6,7 @@ use rocksdb::rocksdb_options;
use hashbrown::HashMap; use hashbrown::HashMap;
use fst::map::Map; use fst::map::Map;
use sdset::Set; use sdset::Set;
use log::warn;
use crate::database::index::{Index, Positive, PositiveBuilder, Negative}; use crate::database::index::{Index, Positive, PositiveBuilder, Negative};
use crate::database::{DATA_INDEX, DocumentKeyAttr}; use crate::database::{DATA_INDEX, DocumentKeyAttr};
@ -67,6 +68,7 @@ impl RawUpdateBuilder {
pub fn document_update(&mut self, document_id: DocumentId) -> &mut DocumentUpdate { pub fn document_update(&mut self, document_id: DocumentId) -> &mut DocumentUpdate {
match self.document_updates.entry(document_id) { match self.document_updates.entry(document_id) {
Entry::Occupied(mut occupied) => { Entry::Occupied(mut occupied) => {
warn!("Already updated document {:?}, clearing it", document_id);
occupied.get_mut().clear(); occupied.get_mut().clear();
occupied.into_mut() occupied.into_mut()
}, },