kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 0788d958beb962a51db38d2394c1c1645ff063ebab212a433b522769edacac3f |
|---|---|
| Author | Alexandre Dutra <alexandre.dutra@datastax.com> · 2015-09-30 15:37 +02:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2015-10-14 22:35 +02:00 |
| Parents | 16505233fda0 |
6 files changed
modified changelog/README.md +1 −0
| @@ -11,6 +11,7 @@ | ||
| 11 | 11 | - [new feature] Add BoundStatement#unset (JAVA-930) |
| 12 | 12 | - [bug] Make table metadata options class visible (JAVA-946) |
| 13 | 13 | - [bug] Add crcCheckChance to TableOptionsMetadata#equals/hashCode (JAVA-939) |
| 14 | +- [bug] Make TypeCodec return mutable collections (JAVA-922) | |
| 14 | 15 | |
| 15 | 16 | |
| 16 | 17 | ### 3.0.0-alpha3 |
modified driver-core/src/main/java/com/datastax/driver/core/GettableByIndexData.java +82 −27
| @@ -258,13 +258,19 @@ | ||
| 258 | 258 | * Returns the {@code i}th value as a list. |
| 259 | 259 | * <p> |
| 260 | 260 | * If the type of the elements is generic, use {@link #getList(int, TypeToken)}. |
| 261 | + * <p> | |
| 262 | + * Implementation note: the actual {@link List} implementation will depend | |
| 263 | + * on the {@link TypeCodec codec} being used; therefore, callers should | |
| 264 | + * make no assumptions concerning its mutability nor its thread-safety. | |
| 265 | + * Furthermore, the behavior of this method in respect to CQL {@code NULL} values is also | |
| 266 | + * codec-dependent. By default, the driver will return mutable instances, and | |
| 267 | + * a CQL {@code NULL} will mapped to an empty collection (note that Cassandra | |
| 268 | + * makes no distinction between {@code NULL} and an empty collection). | |
| 261 | 269 | * |
| 262 | 270 | * @param i the index ({@code 0 <= i < size()}) to retrieve. |
| 263 | 271 | * @param elementsClass the class for the elements of the list to retrieve. |
| 264 | 272 | * @return the value of the {@code i}th element as a list of |
| 265 | - * {@code T} objects. If the value is NULL, an empty list is | |
| 266 | - * returned (note that Cassandra makes no difference between an empty list | |
| 267 | - * and column of type list that is not set). The returned list is immutable. | |
| 273 | + * {@code T} objects. | |
| 268 | 274 | * |
| 269 | 275 | * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object. |
| 270 | 276 | * @throws InvalidTypeException if value {@code i} is not a list or if its |
| @@ -279,13 +285,19 @@ | ||
| 279 | 285 | * <pre> |
| 280 | 286 | * {@code List<List<String>> l = row.getList(1, new TypeToken<List<String>>() {});} |
| 281 | 287 | * </pre> |
| 288 | + * <p> | |
| 289 | + * Implementation note: the actual {@link List} implementation will depend | |
| 290 | + * on the {@link TypeCodec codec} being used; therefore, callers should | |
| 291 | + * make no assumptions concerning its mutability nor its thread-safety. | |
| 292 | + * Furthermore, the behavior of this method in respect to CQL {@code NULL} values is also | |
| 293 | + * codec-dependent. By default, the driver will return mutable instances, and | |
| 294 | + * a CQL {@code NULL} will mapped to an empty collection (note that Cassandra | |
| 295 | + * makes no distinction between {@code NULL} and an empty collection). | |
| 282 | 296 | * |
| 283 | 297 | * @param i the index ({@code 0 <= i < size()}) to retrieve. |
| 284 | 298 | * @param elementsType the type of the elements of the list to retrieve. |
| 285 | 299 | * @return the value of the {@code i}th element as a list of |
| 286 | - * {@code T} objects. If the value is NULL, an empty list is | |
| 287 | - * returned (note that Cassandra makes no difference between an empty list | |
| 288 | - * and column of type list that is not set). The returned list is immutable. | |
| 300 | + * {@code T} objects. | |
| 289 | 301 | * |
| 290 | 302 | * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object. |
| 291 | 303 | * @throws InvalidTypeException if value {@code i} is not a list or if its |
| @@ -297,13 +309,19 @@ | ||
| 297 | 309 | * Returns the {@code i}th value as a set. |
| 298 | 310 | * <p> |
| 299 | 311 | * If the type of the elements is generic, use {@link #getSet(int, TypeToken)}. |
| 312 | + * <p> | |
| 313 | + * Implementation note: the actual {@link Set} implementation will depend | |
| 314 | + * on the {@link TypeCodec codec} being used; therefore, callers should | |
| 315 | + * make no assumptions concerning its mutability nor its thread-safety. | |
| 316 | + * Furthermore, the behavior of this method in respect to CQL {@code NULL} values is also | |
| 317 | + * codec-dependent. By default, the driver will return mutable instances, and | |
| 318 | + * a CQL {@code NULL} will mapped to an empty collection (note that Cassandra | |
| 319 | + * makes no distinction between {@code NULL} and an empty collection). | |
| 300 | 320 | * |
| 301 | 321 | * @param i the index ({@code 0 <= i < size()}) to retrieve. |
| 302 | 322 | * @param elementsClass the class for the elements of the set to retrieve. |
| 303 | 323 | * @return the value of the {@code i}th element as a set of |
| 304 | - * {@code T} objects. If the value is NULL, an empty set is | |
| 305 | - * returned (note that Cassandra makes no difference between an empty set | |
| 306 | - * and column of type set that is not set). The returned set is immutable. | |
| 324 | + * {@code T} objects. | |
| 307 | 325 | * |
| 308 | 326 | * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object. |
| 309 | 327 | * @throws InvalidTypeException if value {@code i} is not a set or if its |
| @@ -318,13 +336,19 @@ | ||
| 318 | 336 | * <pre> |
| 319 | 337 | * {@code Set<List<String>> l = row.getSet(1, new TypeToken<List<String>>() {});} |
| 320 | 338 | * </pre> |
| 339 | + * <p> | |
| 340 | + * Implementation note: the actual {@link Set} implementation will depend | |
| 341 | + * on the {@link TypeCodec codec} being used; therefore, callers should | |
| 342 | + * make no assumptions concerning its mutability nor its thread-safety. | |
| 343 | + * Furthermore, the behavior of this method in respect to CQL {@code NULL} values is also | |
| 344 | + * codec-dependent. By default, the driver will return mutable instances, and | |
| 345 | + * a CQL {@code NULL} will mapped to an empty collection (note that Cassandra | |
| 346 | + * makes no distinction between {@code NULL} and an empty collection). | |
| 321 | 347 | * |
| 322 | 348 | * @param i the index ({@code 0 <= i < size()}) to retrieve. |
| 323 | 349 | * @param elementsType the type for the elements of the set to retrieve. |
| 324 | 350 | * @return the value of the {@code i}th element as a set of |
| 325 | - * {@code T} objects. If the value is NULL, an empty set is | |
| 326 | - * returned (note that Cassandra makes no difference between an empty set | |
| 327 | - * and column of type set that is not set). The returned set is immutable. | |
| 351 | + * {@code T} objects. | |
| 328 | 352 | * |
| 329 | 353 | * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object. |
| 330 | 354 | * @throws InvalidTypeException if value {@code i} is not a set or if its |
| @@ -336,15 +360,20 @@ | ||
| 336 | 360 | * Returns the {@code i}th value as a map. |
| 337 | 361 | * <p> |
| 338 | 362 | * If the type of the keys and/or values is generic, use {@link #getMap(int, TypeToken, TypeToken)}. |
| 363 | + * <p> | |
| 364 | + * Implementation note: the actual {@link Map} implementation will depend | |
| 365 | + * on the {@link TypeCodec codec} being used; therefore, callers should | |
| 366 | + * make no assumptions concerning its mutability nor its thread-safety. | |
| 367 | + * Furthermore, the behavior of this method in respect to CQL {@code NULL} values is also | |
| 368 | + * codec-dependent. By default, the driver will return mutable instances, and | |
| 369 | + * a CQL {@code NULL} will mapped to an empty collection (note that Cassandra | |
| 370 | + * makes no distinction between {@code NULL} and an empty collection). | |
| 339 | 371 | * |
| 340 | 372 | * @param i the index ({@code 0 <= i < size()}) to retrieve. |
| 341 | 373 | * @param keysClass the class for the keys of the map to retrieve. |
| 342 | 374 | * @param valuesClass the class for the values of the map to retrieve. |
| 343 | 375 | * @return the value of the {@code i}th element as a map of |
| 344 | - * {@code K} to {@code V} objects. If the value is NULL, | |
| 345 | - * an empty map is returned (note that Cassandra makes no difference | |
| 346 | - * between an empty map and column of type map that is not set). The | |
| 347 | - * returned map is immutable. | |
| 376 | + * {@code K} to {@code V} objects. | |
| 348 | 377 | * |
| 349 | 378 | * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object. |
| 350 | 379 | * @throws InvalidTypeException if value {@code i} is not a map, if its |
| @@ -361,15 +390,20 @@ | ||
| 361 | 390 | * <pre> |
| 362 | 391 | * {@code Map<Int, List<String>> l = row.getMap(1, TypeToken.of(Integer.class), new TypeToken<List<String>>() {});} |
| 363 | 392 | * </pre> |
| 393 | + * <p> | |
| 394 | + * Implementation note: the actual {@link Map} implementation will depend | |
| 395 | + * on the {@link TypeCodec codec} being used; therefore, callers should | |
| 396 | + * make no assumptions concerning its mutability nor its thread-safety. | |
| 397 | + * Furthermore, the behavior of this method in respect to CQL {@code NULL} values is also | |
| 398 | + * codec-dependent. By default, the driver will return mutable instances, and | |
| 399 | + * a CQL {@code NULL} will mapped to an empty collection (note that Cassandra | |
| 400 | + * makes no distinction between {@code NULL} and an empty collection). | |
| 364 | 401 | * |
| 365 | 402 | * @param i the index ({@code 0 <= i < size()}) to retrieve. |
| 366 | 403 | * @param keysType the type for the keys of the map to retrieve. |
| 367 | 404 | * @param valuesType the type for the values of the map to retrieve. |
| 368 | 405 | * @return the value of the {@code i}th element as a map of |
| 369 | - * {@code K} to {@code V} objects. If the value is NULL, | |
| 370 | - * an empty map is returned (note that Cassandra makes no difference | |
| 371 | - * between an empty map and column of type map that is not set). The | |
| 372 | - * returned map is immutable. | |
| 406 | + * {@code K} to {@code V} objects. | |
| 373 | 407 | * |
| 374 | 408 | * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object. |
| 375 | 409 | * @throws InvalidTypeException if value {@code i} is not a map, if its |
| @@ -411,12 +445,16 @@ | ||
| 411 | 445 | * If a second, custom codec for the same CQL type is registered, which one will |
| 412 | 446 | * be used is unspecified; in such cases, it is preferable to use |
| 413 | 447 | * the more deterministic methods {@link #get(int, Class)} or {@link #get(int, TypeToken)} instead. |
| 448 | + * <p> | |
| 449 | + * Implementation note: the actual object returned by this method will depend | |
| 450 | + * on the {@link TypeCodec codec} being used; therefore, callers should | |
| 451 | + * make no assumptions concerning its mutability nor its thread-safety. | |
| 452 | + * Furthermore, the behavior of this method in respect to CQL {@code NULL} values is also | |
| 453 | + * codec-dependent; by default, a CQL {@code NULL} value translates to {@code null} for | |
| 454 | + * simple types, UDTs and tuples, and to empty collections for all CQL collection types. | |
| 414 | 455 | * |
| 415 | 456 | * @param i the index to retrieve. |
| 416 | 457 | * @return the value of the {@code i}th value as the Java type matching its CQL type. |
| 417 | - * If the value is NULL and is a simple type, UDT or tuple, {@code null} is returned. | |
| 418 | - * If it is NULL and is a collection type, an empty (immutable) collection is returned. | |
| 419 | - * | |
| 420 | 458 | * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object. |
| 421 | 459 | */ |
| 422 | 460 | public Object getObject(int i); |
| @@ -431,12 +469,17 @@ | ||
| 431 | 469 | * where more than one codec is registered for the same CQL type; specifying the Java class |
| 432 | 470 | * allows the {@link CodecRegistry} to narrow down the search and return only an exactly-matching codec (if any), |
| 433 | 471 | * thus avoiding any risk of ambiguity. |
| 472 | + * <p> | |
| 473 | + * Implementation note: the actual object returned by this method will depend | |
| 474 | + * on the {@link TypeCodec codec} being used; therefore, callers should | |
| 475 | + * make no assumptions concerning its mutability nor its thread-safety. | |
| 476 | + * Furthermore, the behavior of this method in respect to CQL {@code NULL} values is also | |
| 477 | + * codec-dependent; by default, a CQL {@code NULL} value translates to {@code null} for | |
| 478 | + * simple CQL types, UDTs and tuples, and to empty collections for all CQL collection types. | |
| 434 | 479 | * |
| 435 | 480 | * @param i the index to retrieve. |
| 436 | 481 | * @param targetClass The Java type the value should be converted to. |
| 437 | 482 | * @return the value of the {@code i}th value converted to the given Java type. |
| 438 | - * If the CQL value is {@code NULL}, this method will return {@code null} | |
| 439 | - * for a simple type, UDT or tuple, and an empty (immutable) collection for collection types. | |
| 440 | 483 | * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object. |
| 441 | 484 | * @throws com.datastax.driver.core.exceptions.CodecNotFoundException |
| 442 | 485 | * if no {@link TypeCodec} instance for {@code targetClass} could be found |
| @@ -454,12 +497,17 @@ | ||
| 454 | 497 | * where more than one codec is registered for the same CQL type; specifying the Java class |
| 455 | 498 | * allows the {@link CodecRegistry} to narrow down the search and return only an exactly-matching codec (if any), |
| 456 | 499 | * thus avoiding any risk of ambiguity. |
| 500 | + * <p> | |
| 501 | + * Implementation note: the actual object returned by this method will depend | |
| 502 | + * on the {@link TypeCodec codec} being used; therefore, callers should | |
| 503 | + * make no assumptions concerning its mutability nor its thread-safety. | |
| 504 | + * Furthermore, the behavior of this method in respect to CQL {@code NULL} values is also | |
| 505 | + * codec-dependent; by default, a CQL {@code NULL} value translates to {@code null} for | |
| 506 | + * simple CQL types, UDTs and tuples, and to empty collections for all CQL collection types. | |
| 457 | 507 | * |
| 458 | 508 | * @param i the index to retrieve. |
| 459 | 509 | * @param targetType The Java type the value should be converted to. |
| 460 | 510 | * @return the value of the {@code i}th value converted to the given Java type. |
| 461 | - * If the CQL value is {@code NULL}, the default set of codecs will return {@code null} | |
| 462 | - * for a simple type, UDT or tuple, and an empty (immutable) collection for collection types. | |
| 463 | 511 | * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object. |
| 464 | 512 | * @throws com.datastax.driver.core.exceptions.CodecNotFoundException |
| 465 | 513 | * if no {@link TypeCodec} instance for {@code targetType} could be found |
| @@ -475,6 +523,13 @@ | ||
| 475 | 523 | * <p> |
| 476 | 524 | * It is the caller's responsibility to ensure that the given codec {@link TypeCodec#accepts(DataType) accepts} |
| 477 | 525 | * the underlying CQL type; failing to do so may result in {@link InvalidTypeException}s being thrown. |
| 526 | + * <p> | |
| 527 | + * Implementation note: the actual object returned by this method will depend | |
| 528 | + * on the {@link TypeCodec codec} being used; therefore, callers should | |
| 529 | + * make no assumptions concerning its mutability nor its thread-safety. | |
| 530 | + * Furthermore, the behavior of this method in respect to CQL {@code NULL} values is also | |
| 531 | + * codec-dependent; by default, a CQL {@code NULL} value translates to {@code null} for | |
| 532 | + * simple CQL types, UDTs and tuples, and to empty collections for all CQL collection types. | |
| 478 | 533 | * |
| 479 | 534 | * @param i the index to retrieve. |
| 480 | 535 | * @param codec The {@link TypeCodec} to use to deserialize the value; may not be {@code null}. |
modified driver-core/src/main/java/com/datastax/driver/core/GettableByNameData.java +82 −24
| @@ -258,13 +258,19 @@ | ||
| 258 | 258 | * Returns the value for {@code name} as a list. |
| 259 | 259 | * <p> |
| 260 | 260 | * If the type of the elements is generic, use {@link #getList(String, TypeToken)}. |
| 261 | + * <p> | |
| 262 | + * Implementation note: the actual {@link List} implementation will depend | |
| 263 | + * on the {@link TypeCodec codec} being used; therefore, callers should | |
| 264 | + * make no assumptions concerning its mutability nor its thread-safety. | |
| 265 | + * Furthermore, the behavior of this method in respect to CQL {@code NULL} values is also | |
| 266 | + * codec-dependent. By default, the driver will return mutable instances, and | |
| 267 | + * a CQL {@code NULL} will mapped to an empty collection (note that Cassandra | |
| 268 | + * makes no distinction between {@code NULL} and an empty collection). | |
| 261 | 269 | * |
| 262 | 270 | * @param name the name to retrieve. |
| 263 | 271 | * @param elementsClass the class for the elements of the list to retrieve. |
| 264 | 272 | * @return the value of the {@code i}th element as a list of |
| 265 | - * {@code T} objects. If the value is NULL, an empty list is | |
| 266 | - * returned (note that Cassandra makes no difference between an empty list | |
| 267 | - * and column of type list that is not set). The returned list is immutable. | |
| 273 | + * {@code T} objects. | |
| 268 | 274 | * |
| 269 | 275 | * @throws IllegalArgumentException if {@code name} is not valid name for this object. |
| 270 | 276 | * @throws InvalidTypeException if value {@code name} is not a list or if its |
| @@ -279,13 +285,19 @@ | ||
| 279 | 285 | * <pre> |
| 280 | 286 | * {@code List<List<String>> l = row.getList("theColumn", new TypeToken<List<String>>() {});} |
| 281 | 287 | * </pre> |
| 288 | + * <p> | |
| 289 | + * Implementation note: the actual {@link List} implementation will depend | |
| 290 | + * on the {@link TypeCodec codec} being used; therefore, callers should | |
| 291 | + * make no assumptions concerning its mutability nor its thread-safety. | |
| 292 | + * Furthermore, the behavior of this method in respect to CQL {@code NULL} values is also | |
| 293 | + * codec-dependent. By default, the driver will return mutable instances, and | |
| 294 | + * a CQL {@code NULL} will mapped to an empty collection (note that Cassandra | |
| 295 | + * makes no distinction between {@code NULL} and an empty collection). | |
| 282 | 296 | * |
| 283 | 297 | * @param name the name to retrieve. |
| 284 | 298 | * @param elementsType the type for the elements of the list to retrieve. |
| 285 | 299 | * @return the value of the {@code i}th element as a list of |
| 286 | - * {@code T} objects. If the value is NULL, an empty list is | |
| 287 | - * returned (note that Cassandra makes no difference between an empty list | |
| 288 | - * and column of type list that is not set). The returned list is immutable. | |
| 300 | + * {@code T} objects. | |
| 289 | 301 | * |
| 290 | 302 | * @throws IllegalArgumentException if {@code name} is not valid name for this object. |
| 291 | 303 | * @throws InvalidTypeException if value {@code name} is not a list or if its |
| @@ -297,13 +309,19 @@ | ||
| 297 | 309 | * Returns the value for {@code name} as a set. |
| 298 | 310 | * <p> |
| 299 | 311 | * If the type of the elements is generic, use {@link #getSet(String, TypeToken)}. |
| 312 | + * <p> | |
| 313 | + * Implementation note: the actual {@link Set} implementation will depend | |
| 314 | + * on the {@link TypeCodec codec} being used; therefore, callers should | |
| 315 | + * make no assumptions concerning its mutability nor its thread-safety. | |
| 316 | + * Furthermore, the behavior of this method in respect to CQL {@code NULL} values is also | |
| 317 | + * codec-dependent. By default, the driver will return mutable instances, and | |
| 318 | + * a CQL {@code NULL} will mapped to an empty collection (note that Cassandra | |
| 319 | + * makes no distinction between {@code NULL} and an empty collection). | |
| 300 | 320 | * |
| 301 | 321 | * @param name the name to retrieve. |
| 302 | 322 | * @param elementsClass the class for the elements of the set to retrieve. |
| 303 | 323 | * @return the value of the {@code i}th element as a set of |
| 304 | - * {@code T} objects. If the value is NULL, an empty set is | |
| 305 | - * returned (note that Cassandra makes no difference between an empty set | |
| 306 | - * and column of type set that is not set). The returned set is immutable. | |
| 324 | + * {@code T} objects. | |
| 307 | 325 | * |
| 308 | 326 | * @throws IllegalArgumentException if {@code name} is not valid name for this object. |
| 309 | 327 | * @throws InvalidTypeException if value {@code name} is not a set or if its |
| @@ -318,13 +336,19 @@ | ||
| 318 | 336 | * <pre> |
| 319 | 337 | * {@code Set<List<String>> l = row.getSet("theColumn", new TypeToken<List<String>>() {});} |
| 320 | 338 | * </pre> |
| 339 | + * <p> | |
| 340 | + * Implementation note: the actual {@link Set} implementation will depend | |
| 341 | + * on the {@link TypeCodec codec} being used; therefore, callers should | |
| 342 | + * make no assumptions concerning its mutability nor its thread-safety. | |
| 343 | + * Furthermore, the behavior of this method in respect to CQL {@code NULL} values is also | |
| 344 | + * codec-dependent. By default, the driver will return mutable instances, and | |
| 345 | + * a CQL {@code NULL} will mapped to an empty collection (note that Cassandra | |
| 346 | + * makes no distinction between {@code NULL} and an empty collection). | |
| 321 | 347 | * |
| 322 | 348 | * @param name the name to retrieve. |
| 323 | 349 | * @param elementsType the type for the elements of the set to retrieve. |
| 324 | 350 | * @return the value of the {@code i}th element as a set of |
| 325 | - * {@code T} objects. If the value is NULL, an empty set is | |
| 326 | - * returned (note that Cassandra makes no difference between an empty set | |
| 327 | - * and column of type set that is not set). The returned set is immutable. | |
| 351 | + * {@code T} objects. | |
| 328 | 352 | * |
| 329 | 353 | * @throws IllegalArgumentException if {@code name} is not valid name for this object. |
| 330 | 354 | * @throws InvalidTypeException if value {@code name} is not a set or if its |
| @@ -336,15 +360,20 @@ | ||
| 336 | 360 | * Returns the value for {@code name} as a map. |
| 337 | 361 | * <p> |
| 338 | 362 | * If the type of the keys and/or values is generic, use {@link #getMap(String, TypeToken, TypeToken)}. |
| 363 | + * <p> | |
| 364 | + * Implementation note: the actual {@link Map} implementation will depend | |
| 365 | + * on the {@link TypeCodec codec} being used; therefore, callers should | |
| 366 | + * make no assumptions concerning its mutability nor its thread-safety. | |
| 367 | + * Furthermore, the behavior of this method in respect to CQL {@code NULL} values is also | |
| 368 | + * codec-dependent. By default, the driver will return mutable instances, and | |
| 369 | + * a CQL {@code NULL} will mapped to an empty collection (note that Cassandra | |
| 370 | + * makes no distinction between {@code NULL} and an empty collection). | |
| 339 | 371 | * |
| 340 | 372 | * @param name the name to retrieve. |
| 341 | 373 | * @param keysClass the class for the keys of the map to retrieve. |
| 342 | 374 | * @param valuesClass the class for the values of the map to retrieve. |
| 343 | 375 | * @return the value of {@code name} as a map of |
| 344 | - * {@code K} to {@code V} objects. If the value is NULL, | |
| 345 | - * an empty map is returned (note that Cassandra makes no difference | |
| 346 | - * between an empty map and column of type map that is not set). The | |
| 347 | - * returned map is immutable. | |
| 376 | + * {@code K} to {@code V} objects. | |
| 348 | 377 | * |
| 349 | 378 | * @throws IllegalArgumentException if {@code name} is not valid name for this object. |
| 350 | 379 | * @throws InvalidTypeException if value {@code name} is not a map, if its |
| @@ -360,15 +389,20 @@ | ||
| 360 | 389 | * <pre> |
| 361 | 390 | * {@code Map<Int, List<String>> l = row.getMap("theColumn", TypeToken.of(Integer.class), new TypeToken<List<String>>() {});} |
| 362 | 391 | * </pre> |
| 392 | + * <p> | |
| 393 | + * Implementation note: the actual {@link Map} implementation will depend | |
| 394 | + * on the {@link TypeCodec codec} being used; therefore, callers should | |
| 395 | + * make no assumptions concerning its mutability nor its thread-safety. | |
| 396 | + * Furthermore, the behavior of this method in respect to CQL {@code NULL} values is also | |
| 397 | + * codec-dependent. By default, the driver will return mutable instances, and | |
| 398 | + * a CQL {@code NULL} will mapped to an empty collection (note that Cassandra | |
| 399 | + * makes no distinction between {@code NULL} and an empty collection). | |
| 363 | 400 | * |
| 364 | 401 | * @param name the name to retrieve. |
| 365 | 402 | * @param keysType the class for the keys of the map to retrieve. |
| 366 | 403 | * @param valuesType the class for the values of the map to retrieve. |
| 367 | 404 | * @return the value of {@code name} as a map of |
| 368 | - * {@code K} to {@code V} objects. If the value is NULL, | |
| 369 | - * an empty map is returned (note that Cassandra makes no difference | |
| 370 | - * between an empty map and column of type map that is not set). The | |
| 371 | - * returned map is immutable. | |
| 405 | + * {@code K} to {@code V} objects. | |
| 372 | 406 | * |
| 373 | 407 | * @throws IllegalArgumentException if {@code name} is not valid name for this object. |
| 374 | 408 | * @throws InvalidTypeException if value {@code name} is not a map, if its |
| @@ -410,11 +444,16 @@ | ||
| 410 | 444 | * If a second, custom codec for the same CQL type is registered, which one will |
| 411 | 445 | * be used is unspecified; in such cases, it is preferable to use |
| 412 | 446 | * the more deterministic methods {@link #get(String, Class)} or {@link #get(String, TypeToken)} instead. |
| 447 | + * <p> | |
| 448 | + * Implementation note: the actual object returned by this method will depend | |
| 449 | + * on the {@link TypeCodec codec} being used; therefore, callers should | |
| 450 | + * make no assumptions concerning its mutability nor its thread-safety. | |
| 451 | + * Furthermore, the behavior of this method in respect to CQL {@code NULL} values is also | |
| 452 | + * codec-dependent; by default, a CQL {@code NULL} value translates to {@code null} for | |
| 453 | + * simple CQL types, UDTs and tuples, and to empty collections for all CQL collection types. | |
| 413 | 454 | * |
| 414 | 455 | * @param name the name to retrieve. |
| 415 | 456 | * @return the value of the {@code i}th value as the Java type matching its CQL type. |
| 416 | - * If the value is NULL and is a simple type, UDT or tuple, {@code null} is returned. | |
| 417 | - * If it is NULL and is a collection type, an empty (immutable) collection is returned. | |
| 418 | 457 | * |
| 419 | 458 | * @throws IllegalArgumentException if {@code name} is not a valid name for this object. |
| 420 | 459 | */ |
| @@ -430,11 +469,17 @@ | ||
| 430 | 469 | * where more than one codec is registered for the same CQL type; specifying the Java class |
| 431 | 470 | * allows the {@link CodecRegistry} to narrow down the search and return only an exactly-matching codec (if any), |
| 432 | 471 | * thus avoiding any risk of ambiguity. |
| 472 | + * <p> | |
| 473 | + * Implementation note: the actual object returned by this method will depend | |
| 474 | + * on the {@link TypeCodec codec} being used; therefore, callers should | |
| 475 | + * make no assumptions concerning its mutability nor its thread-safety. | |
| 476 | + * Furthermore, the behavior of this method in respect to CQL {@code NULL} values is also | |
| 477 | + * codec-dependent; by default, a CQL {@code NULL} value translates to {@code null} for | |
| 478 | + * simple CQL types, UDTs and tuples, and to empty collections for all CQL collection types. | |
| 433 | 479 | * |
| 434 | 480 | * @param name the name to retrieve. |
| 435 | 481 | * @param targetClass The Java type the value should be converted to. |
| 436 | 482 | * @return the value for {@code name} value converted to the given Java type. |
| 437 | - * If the CQL value is {@code NULL}, then {@code null} is returned. | |
| 438 | 483 | * @throws IllegalArgumentException if {@code name} is not a valid name for this object. |
| 439 | 484 | * @throws com.datastax.driver.core.exceptions.CodecNotFoundException |
| 440 | 485 | * if no {@link TypeCodec} instance for {@code targetClass} could be found |
| @@ -452,11 +497,17 @@ | ||
| 452 | 497 | * where more than one codec is registered for the same CQL type; specifying the Java class |
| 453 | 498 | * allows the {@link CodecRegistry} to narrow down the search and return only an exactly-matching codec (if any), |
| 454 | 499 | * thus avoiding any risk of ambiguity. |
| 500 | + * <p> | |
| 501 | + * Implementation note: the actual object returned by this method will depend | |
| 502 | + * on the {@link TypeCodec codec} being used; therefore, callers should | |
| 503 | + * make no assumptions concerning its mutability nor its thread-safety. | |
| 504 | + * Furthermore, the behavior of this method in respect to CQL {@code NULL} values is also | |
| 505 | + * codec-dependent; by default, a CQL {@code NULL} value translates to {@code null} for | |
| 506 | + * simple CQL types, UDTs and tuples, and to empty collections for all CQL collection types. | |
| 455 | 507 | * |
| 456 | 508 | * @param name the name to retrieve. |
| 457 | 509 | * @param targetType The Java type the value should be converted to. |
| 458 | 510 | * @return the value for {@code name} value converted to the given Java type. |
| 459 | - * If the CQL value is {@code NULL}, then {@code null} is returned. | |
| 460 | 511 | * @throws IllegalArgumentException if {@code name} is not a valid name for this object. |
| 461 | 512 | * @throws com.datastax.driver.core.exceptions.CodecNotFoundException |
| 462 | 513 | * if no {@link TypeCodec} instance for {@code targetType} could be found |
| @@ -472,6 +523,13 @@ | ||
| 472 | 523 | * <p> |
| 473 | 524 | * It is the caller's responsibility to ensure that the given codec {@link TypeCodec#accepts(DataType) accepts} |
| 474 | 525 | * the underlying CQL type; failing to do so may result in {@link InvalidTypeException}s being thrown. |
| 526 | + * <p> | |
| 527 | + * Implementation note: the actual object returned by this method will depend | |
| 528 | + * on the {@link TypeCodec codec} being used; therefore, callers should | |
| 529 | + * make no assumptions concerning its mutability nor its thread-safety. | |
| 530 | + * Furthermore, the behavior of this method in respect to CQL {@code NULL} values is also | |
| 531 | + * codec-dependent; by default, a CQL {@code NULL} value translates to {@code null} for | |
| 532 | + * simple CQL types, UDTs and tuples, and to empty collections for all CQL collection types. | |
| 475 | 533 | * |
| 476 | 534 | * @param name the name to retrieve. |
| 477 | 535 | * @param codec The {@link TypeCodec} to use to deserialize the value; may not be {@code null}. |
modified driver-core/src/main/java/com/datastax/driver/core/Row.java +0 −624
| @@ -15,12 +15,6 @@ | ||
| 15 | 15 | */ |
| 16 | 16 | package com.datastax.driver.core; |
| 17 | 17 | |
| 18 | -import java.math.BigDecimal; | |
| 19 | -import java.math.BigInteger; | |
| 20 | -import java.net.InetAddress; | |
| 21 | -import java.nio.ByteBuffer; | |
| 22 | -import java.util.*; | |
| 23 | - | |
| 24 | 18 | import com.datastax.driver.core.exceptions.InvalidTypeException; |
| 25 | 19 | |
| 26 | 20 | /** |
| @@ -31,7 +25,6 @@ | ||
| 31 | 25 | * rules explained in {@link ColumnDefinitions}. |
| 32 | 26 | */ |
| 33 | 27 | public interface Row extends GettableData { |
| 34 | - // Note that we re-include all the methods of GettableData just for the sake of better javadoc | |
| 35 | 28 | |
| 36 | 29 | /** |
| 37 | 30 | * Returns the columns contained in this Row. |
| @@ -40,505 +33,6 @@ | ||
| 40 | 33 | */ |
| 41 | 34 | public ColumnDefinitions getColumnDefinitions(); |
| 42 | 35 | |
| 43 | - /** | |
| 44 | - * Returns whether the {@code i}th value of this row is NULL. | |
| 45 | - * | |
| 46 | - * @param i the index ({@code 0 <= i < size()}) of the column to check. | |
| 47 | - * @return whether the {@code i}th value of this row is NULL. | |
| 48 | - * | |
| 49 | - * @throws IndexOutOfBoundsException if {@code i < 0 || i >= this.columns().size()}. | |
| 50 | - */ | |
| 51 | - @Override | |
| 52 | - public boolean isNull(int i); | |
| 53 | - | |
| 54 | - /** | |
| 55 | - * Returns whether the value for column {@code name} in this row is NULL. | |
| 56 | - * | |
| 57 | - * @param name the name of the column to check. | |
| 58 | - * @return whether the value of column {@code name} is NULL. | |
| 59 | - * | |
| 60 | - * @throws IllegalArgumentException if {@code name} is not part of the | |
| 61 | - * ResultSet this row is part of, i.e. if {@code !this.columns().names().contains(name)}. | |
| 62 | - */ | |
| 63 | - @Override | |
| 64 | - public boolean isNull(String name); | |
| 65 | - | |
| 66 | - /** | |
| 67 | - * Returns the {@code i}th value of this row as a boolean. | |
| 68 | - * | |
| 69 | - * @param i the index ({@code 0 <= i < size()}) of the column to retrieve. | |
| 70 | - * @return the boolean value of the {@code i}th column in this row. If the | |
| 71 | - * value is NULL, {@code false} is returned. | |
| 72 | - * | |
| 73 | - * @throws IndexOutOfBoundsException if {@code i < 0 || i >= this.columns().size()}. | |
| 74 | - * @throws InvalidTypeException if column {@code i} is not of type BOOLEAN. | |
| 75 | - */ | |
| 76 | - @Override | |
| 77 | - public boolean getBool(int i); | |
| 78 | - | |
| 79 | - /** | |
| 80 | - * Returns the value of column {@code name} as a boolean. | |
| 81 | - * | |
| 82 | - * @param name the name of the column to retrieve. | |
| 83 | - * @return the boolean value of column {@code name}. If the value is NULL, | |
| 84 | - * {@code false} is returned. | |
| 85 | - * | |
| 86 | - * @throws IllegalArgumentException if {@code name} is not part of the | |
| 87 | - * ResultSet this row is part of, i.e. if {@code !this.columns().names().contains(name)}. | |
| 88 | - * @throws InvalidTypeException if column {@code name} is not of type BOOLEAN. | |
| 89 | - */ | |
| 90 | - @Override | |
| 91 | - public boolean getBool(String name); | |
| 92 | - | |
| 93 | - /** | |
| 94 | - * Returns the {@code i}th value of this row as a byte. | |
| 95 | - * | |
| 96 | - * @param i the index ({@code 0 <= i < size()}) of the column to retrieve. | |
| 97 | - * @return the value of the {@code i}th column in this row as a byte. If the | |
| 98 | - * value is NULL, {@code 0} is returned. | |
| 99 | - * | |
| 100 | - * @throws IndexOutOfBoundsException if {@code i < 0 || i >= this.columns().size()}. | |
| 101 | - * @throws InvalidTypeException if column {@code i} is not of type TINYINT. | |
| 102 | - */ | |
| 103 | - @Override | |
| 104 | - public byte getByte(int i); | |
| 105 | - | |
| 106 | - /** | |
| 107 | - * Returns the value of column {@code name} as a byte. | |
| 108 | - * | |
| 109 | - * @param name the name of the column to retrieve. | |
| 110 | - * @return the value of column {@code name} as a byte. If the value is NULL, | |
| 111 | - * {@code 0} is returned. | |
| 112 | - * | |
| 113 | - * @throws IllegalArgumentException if {@code name} is not part of the | |
| 114 | - * ResultSet this row is part of, i.e. if {@code !this.columns().names().contains(name)}. | |
| 115 | - * @throws InvalidTypeException if column {@code name} is not of type TINYINT. | |
| 116 | - */ | |
| 117 | - @Override | |
| 118 | - public byte getByte(String name); | |
| 119 | - | |
| 120 | - /** | |
| 121 | - * Returns the {@code i}th value of this row as a short. | |
| 122 | - * | |
| 123 | - * @param i the index ({@code 0 <= i < size()}) of the column to retrieve. | |
| 124 | - * @return the value of the {@code i}th column in this row as a short. If the | |
| 125 | - * value is NULL, {@code 0} is returned. | |
| 126 | - * | |
| 127 | - * @throws IndexOutOfBoundsException if {@code i < 0 || i >= this.columns().size()}. | |
| 128 | - * @throws InvalidTypeException if column {@code i} is not of type SMALLINT. | |
| 129 | - */ | |
| 130 | - @Override | |
| 131 | - public short getShort(int i); | |
| 132 | - | |
| 133 | - /** | |
| 134 | - * Returns the value of column {@code name} as a short. | |
| 135 | - * | |
| 136 | - * @param name the name of the column to retrieve. | |
| 137 | - * @return the value of column {@code name} as a short. If the value is NULL, | |
| 138 | - * {@code 0} is returned. | |
| 139 | - * | |
| 140 | - * @throws IllegalArgumentException if {@code name} is not part of the | |
| 141 | - * ResultSet this row is part of, i.e. if {@code !this.columns().names().contains(name)}. | |
| 142 | - * @throws InvalidTypeException if column {@code name} is not of type SMALLINT. | |
| 143 | - */ | |
| 144 | - @Override | |
| 145 | - public short getShort(String name); | |
| 146 | - | |
| 147 | - /** | |
| 148 | - * Returns the {@code i}th value of this row as an integer. | |
| 149 | - * | |
| 150 | - * @param i the index ({@code 0 <= i < size()}) of the column to retrieve. | |
| 151 | - * @return the value of the {@code i}th column in this row as an integer. If the | |
| 152 | - * value is NULL, {@code 0} is returned. | |
| 153 | - * | |
| 154 | - * @throws IndexOutOfBoundsException if {@code i < 0 || i >= this.columns().size()}. | |
| 155 | - * @throws InvalidTypeException if column {@code i} is not of type INT. | |
| 156 | - */ | |
| 157 | - @Override | |
| 158 | - public int getInt(int i); | |
| 159 | - | |
| 160 | - /** | |
| 161 | - * Returns the value of column {@code name} as an integer. | |
| 162 | - * | |
| 163 | - * @param name the name of the column to retrieve. | |
| 164 | - * @return the value of column {@code name} as an integer. If the value is NULL, | |
| 165 | - * {@code 0} is returned. | |
| 166 | - * | |
| 167 | - * @throws IllegalArgumentException if {@code name} is not part of the | |
| 168 | - * ResultSet this row is part of, i.e. if {@code !this.columns().names().contains(name)}. | |
| 169 | - * @throws InvalidTypeException if column {@code name} is not of type INT. | |
| 170 | - */ | |
| 171 | - @Override | |
| 172 | - public int getInt(String name); | |
| 173 | - | |
| 174 | - /** | |
| 175 | - * Returns the {@code i}th value of this row as a long. | |
| 176 | - * | |
| 177 | - * @param i the index ({@code 0 <= i < size()}) of the column to retrieve. | |
| 178 | - * @return the value of the {@code i}th column in this row as a long. If the | |
| 179 | - * value is NULL, {@code 0L} is returned. | |
| 180 | - * | |
| 181 | - * @throws IndexOutOfBoundsException if {@code i < 0 || i >= this.columns().size()}. | |
| 182 | - * @throws InvalidTypeException if column {@code i} is not of type BIGINT or COUNTER. | |
| 183 | - */ | |
| 184 | - @Override | |
| 185 | - public long getLong(int i); | |
| 186 | - | |
| 187 | - /** | |
| 188 | - * Returns the value of column {@code name} as a long. | |
| 189 | - * | |
| 190 | - * @param name the name of the column to retrieve. | |
| 191 | - * @return the value of column {@code name} as a long. If the value is NULL, | |
| 192 | - * {@code 0L} is returned. | |
| 193 | - * | |
| 194 | - * @throws IllegalArgumentException if {@code name} is not part of the | |
| 195 | - * ResultSet this row is part of, i.e. if {@code !this.columns().names().contains(name)}. | |
| 196 | - * @throws InvalidTypeException if column {@code i} is not of type BIGINT or COUNTER. | |
| 197 | - */ | |
| 198 | - @Override | |
| 199 | - public long getLong(String name); | |
| 200 | - | |
| 201 | - /** | |
| 202 | - * Returns the {@code i}th value of this row as a date. | |
| 203 | - * | |
| 204 | - * @param i the index ({@code 0 <= i < size()}) of the column to retrieve. | |
| 205 | - * @return the value of the {@code i}th column in this row as a data. If the | |
| 206 | - * value is NULL, {@code null} is returned. | |
| 207 | - * | |
| 208 | - * @throws IndexOutOfBoundsException if {@code i < 0 || i >= this.columns().size()}. | |
| 209 | - * @throws InvalidTypeException if column {@code i} is not of type TIMESTAMP. | |
| 210 | - */ | |
| 211 | - @Override | |
| 212 | - public Date getTimestamp(int i); | |
| 213 | - | |
| 214 | - /** | |
| 215 | - * Returns the value of column {@code name} as a date. | |
| 216 | - * | |
| 217 | - * @param name the name of the column to retrieve. | |
| 218 | - * @return the value of column {@code name} as a date. If the value is NULL, | |
| 219 | - * {@code null} is returned. | |
| 220 | - * | |
| 221 | - * @throws IllegalArgumentException if {@code name} is not part of the | |
| 222 | - * ResultSet this row is part of, i.e. if {@code !this.columns().names().contains(name)}. | |
| 223 | - * @throws InvalidTypeException if column {@code name} is not of type TIMESTAMP. | |
| 224 | - */ | |
| 225 | - @Override | |
| 226 | - public Date getTimestamp(String name); | |
| 227 | - | |
| 228 | - /** | |
| 229 | - * Returns the {@code i}th value as a date (without time). | |
| 230 | - * | |
| 231 | - * @param i the index ({@code 0 <= i < size()}) to retrieve. | |
| 232 | - * @return the value of the {@code i}th element as a date. If the | |
| 233 | - * value is NULL, {@code null} is returned. | |
| 234 | - * | |
| 235 | - * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object. | |
| 236 | - * @throws InvalidTypeException if value {@code i} is not of type DATE. | |
| 237 | - */ | |
| 238 | - @Override | |
| 239 | - public LocalDate getDate(int i); | |
| 240 | - | |
| 241 | - /** | |
| 242 | - * Returns the value for {@code name} as a date (without time). | |
| 243 | - * | |
| 244 | - * @param name the name to retrieve. | |
| 245 | - * @return the value for {@code name} as a date. If the value is NULL, | |
| 246 | - * {@code null} is returned. | |
| 247 | - * | |
| 248 | - * @throws IllegalArgumentException if {@code name} is not valid name for this object. | |
| 249 | - * @throws InvalidTypeException if value {@code name} is not of type DATE. | |
| 250 | - */ | |
| 251 | - @Override | |
| 252 | - public LocalDate getDate(String name); | |
| 253 | - | |
| 254 | - /** | |
| 255 | - * Returns the {@code i}th value as a long in nanoseconds since midnight. | |
| 256 | - * | |
| 257 | - * @param i the index ({@code 0 <= i < size()}) to retrieve. | |
| 258 | - * @return the value of the {@code i}th element as a long. If the | |
| 259 | - * value is NULL, {@code 0L} is returned. | |
| 260 | - * | |
| 261 | - * @throws IndexOutOfBoundsException if {@code i} is not a valid index for this object. | |
| 262 | - * @throws InvalidTypeException if value {@code i} is not of type TIME. | |
| 263 | - */ | |
| 264 | - @Override | |
| 265 | - public long getTime(int i); | |
| 266 | - | |
| 267 | - /** | |
| 268 | - * Returns the value for {@code name} as a long in nanoseconds since midnight. | |
| 269 | - * | |
| 270 | - * @param name the name to retrieve. | |
| 271 | - * @return the value for {@code name} as a long. If the value is NULL, | |
| 272 | - * {@code 0L} is returned. | |
| 273 | - * | |
| 274 | - * @throws IllegalArgumentException if {@code name} is not valid name for this object. | |
| 275 | - * @throws InvalidTypeException if value {@code name} is not of type TIME. | |
| 276 | - */ | |
| 277 | - @Override | |
| 278 | - public long getTime(String name); | |
| 279 | - | |
| 280 | - /** | |
| 281 | - * Returns the {@code i}th value of this row as a float. | |
| 282 | - * | |
| 283 | - * @param i the index ({@code 0 <= i < size()}) of the column to retrieve. | |
| 284 | - * @return the value of the {@code i}th column in this row as a float. If the | |
| 285 | - * value is NULL, {@code 0.0f} is returned. | |
| 286 | - * | |
| 287 | - * @throws IndexOutOfBoundsException if {@code i < 0 || i >= this.columns().size()}. | |
| 288 | - * @throws InvalidTypeException if column {@code i} is not of type FLOAT. | |
| 289 | - */ | |
| 290 | - @Override | |
| 291 | - public float getFloat(int i); | |
| 292 | - | |
| 293 | - /** | |
| 294 | - * Returns the value of column {@code name} as a float. | |
| 295 | - * | |
| 296 | - * @param name the name of the column to retrieve. | |
| 297 | - * @return the value of column {@code name} as a float. If the value is NULL, | |
| 298 | - * {@code 0.0f} is returned. | |
| 299 | - * | |
| 300 | - * @throws IllegalArgumentException if {@code name} is not part of the | |
| 301 | - * ResultSet this row is part of, i.e. if {@code !this.columns().names().contains(name)}. | |
| 302 | - * @throws InvalidTypeException if column {@code name} is not of type FLOAT. | |
| 303 | - */ | |
| 304 | - @Override | |
| 305 | - public float getFloat(String name); | |
| 306 | - | |
| 307 | - /** | |
| 308 | - * Returns the {@code i}th value of this row as a double. | |
| 309 | - * | |
| 310 | - * @param i the index ({@code 0 <= i < size()}) of the column to retrieve. | |
| 311 | - * @return the value of the {@code i}th column in this row as a double. If the | |
| 312 | - * value is NULL, {@code 0.0} is returned. | |
| 313 | - * | |
| 314 | - * @throws IndexOutOfBoundsException if {@code i < 0 || i >= this.columns().size()}. | |
| 315 | - * @throws InvalidTypeException if column {@code i} is not of type DOUBLE. | |
| 316 | - */ | |
| 317 | - @Override | |
| 318 | - public double getDouble(int i); | |
| 319 | - | |
| 320 | - /** | |
| 321 | - * Returns the value of column {@code name} as a double. | |
| 322 | - * | |
| 323 | - * @param name the name of the column to retrieve. | |
| 324 | - * @return the value of column {@code name} as a double. If the value is NULL, | |
| 325 | - * {@code 0.0} is returned. | |
| 326 | - * | |
| 327 | - * @throws IllegalArgumentException if {@code name} is not part of the | |
| 328 | - * ResultSet this row is part of, i.e. if {@code !this.columns().names().contains(name)}. | |
| 329 | - * @throws InvalidTypeException if column {@code name} is not of type DOUBLE. | |
| 330 | - */ | |
| 331 | - @Override | |
| 332 | - public double getDouble(String name); | |
| 333 | - | |
| 334 | - /** | |
| 335 | - * Returns the {@code i}th value of this row as a ByteBuffer. | |
| 336 | - * | |
| 337 | - * Note: this method always return the bytes composing the value, even if | |
| 338 | - * the column is not of type BLOB. That is, this method never throw an | |
| 339 | - * InvalidTypeException. However, if the type is not BLOB, it is up to the | |
| 340 | - * caller to handle the returned value correctly. | |
| 341 | - * | |
| 342 | - * @param i the index ({@code 0 <= i < size()}) of the column to retrieve. | |
| 343 | - * @return the value of the {@code i}th column in this row as a ByteBuffer. If the | |
| 344 | - * value is NULL, {@code null} is returned. | |
| 345 | - * | |
| 346 | - * @throws IndexOutOfBoundsException if {@code i < 0 || i >= this.columns().size()}. | |
| 347 | - */ | |
| 348 | - @Override | |
| 349 | - public ByteBuffer getBytesUnsafe(int i); | |
| 350 | - | |
| 351 | - /** | |
| 352 | - * Returns the value of column {@code name} as a ByteBuffer. | |
| 353 | - * | |
| 354 | - * Note: this method always return the bytes composing the value, even if | |
| 355 | - * the column is not of type BLOB. That is, this method never throw an | |
| 356 | - * InvalidTypeException. However, if the type is not BLOB, it is up to the | |
| 357 | - * caller to handle the returned value correctly. | |
| 358 | - * | |
| 359 | - * @param name the name of the column to retrieve. | |
| 360 | - * @return the value of column {@code name} as a ByteBuffer. If the value is NULL, | |
| 361 | - * {@code null} is returned. | |
| 362 | - * | |
| 363 | - * @throws IllegalArgumentException if {@code name} is not part of the | |
| 364 | - * ResultSet this row is part of, i.e. if {@code !this.columns().names().contains(name)}. | |
| 365 | - */ | |
| 366 | - @Override | |
| 367 | - public ByteBuffer getBytesUnsafe(String name); | |
| 368 | - | |
| 369 | - /** | |
| 370 | - * Returns the {@code i}th value of this row as a byte array. | |
| 371 | - * <p> | |
| 372 | - * Note that this method validate that the column is of type BLOB. If you want to retrieve | |
| 373 | - * the bytes for any type of columns, use {@link #getBytesUnsafe(int)} instead. | |
| 374 | - * | |
| 375 | - * @param i the index ({@code 0 <= i < size()}) of the column to retrieve. | |
| 376 | - * @return the value of the {@code i}th column in this row as a byte array. If the | |
| 377 | - * value is NULL, {@code null} is returned. | |
| 378 | - * | |
| 379 | - * @throws IndexOutOfBoundsException if {@code i < 0 || i >= this.columns().size()}. | |
| 380 | - * @throws InvalidTypeException if column {@code i} type is not of type BLOB. | |
| 381 | - */ | |
| 382 | - @Override | |
| 383 | - public ByteBuffer getBytes(int i); | |
| 384 | - | |
| 385 | - /** | |
| 386 | - * Returns the value of column {@code name} as a byte array. | |
| 387 | - * <p> | |
| 388 | - * Note that this method validate that the column is of type BLOB. If you want to retrieve | |
| 389 | - * the bytes for any type of columns, use {@link #getBytesUnsafe(String)} instead. | |
| 390 | - * | |
| 391 | - * @param name the name of the column to retrieve. | |
| 392 | - * @return the value of column {@code name} as a byte array. If the value is NULL, | |
| 393 | - * {@code null} is returned. | |
| 394 | - * | |
| 395 | - * @throws IllegalArgumentException if {@code name} is not part of the | |
| 396 | - * ResultSet this row is part of, i.e. if {@code !this.columns().names().contains(name)}. | |
| 397 | - * @throws InvalidTypeException if column {@code i} type is not of type BLOB. | |
| 398 | - */ | |
| 399 | - @Override | |
| 400 | - public ByteBuffer getBytes(String name); | |
| 401 | - | |
| 402 | - /** | |
| 403 | - * Returns the {@code i}th value of this row as a string. | |
| 404 | - * | |
| 405 | - * @param i the index ({@code 0 <= i < size()}) of the column to retrieve. | |
| 406 | - * @return the value of the {@code i}th column in this row as a string. If the | |
| 407 | - * value is NULL, {@code null} is returned. | |
| 408 | - * | |
| 409 | - * @throws IndexOutOfBoundsException if {@code i < 0 || i >= this.columns().size()}. | |
| 410 | - * @throws InvalidTypeException if column {@code i} type is none of: | |
| 411 | - * VARCHAR, TEXT or ASCII. | |
| 412 | - */ | |
| 413 | - @Override | |
| 414 | - public String getString(int i); | |
| 415 | - | |
| 416 | - /** | |
| 417 | - * Returns the value of column {@code name} as a string. | |
| 418 | - * | |
| 419 | - * @param name the name of the column to retrieve. | |
| 420 | - * @return the value of column {@code name} as a string. If the value is NULL, | |
| 421 | - * {@code null} is returned. | |
| 422 | - * | |
| 423 | - * @throws IllegalArgumentException if {@code name} is not part of the | |
| 424 | - * ResultSet this row is part of, i.e. if {@code !this.columns().names().contains(name)}. | |
| 425 | - * @throws InvalidTypeException if column {@code name} type is none of: | |
| 426 | - * VARCHAR, TEXT or ASCII. | |
| 427 | - */ | |
| 428 | - @Override | |
| 429 | - public String getString(String name); | |
| 430 | - | |
| 431 | - /** | |
| 432 | - * Returns the {@code i}th value of this row as a variable length integer. | |
| 433 | - * | |
| 434 | - * @param i the index ({@code 0 <= i < size()}) of the column to retrieve. | |
| 435 | - * @return the value of the {@code i}th column in this row as a variable | |
| 436 | - * length integer. If the value is NULL, {@code null} is returned. | |
| 437 | - * | |
| 438 | - * @throws IndexOutOfBoundsException if {@code i < 0 || i >= this.columns().size()}. | |
| 439 | - * @throws InvalidTypeException if column {@code i} is not of type VARINT. | |
| 440 | - */ | |
| 441 | - @Override | |
| 442 | - public BigInteger getVarint(int i); | |
| 443 | - | |
| 444 | - /** | |
| 445 | - * Returns the value of column {@code name} as a variable length integer. | |
| 446 | - * | |
| 447 | - * @param name the name of the column to retrieve. | |
| 448 | - * @return the value of column {@code name} as a variable length integer. | |
| 449 | - * If the value is NULL, {@code null} is returned. | |
| 450 | - * | |
| 451 | - * @throws IllegalArgumentException if {@code name} is not part of the | |
| 452 | - * ResultSet this row is part of, i.e. if {@code !this.columns().names().contains(name)}. | |
| 453 | - * @throws InvalidTypeException if column {@code name} is not of type VARINT. | |
| 454 | - */ | |
| 455 | - @Override | |
| 456 | - public BigInteger getVarint(String name); | |
| 457 | - | |
| 458 | - /** | |
| 459 | - * Returns the {@code i}th value of this row as a variable length decimal. | |
| 460 | - * | |
| 461 | - * @param i the index ({@code 0 <= i < size()}) of the column to retrieve. | |
| 462 | - * @return the value of the {@code i}th column in this row as a variable | |
| 463 | - * length decimal. If the value is NULL, {@code null} is returned. | |
| 464 | - * | |
| 465 | - * @throws IndexOutOfBoundsException if {@code i < 0 || i >= this.columns().size()}. | |
| 466 | - * @throws InvalidTypeException if column {@code i} is not of type DECIMAL. | |
| 467 | - */ | |
| 468 | - @Override | |
| 469 | - public BigDecimal getDecimal(int i); | |
| 470 | - | |
| 471 | - /** | |
| 472 | - * Returns the value of column {@code name} as a variable length decimal. | |
| 473 | - * | |
| 474 | - * @param name the name of the column to retrieve. | |
| 475 | - * @return the value of column {@code name} as a variable length decimal. | |
| 476 | - * If the value is NULL, {@code null} is returned. | |
| 477 | - * | |
| 478 | - * @throws IllegalArgumentException if {@code name} is not part of the | |
| 479 | - * ResultSet this row is part of, i.e. if {@code !this.columns().names().contains(name)}. | |
| 480 | - * @throws InvalidTypeException if column {@code name} is not of type DECIMAL. | |
| 481 | - */ | |
| 482 | - @Override | |
| 483 | - public BigDecimal getDecimal(String name); | |
| 484 | - | |
| 485 | - /** | |
| 486 | - * Returns the {@code i}th value of this row as a UUID. | |
| 487 | - * | |
| 488 | - * @param i the index ({@code 0 <= i < size()}) of the column to retrieve. | |
| 489 | - * @return the value of the {@code i}th column in this row as a UUID. | |
| 490 | - * If the value is NULL, {@code null} is returned. | |
| 491 | - * | |
| 492 | - * @throws IndexOutOfBoundsException if {@code i < 0 || i >= this.columns().size()}. | |
| 493 | - * @throws InvalidTypeException if column {@code i} is not of type UUID | |
| 494 | - * or TIMEUUID. | |
| 495 | - */ | |
| 496 | - @Override | |
| 497 | - public UUID getUUID(int i); | |
| 498 | - | |
| 499 | - /** | |
| 500 | - * Returns the value of column {@code name} as a UUID. | |
| 501 | - * | |
| 502 | - * @param name the name of the column to retrieve. | |
| 503 | - * @return the value of column {@code name} as a UUID. | |
| 504 | - * If the value is NULL, {@code null} is returned. | |
| 505 | - * | |
| 506 | - * @throws IllegalArgumentException if {@code name} is not part of the | |
| 507 | - * ResultSet this row is part of, i.e. if {@code !this.columns().names().contains(name)}. | |
| 508 | - * @throws InvalidTypeException if column {@code name} is not of type | |
| 509 | - * UUID or TIMEUUID. | |
| 510 | - */ | |
| 511 | - @Override | |
| 512 | - public UUID getUUID(String name); | |
| 513 | - | |
| 514 | - /** | |
| 515 | - * Returns the {@code i}th value of this row as an InetAddress. | |
| 516 | - * | |
| 517 | - * @param i the index ({@code 0 <= i < size()}) of the column to retrieve. | |
| 518 | - * @return the value of the {@code i}th column in this row as an InetAddress. | |
| 519 | - * If the value is NULL, {@code null} is returned. | |
| 520 | - * | |
| 521 | - * @throws IndexOutOfBoundsException if {@code i < 0 || i >= this.columns().size()}. | |
| 522 | - * @throws InvalidTypeException if column {@code i} is not of type INET. | |
| 523 | - */ | |
| 524 | - @Override | |
| 525 | - public InetAddress getInet(int i); | |
| 526 | - | |
| 527 | - /** | |
| 528 | - * Returns the value of column {@code name} as an InetAddress. | |
| 529 | - * | |
| 530 | - * @param name the name of the column to retrieve. | |
| 531 | - * @return the value of column {@code name} as an InetAddress. | |
| 532 | - * If the value is NULL, {@code null} is returned. | |
| 533 | - * | |
| 534 | - * @throws IllegalArgumentException if {@code name} is not part of the | |
| 535 | - * ResultSet this row is part of, i.e. if {@code !this.columns().names().contains(name)}. | |
| 536 | - * @throws InvalidTypeException if column {@code name} is not of type | |
| 537 | - * INET. | |
| 538 | - */ | |
| 539 | - @Override | |
| 540 | - public InetAddress getInet(String name); | |
| 541 | - | |
| 542 | 36 | /** |
| 543 | 37 | * Returns the {@code i}th value of this row as a {@link Token}. |
| 544 | 38 | * <p> |
| @@ -593,122 +87,4 @@ | ||
| 593 | 87 | */ |
| 594 | 88 | public Token getPartitionKeyToken(); |
| 595 | 89 | |
| 596 | - /** | |
| 597 | - * Returns the {@code i}th value of this row as a list. | |
| 598 | - * | |
| 599 | - * @param <T> the type of the elements of the list to return. | |
| 600 | - * @param i the index ({@code 0 <= i < size()}) of the column to retrieve. | |
| 601 | - * @param elementsClass the class for the elements of the list to retrieve. | |
| 602 | - * @return the value of the {@code i}th column in this row as a list of | |
| 603 | - * {@code elementsClass} objects. If the value is NULL, an empty list is | |
| 604 | - * returned (note that Cassandra makes no difference between an empty list | |
| 605 | - * and column of type list that is not set). The returned list is immutable. | |
| 606 | - * | |
| 607 | - * @throws IndexOutOfBoundsException if {@code i < 0 || i >= this.columns().size()}. | |
| 608 | - * @throws InvalidTypeException if column {@code i} is not a list or if its | |
| 609 | - * elements are not of class {@code elementsClass}. | |
| 610 | - */ | |
| 611 | - @Override | |
| 612 | - public <T> List<T> getList(int i, Class<T> elementsClass); | |
| 613 | - | |
| 614 | - /** | |
| 615 | - * Returns the value of column {@code name} as a list. | |
| 616 | - * | |
| 617 | - * @param <T> the type of the elements of the list to return. | |
| 618 | - * @param name the name of the column to retrieve. | |
| 619 | - * @param elementsClass the class for the elements of the list to retrieve. | |
| 620 | - * @return the value of the {@code i}th column in this row as a list of | |
| 621 | - * {@code elementsClass} objects. If the value is NULL, an empty list is | |
| 622 | - * returned (note that Cassandra makes no difference between an empty list | |
| 623 | - * and column of type list that is not set). The returned list is immutable. | |
| 624 | - * | |
| 625 | - * @throws IllegalArgumentException if {@code name} is not part of the | |
| 626 | - * ResultSet this row is part of, i.e. if {@code !this.columns().names().contains(name)}. | |
| 627 | - * @throws InvalidTypeException if column {@code name} is not a list or if its | |
| 628 | - * elements are not of class {@code elementsClass}. | |
| 629 | - */ | |
| 630 | - @Override | |
| 631 | - public <T> List<T> getList(String name, Class<T> elementsClass); | |
| 632 | - | |
| 633 | - /** | |
| 634 | - * Returns the {@code i}th value of this row as a set. | |
| 635 | - * | |
| 636 | - * @param <T> the type of the elements of the set to return. | |
| 637 | - * @param i the index ({@code 0 <= i < size()}) of the column to retrieve. | |
| 638 | - * @param elementsClass the class for the elements of the set to retrieve. | |
| 639 | - * @return the value of the {@code i}th column in this row as a set of | |
| 640 | - * {@code elementsClass} objects. If the value is NULL, an empty set is | |
| 641 | - * returned (note that Cassandra makes no difference between an empty set | |
| 642 | - * and column of type set that is not set). The returned set is immutable. | |
| 643 | - * | |
| 644 | - * @throws IndexOutOfBoundsException if {@code i < 0 || i >= this.columns().size()}. | |
| 645 | - * @throws InvalidTypeException if column {@code i} is not a set or if its | |
| 646 | - * elements are not of class {@code elementsClass}. | |
| 647 | - */ | |
| 648 | - @Override | |
| 649 | - public <T> Set<T> getSet(int i, Class<T> elementsClass); | |
| 650 | - | |
| 651 | - /** | |
| 652 | - * Returns the value of column {@code name} as a set. | |
| 653 | - * | |
| 654 | - * @param <T> the type of the elements of the set to return. | |
| 655 | - * @param name the name of the column to retrieve. | |
| 656 | - * @param elementsClass the class for the elements of the set to retrieve. | |
| 657 | - * @return the value of the {@code i}th column in this row as a set of | |
| 658 | - * {@code elementsClass} objects. If the value is NULL, an empty set is | |
| 659 | - * returned (note that Cassandra makes no difference between an empty set | |
| 660 | - * and column of type set that is not set). The returned set is immutable. | |
| 661 | - * | |
| 662 | - * @throws IllegalArgumentException if {@code name} is not part of the | |
| 663 | - * ResultSet this row is part of, i.e. if {@code !this.columns().names().contains(name)}. | |
| 664 | - * @throws InvalidTypeException if column {@code name} is not a set or if its | |
| 665 | - * elements are not of class {@code elementsClass}. | |
| 666 | - */ | |
| 667 | - @Override | |
| 668 | - public <T> Set<T> getSet(String name, Class<T> elementsClass); | |
| 669 | - | |
| 670 | - /** | |
| 671 | - * Returns the {@code i}th value of this row as a map. | |
| 672 | - * | |
| 673 | - * @param <K> the type of the keys of the map to return. | |
| 674 | - * @param <V> the type of the values of the map to return. | |
| 675 | - * @param i the index ({@code 0 <= i < size()}) of the column to retrieve. | |
| 676 | - * @param keysClass the class for the keys of the map to retrieve. | |
| 677 | - * @param valuesClass the class for the values of the map to retrieve. | |
| 678 | - * @return the value of the {@code i}th column in this row as a map of | |
| 679 | - * {@code keysClass} to {@code valuesClass} objects. If the value is NULL, | |
| 680 | - * an empty map is returned (note that Cassandra makes no difference | |
| 681 | - * between an empty map and column of type map that is not set). The | |
| 682 | - * returned map is immutable. | |
| 683 | - * | |
| 684 | - * @throws IndexOutOfBoundsException if {@code i < 0 || i >= this.columns().size()}. | |
| 685 | - * @throws InvalidTypeException if column {@code i} is not a map, if its | |
| 686 | - * keys are not of class {@code keysClass} or if its values are not of | |
| 687 | - * class {@code valuesClass}. | |
| 688 | - */ | |
| 689 | - @Override | |
| 690 | - public <K, V> Map<K, V> getMap(int i, Class<K> keysClass, Class<V> valuesClass); | |
| 691 | - | |
| 692 | - /** | |
| 693 | - * Returns the value of column {@code name} as a map. | |
| 694 | - * | |
| 695 | - * @param <K> the type of the keys of the map to return. | |
| 696 | - * @param <V> the type of the values of the map to return. | |
| 697 | - * @param name the name of the column to retrieve. | |
| 698 | - * @param keysClass the class for the keys of the map to retrieve. | |
| 699 | - * @param valuesClass the class for the values of the map to retrieve. | |
| 700 | - * @return the value of the {@code i}th column in this row as a map of | |
| 701 | - * {@code keysClass} to {@code valuesClass} objects. If the value is NULL, | |
| 702 | - * an empty map is returned (note that Cassandra makes no difference | |
| 703 | - * between an empty map and column of type map that is not set). The | |
| 704 | - * returned map is immutable. | |
| 705 | - * | |
| 706 | - * @throws IllegalArgumentException if {@code name} is not part of the | |
| 707 | - * ResultSet this row is part of, i.e. if {@code !this.columns().names().contains(name)}. | |
| 708 | - * @throws InvalidTypeException if column {@code name} is not a map, if its | |
| 709 | - * keys are not of class {@code keysClass} or if its values are not of | |
| 710 | - * class {@code valuesClass}. | |
| 711 | - */ | |
| 712 | - @Override | |
| 713 | - public <K, V> Map<K, V> getMap(String name, Class<K> keysClass, Class<V> valuesClass); | |
| 714 | 90 | } |
modified driver-core/src/main/java/com/datastax/driver/core/TypeCodec.java +11 −19
| @@ -192,9 +192,10 @@ | ||
| 192 | 192 | * <li>Null or empty buffers should be gracefully handled and no exception should be raised; |
| 193 | 193 | * these should be considered as the equivalent of a NULL CQL value and, in most cases, should |
| 194 | 194 | * map to {@code null} or a default value for the corresponding Java type, if applicable;</li> |
| 195 | - * <li>Codecs for CQL collection types should return unmodifiable collections;</li> | |
| 195 | + * <li>Codecs for CQL collection types should clearly document whether they return immutable collections or not | |
| 196 | + * (note that the driver's default collection codecs return <em>mutable</em> collections);</li> | |
| 196 | 197 | * <li>Codecs for CQL collection types should avoid returning {@code null}; |
| 197 | - * they should return empty collections instead.</li> | |
| 198 | + * they should return empty collections instead (the driver's default collection codecs all comply with this rule).</li> | |
| 198 | 199 | * </ol> |
| 199 | 200 | * |
| 200 | 201 | * @param bytes A {@link ByteBuffer} instance containing the serialized form of T; |
| @@ -1598,7 +1599,7 @@ | ||
| 1598 | 1599 | @Override |
| 1599 | 1600 | public C deserialize(ByteBuffer bytes, ProtocolVersion protocolVersion) { |
| 1600 | 1601 | if (bytes == null || bytes.remaining() == 0) |
| 1601 | - return unmodifiable(newInstance(0)); | |
| 1602 | + return newInstance(0); | |
| 1602 | 1603 | try { |
| 1603 | 1604 | ByteBuffer input = bytes.duplicate(); |
| 1604 | 1605 | int n = CodecUtils.readCollectionSize(input, protocolVersion); |
| @@ -1607,7 +1608,7 @@ | ||
| 1607 | 1608 | ByteBuffer databb = CodecUtils.readCollectionValue(input, protocolVersion); |
| 1608 | 1609 | coll.add(eltCodec.deserialize(databb, protocolVersion)); |
| 1609 | 1610 | } |
| 1610 | - return unmodifiable(coll); | |
| 1611 | + return coll; | |
| 1611 | 1612 | } catch (BufferUnderflowException e) { |
| 1612 | 1613 | throw new InvalidTypeException("Not enough bytes to deserialize list"); |
| 1613 | 1614 | } |
| @@ -1681,8 +1682,6 @@ | ||
| 1681 | 1682 | |
| 1682 | 1683 | protected abstract C newInstance(int capacity); |
| 1683 | 1684 | |
| 1684 | - protected abstract C unmodifiable(C coll); | |
| 1685 | - | |
| 1686 | 1685 | protected abstract char getOpeningChar(); |
| 1687 | 1686 | |
| 1688 | 1687 | protected abstract char getClosingChar(); |
| @@ -1691,6 +1690,7 @@ | ||
| 1691 | 1690 | |
| 1692 | 1691 | /** |
| 1693 | 1692 | * This codec maps a CQL {@link DataType#list(DataType) list type} to a Java {@link List}. |
| 1693 | + * Implementation note: this codec returns mutable, non thread-safe {@link ArrayList} instances. | |
| 1694 | 1694 | */ |
| 1695 | 1695 | public static class ListCodec<T> extends CollectionCodec<T, List<T>> { |
| 1696 | 1696 | |
| @@ -1703,11 +1703,6 @@ | ||
| 1703 | 1703 | return new ArrayList<T>(capacity); |
| 1704 | 1704 | } |
| 1705 | 1705 | |
| 1706 | - @Override | |
| 1707 | - protected List<T> unmodifiable(List<T> coll) { | |
| 1708 | - return Collections.unmodifiableList(coll); | |
| 1709 | - } | |
| 1710 | - | |
| 1711 | 1706 | @Override |
| 1712 | 1707 | protected char getOpeningChar() { |
| 1713 | 1708 | return '['; |
| @@ -1722,6 +1717,7 @@ | ||
| 1722 | 1717 | |
| 1723 | 1718 | /** |
| 1724 | 1719 | * This codec maps a CQL {@link DataType#set(DataType) set type} to a Java {@link Set}. |
| 1720 | + * Implementation note: this codec returns mutable, non thread-safe {@link LinkedHashSet} instances. | |
| 1725 | 1721 | */ |
| 1726 | 1722 | public static class SetCodec<T> extends CollectionCodec<T, Set<T>> { |
| 1727 | 1723 | |
| @@ -1734,11 +1730,6 @@ | ||
| 1734 | 1730 | return new LinkedHashSet<T>(capacity); |
| 1735 | 1731 | } |
| 1736 | 1732 | |
| 1737 | - @Override | |
| 1738 | - protected Set<T> unmodifiable(Set<T> coll) { | |
| 1739 | - return Collections.unmodifiableSet(coll); | |
| 1740 | - } | |
| 1741 | - | |
| 1742 | 1733 | @Override |
| 1743 | 1734 | protected char getOpeningChar() { |
| 1744 | 1735 | return '{'; |
| @@ -1752,6 +1743,7 @@ | ||
| 1752 | 1743 | |
| 1753 | 1744 | /** |
| 1754 | 1745 | * This codec maps a CQL {@link DataType#map(DataType, DataType) map type} to a Java {@link Map}. |
| 1746 | + * Implementation note: this codec returns mutable, non thread-safe {@link LinkedHashMap} instances. | |
| 1755 | 1747 | */ |
| 1756 | 1748 | public static class MapCodec<K, V> extends TypeCodec<Map<K, V>> { |
| 1757 | 1749 | |
| @@ -1790,7 +1782,7 @@ | ||
| 1790 | 1782 | idx = ParseUtils.skipSpaces(value, idx); |
| 1791 | 1783 | |
| 1792 | 1784 | if (value.charAt(idx) == '}') |
| 1793 | - return Collections.emptyMap(); | |
| 1785 | + return new LinkedHashMap<K, V>(0); | |
| 1794 | 1786 | |
| 1795 | 1787 | Map<K, V> m = new HashMap<K, V>(); |
| 1796 | 1788 | while (idx < value.length()) { |
| @@ -1885,7 +1877,7 @@ | ||
| 1885 | 1877 | @Override |
| 1886 | 1878 | public Map<K, V> deserialize(ByteBuffer bytes, ProtocolVersion protocolVersion) { |
| 1887 | 1879 | if (bytes == null || bytes.remaining() == 0) |
| 1888 | - return Collections.emptyMap(); | |
| 1880 | + return new LinkedHashMap<K, V>(0); | |
| 1889 | 1881 | try { |
| 1890 | 1882 | ByteBuffer input = bytes.duplicate(); |
| 1891 | 1883 | int n = CodecUtils.readCollectionSize(input, protocolVersion); |
| @@ -1895,7 +1887,7 @@ | ||
| 1895 | 1887 | ByteBuffer vbb = CodecUtils.readCollectionValue(input, protocolVersion); |
| 1896 | 1888 | m.put(keyCodec.deserialize(kbb, protocolVersion), valueCodec.deserialize(vbb, protocolVersion)); |
| 1897 | 1889 | } |
| 1898 | - return Collections.unmodifiableMap(m); | |
| 1890 | + return m; | |
| 1899 | 1891 | } catch (BufferUnderflowException e) { |
| 1900 | 1892 | throw new InvalidTypeException("Not enough bytes to deserialize a map"); |
| 1901 | 1893 | } |
modified upgrade_guide/README.md +3 −0
| @@ -61,6 +61,9 @@ | ||
| 61 | 61 | * `TupleType of(DataType... types)`; users should now use `Metadata.newTupleType(DataType...)`. |
| 62 | 62 | |
| 63 | 63 | <p>The driver runtime behavior changes in the following situations:</p> |
| 64 | + * By default, the driver now returns _mutable_, _non thread-safe_ instances for CQL collection types; | |
| 65 | + This affects methods `getList`, `getSet`, `getMap`, `getObject` and `get` for all instances of | |
| 66 | + `GettableByIndexData` and `GettableByNameData` (`Row`, `BoundStatement`, `TupleValue` and `UDTValue`) | |
| 64 | 67 | * `RuntimeException`s thrown during serialization or deserialization might not be |
| 65 | 68 | the same ones as before, due to the newly-introduced `CodecNotFoundException` |
| 66 | 69 | and to the dynamic nature of codec search introduced by JAVA-721. |