Skip to content

Commit 93a2cf6

Browse files
authored
Merge pull request #10 from input-output-hk/dcoutts/haddocks
Add miscelaneous haddock doc improvements to the normal API
2 parents 64968e0 + 6e7c61a commit 93a2cf6

File tree

3 files changed

+225
-53
lines changed

3 files changed

+225
-53
lines changed

.stylish-haskell.yaml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@ steps:
2121
# Currently, this option is not configurable and will format all exports and
2222
# module declarations to minimize diffs
2323
#
24-
- module_header:
24+
#- module_header:
2525
# # How many spaces use for indentation in the module header.
26-
indent: 2
26+
# indent: 2
2727
#
2828
# # Should export lists be sorted? Sorting is only performed within the
2929
# # export section, as delineated by Haddock comments.
30-
sort: False
30+
# sort: False
3131
#
3232
# # See `separate_lists` for the `imports` step.
33-
separate_lists: true
33+
# separate_lists: true
3434
#
3535
# # When to break the "where".
3636
# # Possible values:
@@ -40,14 +40,14 @@ steps:
4040
# # determined by the `columns` setting. Not applicable when the export
4141
# # list contains comments as newlines will be required.
4242
# # - always: always break before the "where".
43-
break_where: single
43+
# break_where: single
4444
#
4545
# # Where to put open bracket
4646
# # Possible values:
4747
# # - same_line: put open bracket on the same line as the module name, before the
4848
# # comment of the module
4949
# # - next_line: put open bracket on the next line, after module comment
50-
open_bracket: same_line
50+
# open_bracket: same_line
5151

5252
# Format record definitions. This is disabled by default.
5353
#
@@ -510,4 +510,4 @@ language_extensions:
510510
#
511511
# We run stylish from the root of the repo which is a project so this flag
512512
# doesn't apply
513-
cabal: false
513+
cabal: false

src/Database/LSMTree/Common.hs

Lines changed: 51 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,30 +43,71 @@ instance IOLike IO
4343
Sessions
4444
-------------------------------------------------------------------------------}
4545

46-
-- | Context shared across multiple table handles, like counters and filesystem
47-
-- information.
46+
-- | A session provides context that is shared across multiple table handles.
4847
--
49-
-- For one, this is necessary if we want to be able to manipulate and query
50-
-- table handles, duplicate table handles, and load snapshots, all at the same
51-
-- time in the same directory.
48+
-- Sessions are needed to support sharing between multiple table instances.
49+
-- Sharing occurs when tables are duplicated using 'duplicate', or when tables
50+
-- are combined using 'union'. Sharing is preserved by snapshots, using
51+
-- 'snapshot' and 'open'.
52+
--
53+
-- The \"monoidal\" table types support a 'union' operation, which has the
54+
-- constraint that the two input tables must be from the same 'Session'.
55+
--
56+
-- Each session places files for table data under a given directory. It is
57+
-- not permitted to open multiple sessions for the same directory at once.
58+
-- Instead a session should be opened once and shared for all uses of
59+
-- tables. This restriction implies that tables cannot be shared between OS
60+
-- processes. The restriction is enforced using file locks.
61+
--
62+
-- Sessions support both related and independent tables. Related tables are
63+
-- created using 'duplicate', while independent tables can be created using
64+
-- 'new'. It is possible to have multiple independent tables with different
65+
-- configuration and key and value types in the same session. Similarly,
66+
-- a session can have both \"normal\" and \"monoidal\" tables. For independent
67+
-- tables (that are not involved in a 'union') one has a choice between using
68+
-- multiple sessions or a shared session. Using multiple sessions requires
69+
-- using separate directories, while a shared session will place all files
70+
-- under one directory.
5271
--
53-
-- Different types of tables can be live in the same session, but operations
54-
-- like 'merge' only work for __compatible__ tables: tables that belong to the
55-
-- same session, store the same key and value types, and have the same
56-
-- configuration parameters.
5772
type Session :: (Type -> Type) -> Type
5873
data Session m = Session {
5974
sessionRoot :: !FsPath
6075
, sessionHasFS :: !(SomeHasFS m)
6176
}
6277

78+
-- | Create either a new empty table session or open an existing table session,
79+
-- given the path to the session directory.
80+
--
81+
-- A new empty table session is created if the given directory is entirely
82+
-- empty. Otherwise it is intended to open an existing table session.
83+
--
84+
-- Exceptions:
85+
--
86+
-- * This can throw exceptions if the directory does not have the expected file
87+
-- layout for a table session
88+
-- * It will throw an exception if the session is already open (in the current
89+
-- process or another OS process)
90+
--
91+
-- Sessions should be closed using 'closeSession' when no longer needed.
92+
--
6393
newSession ::
6494
IOLike m
6595
=> SomeHasFS m
66-
-> FsPath -- ^ Path to an empty directory.
96+
-> FsPath -- ^ Path to the session directory
6797
-> m (Session m)
6898
newSession = undefined
6999

100+
-- | Close the table session.
101+
--
102+
-- This also closes any open table handles in the session. It would typically
103+
-- be good practice however to close all table handles first rather than
104+
-- relying on this for cleanup.
105+
--
106+
-- Closing a table session allows the session to be opened again elsewhere, for
107+
-- example in a different process. Note that the session will be closed
108+
-- automatically if the processes is terminated (in particular the session file
109+
-- lock will be released).
110+
--
70111
closeSession :: IOLike m => Session m -> m ()
71112
closeSession = undefined
72113

0 commit comments

Comments
 (0)