packages feed

rocksdb-query 0.3.0 → 0.3.1

raw patch · 3 files changed

+52/−24 lines, 3 filesnew-uploader

Files

CHANGELOG.md view
@@ -4,6 +4,12 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## 0.3.1+### Changed+- List functions do not use conduits.+- Reuse serialized version of key prefix.+- Avoid building extra bytestring for key prefix comparison.+ ## 0.3.0 ### Changed - Make conduits polymorphic on input parameter.
rocksdb-query.cabal view
@@ -1,20 +1,20 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.31.1.+-- This file has been generated from package.yaml by hpack version 0.31.2. -- -- see: https://github.com/sol/hpack ----- hash: b7e491e8885a215059e085b94eefba33b2304abb0270194e7bae25d74e83b93b+-- hash: 4a065d3528e82c86f422f36eb64efbe60c3b287270c330f05ea1622671fa4973  name:           rocksdb-query-version:        0.3.0+version:        0.3.1 synopsis:       RocksDB database querying library for Haskell-description:    Please see the README on GitHub at <https://github.com/xenog/rocksdb-query#readme>+description:    Please see the README on GitHub at <https://github.com/jprupp/rocksdb-query#readme> category:       Database-homepage:       https://github.com/xenog/rocksdb-query#readme-bug-reports:    https://github.com/xenog/rocksdb-query/issues+homepage:       https://github.com/jprupp/rocksdb-query#readme+bug-reports:    https://github.com/jprupp/rocksdb-query/issues author:         Jean-Pierre Rupp-maintainer:     xenog@protonmail.com+maintainer:     jprupp@protonmail.ch copyright:      No Rights Reserved license:        PublicDomain license-file:   UNLICENSE@@ -25,7 +25,7 @@  source-repository head   type: git-  location: https://github.com/xenog/rocksdb-query+  location: https://github.com/jprupp/rocksdb-query  library   exposed-modules:
src/Database/RocksDB/Query.hs view
@@ -39,6 +39,26 @@                 Left e  -> throwString e                 Right x -> return (Just x) +matchRecursiveList ::+     (MonadIO m, KeyValue key value, Serialize key, Serialize value)+  => key+  -> Iterator+  -> m [(key, value)]+matchRecursiveList base it = go+  where+    go =+      iterEntry it >>= \case+        Nothing -> return []+        Just (key_bytes, value_bytes) -> do+          if base_bytes `B.isPrefixOf` key_bytes+            then do+              key <- either throwString return (decode key_bytes)+              value <- either throwString return (decode value_bytes)+              iterNext it+              ((key, value) :) <$> go+            else return []+    base_bytes = encode base+ -- | Internal function for recursively matching a key. matchRecursive ::        ( MonadIO m@@ -49,20 +69,20 @@     => key     -> Iterator     -> ConduitT i (key, value) m ()-matchRecursive base it =-    iterEntry it >>= \case+matchRecursive base it = go+  where+    go =+      iterEntry it >>= \case         Nothing -> return ()         Just (key_bytes, value_bytes) -> do-            let start_bytes = B.take (B.length base_bytes) key_bytes-            if start_bytes /= base_bytes-                then return ()-                else do-                    key <- either throwString return (decode key_bytes)-                    value <- either throwString return (decode value_bytes)-                    yield (key, value)-                    iterNext it-                    matchRecursive base it-  where+          if base_bytes `B.isPrefixOf` key_bytes+            then do+              key <- either throwString return (decode key_bytes)+              value <- either throwString return (decode value_bytes)+              yield (key, value)+              iterNext it+              go+            else return ()     base_bytes = encode base  -- | Pass a short key to filter all the elements whose key prefix match it. Use@@ -191,8 +211,9 @@     -> key     -> m [(key, value)] matchingAsList db opts base =-    runResourceT . runConduit $-    matching db opts base .| sinkList+  runResourceT . withIterator db opts $ \it -> do+    iterSeek it (encode base)+    matchRecursiveList base it  -- | Like 'matchingSkip', but return a list. matchingSkipAsList ::@@ -207,5 +228,6 @@     -> key     -> m [(key, value)] matchingSkipAsList db opts base start =-    runResourceT . runConduit $-    matchingSkip db opts base start .| sinkList+  runResourceT . withIterator db opts $ \it -> do+    iterSeek it (encode start)+    matchRecursiveList base it