| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Ecluse.Core.Registry.Json.Packed
Description
The packed form: one table per document holding the bytes aeson writes for each shared string, and one opcode blob per retained value. A render copies those bytes into a buffer of the output's exact length, so no string is escaped again. A value holds at most one hole: a URL string that a render may rebase onto a per-request prefix, keeping the URL's file name.
Synopsis
- encodeString :: Text -> ByteString
- encodedLength :: Text -> Int
- writeEncoded :: Text -> MutableByteArray st -> Int -> ST st Int
- plain :: Text -> Bool
- quote :: Word8
- opNull :: Word8
- opFalse :: Word8
- opTrue :: Word8
- opShared :: Word8
- opObject :: Word8
- opArray :: Word8
- opInline :: Word8
- varintSize :: Int -> Int
- readVarint :: ByteArray -> Int -> (# Int, Int #)
- writeVarint :: Int -> MutableByteArray st -> Int -> ST st Int
- valueEnd :: ByteArray -> Int -> Int
- data DocTable
- docTable :: SmallArray Text -> DocTable
- tableResident :: DocTable -> Int
- data Packed
- packed :: ByteArray -> Int -> Packed
- packedBlob :: Packed -> ByteArray
- packedBytes :: Packed -> Int
- packedResident :: Packed -> Int
- withoutHole :: Packed -> Packed
- data UrlPrefix
- urlPrefix :: Text -> UrlPrefix
- data Piece = Piece !Int !Packed
- data Pieces
- = ObjectPieces ![(Text, Piece)]
- | ArrayPieces ![Piece]
- data RenderPlan = RenderPlan {
- planMembers :: !(KeyMap Value)
- planSlot :: !Key
- planTables :: !(SmallArray DocTable)
- planPieces :: !Pieces
- planPrefix :: !(Maybe UrlPrefix)
- renderPlan :: RenderPlan -> Maybe ByteString
- planValue :: RenderPlan -> Maybe Value
- planResident :: RenderPlan -> Int
- class TableStrings (t :: Type -> Type) where
- decodeWith :: TableStrings t => t st -> ByteArray -> PrimVar st Int -> ST st Value
- decodeKeyWith :: TableStrings t => t st -> ByteArray -> PrimVar st Int -> ST st Key
- decodeScalar :: ByteArray -> Int -> Int -> Value
- packedValue :: DocTable -> Packed -> Maybe Value
Encoded strings
encodeString :: Text -> ByteString Source #
The bytes aeson writes for a string, quotes included: encodedLength of them.
encodedLength :: Text -> Int Source #
The length of encodeString, from the escape writeEncoded writes for each byte.
writeEncoded :: Text -> MutableByteArray st -> Int -> ST st Int Source #
Write encodeString at an offset, and return the offset after it.
plain :: Text -> Bool Source #
Whether aeson writes the string's bytes as they are: no backslash, quote or byte below a space.
The format
Each value's first byte. A table index, a count, or an inline length and aeson's bytes follow. A member key is twice its table index, or twice its inline length plus one followed by its bytes.
Each value's first byte. A table index, a count, or an inline length and aeson's bytes follow. A member key is twice its table index, or twice its inline length plus one followed by its bytes.
Each value's first byte. A table index, a count, or an inline length and aeson's bytes follow. A member key is twice its table index, or twice its inline length plus one followed by its bytes.
Each value's first byte. A table index, a count, or an inline length and aeson's bytes follow. A member key is twice its table index, or twice its inline length plus one followed by its bytes.
Each value's first byte. A table index, a count, or an inline length and aeson's bytes follow. A member key is twice its table index, or twice its inline length plus one followed by its bytes.
Each value's first byte. A table index, a count, or an inline length and aeson's bytes follow. A member key is twice its table index, or twice its inline length plus one followed by its bytes.
Each value's first byte. A table index, a count, or an inline length and aeson's bytes follow. A member key is twice its table index, or twice its inline length plus one followed by its bytes.
varintSize :: Int -> Int Source #
The bytes a varint of the integer takes.
readVarint :: ByteArray -> Int -> (# Int, Int #) Source #
The varint at a position, and the position after it.
writeVarint :: Int -> MutableByteArray st -> Int -> ST st Int Source #
Write the integer's varint at an offset, and return the offset after it.
The document table
One document's shared strings, back to back as aeson writes them, and where each begins.
tableResident :: DocTable -> Int Source #
The heap bytes the table holds: its record, and its two arrays with their headers.
Packed values
One retained value: its opcodes, and where its hole's string starts, or -1.
packed :: ByteArray -> Int -> Packed Source #
A value from its opcodes and the position of its hole, or -1 for none.
packedBlob :: Packed -> ByteArray Source #
The value's opcodes.
packedBytes :: Packed -> Int Source #
The bytes the value holds itself, outside its table.
packedResident :: Packed -> Int Source #
The heap bytes the value holds itself: its record, and its blob with the array's header.
withoutHole :: Packed -> Packed Source #
The value with no hole, so every render writes it as read.
Rendering
A URL prefix a render writes in place of a hole's URL, before the URL's file name: the bytes aeson writes for its characters, quotes excluded.
One packed value in a render, and the index of the plan's table its own document's read sealed.
Instances
The packed member of a rendered document: an object's members, sorted by key with no key twice, or an array's items. A render writes them in list order.
Constructors
| ObjectPieces ![(Text, Piece)] | |
| ArrayPieces ![Piece] |
data RenderPlan Source #
An assembled document: small members aeson encodes, and one member that renders from pieces over its sources' tables, each hole rebased onto the prefix when the document rebases.
Constructors
| RenderPlan | |
Fields
| |
Instances
| Show RenderPlan Source # | |
Defined in Ecluse.Core.Registry.Json.Packed Methods showsPrec :: Int -> RenderPlan -> ShowS # show :: RenderPlan -> String # showList :: [RenderPlan] -> ShowS # | |
| Eq RenderPlan Source # | |
Defined in Ecluse.Core.Registry.Json.Packed | |
renderPlan :: RenderPlan -> Maybe ByteString Source #
Render an assembled document into one buffer of its exact length, or nothing when a piece names a table or string the plan lacks, or the render does not fill the buffer exactly.
planValue :: RenderPlan -> Maybe Value Source #
The assembled document as aeson's tree, as its render writes it, or nothing when a piece names a table or string the plan lacks.
planResident :: RenderPlan -> Int Source #
The heap bytes the plan's tables and pieces hold, each piece with its list cell, record and key.
Reading back
class TableStrings (t :: Type -> Type) where Source #
Where a decode finds the string and the key a table index names.
decodeWith :: TableStrings t => t st -> ByteArray -> PrimVar st Int -> ST st Value Source #
Read the value at the position the variable holds back as aeson's tree, and move the variable past it. The strings resolve a table index to its string and to its key.
decodeKeyWith :: TableStrings t => t st -> ByteArray -> PrimVar st Int -> ST st Key Source #
The member key at the position the variable holds, moving the variable to its value.