Commit affcc42
Feature/diff path support (#821)
* feat: add path field to diff response using PathSummary
- Add path field to JsonDiffSerializer.java using PathSummary (enabled by default)
- Add resolveArrayPositions method to convert path like /arr/[] to /arr/[3]
- Add include-data query param to DiffHandler.kt (default false for compact mode)
- Add generateDiff overload to BasicJsonDiff.java that accepts includeData param
This enables the frontend to display diffs with full paths without requiring DeweyIDs.
* fix: update tests for new path field in diff serialization
- Update expected JSON files in basicJsonDiffTest to include path field
- Fix JsonResourceCopy to handle delete as object instead of primitive
(delete now returns {nodeKey, path, ...} instead of just nodeKey)
* feat: implement delete() in JsonDBItem for sdb:select-item support
Implements the delete() method from UpdatableJsonItem interface,
enabling JSONiq delete expressions to work with sdb:select-item().
Changes:
- Add default delete() implementation in JsonDBItem interface
- Add test testRemoveFromObjectViaSdbSelectItem() to verify functionality
This allows queries like:
delete json sdb:select-item(jn:doc('db','res'), nodeKey)
Requires Brackit feature/sdb-select-item-delete-support branch.
* feat: implement delete() in JsonDBItem for sdb:select-item support
Implements the delete() method from UpdatableJsonItem interface,
enabling JSONiq delete expressions to work with sdb:select-item().
Changes:
- Add default delete() implementation in JsonDBItem interface
- Add test testRemoveFromObjectViaSdbSelectItem() to verify functionality
This allows queries like:
delete json sdb:select-item(jn:doc('db','res'), nodeKey)
Requires Brackit feature/sdb-select-item-delete-support branch.
* Update expected diff output to include path fields
The JsonDiffSerializer now includes path information in the diff output
for insert, delete, replace, and update operations. Updated the expected
test output file to match the new format with path fields.
* Fix test
* feat: enable branching from historical revisions
When editing a document opened at a historical revision (e.g., revision 1),
the write transaction is now automatically reverted to that revision before
applying changes. This enables true branching from any point in history.
Changes:
- JsonDBItem.getOrCreateWriteTrx(): New method that gets or creates a write
transaction and calls revertTo(sourceRevision) if the source document is
from an older revision than the most recent
- JsonDBItem.delete() and replaceValue(): Now use getOrCreateWriteTrx()
- AbstractJsonDBArray.getReadWriteTrx(): Added revertTo logic
- JsonDBObject.getReadWriteTrx(): Added revertTo logic
This allows users to:
1. View any historical revision in the Explorer
2. Make edits (insert, update, delete)
3. Commit - creates a new revision branching from that historical point
4. All intermediate revisions remain preserved (SirixDB's append-only model)
* Add reference counting to MMStorage to prevent premature arena closure
When MMStorage remaps memory-mapped segments due to file growth, it was
previously closing the old arena immediately, which invalidated any
existing readers still using those segments.
This change:
- Adds ArenaGeneration class to track arena/segments with reference count
- Readers increment ref count when created, decrement when closed
- Old arenas are only closed when their ref count reaches zero
- Fixes 'Already closed' errors in JsonDiffSerializer path resolution
Also reverts the exception-catching workaround in JsonDiffSerializer
since the root cause is now properly addressed.
* fix: use int for revision references length instead of byte
- Changed from writeByte/readByte to writeInt/readInt for the length
field in REVISION_REFERENCES_NODE serialization
- This supports nodes with more than 255 revision references
- Previously, a byte could only hold 0-255, and due to signed byte
interpretation, values > 127 caused IndexOutOfBoundsException
* Fix test
* Fix JSONiq bug, replacing two values...
---------
Co-authored-by: Johannes Lichtenberger <johannes.lichtenberger@sirix.io>1 parent f6a04fe commit affcc42
20 files changed
Lines changed: 461 additions & 71 deletions
File tree
- bundles
- sirix-core/src
- main/java/io/sirix
- diff
- io/memorymapped
- node
- service/json
- shredder
- test/resources/json
- basicJsonDiffTest
- sirix-query/src
- main/java/io/sirix/query
- json
- node
- test
- java/io/sirix/query
- resources/json
- sirix-rest-api
- bin/main/io/sirix/rest/crud
- src/main/kotlin/io/sirix/rest/crud
Lines changed: 142 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
| 10 | + | |
8 | 11 | | |
9 | 12 | | |
10 | 13 | | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| 17 | + | |
14 | 18 | | |
15 | 19 | | |
16 | 20 | | |
| |||
78 | 82 | | |
79 | 83 | | |
80 | 84 | | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
81 | 88 | | |
82 | 89 | | |
83 | 90 | | |
| |||
92 | 99 | | |
93 | 100 | | |
94 | 101 | | |
| 102 | + | |
95 | 103 | | |
96 | | - | |
97 | | - | |
| 104 | + | |
98 | 105 | | |
99 | | - | |
| 106 | + | |
| 107 | + | |
100 | 108 | | |
| 109 | + | |
101 | 110 | | |
102 | 111 | | |
103 | 112 | | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | 113 | | |
109 | 114 | | |
| 115 | + | |
110 | 116 | | |
111 | 117 | | |
112 | 118 | | |
| |||
118 | 124 | | |
119 | 125 | | |
120 | 126 | | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
121 | 130 | | |
122 | 131 | | |
123 | 132 | | |
| |||
134 | 143 | | |
135 | 144 | | |
136 | 145 | | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
137 | 149 | | |
138 | 150 | | |
139 | 151 | | |
| |||
227 | 239 | | |
228 | 240 | | |
229 | 241 | | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
230 | 365 | | |
Lines changed: 39 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
69 | 69 | | |
70 | 70 | | |
71 | 71 | | |
72 | | - | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
73 | 84 | | |
74 | 85 | | |
75 | 86 | | |
| |||
82 | 93 | | |
83 | 94 | | |
84 | 95 | | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
85 | 115 | | |
86 | 116 | | |
87 | 117 | | |
88 | 118 | | |
89 | | - | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
90 | 122 | | |
91 | 123 | | |
92 | 124 | | |
| |||
161 | 193 | | |
162 | 194 | | |
163 | 195 | | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
164 | 200 | | |
165 | 201 | | |
166 | | - | |
| 202 | + | |
167 | 203 | | |
168 | 204 | | |
169 | 205 | | |
| |||
0 commit comments