Skip to content
This repository was archived by the owner on Jan 2, 2026. It is now read-only.

Commit d334d2c

Browse files
authored
๐Ÿ“ฆ๏ธ Chore: gptEmbeddingLoadingAdapter ๋กœ๊น… ์ถ”๊ฐ€ (#50)
1 parent 214dd2f commit d334d2c

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

โ€Žsrc/main/java/com/likelion/backendplus4/yakplus/index/application/service/DrugIndexer.javaโ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@ public void index() {
5454
saveDrugs(esIndexName, drugs);
5555
}
5656
} catch (Exception e) {
57-
log(LogLevel.ERROR,"indexing ์‹œ ๋ฐ์ดํ„ฐ 5000๊ฐœ ๋ณด๋‹ค ์ ์–ด์„œ ์—๋Ÿฌ ๋ฐœ์ƒ (๋ฐ์ดํ„ฐ 5000๊ฐœ ์ดํ•˜๋ฉด ์ „์ฒด ๋™์ž‘)", e);
57+
log(LogLevel.ERROR,"indexing ์‹œ ๋ฐ์ดํ„ฐ 5000๊ฐœ ๋ณด๋‹ค ์ ์–ด์„œ ์—๋Ÿฌ ๋ฐœ์ƒ", e);
58+
e.printStackTrace();
5859
}
5960

6061
}

โ€Žsrc/main/java/com/likelion/backendplus4/yakplus/index/infrastructure/adapter/persistence/GptEmbeddingLoadingAdapter.javaโ€Ž

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
import java.util.List;
1717
import java.util.Map;
1818

19+
import static com.likelion.backendplus4.yakplus.common.util.log.LogUtil.log;
20+
1921
@Repository("gptAdapter")
2022
@Primary
2123
@RequiredArgsConstructor
@@ -49,20 +51,29 @@ public List<Drug> loadAllEmbeddings() {
4951
public List<Drug> loadEmbeddingsByPage(Pageable pageable) {
5052
List<DrugRawDataEntity> rawDataEntities = govDrugJpaRepository.findAll(pageable).getContent();
5153
List<DrugGptEmbedEntity> drugGptEmbedEntities = govDrugGptEmbedJpaRepository.findAll(pageable).getContent();
54+
log("loadEmbeddingsByPage - " + pageable.getPageNumber() +"ํŽ˜์ด์ง€ ์—์„œ ๋ฐ›์•„์˜จ drug ์ƒ์„ธ์ •๋ณด ์ˆ˜: " + rawDataEntities.size());
55+
log("loadEmbeddingsByPage - " + pageable.getPageNumber() +"ํŽ˜์ด์ง€ ์—์„œ ๋ฐ›์•„์˜จ drug ์ž„๋ฒ ๋”ฉ ๋ฒกํ„ฐ์ˆ˜: " + drugGptEmbedEntities.size());
5256

5357
// drugGptEmbedEntities๋ฅผ Map์œผ๋กœ ๋ณ€ํ™˜ (key: drugId)
5458
Map<Long, DrugGptEmbedEntity> gptEmbedMap = new HashMap<>();
5559
for (DrugGptEmbedEntity embed : drugGptEmbedEntities) {
60+
log("loadEmbeddingsByPage - " +pageable.getPageNumber()+"ํŽ˜์ด์ง€์—์„œ ์ž„๋ฒ ๋”ฉ ๋ฒกํ„ฐ ๋ฐ›์•„์˜จ ์•ฝํ’ˆ ID: " + embed.getDrugId());
5661
gptEmbedMap.put(embed.getDrugId(), embed);
5762
}
5863

5964
List<Drug> drugs = new ArrayList<>();
65+
log("loadEmbeddingsByPage - Drug ๋„๋ฉ”์ธ ๊ฐ์ฒด ์ƒ์„ฑ ์‹œ์ž‘");
6066
for (DrugRawDataEntity drugRawData : rawDataEntities) {
6167
DrugGptEmbedEntity embed = gptEmbedMap.get(drugRawData.getDrugId());
68+
if(embed == null) {
69+
log("loadEmbeddingsByPage - " + "Drug ๋„๋ฉ”์ธ ๊ฐ์ฒด ์ƒ์„ฑ ๋Œ€์ƒ " + drugRawData.getDrugId() + "์˜ ๋ฒกํ„ฐ๊ฐ€ ์—†์œผ๋ฏ€๋กœ skip");
70+
continue;
71+
}
72+
log("loadEmbeddingsByPage - Drug ๋„๋ฉ”์ธ ๊ฐ์ฒด ์ƒ์„ฑ ๋Œ€์ƒ " + drugRawData.getDrugId() + "์˜ ๋ฒกํ„ฐ ๊ธธ์ด: " + embed.getGptVector().length());
6273
Drug drug = toDomainFromEntity(drugRawData, embed);
6374
drugs.add(drug);
6475
}
65-
76+
log("loadEmbeddingsByPage - Drug ๋„๋ฉ”์ธ ๊ฐ์ฒด ์ƒ์„ฑ ์™„๋ฃŒ");
6677
return drugs;
6778
}
6879

0 commit comments

Comments
ย (0)