consolidate key/value types; consistent interface arguments
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
46423cab4f
commit
a2d25215a3
8 changed files with 172 additions and 79 deletions
|
@ -20,15 +20,18 @@ impl Data {
|
|||
}
|
||||
|
||||
pub(super) fn index_pdu(&self, shortroomid: u64, pdu_id: &[u8], message_body: &str) -> Result<()> {
|
||||
let mut batch = tokenize(message_body).map(|word| {
|
||||
let mut key = shortroomid.to_be_bytes().to_vec();
|
||||
key.extend_from_slice(word.as_bytes());
|
||||
key.push(0xFF);
|
||||
key.extend_from_slice(pdu_id); // TODO: currently we save the room id a second time here
|
||||
(key, Vec::new())
|
||||
});
|
||||
let batch = tokenize(message_body)
|
||||
.map(|word| {
|
||||
let mut key = shortroomid.to_be_bytes().to_vec();
|
||||
key.extend_from_slice(word.as_bytes());
|
||||
key.push(0xFF);
|
||||
key.extend_from_slice(pdu_id); // TODO: currently we save the room id a second time here
|
||||
(key, Vec::<u8>::new())
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
self.tokenids.insert_batch(&mut batch)
|
||||
self.tokenids
|
||||
.insert_batch(batch.iter().map(database::KeyVal::from))
|
||||
}
|
||||
|
||||
pub(super) fn deindex_pdu(&self, shortroomid: u64, pdu_id: &[u8], message_body: &str) -> Result<()> {
|
||||
|
|
|
@ -268,9 +268,9 @@ impl Data {
|
|||
}
|
||||
|
||||
self.userroomid_notificationcount
|
||||
.increment_batch(&mut notifies_batch.into_iter())?;
|
||||
.increment_batch(notifies_batch.iter().map(Vec::as_slice))?;
|
||||
self.userroomid_highlightcount
|
||||
.increment_batch(&mut highlights_batch.into_iter())?;
|
||||
.increment_batch(highlights_batch.iter().map(Vec::as_slice))?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue