ecluse:ecluse-core
Safe HaskellNone
LanguageGHC2021

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

The format

opNull :: Word8 Source #

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.

opFalse :: Word8 Source #

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.

opTrue :: Word8 Source #

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.

opShared :: Word8 Source #

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.

opObject :: Word8 Source #

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.

opArray :: Word8 Source #

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.

opInline :: Word8 Source #

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.

valueEnd :: ByteArray -> Int -> Int Source #

The position after the value that starts at a position.

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

data DocTable Source #

One document's shared strings, back to back as aeson writes them, and where each begins.

Instances

Instances details
Show DocTable Source # 
Instance details

Defined in Ecluse.Core.Registry.Json.Packed

Eq DocTable Source # 
Instance details

Defined in Ecluse.Core.Registry.Json.Packed

docTable :: SmallArray Text -> DocTable Source #

Lay out the table from its strings in index order.

tableResident :: DocTable -> Int Source #

The heap bytes the table holds: its record, and its two arrays with their headers.

Packed values

data Packed Source #

Opcodes over a sealed read table, the string-hole offset (-1 for none), and the original encoded length.

Instances

Instances details
Show Packed Source # 
Instance details

Defined in Ecluse.Core.Registry.Json.Packed

Eq Packed Source # 
Instance details

Defined in Ecluse.Core.Registry.Json.Packed

Methods

(==) :: Packed -> Packed -> Bool #

(/=) :: Packed -> Packed -> Bool #

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

data UrlPrefix Source #

Aeson's encoded prefix bytes without quotes, inserted before the filename when rebasing a URL hole.

Instances

Instances details
Show UrlPrefix Source # 
Instance details

Defined in Ecluse.Core.Registry.Json.Packed

Eq UrlPrefix Source # 
Instance details

Defined in Ecluse.Core.Registry.Json.Packed

urlPrefix :: Text -> UrlPrefix Source #

Encode a prefix once for every hole a render rebases.

data Piece Source #

One packed value in a render, and the index of the plan's table its own document's read sealed.

Constructors

Piece !Int !Packed 

Instances

Instances details
Show Piece Source # 
Instance details

Defined in Ecluse.Core.Registry.Json.Packed

Methods

showsPrec :: Int -> Piece -> ShowS #

show :: Piece -> String #

showList :: [Piece] -> ShowS #

Eq Piece Source # 
Instance details

Defined in Ecluse.Core.Registry.Json.Packed

Methods

(==) :: Piece -> Piece -> Bool #

(/=) :: Piece -> Piece -> Bool #

data Pieces Source #

Object members sorted by key without duplicates, or array items. Both render in list order.

Constructors

ObjectPieces ![(Text, Piece)] 
ArrayPieces ![Piece] 

Instances

Instances details
Show Pieces Source # 
Instance details

Defined in Ecluse.Core.Registry.Json.Packed

Eq Pieces Source # 
Instance details

Defined in Ecluse.Core.Registry.Json.Packed

Methods

(==) :: Pieces -> Pieces -> Bool #

(/=) :: Pieces -> Pieces -> Bool #

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.

Instances

Instances details
Show RenderPlan Source # 
Instance details

Defined in Ecluse.Core.Registry.Json.Packed

Eq RenderPlan Source # 
Instance details

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.

data LinePlan Source #

Ordered native records reference their source tables without a JSON envelope or URL holes.

Constructors

LinePlan 

Instances

Instances details
Show LinePlan Source # 
Instance details

Defined in Ecluse.Core.Registry.Json.Packed

Eq LinePlan Source # 
Instance details

Defined in Ecluse.Core.Registry.Json.Packed

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.

Methods

tableValue :: t st -> Int -> ST st Value Source #

tableKey :: t st -> Int -> ST st Key Source #

Instances

Instances details
TableStrings Writer Source # 
Instance details

Defined in Ecluse.Core.Registry.Json.Writer

Methods

tableValue :: Writer st -> Int -> ST st Value Source #

tableKey :: Writer st -> Int -> ST st Key Source #

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.

decodeScalar :: ByteArray -> Int -> Int -> Value Source #

Decode aeson's string or number bytes, preserving a number's exponent or fraction encoding on re-encoding.

packedValue :: DocTable -> Packed -> Maybe Value Source #

The value back as aeson's tree, or nothing when it names a string its table lacks.