| Safe Haskell | None |
|---|---|
| Language | GHC2021 |
Ecluse.Core.Registry.Json.Packed
Description
Opcode values with shared encoded strings and precomputed output lengths. A value can retain one URL hole for rebasing while preserving its filename.
Synopsis
- 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
- separators :: Int -> Int
- data DocTable
- docTable :: SmallArray Text -> DocTable
- tableResident :: DocTable -> Int
- data Packed
- packed :: ByteArray -> Int -> Int -> Packed
- packedBlob :: Packed -> ByteArray
- packedBytes :: Packed -> Int
- packedEncodedLength :: Packed -> Int
- packedResident :: Packed -> Int
- withoutHole :: Packed -> Packed
- hasHole :: Packed -> Bool
- 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
- data LinePlan = LinePlan {
- lineTables :: !(SmallArray DocTable)
- linePieces :: ![Piece]
- renderPackedLines :: LinePlan -> Maybe ByteString
- linePlanValues :: LinePlan -> Maybe [Value]
- linePlanResident :: LinePlan -> 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
The format
Value tags precede table indices, counts or inline lengths and aeson's bytes. Keys encode twice their table index, or twice their inline length plus one followed by bytes.
Value tags precede table indices, counts or inline lengths and aeson's bytes. Keys encode twice their table index, or twice their inline length plus one followed by bytes.
Value tags precede table indices, counts or inline lengths and aeson's bytes. Keys encode twice their table index, or twice their inline length plus one followed by bytes.
Value tags precede table indices, counts or inline lengths and aeson's bytes. Keys encode twice their table index, or twice their inline length plus one followed by bytes.
Value tags precede table indices, counts or inline lengths and aeson's bytes. Keys encode twice their table index, or twice their inline length plus one followed by bytes.
Value tags precede table indices, counts or inline lengths and aeson's bytes. Keys encode twice their table index, or twice their inline length plus one followed by bytes.
Value tags precede table indices, counts or inline lengths and aeson's bytes. Keys encode twice their table index, or twice their inline length plus one followed by 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.
separators :: Int -> Int Source #
The bytes an object or array of the given count encodes beside its members: two brackets and a comma between each pair.
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
Opcodes over a sealed read table, the string-hole offset (-1 for none), and the original encoded length.
packed :: ByteArray -> Int -> Int -> Packed Source #
A value from its opcodes, the position of its hole, or -1 for none, and the length of its encoding as read.
packedBlob :: Packed -> ByteArray Source #
The value's opcodes.
packedBytes :: Packed -> Int Source #
The bytes the value holds itself, outside its table.
packedEncodedLength :: Packed -> Int Source #
The bytes a render writes for the value with no hole rebased, as the writer measured them at its seal.
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.
hasHole :: Packed -> Bool Source #
Whether the value carries a string at its configured rewrite path.
Rendering
Aeson's encoded prefix bytes without quotes, inserted before the filename when rebasing a URL hole.
One packed value in a render, and the index of the plan's table its own document's read sealed.
Instances
Object members sorted by key without duplicates, or array items. Both render in list order.
Constructors
| ObjectPieces ![(Text, Piece)] | |
| ArrayPieces ![Piece] |
data RenderPlan Source #
Small members encoded by aeson and one packed member over source tables, with each URL hole rebased onto the plan's prefix.
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 #
Write one buffer of the exact output length. Refuse missing tables or strings and a buffer the render does not fill exactly.
planValue :: RenderPlan -> Maybe Value Source #
The tree the plan renders, or Nothing for missing tables or strings.
planResident :: RenderPlan -> Int Source #
The heap bytes the plan's tables and pieces hold, each piece with its list cell, record and key.
Ordered native records reference their source tables without a JSON envelope or URL holes.
Constructors
| LinePlan | |
Fields
| |
renderPackedLines :: LinePlan -> Maybe ByteString Source #
Emit each record followed by LF, refusing missing tables, strings or an inexact buffer fill.
linePlanValues :: LinePlan -> Maybe [Value] Source #
Materialise a native line plan only for callers that need tree access.
linePlanResident :: LinePlan -> Int Source #
Charge source tables once and every retained packed record and list cell.
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 #
Decode the value at the cursor and advance past it. Table indices resolve through TableStrings to strings and keys.
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.