|
@@ -226,42 +226,40 @@ impl Storage for RocksDb {
|
|
|
let ns: Arc<BoundColumnFamily<'_>> =
|
|
|
self.reference_to_cf_handle(ReferenceType::RefEvent)?;
|
|
|
|
|
|
- let keys = query
|
|
|
- .references_to_event
|
|
|
- .iter()
|
|
|
- .map(|c| c.as_ref().to_vec())
|
|
|
+ let keys = std::mem::take(&mut query.references_to_event)
|
|
|
+ .into_iter()
|
|
|
+ .map(|c| c.take())
|
|
|
.collect();
|
|
|
- query.references_to_event.clear();
|
|
|
(Some(ns), None, keys)
|
|
|
} else if !query.references_to_public_key.is_empty() {
|
|
|
let ns = self.reference_to_cf_handle(ReferenceType::RefEvent)?;
|
|
|
- let keys = query
|
|
|
- .references_to_public_key
|
|
|
- .iter()
|
|
|
- .map(|c| c.as_ref().to_vec())
|
|
|
+ let keys = std::mem::take(&mut query.references_to_public_key)
|
|
|
+ .into_iter()
|
|
|
+ .map(|c| c.take())
|
|
|
.collect();
|
|
|
- query.references_to_public_key.clear();
|
|
|
(Some(ns), None, keys)
|
|
|
} else if !query.ids.is_empty() {
|
|
|
- let keys = query.ids.iter().map(|c| c.as_ref().to_vec()).collect();
|
|
|
- query.ids.clear();
|
|
|
+ let keys = std::mem::take(&mut query.ids)
|
|
|
+ .into_iter()
|
|
|
+ .map(|c| c.take())
|
|
|
+ .collect();
|
|
|
(None, None, keys)
|
|
|
} else if !query.authors.is_empty() {
|
|
|
let ns = self.reference_to_cf_handle(ReferenceType::Author)?;
|
|
|
- let keys = query.authors.iter().map(|c| c.as_ref().to_vec()).collect();
|
|
|
- query.authors.clear();
|
|
|
+ let keys = std::mem::take(&mut query.authors)
|
|
|
+ .into_iter()
|
|
|
+ .map(|c| c.take())
|
|
|
+ .collect();
|
|
|
(Some(ns), None, keys)
|
|
|
} else if !query.kinds.is_empty() {
|
|
|
let ns = self.reference_to_cf_handle(ReferenceType::Kind)?;
|
|
|
- let keys = query
|
|
|
- .kinds
|
|
|
- .iter()
|
|
|
+ let keys = std::mem::take(&mut query.kinds)
|
|
|
+ .into_iter()
|
|
|
.map(|kind| {
|
|
|
- let kind: u32 = (*kind).into();
|
|
|
+ let kind: u32 = kind.into();
|
|
|
kind.to_be_bytes().to_vec()
|
|
|
})
|
|
|
.collect();
|
|
|
- query.kinds.clear();
|
|
|
(Some(ns), None, keys)
|
|
|
} else {
|
|
|
let cf_handle = self.reference_to_cf_handle(ReferenceType::Stream)?;
|