Skip to content

Commit c6f4825

Browse files
tolbertamadutra
authored andcommitted
JAVA-2062: Document frozen collection preference with Mapper (apache#1153)
1 parent 6dff22c commit c6f4825

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

changelog/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
### 3.7.0 (In progress)
44

5-
- [improvement] JAVA-2025: Include exception message in Abstract*Codec.accepts(null).
5+
- [improvement] JAVA-2025: Include exception message in Abstract\*Codec.accepts(null).
66
- [improvement] JAVA-1980: Use covariant return types in RemoteEndpointAwareJdkSSLOptions.Builder methods.
7+
- [documentation] JAVA-2062: Document frozen collection preference with Mapper.
78

89

910
### 3.6.0

manual/object_mapper/creating/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,26 @@ private Map<String, List<Address>> frozenValueMap;
363363
[frozenkey]:http://docs.datastax.com/en/drivers/java/3.6/com/datastax/driver/mapping/annotations/FrozenKey.html
364364
[frozenvalue]:http://docs.datastax.com/en/drivers/java/3.6/com/datastax/driver/mapping/annotations/FrozenValue.html
365365

366+
#### Prefer Frozen Collections
367+
368+
If `Mapper.save` is used to create and update entities, it is recommended to
369+
use frozen collections over non-frozen collections.
370+
371+
Frozen collections in Cassandra are serialized as a single cell value where
372+
non-frozen collections serialize each individual element in a collection as a
373+
cell.
374+
375+
Since `Mapper.save` provides the entire collection for an entity field value on
376+
each invocation, it is more efficient to use frozen collections as the entire
377+
collection is serialized as one cell.
378+
379+
Also, when using non-frozen collections, on INSERT Cassandra must
380+
create a tombstone to invalidate all existing collection elements, even if
381+
there are none. When using frozen collections, no such tombstone is needed.
382+
383+
See [Freezing collection types] for more information about the frozen keyword.
384+
385+
[Freezing collection types]: https://docs.datastax.com/en/dse/6.7/cql/cql/cql_using/refCollectionType.html
366386

367387
### Polymorphism support
368388

0 commit comments

Comments
 (0)