Elffuss BraidHub

kikocis/java-driver public

Minor changes to get/setRoutingKey comments.
Changeset1dbe77eef4e5c6cdb19fdd7a22a9343398064613a9ad44b408c42e70602dc513
Authorolim7t <omichallat+github@gmail.com> · 2014-09-23 17:30 +02:00
Committerolim7t <omichallat+github@gmail.com> · 2014-09-23 17:30 +02:00
Parents3915fb25e480

Browse the files at this changeset

2 files changed

modified driver-core/src/main/java/com/datastax/driver/core/BoundStatement.java +11 −15
@@ -27,7 +27,7 @@
2727 * A prepared statement with values bound to the bind variables.
2828 * <p>
2929 * 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
3131 * {@link Session#execute(Statement)}).
3232 * <p>
3333 * The values of a BoundStatement can be set by either index or name. When
@@ -43,7 +43,7 @@
4343 final PreparedStatement statement;
4444 final ByteBuffer[] values;
4545 private ByteBuffer routingKey;
46-
46+
4747 /**
4848 * Creates a new {@code BoundStatement} from the provided prepared
4949 * statement.
@@ -52,7 +52,7 @@
5252 public BoundStatement(PreparedStatement statement) {
5353 this.statement = statement;
5454 this.values = new ByteBuffer[statement.getVariables().size()];
55-
55+
5656 if (statement.getConsistencyLevel() != null)
5757 this.setConsistencyLevel(statement.getConsistencyLevel());
5858 if (statement.getSerialConsistencyLevel() != null)
@@ -90,7 +90,7 @@
9090 * bound to a non-null value.
9191 *
9292 * @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
9494 * bound to a non-null value.
9595 *
9696 * @throws IllegalArgumentException if {@code name} is not a prepared
@@ -199,17 +199,14 @@
199199 /**
200200 * Sets the routing key for this bound statement.
201201 * <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.
208205 *
209206 * @param routingKey the raw (binary) value to use as routing key.
210207 * @return this {@code BoundStatement} object.
211208 *
212- * @see Statement#getRoutingKey
209+ * @see BoundStatement#getRoutingKey
213210 */
214211 public BoundStatement setRoutingKey(ByteBuffer routingKey) {
215212 this.routingKey = routingKey;
@@ -221,12 +218,11 @@
221218 * <p>
222219 * This method will return a non-{@code null} value if either of the following occur:
223220 * <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>
228222 * <li>The routing key has been set through {@link PreparedStatement#setRoutingKey} for the
229223 * {@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>
230226 * </ul>
231227 * Otherwise, {@code null} is returned.
232228 * <p>
modified driver-core/src/main/java/com/datastax/driver/core/PreparedStatement.java +8 −3
@@ -90,7 +90,7 @@
9090 /**
9191 * Sets the routing key for this prepared statement.
9292 * <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
9494 * statement with this method, it is not mandatory to provide
9595 * one through this method. This method should only be used
9696 * if the partition key of the prepared query is not part of the prepared
@@ -98,11 +98,16 @@
9898 * <p>
9999 * Note that if the partition key is part of the prepared variables, the
100100 * 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.
101105 *
102106 * @param routingKey the raw (binary) value to use as routing key.
103107 * @return this {@code PreparedStatement} object.
104108 *
105109 * @see Statement#getRoutingKey
110+ * @see BoundStatement#getRoutingKey
106111 */
107112 public PreparedStatement setRoutingKey(ByteBuffer routingKey);
108113
@@ -130,7 +135,7 @@
130135 public ByteBuffer getRoutingKey();
131136
132137 /**
133- * Sets a default consistency level for all bound statements
138+ * Sets a default consistency level for all bound statements
134139 * created from this prepared statement.
135140 * <p>
136141 * If no consistency level is set through this method, the bound statement
@@ -154,7 +159,7 @@
154159 public ConsistencyLevel getConsistencyLevel();
155160
156161 /**
157- * Sets a default serial consistency level for all bound statements
162+ * Sets a default serial consistency level for all bound statements
158163 * created from this prepared statement.
159164 * <p>
160165 * If no serial consistency level is set through this method, the bound statement