tilie_server.routers.match_claims#
The MatchClaims route: a package’s MatchClaim table as the editor’s columns.
The editor has no Parquet reader. It posts the manifest file’s text together
with the picked match_claims.parquet; the route reads the table with
timetoalign, checks it against the manifest with TimeToShare’s table checks
and answers with the columns the editor’s anchor index takes, as raw
little-endian arrays behind a small header, which the browser views where
they lie. The repository’s decisions/0029-match-claim-columns.md fixes
the arrays and their encoding, decisions/0030-match-claims-answer.md the
bytes of the request and of the answer.
Besides the columns the answer holds every row’s beliefs, from which the editor computes the belief filter’s row mask; the route filters nothing.
A server may bound the tables it reads (TableBounds): a public
server does, since a small Parquet file can decode to a table many times its
size. Every route that reads a posted table reads it through the reader
table_reader() returns, which keeps to the server’s bounds.
pyarrow, TimeToShare’s table checks and timetoalign’s MatchClaim table are imported when a request needs them, so a server whose installed timetoalign or timetoshare lacks them still starts and answers every other route; this route then answers 501.
- tilie_server.routers.match_claims.FORMAT = 'tilie-match-claims'#
The answer’s
format.
- tilie_server.routers.match_claims.FORMAT_VERSION = 1#
The answer’s
version, the layout of ADR 0030.
- tilie_server.routers.match_claims.MEDIA_TYPE = 'application/octet-stream'#
The media type of the request and of the answer.
- tilie_server.routers.match_claims.ALIGNMENT = 8#
Every array starts at a multiple of eight bytes from the answer’s start.
- tilie_server.routers.match_claims.PREFIX = <_struct.Struct object>#
The little-endian 32-bit length opening the request and the answer.
- tilie_server.routers.match_claims.BATCH_ROWS = 1024#
The rows of a bounded table decoded at a time, each batch counted before the next is decoded.
- tilie_server.routers.match_claims.TOO_LARGE = 413#
The status of a table beyond the server’s bounds.
- class tilie_server.routers.match_claims.TableBounds(rows=None, size=None)[source]#
Bases:
objectThe most rows, and the most bytes uncompressed, of a posted table the server reads;
Nonefor no bound.- Variables:
- Parameters:
- async tilie_server.routers.match_claims.table_bounds(request)[source]#
The server’s bounds of a posted table: the dependency through which a route reading one takes them.
- Parameters:
request (Request)
- Return type:
- tilie_server.routers.match_claims.PostedTableBounds#
A route’s parameter taking the server’s bounds of a posted table.
alias of
Annotated[TableBounds,Depends(dependency=table_bounds, use_cache=True, scope=None)]
- tilie_server.routers.match_claims.bounded_table(parquet, pyarrow, data, bounds)[source]#
Read Parquet bytes into an Arrow table, within
bounds.Without bounds the file is read whole. With them, the footer is checked first, before any row is decoded: its rows (the file’s count, or the sum of its row groups’ where that is larger, since the reader follows the row groups) and its row groups’ summed
total_byte_size. The footer is the sender’s statement and measures encoded pages, so the table is then decodedBATCH_ROWSrows at a time and the bytes of the decoded batches are summed; the read stops at the batch that passes the size bound. One batch is thus decoded before it is counted.- Raises:
Refusal – 413 as
TableBounds.check_rows()andTableBounds.check_size().- Parameters:
parquet (Any)
pyarrow (Any)
data (bytes)
bounds (TableBounds)
- Return type:
- tilie_server.routers.match_claims.table_reader(bounds)[source]#
Return what reads, checks and encodes a MatchClaim table.
- Parameters:
bounds (TableBounds) – The server’s bounds of a posted table, which the reader keeps.
- Returns:
A reader of Parquet bytes into an Arrow table (
bounded_table()), the moduletimetoshare.tables, timetoalign’sMatchClaimFieldandtilie_server.claim_columns.columns_of().- Raises:
Refusal – 501, if timetoshare cannot check MatchClaim tables (it or pyarrow is missing), or timetoalign cannot read them.
- Return type:
- tilie_server.routers.match_claims.split_body(body)[source]#
Split a request into the manifest file’s bytes and the table’s.
- tilie_server.routers.match_claims.checked_table(tables, field_class, table, manifest)[source]#
The table as timetoalign reads it, once TimeToShare’s checks accept it.
The checks run on the file’s table against the manifest; timetoalign then reads the columns the table type declares (a table may hold others, which are no part of a MatchClaim) in the package form, each coordinate cell’s number written once as its
number_typesays, and gives back the same rows in that form.
- tilie_server.routers.match_claims.answer_bytes(header, arrays)[source]#
Write the answer: the header’s length, the header, then the arrays.
The first array starts at the first multiple of
ALIGNMENTafter the header; each array’s offset from there is a multiple of it too, so every array starts at a multiple of eight bytes from the answer’s start. The header names each array’s offset and number of entries. Padding is zero bytes.
- tilie_server.routers.match_claims.match_claims_answer(body, bounds)[source]#
The answer to a request’s body, its table read within
bounds.- Raises:
Refusal – As
table_reader(), its reader,split_body(),tilie_server.manifests.read_manifest()andchecked_table().- Parameters:
body (bytes)
bounds (TableBounds)
- Return type:
- tilie_server.routers.match_claims.match_claims(body, bounds)[source]#
Answer the columns of the posted MatchClaim table, checked against the posted manifest.
The body is the manifest file’s length in bytes (a little-endian 32-bit integer), the manifest file’s text in any serialization, then the Parquet file. A body that cannot be split or read, or a table the checks refuse, is answered 422 with
{"detail": {"path", "message"}}, a refused table withproblemsbesides (each{code, row, column, message}, the checks’ own); a table beyond the server’s bounds 413 in the same form; a server that cannot read or check MatchClaim tables, or read manifest files, 501.- Parameters:
body (Annotated[bytes, Depends(dependency=~tilie_server.manifests.posted_body, use_cache=True, scope=function)])
bounds (Annotated[TableBounds, Depends(dependency=~tilie_server.routers.match_claims.table_bounds, use_cache=True, scope=None)])
- Return type:
Response