()
| 310 | } |
| 311 | |
| 312 | @Test |
| 313 | public void data() throws RocksDBException { |
| 314 | try (final WriteBatch batch1 = new WriteBatch()) { |
| 315 | batch1.delete("k0".getBytes()); |
| 316 | batch1.put("k1".getBytes(), "v1".getBytes()); |
| 317 | batch1.put("k2".getBytes(), "v2".getBytes()); |
| 318 | batch1.put("k3".getBytes(), "v3".getBytes()); |
| 319 | batch1.putLogData("log1".getBytes()); |
| 320 | batch1.merge("k2".getBytes(), "v22".getBytes()); |
| 321 | batch1.delete("k3".getBytes()); |
| 322 | |
| 323 | final byte[] serialized = batch1.data(); |
| 324 | |
| 325 | try(final WriteBatch batch2 = new WriteBatch(serialized)) { |
| 326 | assertThat(batch2.count()).isEqualTo(batch1.count()); |
| 327 | |
| 328 | try(final CapturingWriteBatchHandler handler1 = new CapturingWriteBatchHandler()) { |
| 329 | batch1.iterate(handler1); |
| 330 | |
| 331 | try (final CapturingWriteBatchHandler handler2 = new CapturingWriteBatchHandler()) { |
| 332 | batch2.iterate(handler2); |
| 333 | |
| 334 | assertThat(handler1.getEvents().equals(handler2.getEvents())).isTrue(); |
| 335 | } |
| 336 | } |
| 337 | } |
| 338 | } |
| 339 | } |
| 340 | |
| 341 | @Test |
| 342 | public void dataSize() throws RocksDBException { |
no test coverage detected