Elffuss BraidHub

kikocis/java-driver public

Fix documentation inaccuracies.
Changeset977ad7941eff5c5d10c75dfae91e7d63ece6c577fc695a139c5599b67363493c
AuthorAlexandre Dutra <alexandre.dutra@datastax.com> · 2016-09-07 14:17 +02:00
Committerolim7t <omichallat+github@gmail.com> · 2016-10-03 09:02 -07:00
Parents86638feb1f1b

Browse the files at this changeset

1 file changed

modified manual/custom_codecs/extras/README.md +8 −13
@@ -82,9 +82,9 @@
8282
8383 Like for JDK8, there is a codec for each time type:
8484
85-* [InstantCodec][InstantCodec_joda]: [Instant][Instant_joda] to `timestamp`;
86-* [LocalDateCodec][LocalDateCodec_joda]: [LocalDate][LocalDate_joda] to `date`;
87-* [LocalTime][LocalTime_joda]: [LocalTime][LocalTime_joda] to `time`.
85+* [InstantCodec][InstantCodec_joda]: maps [Instant][Instant_joda] to `timestamp`;
86+* [LocalDateCodec][LocalDateCodec_joda]: maps [LocalDate][LocalDate_joda] to `date`;
87+* [LocalTimeCodec][LocalTimeCodec_joda]: maps [LocalTime][LocalTime_joda] to `time`.
8888
8989 ```java
9090 import com.datastax.driver.extras.codecs.joda.InstantCodec;
@@ -127,7 +127,7 @@
127127
128128 * [SimpleTimestampCodec] maps `timestamp` to a primitive Java `long` representing the number of milliseconds since the
129129 Epoch;
130-* [SimpleDateCodec] maps `date` to a primitive Java `int` representing the number of milliseconds since the Epoch.
130+* [SimpleDateCodec] maps `date` to a primitive Java `int` representing the number of days since the Epoch.
131131
132132 There is no extra codec for `time`, because by default the driver already maps that type to a `long` representing the
133133 number of milliseconds since midnight.
@@ -166,14 +166,10 @@
166166 // state saved as 0
167167 ```
168168
169-Note that if you registered both codecs at the same time, there would be a problem: because `session.execute` uses a
170-[simple statement](../../statements/simple/), the target CQL type is not known in advance, so the driver picks the first
171-codec that accepts a `State`. So one of the statements would serialize its value to the wrong type, and the request
172-would fail on the server side.
169+Note that if you registered an `EnumNameCodec` and an `EnumOrdinalCodec` _for the same enum_ at the same time, there could be a problem when executing [simple statements](../../statements/simple/), because in a simple statement, the target CQL type of a given query parameter is not known in advance, so the driver, on a best-effort attempt, will pick one or the other, whichever was registered first. If the chosen codec proves to be the wrong one, the request would fail on the server side.
173170
174171 In practice, this is unlikely to happen, because you'll probably stick to a single CQL type for a given enum type;
175-however, if you ever run into that issue, the workaround is to use [prepared statements](../../statements/prepared/),
176-for which the driver knows the CQL type and can pick the exact codec.
172+however, if you ever run into that issue, the workaround is to use [prepared statements](../../statements/prepared/), for which the driver knows the CQL type and can pick the exact codec.
177173
178174 [EnumNameCodec]: http://docs.datastax.com/en/drivers/java/3.0/com/datastax/driver/extras/codecs/enums/EnumNameCodec.html
179175 [EnumOrdinalCodec]: http://docs.datastax.com/en/drivers/java/3.0/com/datastax/driver/extras/codecs/enums/EnumOrdinalCodec.html
@@ -231,7 +227,7 @@
231227
232228 It requires an explicit dependency on the JSR-353 API and an implementation:
233229
234-```java
230+```xml
235231 <dependency>
236232 <groupId>javax.json</groupId>
237233 <artifactId>javax.json-api</artifactId>
@@ -337,8 +333,7 @@
337333 cluster.getConfiguration().getCodecRegistry()
338334 .register(optionalIntCodec);
339335
340-TypeToken<Optional<Integer>> optionalIntToken = new TypeToken<Optional<Integer>>() {
341-};
336+TypeToken<Optional<Integer>> optionalIntToken = new TypeToken<Optional<Integer>>() {};
342337
343338 // schema: create table example (id int primary key, v int);
344339 PreparedStatement pst = session.prepare("insert into example (id, v) values (?, ?)");