Copyright | (c) CNRS 2017-Present |
---|---|
License | AGPL + CECILL v3 |
Maintainer | team@gargantext.org |
Stability | experimental |
Portability | POSIX |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
A Node Story is a Map between NodeId and an Archive (with state, version and history) for that node.
Couple of words on how this is implemented.
First version used files which stored Archive for each NodeId in a separate .cbor file.
For performance reasons, it is rewritten to use the DB.
The table node_stories
contains two columns: node_id
and
archive
.
Next, it was observed that a_history
in Archive
takes much
space. So a new table was created, node_story_archive_history
with
columns: node_id
, ngrams_type_id
, patch
. This is because each
history item is in fact a map from NgramsType
to NgramsTablePatch
(see the NgramsStatePatch'
type).
Moreover, since in commitStatePatch
we use current state
only, with only recent history items, I concluded that it is not
necessary to load whole history into memory. Instead, it is kept in DB
(history is immutable) and only recent changes are added to
a_history
. Then that record is cleared whenever Archive
is saved.
Please note that
TODO: - remove - filter - charger les listes
Synopsis
- module Gargantext.Core.NodeStory.Types
- getNodesArchiveHistory :: Connection -> [NodeId] -> IO [(NodeId, Map NgramsType [HashMap NgramsTerm NgramsPatch])]
- data Archive s p = Archive {
- _a_version :: !Version
- _a_state :: !s
- _a_history :: ![p]
- nodeExists :: Connection -> NodeId -> IO Bool
- getNodesIdWithType :: Connection -> NodeType -> IO [NodeId]
- fromDBNodeStoryEnv :: Pool Connection -> IO NodeStoryEnv
- upsertNodeStories :: Connection -> NodeId -> ArchiveList -> IO ()
- getNodeStory' :: Connection -> NodeId -> IO ArchiveList
- nodeStoriesQuery :: Query
- currentVersion :: HasNodeStory env err m => ListId -> m Version
- archiveStateFromList :: ArchiveStateList -> NgramsState'
- archiveStateToList :: NgramsState' -> ArchiveStateList
- fixNodeStoryVersions :: HasNodeStory env err m => m ()
- fixChildrenDuplicatedAsParents :: NgramsState' -> NgramsState'
- getParentsChildren :: NgramsState' -> (ArchiveStateList, ArchiveStateList)
Documentation
getNodesArchiveHistory :: Connection -> [NodeId] -> IO [(NodeId, Map NgramsType [HashMap NgramsTerm NgramsPatch])] #
Archive | |
|
Instances
nodeExists :: Connection -> NodeId -> IO Bool #
getNodesIdWithType :: Connection -> NodeType -> IO [NodeId] #
upsertNodeStories :: Connection -> NodeId -> ArchiveList -> IO () #
getNodeStory' :: Connection -> NodeId -> IO ArchiveList #
currentVersion :: HasNodeStory env err m => ListId -> m Version #
archiveStateToList :: NgramsState' -> ArchiveStateList #
Functions to convert archive state (which is a `Map NgramsType (Map NgramsTerm NgramsRepoElement`)) to/from a flat list
fixNodeStoryVersions :: HasNodeStory env err m => m () #
To be called from the REPL
fixChildrenDuplicatedAsParents :: NgramsState' -> NgramsState' #
Sometimes children can also become parents (e.g. #313). Find such | children and remove them from the list.