kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 1dbe77eef4e5c6cdb19fdd7a22a9343398064613a9ad44b408c42e70602dc513 |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2014-09-23 17:30 +02:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2014-09-23 17:30 +02:00 |
| Parents | 3915fb25e480 |
2 files changed
modified driver-core/src/main/java/com/datastax/driver/core/BoundStatement.java +11 −15
| @@ -27,7 +27,7 @@ | ||
| 27 | 27 | * A prepared statement with values bound to the bind variables. |
| 28 | 28 | * <p> |
| 29 | 29 | * Once values has been provided for the variables of the {@link PreparedStatement} |
| 30 | - * it has been created from, such BoundStatement can be executed (through | |
| 30 | + * it has been created from, such BoundStatement can be executed (through | |
| 31 | 31 | * {@link Session#execute(Statement)}). |
| 32 | 32 | * <p> |
| 33 | 33 | * The values of a BoundStatement can be set by either index or name. When |
| @@ -43,7 +43,7 @@ | ||
| 43 | 43 | final PreparedStatement statement; |
| 44 | 44 | final ByteBuffer[] values; |
| 45 | 45 | private ByteBuffer routingKey; |
| 46 | - | |
| 46 | + | |
| 47 | 47 | /** |
| 48 | 48 | * Creates a new {@code BoundStatement} from the provided prepared |
| 49 | 49 | * statement. |
| @@ -52,7 +52,7 @@ | ||
| 52 | 52 | public BoundStatement(PreparedStatement statement) { |
| 53 | 53 | this.statement = statement; |
| 54 | 54 | this.values = new ByteBuffer[statement.getVariables().size()]; |
| 55 | - | |
| 55 | + | |
| 56 | 56 | if (statement.getConsistencyLevel() != null) |
| 57 | 57 | this.setConsistencyLevel(statement.getConsistencyLevel()); |
| 58 | 58 | if (statement.getSerialConsistencyLevel() != null) |
| @@ -90,7 +90,7 @@ | ||
| 90 | 90 | * bound to a non-null value. |
| 91 | 91 | * |
| 92 | 92 | * @param name the name of the variable to check. |
| 93 | - * @return whether the first occurrence of variable {@code name} has been | |
| 93 | + * @return whether the first occurrence of variable {@code name} has been | |
| 94 | 94 | * bound to a non-null value. |
| 95 | 95 | * |
| 96 | 96 | * @throws IllegalArgumentException if {@code name} is not a prepared |
| @@ -199,17 +199,14 @@ | ||
| 199 | 199 | /** |
| 200 | 200 | * Sets the routing key for this bound statement. |
| 201 | 201 | * <p> |
| 202 | - * While you can provide a fixed routing key for all executions of this bound statement with this method, it is | |
| 203 | - * not mandatory to provide one through this method. This method should only be used if the partition key of the | |
| 204 | - * prepared query is not part of the prepared variables (that is if the partition key is fixed). | |
| 205 | - * <p> | |
| 206 | - * Note that if the partition key is part of the prepared variables, the routing key will be automatically computed | |
| 207 | - * once those variables are bound. | |
| 202 | + * This is useful when the routing key can neither be set on the {@code PreparedStatement} this bound statement | |
| 203 | + * was built from, nor automatically computed from bound variables. In particular, this is the case if the | |
| 204 | + * partition key is composite and only some of its components are bound. | |
| 208 | 205 | * |
| 209 | 206 | * @param routingKey the raw (binary) value to use as routing key. |
| 210 | 207 | * @return this {@code BoundStatement} object. |
| 211 | 208 | * |
| 212 | - * @see Statement#getRoutingKey | |
| 209 | + * @see BoundStatement#getRoutingKey | |
| 213 | 210 | */ |
| 214 | 211 | public BoundStatement setRoutingKey(ByteBuffer routingKey) { |
| 215 | 212 | this.routingKey = routingKey; |
| @@ -221,12 +218,11 @@ | ||
| 221 | 218 | * <p> |
| 222 | 219 | * This method will return a non-{@code null} value if either of the following occur: |
| 223 | 220 | * <ul> |
| 224 | - * <li>All the columns composing the partition key are bound variables of this {@code BoundStatement}. The routing | |
| 225 | - * key will then be built using the values provided for these partition key columns.</li> | |
| 226 | - * <li>The routing key has been set through {@link BoundStatement#setRoutingKey} for the {@code BoundStatement} this | |
| 227 | - * statement has been built from.</li> | |
| 221 | + * <li>The routing key has been set directly through {@link BoundStatement#setRoutingKey}.</li> | |
| 228 | 222 | * <li>The routing key has been set through {@link PreparedStatement#setRoutingKey} for the |
| 229 | 223 | * {@code PreparedStatement} this statement has been built from.</li> |
| 224 | + * <li>All the columns composing the partition key are bound variables of this {@code BoundStatement}. The routing | |
| 225 | + * key will then be built using the values provided for these partition key columns.</li> | |
| 230 | 226 | * </ul> |
| 231 | 227 | * Otherwise, {@code null} is returned. |
| 232 | 228 | * <p> |
modified driver-core/src/main/java/com/datastax/driver/core/PreparedStatement.java +8 −3
| @@ -90,7 +90,7 @@ | ||
| 90 | 90 | /** |
| 91 | 91 | * Sets the routing key for this prepared statement. |
| 92 | 92 | * <p> |
| 93 | - * While you can provide a fixed routing key for all executions of this prepared | |
| 93 | + * While you can provide a fixed routing key for all executions of this prepared | |
| 94 | 94 | * statement with this method, it is not mandatory to provide |
| 95 | 95 | * one through this method. This method should only be used |
| 96 | 96 | * if the partition key of the prepared query is not part of the prepared |
| @@ -98,11 +98,16 @@ | ||
| 98 | 98 | * <p> |
| 99 | 99 | * Note that if the partition key is part of the prepared variables, the |
| 100 | 100 | * routing key will be automatically computed once those variables are bound. |
| 101 | + * <p> | |
| 102 | + * If the partition key is neither fixed nor part of the prepared variables (e.g. | |
| 103 | + * a composite partition key where only some of the components are bound), the | |
| 104 | + * routing key can also be set on each bound statement. | |
| 101 | 105 | * |
| 102 | 106 | * @param routingKey the raw (binary) value to use as routing key. |
| 103 | 107 | * @return this {@code PreparedStatement} object. |
| 104 | 108 | * |
| 105 | 109 | * @see Statement#getRoutingKey |
| 110 | + * @see BoundStatement#getRoutingKey | |
| 106 | 111 | */ |
| 107 | 112 | public PreparedStatement setRoutingKey(ByteBuffer routingKey); |
| 108 | 113 | |
| @@ -130,7 +135,7 @@ | ||
| 130 | 135 | public ByteBuffer getRoutingKey(); |
| 131 | 136 | |
| 132 | 137 | /** |
| 133 | - * Sets a default consistency level for all bound statements | |
| 138 | + * Sets a default consistency level for all bound statements | |
| 134 | 139 | * created from this prepared statement. |
| 135 | 140 | * <p> |
| 136 | 141 | * If no consistency level is set through this method, the bound statement |
| @@ -154,7 +159,7 @@ | ||
| 154 | 159 | public ConsistencyLevel getConsistencyLevel(); |
| 155 | 160 | |
| 156 | 161 | /** |
| 157 | - * Sets a default serial consistency level for all bound statements | |
| 162 | + * Sets a default serial consistency level for all bound statements | |
| 158 | 163 | * created from this prepared statement. |
| 159 | 164 | * <p> |
| 160 | 165 | * If no serial consistency level is set through this method, the bound statement |