| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Ecluse.Core.Registry.Json.Intern
Contents
Description
The first copy of each key and string that one document's retained values hold, found by the bytes the lexer read before any text is built. Keep one table per read and drop it when the read ends, so no table outlives the document it serves. The table hashes with SipHash-1-3 under a key drawn for its read, so upstream text cannot choose which names collide.
Synopsis
- data Name = Plain !ByteString
- decodedName :: Text -> Name
- foldName :: (ByteString -> a) -> (Text -> a) -> Name -> a
- nameText :: Name -> Text
- nameBytes :: Name -> ByteString
- data InternTable
- data SipKey = SipKey !Word64 !Word64
- newTableKey :: IO SipKey
- newInternTable :: SipKey -> [Text] -> InternTable
- data Entry
- entryText :: Entry -> Text
- entryString :: Entry -> Value
- entryKeeps :: Entry -> Bool
- entryIndex :: Entry -> Int
- data Interned = Interned !Entry !InternTable
- internName :: Name -> InternTable -> Interned
- tableTexts :: InternTable -> SmallArray Text
- sipHash :: Int -> Int -> SipKey -> ByteString -> Word64
Names as read
A member name or string as the lexer read it: plain ASCII bytes, or text decoded from escapes or UTF-8.
Constructors
| Plain !ByteString |
decodedName :: Text -> Name Source #
A name decoded from escapes or UTF-8. Its bytes are encoded once, when first asked for.
foldName :: (ByteString -> a) -> (Text -> a) -> Name -> a Source #
Take a name as its plain ASCII bytes or as its decoded text.
nameText :: Name -> Text Source #
The name's text on an array of its own. Plain bytes are copied, so no text keeps its input chunk.
nameBytes :: Name -> ByteString Source #
The name's UTF-8 bytes. Plain bytes are the input's own, so hold them only for the current lookup.
The table
data InternTable Source #
One read's table and its entry count. Each entry's text is also its key, and each key carries its hash.
newTableKey :: IO SipKey Source #
A fresh key for one read's table, so no key outlives the table it seeds.
newInternTable :: SipKey -> [Text] -> InternTable Source #
A table for one document that keeps the values of the named members as read. Name the members whose values differ in every release or file, so they never enter the table.
One table entry: the shared text, its shared string value, whether a member's value is kept as read, and its index. Only a table makes one, so every index lies within its table.
entryString :: Entry -> Value Source #
The entry's text as its shared string value.
entryKeeps :: Entry -> Bool Source #
Whether a member of this name keeps its value as read.
entryIndex :: Entry -> Int Source #
The entry's index, which lies within the table that made it.
The table's entry for a name, with the table that holds it.
Constructors
| Interned !Entry !InternTable |
internName :: Name -> InternTable -> Interned Source #
The table's entry for a name. A name the table lacks gets an entry of its own text, which the returned table holds from then on.
tableTexts :: InternTable -> SmallArray Text Source #
Every entry's text in index order. Each index below the table's count holds exactly one entry.