packages feed

rocksdb-haskell-jprupp 2.3.1 → 2.4.0

raw patch · 5 files changed

+50/−1 lines, 5 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Database.RocksDB: [dbWriteBufferSize] :: Config -> !Maybe Int
+ Database.RocksDB: [writeBufferSize] :: Config -> !Maybe Int
- Database.RocksDB: Config :: !Bool -> !Bool -> !Bool -> !Maybe Int -> !Maybe Int -> !Bool -> Config
+ Database.RocksDB: Config :: !Bool -> !Bool -> !Bool -> !Maybe Int -> !Maybe Int -> !Bool -> !Maybe Int -> !Maybe Int -> Config

Files

CHANGELOG.md view
@@ -1,3 +1,8 @@+## 2.4.0++ * Add `writeBufferSize` (`write_buffer_size`) and `dbWriteBufferSize`+   (`db_write_buffer_size`) to `Config`, to bound memtable memory.+ ## 2.3.1   * Do not call next/prev on invalid iterators (fixes assertion failure).
rocksdb-haskell-jprupp.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack  name:           rocksdb-haskell-jprupp-version:        2.3.1+version:        2.4.0 synopsis:       Haskell bindings for RocksDB description:    See README at <https://github.com/jprupp/rocksdb-haskell#readme> category:       Database, FFI
src/Database/RocksDB/C.hs view
@@ -72,6 +72,8 @@     , c_rocksdb_options_set_error_if_exists     , c_rocksdb_options_set_paranoid_checks     , c_rocksdb_options_set_max_open_files+    , c_rocksdb_options_set_write_buffer_size+    , c_rocksdb_options_set_db_write_buffer_size     , c_rocksdb_options_set_prefix_extractor     , c_rocksdb_options_set_block_based_table_factory     , c_rocksdb_block_based_options_create@@ -370,6 +372,12 @@  foreign import ccall safe "rocksdb/c.h rocksdb_options_set_max_open_files"   c_rocksdb_options_set_max_open_files :: Options -> CInt -> IO ()++foreign import ccall safe "rocksdb/c.h rocksdb_options_set_write_buffer_size"+  c_rocksdb_options_set_write_buffer_size :: Options -> CSize -> IO ()++foreign import ccall safe "rocksdb/c.h rocksdb_options_set_db_write_buffer_size"+  c_rocksdb_options_set_db_write_buffer_size :: Options -> CSize -> IO ()  foreign import ccall safe "rocksdb/c.h rocksdb_options_set_prefix_extractor"   c_rocksdb_options_set_prefix_extractor :: Options
src/Database/RocksDB/Internal.hs view
@@ -51,6 +51,13 @@                      , maxFiles        :: !(Maybe Int)                      , prefixLength    :: !(Maybe Int)                      , bloomFilter     :: !Bool+                     , writeBufferSize :: !(Maybe Int)+                       -- ^ bytes per memtable (RocksDB default 64 MiB);+                       -- per column family+                     , dbWriteBufferSize :: !(Maybe Int)+                       -- ^ bytes for all memtables across all column+                       -- families (RocksDB default unlimited); database-wide,+                       -- ignored in column family configs                      } deriving (Eq, Show)  instance Default Config where@@ -60,6 +67,8 @@                  , maxFiles         = Nothing                  , prefixLength     = Nothing                  , bloomFilter      = False+                 , writeBufferSize  = Nothing+                 , dbWriteBufferSize = Nothing                  }  withOptions :: Config -> (Options -> IO a) -> IO a@@ -74,6 +83,10 @@         c_rocksdb_options_set_prefix_extractor opts t     forM_ maxFiles $         c_rocksdb_options_set_max_open_files opts . intToCInt+    forM_ writeBufferSize $+        c_rocksdb_options_set_write_buffer_size opts . intToCSize+    forM_ dbWriteBufferSize $+        c_rocksdb_options_set_db_write_buffer_size opts . intToCSize     c_rocksdb_options_set_create_if_missing         opts (boolToCBool createIfMissing)     c_rocksdb_options_set_error_if_exists
test/Spec.hs view
@@ -227,3 +227,26 @@         forM_ mReadOpts destroyReadOpts         (k1, v1) `shouldBe` (Just "m", Just "10")         (k2, v2) `shouldBe` (Just "n", Just "20")+    describe "Write buffers" $ do+      it "flushes small memtables and keeps the data" $ \_ -> do+        let small =+              conf+                { writeBufferSize = Just (64 * 1024),+                  dbWriteBufferSize = Just (256 * 1024)+                }+            cfConf = small {dbWriteBufferSize = Nothing}+            key :: Int -> C.ByteString+            key i = C.pack (printf "k%07d" i)+            value = C.replicate 100 'v'+        withSystemTempDirectory "rocksdb-tests-wb" $ \path ->+          withDBCF path small [("one", cfConf), ("two", cfConf)] $ \db -> do+            let [one, two] = columnFamilies db+            forM_ [1 .. 20000] $ \i -> do+              put db (key i) value+              putCF db one (key i) value+              putCF db two (key i) value+            get db (key 1) `shouldReturn` Just value+            getCF db one (key 10000) `shouldReturn` Just value+            getCF db two (key 20000) `shouldReturn` Just value+            files <- getProperty db SSTables+            files `shouldSatisfy` maybe False (not . C.null)