Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update algorithms to use new processing model. #30

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

wes-smith
Copy link
Contributor

@wes-smith wes-smith commented Aug 27, 2024

Comment on lines +594 to +596
In this section we specify the algorithms required to convert JSON-LD to CBOR-LD
and vice versa. We first provide the context processing algorithms, which are required
for both decompression and compression, then provide the mode-specific algorithms.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In this section we specify the algorithms required to convert JSON-LD to CBOR-LD
and vice versa. We first provide the context processing algorithms, which are required
for both decompression and compression, then provide the mode-specific algorithms.
In this section, we specify the algorithms required to convert JSON-LD to CBOR-LD
and vice versa. We provide first the context processing algorithms, which are required
for both decompression and compression; we then provide the mode-specific algorithms.

Comment on lines +601 to +604
that is needed to compress or decompress to/from CBOR-LD. During compression and decompression, the
<a href="top-level-term-codec-map-generation-algorithm"></a> is run once during setup, and the
<a href="update-term-codec-map-with-type-scoped-context-algorithm"></a> and
<a href="update-term-codec-map-with-property-scoped-context-algorithm"></a> are run on an as-needed basis.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
that is needed to compress or decompress to/from CBOR-LD. During compression and decompression, the
<a href="top-level-term-codec-map-generation-algorithm"></a> is run once during setup, and the
<a href="update-term-codec-map-with-type-scoped-context-algorithm"></a> and
<a href="update-term-codec-map-with-property-scoped-context-algorithm"></a> are run on an as-needed basis.
that is needed to compress to or decompress from CBOR-LD. For compression and decompression, the
<a href="top-level-term-codec-map-generation-algorithm"></a> is run once during setup, and the
<a href="update-term-codec-map-with-type-scoped-context-algorithm"></a> and
<a href="update-term-codec-map-with-property-scoped-context-algorithm"></a> are run on an as-needed basis.

<section>
<h2>Top-level Term Codec Map Generation Algorithm</h2>
<p>
This algorithm takes a map `typeTable` and an array of JSON-LD contexts `contexts` and
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be like the other algorithms, with ({datatype} {name}) or similar for each input and output?

Suggested change
This algorithm takes a map `typeTable` and an array of JSON-LD contexts `contexts` and
This algorithm takes a map `typeTable` and an array of JSON-LD contexts `contexts` as inputs, and

<li>Let `termToEncodedValue` be an ordered map.</li>
<li>
For each value in `contextUrls`, dereference the JSON-LD contexts and process
every entry at the top level (i.e. ignoring type and property-scoped contexts).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the parenthetical meant to be read as ignoring type-scoped and property-scoped contexts? or ignoring (type) and (property-scoped contexts)? or something else? I'm guessing it's the first, which calls for the addition of this hyphen —

Suggested change
every entry at the top level (i.e. ignoring type and property-scoped contexts).
every entry at the top level (i.e., ignoring type- and property-scoped contexts).

</ol>
</li>
<li>
Sort the keys in `termToEncodedValue` by value.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sort order should be more explicit. I'm guessing it should be by codepoint value, which sometimes means we need to force a codepage or call for it to be declared (e.g., UTF-8, UTF-16, UTF-32, etc.)....

<li>
For each entry in the typeTables array in the CBOR-LD Varint Registry Entry associated with
`registryEntryId`, dereference the URL if necessary and add ${type}: ${table} from the resulting
document to `typeTable`. If "callerProvidedTable" appears in contextTables, populate `typeTables`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
document to `typeTable`. If "callerProvidedTable" appears in contextTables, populate `typeTables`
document to `typeTable`. If "callerProvidedTable" appears in `contextTables`, populate `typeTables`

<section>
<h2>Get CBOR-LD Registry Entry ID Algorithm</h2>
<p>
This algorithm takes a CBOR-LD payload `cborldBytes` as input and returns
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This algorithm takes a CBOR-LD payload `cborldBytes` as input and returns
This algorithm takes a CBOR-LD payload `cborldBytes` as input, and returns

Comment on lines +911 to +915
If the CBOR tag on `cborldBytes` is not in the range `0x0600-0x06FF`, throw an
ERR_NON_CBOR_LD_TAG error.
</li>
<li>
Otherwise if the CBOR tag on `cborldBytes` is in the range `0x0600-0x067F`, set `registryEntryId` to
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If the CBOR tag on `cborldBytes` is not in the range `0x0600-0x06FF`, throw an
ERR_NON_CBOR_LD_TAG error.
</li>
<li>
Otherwise if the CBOR tag on `cborldBytes` is in the range `0x0600-0x067F`, set `registryEntryId` to
If the CBOR tag on `cborldBytes` is not in the range `0x0600`–`0x06FF`, throw an
`ERR_NON_CBOR_LD_TAG` error.
</li>
<li>
Otherwise if the CBOR tag on `cborldBytes` is in the range `0x0600`–`0x067F`, set `registryEntryId` to

<ol>
<li>
If the last byte of the CBOR tag does not form the first byte of a valid varint, throw an
ERR_INVALID_VARINT_VALUE error.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ERR_INVALID_VARINT_VALUE error.
`ERR_INVALID_VARINT_VALUE` error.

Generate Decompressed JSON-LD Algorithm
</h2>
<p>
This algorithm takes as input CBOR-LD payload `cborldBytes` and a map `typeTable` and returns a JSON-LD document.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This algorithm takes as input CBOR-LD payload `cborldBytes` and a map `typeTable` and returns a JSON-LD document.
This algorithm takes a CBOR-LD payload `cborldBytes` and a map `typeTable` as inputs, and returns a JSON-LD document.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants