Alternative map sorting
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 25/100
- issue の種類
- 機能追加
- 明瞭さ
- 説明が足りない
- 活発さ
- 停滞
- 技術スタック
- c
- 領域
- embedded-iot
調査の方向性
cborvalidation.c の 475 行目付近から始め、既存の map のソートおよび一意性のフラグを確認してください。代替ソートが現在の動作を置き換えるべきか補完すべきかを明確にし、その後、想定される順序、キーの扱い、重複キーの動作を定義してください。完了には、合意された設計と実装範囲が必要です。
索引モデルが issue の本文から書いたものです。
説明
Hello,
I've been looking into the CBOR validator and how maps are considered as sorted or not. In another project, I have previously been using another serialization standard that strictly defines maps in another way. Such as keys must only be strings, keys must be stored in lexicographical order and that no duplicates are allowed. Now we are looking into changing to cbor.
The CBOR specification does not strictly specifies what an ordered map is, but recommends that they should also be sorted in length. Meaning that "aa" > "b".
The alternatives are:
- Change sorting specification in our protocol (to order the fields like CBOR specification recommends)
- Not having sorted maps
- Finding/adapting a cbor library to allow for alternative sorting
Sorting is nice since is allows for linear parsing. Since we rely on this, we cannot directly swap to cbor. I would like to start a discussion of supporting an alternative sorting in tinycbor.
Wrote a short proof of concept for this (removes old sorting behavior) cborvalidation.c:475:
if (flags & CborValidateMapIsSorted) {
if (previous) {
uint64_t len1, len2;
const uint8_t *ptr;
/* extract the two lengths */
ptr = previous;
_cbor_value_extract_number(&ptr, it->parser->end, &len1);
ptr = current;
_cbor_value_extract_number(&ptr, it->parser->end, &len2);
size_t bytelen1 = (size_t)(previous_end - previous);
size_t bytelen2 = (size_t)(it->ptr - current);
/*
* Offset of actual key value (not including type information) is bytelenX - lenX??
* What if key value is indefinite??
*/
int r = memcmp(&previous[bytelen1 - len1], ¤t[bytelen2 - len2], len1 <= len2 ? len1 : len2);
if (r == 0 && len1 != len2)
r = len1 < len2 ? -1 : +1;
if (r > 0)
return CborErrorMapNotSorted;
if (r == 0 && (flags & CborValidateMapKeysAreUnique) == CborValidateMapKeysAreUnique)
return CborErrorMapKeysNotUnique;
}
Would it be possible to add a flag that would allow for this kind of sorting?
- 主要言語
- C
- スター
- 632
- フォーク
- 222
- 平均マージ
- 1日 25分
- マージ済み PR(30日)
- 2
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
intel/tinycbor のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 45/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
似ている issue
-
hfile_s3: reading to EOF fails with EINVAL when object size is a multiple of the read part sizeオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 3 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
Ryan-Millard/Img2Num#652 · コメント 1 件 ·
メンテナーはふだん 2 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 92/100
メンテナーはふだん 1 日以内に返信
-
Status: Opened
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
メンテナーはふだん 1 日以内に返信