Cargo clippy pass

This commit is contained in:
Clément Renault 2019-10-18 13:21:41 +02:00
parent ca26a0f2e4
commit 9dce41ed6b
No known key found for this signature in database
GPG key ID: 92ADA4E935E71FA4
16 changed files with 82 additions and 66 deletions

View file

@ -11,7 +11,7 @@ pub struct DocsWords {
impl DocsWords {
pub fn put_doc_words(
&self,
self,
writer: &mut zlmdb::RwTxn,
document_id: DocumentId,
words: &fst::Set,
@ -22,7 +22,7 @@ impl DocsWords {
}
pub fn del_doc_words(
&self,
self,
writer: &mut zlmdb::RwTxn,
document_id: DocumentId,
) -> ZResult<bool> {
@ -31,7 +31,7 @@ impl DocsWords {
}
pub fn doc_words(
&self,
self,
reader: &zlmdb::RoTxn,
document_id: DocumentId,
) -> ZResult<Option<fst::Set>> {

View file

@ -12,7 +12,7 @@ pub struct DocumentsFields {
impl DocumentsFields {
pub fn put_document_field(
&self,
self,
writer: &mut zlmdb::RwTxn,
document_id: DocumentId,
attribute: SchemaAttr,
@ -23,7 +23,7 @@ impl DocumentsFields {
}
pub fn del_all_document_fields(
&self,
self,
writer: &mut zlmdb::RwTxn,
document_id: DocumentId,
) -> ZResult<usize> {
@ -33,7 +33,7 @@ impl DocumentsFields {
}
pub fn document_attribute<'txn>(
&self,
self,
reader: &'txn zlmdb::RoTxn,
document_id: DocumentId,
attribute: SchemaAttr,
@ -43,7 +43,7 @@ impl DocumentsFields {
}
pub fn document_fields<'txn>(
&self,
self,
reader: &'txn zlmdb::RoTxn,
document_id: DocumentId,
) -> ZResult<DocumentFieldsIter<'txn>> {
@ -67,7 +67,7 @@ impl<'txn> Iterator for DocumentFieldsIter<'txn> {
let attr = SchemaAttr(key.attr.get());
Some(Ok((attr, bytes)))
}
Some(Err(e)) => Some(Err(e.into())),
Some(Err(e)) => Some(Err(e)),
None => None,
}
}

View file

@ -11,7 +11,7 @@ pub struct DocumentsFieldsCounts {
impl DocumentsFieldsCounts {
pub fn put_document_field_count(
&self,
self,
writer: &mut zlmdb::RwTxn,
document_id: DocumentId,
attribute: SchemaAttr,
@ -22,7 +22,7 @@ impl DocumentsFieldsCounts {
}
pub fn del_all_document_fields_counts(
&self,
self,
writer: &mut zlmdb::RwTxn,
document_id: DocumentId,
) -> ZResult<usize> {
@ -33,7 +33,7 @@ impl DocumentsFieldsCounts {
}
pub fn document_field_count(
&self,
self,
reader: &zlmdb::RoTxn,
document_id: DocumentId,
attribute: SchemaAttr,
@ -46,7 +46,7 @@ impl DocumentsFieldsCounts {
}
pub fn document_fields_counts<'txn>(
&self,
self,
reader: &'txn zlmdb::RoTxn,
document_id: DocumentId,
) -> ZResult<DocumentFieldsCountsIter<'txn>> {
@ -57,7 +57,7 @@ impl DocumentsFieldsCounts {
}
pub fn documents_ids<'txn>(
&self,
self,
reader: &'txn zlmdb::RoTxn,
) -> ZResult<DocumentsIdsIter<'txn>> {
let iter = self.documents_fields_counts.iter(reader)?;
@ -68,7 +68,7 @@ impl DocumentsFieldsCounts {
}
pub fn all_documents_fields_counts<'txn>(
&self,
self,
reader: &'txn zlmdb::RoTxn,
) -> ZResult<AllDocumentsFieldsCountsIter<'txn>> {
let iter = self.documents_fields_counts.iter(reader)?;
@ -89,7 +89,7 @@ impl Iterator for DocumentFieldsCountsIter<'_> {
let attr = SchemaAttr(key.attr.get());
Some(Ok((attr, count)))
}
Some(Err(e)) => Some(Err(e.into())),
Some(Err(e)) => Some(Err(e)),
None => None,
}
}
@ -113,7 +113,7 @@ impl Iterator for DocumentsIdsIter<'_> {
return Some(Ok(document_id));
}
}
Err(e) => return Some(Err(e.into())),
Err(e) => return Some(Err(e)),
}
}
None
@ -134,7 +134,7 @@ impl<'r> Iterator for AllDocumentsFieldsCountsIter<'r> {
let attr = SchemaAttr(key.attr.get());
Some(Ok((docid, attr, count)))
}
Some(Err(e)) => Some(Err(e.into())),
Some(Err(e)) => Some(Err(e)),
None => None,
}
}

