nlfiedler / mokuroku

Secondary indices for RocksDB in Rust.
https://crates.io/crates/mokuroku
Apache License 2.0
39 stars 4 forks source link

Query Reverse #8

Closed Thomas55777 closed 3 years ago

Thomas55777 commented 4 years ago

I like the library, it is very nice.

Any chance you can add a query descending function using Direction::Reverse. Something like:

    pub fn query_desc<K: AsRef<[u8]>>(
        &mut self,
        view: &str,
        key: K,
    ) -> Result<QueryIterator, Error> {
        let mrview = self.ensure_view_built(view)?;
        let cf = self
            .db
            .cf_handle(&mrview)
            .ok_or_else(|| err_msg("missing view column family"))?;
        let iter = self
            .db
            .iterator_cf(&cf, IteratorMode::From(key.as_ref(), Direction::Reverse));
        Ok(QueryIterator::new(&self.db, iter, &self.key_sep, cf))
    }
nlfiedler commented 4 years ago

Does commit 0fcb5c039bf7f1f461093f8df286a36fa62c489e look reasonable? If so, I'll tag and push an update. Thanks for the suggestion.

Thomas55777 commented 4 years ago

Wow, thats great. Thank you so much for you very quick response!

nlfiedler commented 3 years ago

Oops, forgot to close this issue. Fixed in commit 0fcb5c039bf7f1f461093f8df286a36fa62c489e