doc: add Javadoc to INDEXED file related classes#843
Open
ytr-sakamoto wants to merge 6 commits into
Open
Conversation
Fill in the placeholder Javadoc of the INDEXED file implementation (CobolIndexedFile, CobolFileKey, KeyComponent, IndexedFile and the FetchResult helper in IndexedCursor) with meaningful descriptions covering the public API.
Convert the Javadoc comments added for the INDEXED file classes (CobolIndexedFile, CobolFileKey, KeyComponent, IndexedFile and the FetchResult helper in IndexedCursor) from English to Japanese.
yutaro-sakamoto
force-pushed
the
javadoc/indexed
branch
from
June 2, 2026 06:24
9c01d29 to
e079f14
Compare
ytr-sakamoto
marked this pull request as ready for review
July 14, 2026 07:19
tsh-hashimoto
self-requested a review
July 14, 2026 07:39
tsh-hashimoto
left a comment
Contributor
There was a problem hiding this comment.
レビュー(ドキュメントのみの PR)
ロジック変更のない Javadoc 付与 PR です。SQLite のテーブル構成(file_lock / locked_by 列 / metadata_*)、トランザクション設定(setAutoCommit(false) + TRANSACTION_SERIALIZABLE)、IndexedFile の「予約済み・未使用」フィールド群、last_key の順序チェック用途など、実装と照合して正確な記述が大半でした。丁寧な作業に感謝します。
一方で、実装挙動と食い違う記述が数点あります。ドキュメントのみの PR では「記述の正確さ」が唯一の品質軸なので、以下を修正いただけると助かります。
1. 🔴 indexed_start_internal の @param cond / @return が実挙動と不一致
CobolIndexedFile.java (@param cond / @return)
- Javadoc:「
COB_NEはサポートされておらず、カーソルの生成に失敗する」「カーソル生成に失敗した場合はCOB_STATUS_30_PERMANENT_ERROR」 - 実装:
IndexedCursor.createCursor()は常にOptional.of(...)を返し、カーソル生成は決して失敗しません。よってindexed_start_internal内のif (!this.cursor.isPresent())→COB_STATUS_30分岐は到達不能なデッドコードです。 COB_NEを渡した場合の実挙動は「生成失敗」ではなく、getCompOperator()がnullを返し、SQL 文にnullが埋め込まれてSQLException→ 例外を握ってOptional.empty()→ 結果としてCOB_STATUS_23_KEY_NOT_EXISTSを返す経路です。- → 「カーソル生成失敗」「
COB_STATUS_30」という記述は誤りです。COB_NEの扱いと@returnの条件を実挙動に合わせて修正が必要です。
2. 🟡 コンストラクタ @param fileStatus の「4バイトのバッファ」が根拠なし
- Javadoc:「COBOL の
FILE STATUS用ストレージ(4バイトのバッファ)」 - 実装は
file_status[0]とfile_status[1]の2バイトのみを読み書きします(CobolFile.java)。COBOL の FILE STATUS も 2 桁です。「4バイト」という具体的サイズはコード上の根拠がなく、誤りの可能性が高いです。サイズ記述の削除、または「2バイト」への修正を推奨します。
3. 🟡 IndexedFile.record_locked の記述が実態より強い
- Javadoc:「このプロセスが現在レコードロックを保持している間は
true」 - 実装では
p.record_locked = false;で false 代入されるのみで、trueを設定する箇所も、条件として読む箇所もありません。兄弟フィールド(last_readkey/lock_id/record_lock等)は「予約されているが未使用」と正直に書かれているので、このフィールドも同様に「予約済み/現状未使用」と揃えるのが正確です。
4. 🟢 indexed_start_internal の @param readOpts — 未使用注記の欠落(軽微)
testLockには「現状このメソッドでは未使用」と明記されていますが、readOptsも本メソッド本体では一切参照されていません。整合性のためreadOptsにも同様の注記を付けると親切です。
いずれもドキュメント文言の修正で対応可能です。とくに 1 が唯一の実挙動との明確な矛盾なので優先的に直すのがよいと思います。
tsh-hashimoto
requested changes
Jul 16, 2026
Contributor
There was a problem hiding this comment.
@yutaro-sakamoto @ytr-sakamoto
Claudeにレビューしてもらいました。
コメントを確認の上、修正が必要なものについては対応をお願いします。
cond変数にCOB_NEが指定された場合、常にCOB_STATUS_23_KEY_NOT_EXISTS を返すことを明記
fileStatus変数は4バイトではなく2バイトであることを書いた
record_lockedは未使用であることを示す説明に差し替えた
readOptsが未使用である旨を記載した
Contributor
|
4件すべて指摘通り修正しました。 IDENTIFICATION DIVISION.
PROGRAM-ID. prog.
******************************************************************
ENVIRONMENT DIVISION.
INPUT-OUTPUT SECTION.
FILE-CONTROL.
SELECT MYFILE ASSIGN TO EXTERNAL OUTPUT_FILE
ORGANIZATION IS INDEXED
ACCESS MODE IS SEQUENTIAL
RECORD KEY IS R-KEY.
******************************************************************
DATA DIVISION.
FILE SECTION.
FD MYFILE.
01 R-REC.
03 R-KEY PIC X(03).
03 R-DATA PIC X(03).
******************************************************************
working-storage section.
PROCEDURE DIVISION.
MAIN SECTION.
OPEN OUTPUT MYFILE.
MOVE "AAABBB" TO R-REC.
WRITE R-REC.
CLOSE MYFILE.
INITIALIZE R-REC.
OPEN INPUT MYFILE.
MOVE "XXX" TO R-KEY.
* MOVE "AAA" TO R-KEY.
START MYFILE KEY IS NOT EQUAL TO R-KEY.
READ MYFILE.
DISPLAY R-REC.
CLOSE MYFILE.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
INDEXEDファイル関連のJavaクラスに、これまでプレースホルダ(
TODO: 準備中)のままだったJavadocコメントを記述しました。対象クラス
CobolIndexedFile— INDEXEDファイルの具象実装(SQLiteをストレージとして利用)CobolFileKey— 1つのキー(主キー/副キー)を表すクラスKeyComponent— SPLIT KEYの構成要素を表すクラスIndexedFile— オープン中の1ファイルの実行時状態を保持するクラスIndexedCursor内のFetchResult— フェッチ結果を表すクラス補足
Summary
This PR fills in the Javadoc comments for the INDEXED-file related Java classes, which were previously left as
TODO: 準備中placeholders.Target classes
CobolIndexedFile— concrete implementation of INDEXED files (backed by SQLite)CobolFileKey— represents a single key (primary / alternate)KeyComponent— represents a component of a SPLIT KEYIndexedFile— holds the runtime state of one opened fileFetchResultinIndexedCursor— represents a fetch resultNotes