View file

@ -17,12 +17,12 @@ pub struct Main {
}
impl Main {
pub fn put_words_fst(&self, writer: &mut zlmdb::RwTxn, fst: &fst::Set) -> ZResult<()> {
pub fn put_words_fst(self, writer: &mut zlmdb::RwTxn, fst: &fst::Set) -> ZResult<()> {
let bytes = fst.as_fst().as_bytes();
self.main.put::<Str, ByteSlice>(writer, WORDS_KEY, bytes)
}
pub fn words_fst(&self, reader: &zlmdb::RoTxn) -> ZResult<Option<fst::Set>> {
pub fn words_fst(self, reader: &zlmdb::RoTxn) -> ZResult<Option<fst::Set>> {
match self.main.get::<Str, ByteSlice>(reader, WORDS_KEY)? {
Some(bytes) => {
let len = bytes.len();
@ -34,31 +34,31 @@ impl Main {
}
}
pub fn put_schema(&self, writer: &mut zlmdb::RwTxn, schema: &Schema) -> ZResult<()> {
pub fn put_schema(self, writer: &mut zlmdb::RwTxn, schema: &Schema) -> ZResult<()> {
self.main
.put::<Str, Serde<Schema>>(writer, SCHEMA_KEY, schema)
}
pub fn schema(&self, reader: &zlmdb::RoTxn) -> ZResult<Option<Schema>> {
pub fn schema(self, reader: &zlmdb::RoTxn) -> ZResult<Option<Schema>> {
self.main.get::<Str, Serde<Schema>>(reader, SCHEMA_KEY)
}
pub fn put_ranked_map(&self, writer: &mut zlmdb::RwTxn, ranked_map: &RankedMap) -> ZResult<()> {
pub fn put_ranked_map(self, writer: &mut zlmdb::RwTxn, ranked_map: &RankedMap) -> ZResult<()> {
self.main
.put::<Str, Serde<RankedMap>>(writer, RANKED_MAP_KEY, &ranked_map)
}
pub fn ranked_map(&self, reader: &zlmdb::RoTxn) -> ZResult<Option<RankedMap>> {
pub fn ranked_map(self, reader: &zlmdb::RoTxn) -> ZResult<Option<RankedMap>> {
self.main
.get::<Str, Serde<RankedMap>>(reader, RANKED_MAP_KEY)
}
pub fn put_synonyms_fst(&self, writer: &mut zlmdb::RwTxn, fst: &fst::Set) -> ZResult<()> {
pub fn put_synonyms_fst(self, writer: &mut zlmdb::RwTxn, fst: &fst::Set) -> ZResult<()> {
let bytes = fst.as_fst().as_bytes();
self.main.put::<Str, ByteSlice>(writer, SYNONYMS_KEY, bytes)
}
pub fn synonyms_fst(&self, reader: &zlmdb::RoTxn) -> ZResult<Option<fst::Set>> {
pub fn synonyms_fst(self, reader: &zlmdb::RoTxn) -> ZResult<Option<fst::Set>> {
match self.main.get::<Str, ByteSlice>(reader, SYNONYMS_KEY)? {
Some(bytes) => {
let len = bytes.len();
@ -70,7 +70,7 @@ impl Main {
}
}
pub fn put_number_of_documents<F>(&self, writer: &mut zlmdb::RwTxn, f: F) -> ZResult<u64>
pub fn put_number_of_documents<F>(self, writer: &mut zlmdb::RwTxn, f: F) -> ZResult<u64>
where
F: Fn(u64) -> u64,
{
@ -80,7 +80,7 @@ impl Main {
Ok(new)
}
pub fn number_of_documents(&self, reader: &zlmdb::RoTxn) -> ZResult<u64> {
pub fn number_of_documents(self, reader: &zlmdb::RoTxn) -> ZResult<u64> {
match self
.main
.get::<Str, OwnedType<u64>>(reader, NUMBER_OF_DOCUMENTS_KEY)?
@ -90,12 +90,12 @@ impl Main {
}
}
pub fn put_customs(&self, writer: &mut zlmdb::RwTxn, customs: &[u8]) -> ZResult<()> {
pub fn put_customs(self, writer: &mut zlmdb::RwTxn, customs: &[u8]) -> ZResult<()> {
self.main
.put::<Str, ByteSlice>(writer, CUSTOMS_KEY, customs)
}
pub fn customs<'txn>(&self, reader: &'txn zlmdb::RoTxn) -> ZResult<Option<&'txn [u8]>> {
pub fn customs<'txn>(self, reader: &'txn zlmdb::RoTxn) -> ZResult<Option<&'txn [u8]>> {
self.main.get::<Str, ByteSlice>(reader, CUSTOMS_KEY)
}
}

View file

@ -106,7 +106,7 @@ impl Index {
let attributes = match attributes {
Some(attributes) => attributes
.into_iter()
.iter()
.map(|name| schema.attribute(name))
.collect(),
None => None,

View file

@ -11,7 +11,7 @@ pub struct PostingsLists {
impl PostingsLists {
pub fn put_postings_list(
&self,
self,
writer: &mut zlmdb::RwTxn,
word: &[u8],
words_indexes: &Set<DocIndex>,
@ -19,12 +19,12 @@ impl PostingsLists {
self.postings_lists.put(writer, word, words_indexes)
}
pub fn del_postings_list(&self, writer: &mut zlmdb::RwTxn, word: &[u8]) -> ZResult<bool> {
pub fn del_postings_list(self, writer: &mut zlmdb::RwTxn, word: &[u8]) -> ZResult<bool> {
self.postings_lists.delete(writer, word)
}
pub fn postings_list<'txn>(
&self,
self,
reader: &'txn zlmdb::RoTxn,
word: &[u8],
) -> ZResult<Option<Cow<'txn, Set<DocIndex>>>> {

View file

@ -9,7 +9,7 @@ pub struct Synonyms {
impl Synonyms {
pub fn put_synonyms(
&self,
self,
writer: &mut zlmdb::RwTxn,
word: &[u8],
synonyms: &fst::Set,
@ -18,11 +18,11 @@ impl Synonyms {
self.synonyms.put(writer, word, bytes)
}
pub fn del_synonyms(&self, writer: &mut zlmdb::RwTxn, word: &[u8]) -> ZResult<bool> {
pub fn del_synonyms(self, writer: &mut zlmdb::RwTxn, word: &[u8]) -> ZResult<bool> {
self.synonyms.delete(writer, word)
}
pub fn synonyms(&self, reader: &zlmdb::RoTxn, word: &[u8]) -> ZResult<Option<fst::Set>> {
pub fn synonyms(self, reader: &zlmdb::RoTxn, word: &[u8]) -> ZResult<Option<fst::Set>> {
match self.synonyms.get(reader, word)? {
Some(bytes) => {
let len = bytes.len();

View file

@ -36,7 +36,7 @@ pub struct Updates {
impl Updates {
// TODO do not trigger deserialize if possible
pub fn last_update_id(&self, reader: &zlmdb::RoTxn) -> ZResult<Option<(u64, Update)>> {
pub fn last_update_id(self, reader: &zlmdb::RoTxn) -> ZResult<Option<(u64, Update)>> {
match self.updates.last(reader)? {
Some((key, data)) => Ok(Some((key.get(), data))),
None => Ok(None),
@ -44,7 +44,7 @@ impl Updates {
}
// TODO do not trigger deserialize if possible
fn first_update_id(&self, reader: &zlmdb::RoTxn) -> ZResult<Option<(u64, Update)>> {
fn first_update_id(self, reader: &zlmdb::RoTxn) -> ZResult<Option<(u64, Update)>> {
match self.updates.first(reader)? {
Some((key, data)) => Ok(Some((key.get(), data))),
None => Ok(None),
@ -52,13 +52,13 @@ impl Updates {
}
// TODO do not trigger deserialize if possible
pub fn contains(&self, reader: &zlmdb::RoTxn, update_id: u64) -> ZResult<bool> {
pub fn contains(self, reader: &zlmdb::RoTxn, update_id: u64) -> ZResult<bool> {
let update_id = BEU64::new(update_id);
self.updates.get(reader, &update_id).map(|v| v.is_some())
}
pub fn put_update(
&self,
self,
writer: &mut zlmdb::RwTxn,
update_id: u64,
update: &Update,
@ -68,7 +68,7 @@ impl Updates {
self.updates.put(writer, &update_id, update)
}
pub fn pop_front(&self, writer: &mut zlmdb::RwTxn) -> ZResult<Option<(u64, Update)>> {
pub fn pop_front(self, writer: &mut zlmdb::RwTxn) -> ZResult<Option<(u64, Update)>> {
match self.first_update_id(writer)? {
Some((update_id, update)) => {
let key = BEU64::new(update_id);

View file

@ -9,7 +9,7 @@ pub struct UpdatesResults {
}
impl UpdatesResults {
pub fn last_update_id(&self, reader: &zlmdb::RoTxn) -> ZResult<Option<(u64, UpdateResult)>> {
pub fn last_update_id(self, reader: &zlmdb::RoTxn) -> ZResult<Option<(u64, UpdateResult)>> {
match self.updates_results.last(reader)? {
Some((key, data)) => Ok(Some((key.get(), data))),
None => Ok(None),
@ -17,7 +17,7 @@ impl UpdatesResults {
}
pub fn put_update_result(
&self,
self,
writer: &mut zlmdb::RwTxn,
update_id: u64,
update_result: &UpdateResult,
@ -27,7 +27,7 @@ impl UpdatesResults {
}
pub fn update_result(
&self,
self,
reader: &zlmdb::RoTxn,
update_id: u64,
) -> ZResult<Option<UpdateResult>> {