def get

mylsm-lsm-store@0.6.0.1 · src/ByteDurableDb.bend:1553

import mylsm-lsm-store@0.6.0.1/src/ByteDurableDb.bend as ByteDurableDb
import Base
import bend-kit-bytes@0.3.2.0/bytes.bend as Bytes

1553# Reads one raw byte key while retaining the database handle.
1554def get(
1555  handle: Handle,
1556  key: Bytes.Bytes
1557) -> IO(Handle & Result<&1, &1, Error, Maybe<&1, Bytes.Bytes>>):
1558  match handle:
1559    case Handle{path, lock, table, Open{}, base_stats}:
1560      do IO<Handle & Result<&1, &1, Error, Maybe<&1, Bytes.Bytes>>>:
1561        pair : Handle & Result<&1, &1, Error, Maybe<&1, Bytes.Bytes>> <-
1562          get.pathcopies(path.clone.pair(path), lock, key, table)
1563        return get.retained(base_stats, pair)
1564    case Handle{path, lock, table, Poisoned{}, base_stats}:
1565      IO.pure(Handle & Result<&1, &1, Error, Maybe<&1, Bytes.Bytes>>,
1566        (Handle{path, lock, table, Poisoned{}, base_stats},
1567          Fail{CommitUnknown{0, "database handle requires reopen"}}))

Uses (14)

Used by (2)