Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe pull request adds an unpaginated Changes
Sequence Diagram(s)sequenceDiagram
participant Extractor as KeywordExtractor
participant RepoKW as ArticleKeywordRepository
participant RepoMap as ArticleKeywordUserMapRepository
participant DB as Database
Extractor->>RepoKW: findAll()
RepoKW->>DB: query all ArticleKeyword rows
DB-->>RepoKW: list of ArticleKeyword
RepoKW-->>Extractor: List<ArticleKeyword>
Extractor->>RepoMap: findAllByKeywordIdIn(nonDeletedIds)
RepoMap->>DB: query ArticleKeywordUserMap by keyword IDs and not-deleted
DB-->>RepoMap: list of mappings
RepoMap-->>Extractor: List<ArticleKeywordUserMap>
Extractor->>Extractor: build matchedKeywordByUserIdByArticleId(articles, mappings)
Extractor-->>Caller: matched results
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/main/java/in/koreatech/koin/domain/community/util/KeywordExtractor.java`:
- Around line 29-46: The current implementation in KeywordExtractor loads all
ArticleKeyword rows and then calls
articleKeywordUserMapRepository.findAllByArticleKeywordIdIn over every id,
causing unbounded memory/latency when matchKeyword() is called during lost-item
creation; change this to a paged/batched scan: iterate ArticleKeyword pages (use
ArticleKeywordRepository pageable/streaming API) and for each page collect its
ids and call articleKeywordUserMapRepository.findAllByArticleKeywordIdIn for
just that batch (or use a repository method that accepts a page/stream), build
the userMapsByKeywordId incrementally (merging per-page results) and keep
filtering out deleted ArticleKeywordUserMap entries as before so memory and
latency scale with the input batch rather than the whole table.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 91f5a1fa-498e-4560-b1a3-f1b06d171826
📒 Files selected for processing (2)
src/main/java/in/koreatech/koin/domain/community/keyword/repository/ArticleKeywordRepository.javasrc/main/java/in/koreatech/koin/domain/community/util/KeywordExtractor.java
| List<ArticleKeyword> keywords = articleKeywordRepository.findAll(); | ||
|
|
||
| while (true) { | ||
| Pageable pageable = PageRequest.of(offset / KEYWORD_BATCH_SIZE, KEYWORD_BATCH_SIZE); | ||
| List<ArticleKeyword> keywords = articleKeywordRepository.findAll(pageable); | ||
| if (keywords.isEmpty()) { | ||
| return List.of(); | ||
| } | ||
|
|
||
| if (keywords.isEmpty()) { | ||
| break; | ||
| } | ||
| List<Integer> keywordIds = keywords.stream() | ||
| .map(ArticleKeyword::getId) | ||
| .toList(); | ||
| Map<Integer, List<ArticleKeywordUserMap>> userMapsByKeywordId = articleKeywordUserMapRepository | ||
| .findAllByArticleKeywordIdIn(keywordIds) | ||
| .stream() | ||
| .filter(keywordUserMap -> !keywordUserMap.getIsDeleted()) | ||
| .collect(Collectors.groupingBy( | ||
| keywordUserMap -> keywordUserMap.getArticleKeyword().getId(), | ||
| LinkedHashMap::new, | ||
| Collectors.toList() | ||
| )); | ||
| List<Integer> keywordIds = keywords.stream() | ||
| .map(ArticleKeyword::getId) | ||
| .toList(); | ||
| Map<Integer, List<ArticleKeywordUserMap>> userMapsByKeywordId = articleKeywordUserMapRepository | ||
| .findAllByArticleKeywordIdIn(keywordIds) | ||
| .stream() | ||
| .filter(keywordUserMap -> !keywordUserMap.getIsDeleted()) | ||
| .collect(Collectors.groupingBy( | ||
| keywordUserMap -> keywordUserMap.getArticleKeyword().getId(), | ||
| LinkedHashMap::new, | ||
| Collectors.toList() | ||
| )); |
There was a problem hiding this comment.
Keep the paged scan on this request path.
This now loads the full ArticleKeyword table and then issues an unbounded findAllByArticleKeywordIdIn(keywordIds) over every keyword id before checking a few titles. src/main/java/in/koreatech/koin/domain/community/article/service/LostItemArticleService.java:173-186 and 254-261 call matchKeyword() during lost-item creation, so latency and memory now grow with total keyword volume instead of the current articles input. Please keep the batched/paged scan here, or move the full scan behind a cached/background path if this is only needed for testing.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@src/main/java/in/koreatech/koin/domain/community/util/KeywordExtractor.java`
around lines 29 - 46, The current implementation in KeywordExtractor loads all
ArticleKeyword rows and then calls
articleKeywordUserMapRepository.findAllByArticleKeywordIdIn over every id,
causing unbounded memory/latency when matchKeyword() is called during lost-item
creation; change this to a paged/batched scan: iterate ArticleKeyword pages (use
ArticleKeywordRepository pageable/streaming API) and for each page collect its
ids and call articleKeywordUserMapRepository.findAllByArticleKeywordIdIn for
just that batch (or use a repository method that accepts a page/stream), build
the userMapsByKeywordId incrementally (merging per-page results) and keep
filtering out deleted ArticleKeywordUserMap entries as before so memory and
latency scale with the input batch rather than the whole table.
🔍 개요
🚀 주요 변경 내용
💬 참고 사항
✅ Checklist (완료 조건)
Summary by CodeRabbit