streamly-lmdb: Stream data to or from LMDB databases using the streamly library.

This is a package candidate release! Here you can preview how this package release will appear once published to the main package index (which can be accomplished via the 'maintain' link below). Please note that once a package has been published to the main package index it cannot be undone! Please consult the package uploading documentation for more information.

[maintain] [Publish]

Please see the README on GitHub at https://github.com/shlok/streamly-lmdb#readme


[Skip to Readme]

Properties

Versions 0.0.1, 0.0.1.1, 0.1.0, 0.2.0, 0.2.1, 0.3.0, 0.4.0, 0.5.0, 0.6.0, 0.7.0, 0.8.0, 0.8.0
Change log ChangeLog.md
Dependencies base (>=4.7 && <5), bytestring (>=0.10.10.0 && <0.12), containers (>=0.6.5.1 && <0.7), directory (>=1.3.6.0 && <1.4), lifted-base (>=0.2.3.12 && <0.3), monad-control (>=1.0.3.1 && <1.1), safe-exceptions (>=0.1.7.3 && <0.2), stm (>=2.5.0.2 && <2.6), streamly (>=0.10.0 && <0.11), streamly-core (>=0.2.0 && <0.3) [details]
License BSD-3-Clause
Copyright 2024 Shlok Datye
Author Shlok Datye
Maintainer sd-haskell@quant.is
Category Database, Streaming, Streamly
Home page https://github.com/shlok/streamly-lmdb
Bug tracker https://github.com/shlok/streamly-lmdb/issues
Source repo head: git clone https://github.com/shlok/streamly-lmdb
Uploaded by shlok at 2024-10-07T03:55:12Z

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees


Readme for streamly-lmdb-0.8.0

[back to package description]

streamly-lmdb

Hackage CI

Stream data to or from LMDB databases using the Haskell streamly library.

Requirements

Install LMDB on your system:

Quick start

{-# LANGUAGE OverloadedStrings #-}

module Main where

import Data.Function
import qualified Streamly.Data.Fold as F
import qualified Streamly.Data.Stream.Prelude as S
import Streamly.External.LMDB

main :: IO ()
main = do
  -- Open an environment. There should already exist a file or
  -- directory at the given path. (Empty for a new environment.)
  env <-
    openEnvironment
      "/path/to/lmdb-database"
      defaultLimits {mapSize = tebibyte}

  -- Get the main database.
  -- Note: It is common practice with LMDB to create the database
  -- once and reuse it for the remainder of the program’s execution.
  db <- getDatabase env Nothing

  -- Stream key-value pairs into the database.
  withReadWriteTransaction env $ \txn ->
    [("baz", "a"), ("foo", "b"), ("bar", "c")]
      & S.fromList
      & S.fold (writeLMDB defaultWriteOptions db txn)

  -- Stream key-value pairs out of the
  -- database, printing them along the way.
  -- Output:
  --     ("bar","c")
  --     ("baz","a")
  --     ("foo","b")
  S.unfold readLMDB (defaultReadOptions, db, LeftTxn Nothing)
    & S.mapM print
    & S.fold F.drain

Benchmarks

See bench/README.md. Summary (with rough figures from our machine):

September 2024; NixOS 24.11; Intel i7-12700K (3.6 GHz, 12 cores); Corsair VENGEANCE LPX DDR4 RAM 64GB (2 x 32GB) 3200MHz; Samsung 970 EVO Plus SSD 2TB (M.2 NVMe).