Commit 2808679
committed
refactor(artifact): simplify chunk retrieval and align chunk type naming with protobuf (#270)
Because
- The `GetChunksByFile` function was returning an unnecessary
`map[types.TextChunkUIDType]string` that duplicated data already
available through parallel arrays (`textChunks` and `texts`), adding
complexity and memory overhead
- The codebase was using the legacy string value `"chunk"` for content
chunks, which was inconsistent with the protobuf enum rename from
`TYPE_CHUNK` to `TYPE_CONTENT`
- Database records stored `chunk_type = "chunk"` instead of `"content"`,
causing a mismatch between the API layer (using `TYPE_CONTENT`) and the
persistence layer
- Comments and documentation still referenced the old "chunk"
terminology instead of "content"
This commit
**Simplifies chunk retrieval:**
- Removes the unnecessary `map[types.TextChunkUIDType]string` return
value from `GetChunksByFile` service method
- Updates `GetFileCatalogResponse` handler to use direct array indexing
(`texts[i]`) instead of map lookup (`chunkUIDToContent[chunk.UID]`)
- Simplifies the service interface signature from 6 return values to 5
- Improves performance by eliminating map allocation and lookup overhead
**Aligns chunk type naming across all layers:**
- Updates database migration 032 to include data migration: `UPDATE
text_chunk/embedding SET chunk_type = 'content' WHERE chunk_type =
'chunk'`
- Updates all enum-to-string conversions in worker activities
(`SaveTextChunksActivity`, `ProcessContentActivity`) to use `"content"`
instead of `"chunk"`
- Updates all string-to-enum conversions in handlers
(`convertToProtoChunk`) and services (`SimilarityChunksSearch`) to map
`"content"` to `TYPE_CONTENT`
- Updates sorting logic in `ListChunks` handler to use `"content"`
priority and correct field reference (`ChunkType` instead of
`ContentType`)
- Updates 20+ test cases across `process_file_activity_test.go`,
`embed_activity_test.go`, and `embed_workflow_test.go`
- Updates documentation comments in repository models to reflect
"content/summary/augmented" terminology1 parent 89d528f commit 2808679
File tree
64 files changed
+5931
-2778
lines changed- cmd/worker
- integration-test
- proto/artifact/artifact/v1alpha
- internal/ai
- gemini
- pkg
- db/migration
- handler
- mock
- pipeline
- repository
- service
- types
- worker
- mock
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
64 files changed
+5931
-2778
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
102 | 105 | | |
103 | 106 | | |
104 | 107 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
198 | 198 | | |
199 | 199 | | |
200 | 200 | | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
| 201 | + | |
| 202 | + | |
205 | 203 | | |
206 | 204 | | |
207 | 205 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
16 | | - | |
| 16 | + | |
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
301 | 301 | | |
302 | 302 | | |
303 | 303 | | |
304 | | - | |
305 | | - | |
| 304 | + | |
| 305 | + | |
306 | 306 | | |
307 | 307 | | |
308 | 308 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
102 | 102 | | |
103 | 103 | | |
104 | 104 | | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
118 | 118 | | |
119 | 119 | | |
120 | 120 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
| 17 | + | |
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
20 | | - | |
| 20 | + | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| |||
172 | 172 | | |
173 | 173 | | |
174 | 174 | | |
175 | | - | |
| 175 | + | |
176 | 176 | | |
177 | 177 | | |
178 | 178 | | |
| |||
0 commit comments