Architecture for to-string conversion
まだ誰も着手していません。
評価
- 難易度
- 5/5
- 見積もり時間
- 1週間以上
- 初心者へのやさしさ
- 35/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- c
調査の方向性
現在の json_object-to-string パスとその struct printbuf 実装から始め、提案されているエントリーポイント fjson_object_write と fjson_object_write_ex を確認します。完了条件は、ユーザーコールバックがシリアライズされた出力を受け取れること、既存の printbuf の動作をコールバック API 上に構築できること、そして並行変換がオブジェクト所有の出力バッファに依存しなくなることです。
索引モデルが issue の本文から書いたものです。
説明
Hi Rainer,
We have some issues with converting the json tree to a string from multiple threads at the same time. I think the problem is with the printbuf member that is being used by two threads. We will probably be able to work around this, but after looking at the code, I think it is a peculiar design that the output buffer is part of the json_object.
What would you think of adding the following functions to libfastjson:
/**
* Signature of a custom print function that can be implemented by the user.
* @param ptr user-supplied pointer
* @param buffer buffer to be written
* @param size size of the buffer
* @return size_t number of bytes written
*/
typedef size_t (fjson_print_fn)(void *ptr, const char *buffer, size_t size);
/**
* Write the json tree to a user-supplied function
* @param jso the fjson_object instance
* @param func the user supplied function to which all data will be passed
* @param ptr user-supplied pointer that is passed as first param to the callback
* @returns the number of bytes written
*/
extern size_t fjson_object_write(struct fjson_object *jso, fjson_print_fn *func, void *ptr);
/**
* Extended write function that allows extra flags to be passed
* @param jso the fjson_object instance
* @param flags formatting options, see FJSON_TO_STRING_PRETTY and other constants
* @param func the user supplied function to which all data will be passed
* @param ptr user-supplied pointer that is passed as first param to the callback
* @returns the number of bytes written
*/
extern size_t fjson_object_write_ex(struct fjson_object *jso, int flags, fjson_print_fn *func, void *ptr);
This would allow users to supply their own output function, for example to write the json to a FILE*, or to write it to a fixed size buffer on the stack or to a dynamically growing buffer just like the current "struct printbuf" does. In fact, the "printbuf" implementation could be implemented on top of these functions.
This will often also be a performance improvement because now we're always stuck with the dynamically growing printbuf -- even if we have a pretty good idea how big the output is going to be, or when we want to write to a file instead of to a dynamically allocated buffer.
Are you willing to accept a pull request that implements this?
- 主要言語
- C
- スター
- 61
- フォーク
- 34
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
rsyslog/libfastjson のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
rsyslog/libfastjson#154 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
rsyslog/libfastjson#169 · コメント 3 件 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 45/100
rsyslog/libfastjson#168 · コメント 3 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
rsyslog/libfastjson#165 · コメント 2 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 25/100
rsyslog/libfastjson#164 · コメント 3 件 ·
rsyslog/libfastjson の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 79/100
メンテナーはふだん 2 日以内に返信
-
BUG: linalg.bandwidth: misses the upper band in a wide matrix's last row対応中かも @ilayn が 205 日前に担当しました。 オープンdefect scipy.linalg
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
scipy/scipy#26579 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 80/100
メンテナーはふだん 1 日以内に返信