kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 4ae4b04a5f43d2e36beaf967c328dcb6f3378d8ef0bf28df863b370d452ca686 |
|---|---|
| Author | olim7t <omichallat+github@gmail.com> · 2015-08-17 12:34 +02:00 |
| Committer | olim7t <omichallat+github@gmail.com> · 2015-08-17 15:01 +02:00 |
| Parents | a22272b12861 |
9 files changed
modified driver-core/src/main/java/com/datastax/driver/core/TupleType.java +21 −0
| @@ -40,6 +40,27 @@ | ||
| 40 | 40 | this.codecRegistry = codecRegistry; |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | + /** | |
| 44 | + * Creates a "disconnected" tuple type (<b>you should prefer | |
| 45 | + * {@link Metadata#newTupleType(DataType...) cluster.getMetadata().newTupleType(...)} | |
| 46 | + * whenever possible</b>). | |
| 47 | + * <p> | |
| 48 | + * This method is only exposed for situations where you don't have a {@code Cluster} | |
| 49 | + * instance available. If you create a type with this method and use it with a | |
| 50 | + * {@code Cluster} later, you won't be able to set tuple fields with custom codecs | |
| 51 | + * registered against the cluster, or you might get errors if the protocol versions don't | |
| 52 | + * match. | |
| 53 | + * | |
| 54 | + * @param protocolVersion the protocol version to use. | |
| 55 | + * @param codecRegistry the codec registry to use. | |
| 56 | + * @param types the types for the tuple type. | |
| 57 | + * | |
| 58 | + * @return the newly created tuple type. | |
| 59 | + */ | |
| 60 | + public static TupleType of(ProtocolVersion protocolVersion, CodecRegistry codecRegistry, DataType... types) { | |
| 61 | + return new TupleType(Arrays.asList(types), protocolVersion, codecRegistry); | |
| 62 | + } | |
| 63 | + | |
| 43 | 64 | /** |
| 44 | 65 | * The (immutable) list of types composing this tuple type. |
| 45 | 66 | * |
modified driver-core/src/main/java/com/datastax/driver/core/querybuilder/Batch.java +2 −2
| @@ -33,8 +33,8 @@ | ||
| 33 | 33 | // Only used when we add at last one statement that is not a BuiltStatement subclass |
| 34 | 34 | private int nonBuiltStatementValues; |
| 35 | 35 | |
| 36 | - Batch(Cluster cluster, RegularStatement[] statements, boolean logged) { | |
| 37 | - super((String)null, cluster); | |
| 36 | + Batch(ProtocolVersion protocolVersion, CodecRegistry codecRegistry, RegularStatement[] statements, boolean logged) { | |
| 37 | + super((String)null, protocolVersion, codecRegistry); | |
| 38 | 38 | this.statements = statements.length == 0 |
| 39 | 39 | ? new ArrayList<RegularStatement>() |
| 40 | 40 | : new ArrayList<RegularStatement>(statements.length); |
modified driver-core/src/main/java/com/datastax/driver/core/querybuilder/BuiltStatement.java +11 −14
| @@ -37,7 +37,8 @@ | ||
| 37 | 37 | private final List<ColumnMetadata> partitionKey; |
| 38 | 38 | private final List<Object> routingKeyValues; |
| 39 | 39 | final String keyspace; |
| 40 | - protected final Cluster cluster; | |
| 40 | + private final ProtocolVersion protocolVersion; | |
| 41 | + private final CodecRegistry codecRegistry; | |
| 41 | 42 | |
| 42 | 43 | private boolean dirty; |
| 43 | 44 | private String cache; |
| @@ -50,18 +51,20 @@ | ||
| 50 | 51 | boolean hasBindMarkers; |
| 51 | 52 | private boolean forceNoValues; |
| 52 | 53 | |
| 53 | - BuiltStatement(String keyspace, Cluster cluster) { | |
| 54 | + BuiltStatement(String keyspace, ProtocolVersion protocolVersion, CodecRegistry codecRegistry) { | |
| 54 | 55 | this.partitionKey = null; |
| 55 | 56 | this.routingKeyValues = null; |
| 56 | 57 | this.keyspace = keyspace; |
| 57 | - this.cluster = cluster; | |
| 58 | + this.protocolVersion = protocolVersion; | |
| 59 | + this.codecRegistry = codecRegistry; | |
| 58 | 60 | } |
| 59 | 61 | |
| 60 | - BuiltStatement(TableMetadata tableMetadata, Cluster cluster) { | |
| 62 | + BuiltStatement(TableMetadata tableMetadata, ProtocolVersion protocolVersion, CodecRegistry codecRegistry) { | |
| 61 | 63 | this.partitionKey = tableMetadata.getPartitionKey(); |
| 62 | 64 | this.routingKeyValues = Arrays.asList(new Object[tableMetadata.getPartitionKey().size()]); |
| 63 | 65 | this.keyspace = escapeId(tableMetadata.getKeyspace().getName()); |
| 64 | - this.cluster = cluster; | |
| 66 | + this.protocolVersion = protocolVersion; | |
| 67 | + this.codecRegistry = codecRegistry; | |
| 65 | 68 | } |
| 66 | 69 | |
| 67 | 70 | // Same as Metadata.escapeId, but we don't have access to it here. |
| @@ -160,19 +163,13 @@ | ||
| 160 | 163 | } |
| 161 | 164 | |
| 162 | 165 | CodecRegistry getCodecRegistry(){ |
| 163 | - return cluster.getConfiguration().getCodecRegistry(); | |
| 166 | + return codecRegistry; | |
| 164 | 167 | } |
| 165 | 168 | |
| 166 | 169 | ProtocolVersion getProtocolVersion() { |
| 167 | - cluster.init(); | |
| 168 | - return cluster.getConfiguration().getProtocolOptions().getProtocolVersion(); | |
| 170 | + return protocolVersion; | |
| 169 | 171 | } |
| 170 | 172 | |
| 171 | - /** | |
| 172 | - * {@inheritDoc} | |
| 173 | - * <p> | |
| 174 | - * Note: Calling this method may trigger the underlying {@link Cluster} initialization. | |
| 175 | - */ | |
| 176 | 173 | @Override |
| 177 | 174 | public ByteBuffer getRoutingKey() { |
| 178 | 175 | if (routingKeyValues == null) |
| @@ -278,7 +275,7 @@ | ||
| 278 | 275 | T statement; |
| 279 | 276 | |
| 280 | 277 | ForwardingStatement(T statement) { |
| 281 | - super((String)null, statement.cluster); | |
| 278 | + super((String)null, statement.getProtocolVersion(), statement.getCodecRegistry()); | |
| 282 | 279 | this.statement = statement; |
| 283 | 280 | } |
| 284 | 281 |
modified driver-core/src/main/java/com/datastax/driver/core/querybuilder/Delete.java +17 −13
| @@ -20,6 +20,7 @@ | ||
| 20 | 20 | |
| 21 | 21 | import com.datastax.driver.core.Cluster; |
| 22 | 22 | import com.datastax.driver.core.CodecRegistry; |
| 23 | +import com.datastax.driver.core.ProtocolVersion; | |
| 23 | 24 | import com.datastax.driver.core.TableMetadata; |
| 24 | 25 | |
| 25 | 26 | /** |
| @@ -34,8 +35,8 @@ | ||
| 34 | 35 | private final Conditions conditions; |
| 35 | 36 | private boolean ifExists; |
| 36 | 37 | |
| 37 | - Delete(Cluster cluster, String keyspace, String table, List<Selector> columns) { | |
| 38 | - super(keyspace, cluster); | |
| 38 | + Delete(ProtocolVersion protocolVersion, CodecRegistry codecRegistry, String keyspace, String table, List<Selector> columns) { | |
| 39 | + super(keyspace, protocolVersion, codecRegistry); | |
| 39 | 40 | this.table = table; |
| 40 | 41 | this.columns = columns; |
| 41 | 42 | this.where = new Where(this); |
| @@ -43,8 +44,8 @@ | ||
| 43 | 44 | this.conditions = new Conditions(this); |
| 44 | 45 | } |
| 45 | 46 | |
| 46 | - Delete(Cluster cluster, TableMetadata table, List<Selector> columns) { | |
| 47 | - super(table, cluster); | |
| 47 | + Delete(ProtocolVersion protocolVersion, CodecRegistry codecRegistry, TableMetadata table, List<Selector> columns) { | |
| 48 | + super(table, protocolVersion, codecRegistry); | |
| 48 | 49 | this.table = escapeId(table.getName()); |
| 49 | 50 | this.columns = columns; |
| 50 | 51 | this.where = new Where(this); |
| @@ -277,16 +278,19 @@ | ||
| 277 | 278 | */ |
| 278 | 279 | public static class Builder { |
| 279 | 280 | |
| 280 | - private final Cluster cluster; | |
| 281 | + private final ProtocolVersion protocolVersion; | |
| 282 | + private final CodecRegistry codecRegistry; | |
| 281 | 283 | |
| 282 | 284 | List<Selector> columns = new ArrayList<Selector>(); |
| 283 | 285 | |
| 284 | - Builder(Cluster cluster) { | |
| 285 | - this.cluster = cluster; | |
| 286 | + Builder(ProtocolVersion protocolVersion, CodecRegistry codecRegistry) { | |
| 287 | + this.protocolVersion = protocolVersion; | |
| 288 | + this.codecRegistry = codecRegistry; | |
| 286 | 289 | } |
| 287 | 290 | |
| 288 | - Builder(Cluster cluster, String... columnNames) { | |
| 289 | - this.cluster = cluster; | |
| 291 | + Builder(ProtocolVersion protocolVersion, CodecRegistry codecRegistry, String... columnNames) { | |
| 292 | + this.protocolVersion = protocolVersion; | |
| 293 | + this.codecRegistry = codecRegistry; | |
| 290 | 294 | for (String columnName : columnNames) { |
| 291 | 295 | this.columns.add(new Selector(columnName)); |
| 292 | 296 | } |
| @@ -310,7 +314,7 @@ | ||
| 310 | 314 | * @return a newly built DELETE statement that deletes from {@code keyspace.table}. |
| 311 | 315 | */ |
| 312 | 316 | public Delete from(String keyspace, String table) { |
| 313 | - return new Delete(cluster, keyspace, table, columns); | |
| 317 | + return new Delete(protocolVersion, codecRegistry, keyspace, table, columns); | |
| 314 | 318 | } |
| 315 | 319 | |
| 316 | 320 | /** |
| @@ -320,7 +324,7 @@ | ||
| 320 | 324 | * @return a newly built DELETE statement that deletes from {@code table}. |
| 321 | 325 | */ |
| 322 | 326 | public Delete from(TableMetadata table) { |
| 323 | - return new Delete(cluster, table, columns); | |
| 327 | + return new Delete(protocolVersion, codecRegistry, table, columns); | |
| 324 | 328 | } |
| 325 | 329 | } |
| 326 | 330 | |
| @@ -329,8 +333,8 @@ | ||
| 329 | 333 | */ |
| 330 | 334 | public static class Selection extends Builder { |
| 331 | 335 | |
| 332 | - Selection(Cluster cluster) { | |
| 333 | - super(cluster); | |
| 336 | + Selection(ProtocolVersion protocolVersion, CodecRegistry codecRegistry) { | |
| 337 | + super(protocolVersion, codecRegistry); | |
| 334 | 338 | } |
| 335 | 339 | |
| 336 | 340 | /** |
modified driver-core/src/main/java/com/datastax/driver/core/querybuilder/Insert.java +5 −4
| @@ -21,6 +21,7 @@ | ||
| 21 | 21 | |
| 22 | 22 | import com.datastax.driver.core.Cluster; |
| 23 | 23 | import com.datastax.driver.core.CodecRegistry; |
| 24 | +import com.datastax.driver.core.ProtocolVersion; | |
| 24 | 25 | import com.datastax.driver.core.TableMetadata; |
| 25 | 26 | |
| 26 | 27 | /** |
| @@ -34,14 +35,14 @@ | ||
| 34 | 35 | private final Options usings; |
| 35 | 36 | private boolean ifNotExists; |
| 36 | 37 | |
| 37 | - Insert(Cluster cluster, String keyspace, String table) { | |
| 38 | - super(keyspace, cluster); | |
| 38 | + Insert(ProtocolVersion protocolVersion, CodecRegistry codecRegistry, String keyspace, String table) { | |
| 39 | + super(keyspace, protocolVersion, codecRegistry); | |
| 39 | 40 | this.table = table; |
| 40 | 41 | this.usings = new Options(this); |
| 41 | 42 | } |
| 42 | 43 | |
| 43 | - Insert(Cluster cluster, TableMetadata table) { | |
| 44 | - super(table, cluster); | |
| 44 | + Insert(ProtocolVersion protocolVersion, CodecRegistry codecRegistry, TableMetadata table) { | |
| 45 | + super(table, protocolVersion, codecRegistry); | |
| 45 | 46 | this.table = escapeId(table.getName()); |
| 46 | 47 | this.usings = new Options(this); |
| 47 | 48 | } |
modified driver-core/src/main/java/com/datastax/driver/core/querybuilder/QueryBuilder.java +43 −22
| @@ -17,9 +17,7 @@ | ||
| 17 | 17 | |
| 18 | 18 | import java.util.*; |
| 19 | 19 | |
| 20 | -import com.datastax.driver.core.Cluster; | |
| 21 | -import com.datastax.driver.core.RegularStatement; | |
| 22 | -import com.datastax.driver.core.TableMetadata; | |
| 20 | +import com.datastax.driver.core.*; | |
| 23 | 21 | import com.datastax.driver.core.exceptions.InvalidQueryException; |
| 24 | 22 | |
| 25 | 23 | /** |
| @@ -40,17 +38,40 @@ | ||
| 40 | 38 | */ |
| 41 | 39 | public final class QueryBuilder { |
| 42 | 40 | |
| 43 | - private final Cluster cluster; | |
| 41 | + private final ProtocolVersion protocolVersion; | |
| 42 | + private final CodecRegistry codecRegistry; | |
| 44 | 43 | |
| 45 | 44 | /** |
| 46 | 45 | * Create a new QueryBuilder instance and associate it with the given {@link Cluster}. |
| 47 | - * Note: if the {@link Cluster} is not yet initialized, certain methods of the QueryBuilder API | |
| 48 | - * may trigger its initialization. | |
| 46 | + * Note: if the {@link Cluster} is not yet initialized, this method | |
| 47 | + * will trigger its initialization. | |
| 49 | 48 | * |
| 50 | 49 | * @param cluster The {@link Cluster} instance this object should be attached to. |
| 51 | 50 | */ |
| 52 | 51 | public QueryBuilder(Cluster cluster) { |
| 53 | - this.cluster = cluster; | |
| 52 | + this(getProtocolVersion(cluster), cluster.getConfiguration().getCodecRegistry()); | |
| 53 | + } | |
| 54 | + | |
| 55 | + private static ProtocolVersion getProtocolVersion(Cluster cluster) { | |
| 56 | + cluster.init(); | |
| 57 | + return cluster.getConfiguration().getProtocolOptions().getProtocolVersion(); | |
| 58 | + } | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * Create a "disconnected" QueryBuilder instance (<b>you should prefer | |
| 62 | + * {@link #QueryBuilder(Cluster)} whenever possible</b>). | |
| 63 | + * <p> | |
| 64 | + * This constructor is only exposed for situations where you don't have a {@code Cluster} | |
| 65 | + * instance available. If you use this constructor, and use statements built from it | |
| 66 | + * with a {@code Cluster} later, you won't be able to rely on custom codecs registered | |
| 67 | + * against the cluster, or you might get errors if the protocol versions don't match. | |
| 68 | + * | |
| 69 | + * @param protocolVersion the protocol version. | |
| 70 | + * @param codecRegistry the codec registry. | |
| 71 | + */ | |
| 72 | + public QueryBuilder(ProtocolVersion protocolVersion, CodecRegistry codecRegistry) { | |
| 73 | + this.protocolVersion = protocolVersion; | |
| 74 | + this.codecRegistry = codecRegistry; | |
| 54 | 75 | } |
| 55 | 76 | |
| 56 | 77 | /** |
| @@ -63,7 +84,7 @@ | ||
| 63 | 84 | * least a FROM clause to complete the query). |
| 64 | 85 | */ |
| 65 | 86 | public Select.Builder select(String... columns) { |
| 66 | - return new Select.Builder(cluster, Arrays.asList((Object[])columns)); | |
| 87 | + return new Select.Builder(protocolVersion, codecRegistry, Arrays.asList((Object[])columns)); | |
| 67 | 88 | } |
| 68 | 89 | |
| 69 | 90 | /** |
| @@ -74,7 +95,7 @@ | ||
| 74 | 95 | */ |
| 75 | 96 | public Select.Selection select() { |
| 76 | 97 | // Note: the fact we return Select.Selection as return type is on purpose. |
| 77 | - return new Select.SelectionOrAlias(cluster); | |
| 98 | + return new Select.SelectionOrAlias(protocolVersion, codecRegistry); | |
| 78 | 99 | } |
| 79 | 100 | |
| 80 | 101 | /** |
| @@ -84,7 +105,7 @@ | ||
| 84 | 105 | * @return an in-construction INSERT query. |
| 85 | 106 | */ |
| 86 | 107 | public Insert insertInto(String table) { |
| 87 | - return new Insert(cluster, null, table); | |
| 108 | + return new Insert(protocolVersion, codecRegistry, null, table); | |
| 88 | 109 | } |
| 89 | 110 | |
| 90 | 111 | /** |
| @@ -95,7 +116,7 @@ | ||
| 95 | 116 | * @return an in-construction INSERT query. |
| 96 | 117 | */ |
| 97 | 118 | public Insert insertInto(String keyspace, String table) { |
| 98 | - return new Insert(cluster, keyspace, table); | |
| 119 | + return new Insert(protocolVersion, codecRegistry, keyspace, table); | |
| 99 | 120 | } |
| 100 | 121 | |
| 101 | 122 | /** |
| @@ -105,7 +126,7 @@ | ||
| 105 | 126 | * @return an in-construction INSERT query. |
| 106 | 127 | */ |
| 107 | 128 | public Insert insertInto(TableMetadata table) { |
| 108 | - return new Insert(cluster, table); | |
| 129 | + return new Insert(protocolVersion, codecRegistry, table); | |
| 109 | 130 | } |
| 110 | 131 | |
| 111 | 132 | /** |
| @@ -116,7 +137,7 @@ | ||
| 116 | 137 | * clause needs to be provided to complete the query). |
| 117 | 138 | */ |
| 118 | 139 | public Update update(String table) { |
| 119 | - return new Update(cluster, null, table); | |
| 140 | + return new Update(protocolVersion, codecRegistry, null, table); | |
| 120 | 141 | } |
| 121 | 142 | |
| 122 | 143 | /** |
| @@ -128,7 +149,7 @@ | ||
| 128 | 149 | * clause needs to be provided to complete the query). |
| 129 | 150 | */ |
| 130 | 151 | public Update update(String keyspace, String table) { |
| 131 | - return new Update(cluster, keyspace, table); | |
| 152 | + return new Update(protocolVersion, codecRegistry, keyspace, table); | |
| 132 | 153 | } |
| 133 | 154 | |
| 134 | 155 | /** |
| @@ -139,7 +160,7 @@ | ||
| 139 | 160 | * clause needs to be provided to complete the query). |
| 140 | 161 | */ |
| 141 | 162 | public Update update(TableMetadata table) { |
| 142 | - return new Update(cluster, table); | |
| 163 | + return new Update(protocolVersion, codecRegistry, table); | |
| 143 | 164 | } |
| 144 | 165 | |
| 145 | 166 | /** |
| @@ -150,7 +171,7 @@ | ||
| 150 | 171 | * clause needs to be provided to complete the query). |
| 151 | 172 | */ |
| 152 | 173 | public Delete.Builder delete(String... columns) { |
| 153 | - return new Delete.Builder(cluster, columns); | |
| 174 | + return new Delete.Builder(protocolVersion, codecRegistry, columns); | |
| 154 | 175 | } |
| 155 | 176 | |
| 156 | 177 | /** |
| @@ -161,7 +182,7 @@ | ||
| 161 | 182 | * query). |
| 162 | 183 | */ |
| 163 | 184 | public Delete.Selection delete() { |
| 164 | - return new Delete.Selection(cluster); | |
| 185 | + return new Delete.Selection(protocolVersion, codecRegistry); | |
| 165 | 186 | } |
| 166 | 187 | |
| 167 | 188 | /** |
| @@ -178,7 +199,7 @@ | ||
| 178 | 199 | * @return a new {@code RegularStatement} that batch {@code statements}. |
| 179 | 200 | */ |
| 180 | 201 | public Batch batch(RegularStatement... statements) { |
| 181 | - return new Batch(cluster, statements, true); | |
| 202 | + return new Batch(protocolVersion, codecRegistry, statements, true); | |
| 182 | 203 | } |
| 183 | 204 | |
| 184 | 205 | /** |
| @@ -199,7 +220,7 @@ | ||
| 199 | 220 | * using the batch log. |
| 200 | 221 | */ |
| 201 | 222 | public Batch unloggedBatch(RegularStatement... statements) { |
| 202 | - return new Batch(cluster, statements, false); | |
| 223 | + return new Batch(protocolVersion, codecRegistry, statements, false); | |
| 203 | 224 | } |
| 204 | 225 | |
| 205 | 226 | /** |
| @@ -209,7 +230,7 @@ | ||
| 209 | 230 | * @return the truncation query. |
| 210 | 231 | */ |
| 211 | 232 | public Truncate truncate(String table) { |
| 212 | - return new Truncate(cluster, null, table); | |
| 233 | + return new Truncate(protocolVersion, codecRegistry, null, table); | |
| 213 | 234 | } |
| 214 | 235 | |
| 215 | 236 | /** |
| @@ -220,7 +241,7 @@ | ||
| 220 | 241 | * @return the truncation query. |
| 221 | 242 | */ |
| 222 | 243 | public Truncate truncate(String keyspace, String table) { |
| 223 | - return new Truncate(cluster, keyspace, table); | |
| 244 | + return new Truncate(protocolVersion, codecRegistry, keyspace, table); | |
| 224 | 245 | } |
| 225 | 246 | |
| 226 | 247 | /** |
| @@ -230,7 +251,7 @@ | ||
| 230 | 251 | * @return the truncation query. |
| 231 | 252 | */ |
| 232 | 253 | public Truncate truncate(TableMetadata table) { |
| 233 | - return new Truncate(cluster, table); | |
| 254 | + return new Truncate(protocolVersion, codecRegistry, table); | |
| 234 | 255 | } |
| 235 | 256 | |
| 236 | 257 | /** |
modified driver-core/src/main/java/com/datastax/driver/core/querybuilder/Select.java +19 −15
| @@ -22,6 +22,7 @@ | ||
| 22 | 22 | |
| 23 | 23 | import com.datastax.driver.core.Cluster; |
| 24 | 24 | import com.datastax.driver.core.CodecRegistry; |
| 25 | +import com.datastax.driver.core.ProtocolVersion; | |
| 25 | 26 | import com.datastax.driver.core.TableMetadata; |
| 26 | 27 | |
| 27 | 28 | /** |
| @@ -39,16 +40,16 @@ | ||
| 39 | 40 | private Object limit; |
| 40 | 41 | private boolean allowFiltering; |
| 41 | 42 | |
| 42 | - Select(Cluster cluster, String keyspace, String table, List<Object> columnNames, boolean isDistinct) { | |
| 43 | - super(keyspace, cluster); | |
| 43 | + Select(ProtocolVersion protocolVersion, CodecRegistry codecRegistry, String keyspace, String table, List<Object> columnNames, boolean isDistinct) { | |
| 44 | + super(keyspace, protocolVersion, codecRegistry); | |
| 44 | 45 | this.table = table; |
| 45 | 46 | this.isDistinct = isDistinct; |
| 46 | 47 | this.columnNames = columnNames; |
| 47 | 48 | this.where = new Where(this); |
| 48 | 49 | } |
| 49 | 50 | |
| 50 | - Select(Cluster cluster, TableMetadata table, List<Object> columnNames, boolean isDistinct) { | |
| 51 | - super(table, cluster); | |
| 51 | + Select(ProtocolVersion protocolVersion, CodecRegistry codecRegistry, TableMetadata table, List<Object> columnNames, boolean isDistinct) { | |
| 52 | + super(table, protocolVersion, codecRegistry); | |
| 52 | 53 | this.table = escapeId(table.getName()); |
| 53 | 54 | this.isDistinct = isDistinct; |
| 54 | 55 | this.columnNames = columnNames; |
| @@ -257,16 +258,19 @@ | ||
| 257 | 258 | */ |
| 258 | 259 | public static class Builder { |
| 259 | 260 | |
| 260 | - private final Cluster cluster; | |
| 261 | + private final ProtocolVersion protocolVersion; | |
| 262 | + private final CodecRegistry codecRegistry; | |
| 261 | 263 | List<Object> columnNames; |
| 262 | 264 | boolean isDistinct; |
| 263 | 265 | |
| 264 | - Builder(Cluster cluster) { | |
| 265 | - this.cluster = cluster; | |
| 266 | + Builder(ProtocolVersion protocolVersion, CodecRegistry codecRegistry) { | |
| 267 | + this.protocolVersion = protocolVersion; | |
| 268 | + this.codecRegistry = codecRegistry; | |
| 266 | 269 | } |
| 267 | 270 | |
| 268 | - Builder(Cluster cluster, List<Object> columnNames) { | |
| 269 | - this.cluster = cluster; | |
| 271 | + Builder(ProtocolVersion protocolVersion, CodecRegistry codecRegistry, List<Object> columnNames) { | |
| 272 | + this.protocolVersion = protocolVersion; | |
| 273 | + this.codecRegistry = codecRegistry; | |
| 270 | 274 | this.columnNames = columnNames; |
| 271 | 275 | } |
| 272 | 276 | |
| @@ -298,7 +302,7 @@ | ||
| 298 | 302 | * @return a newly built SELECT statement that selects from {@code keyspace.table}. |
| 299 | 303 | */ |
| 300 | 304 | public Select from(String keyspace, String table) { |
| 301 | - return new Select(cluster, keyspace, table, columnNames, isDistinct); | |
| 305 | + return new Select(protocolVersion, codecRegistry, keyspace, table, columnNames, isDistinct); | |
| 302 | 306 | } |
| 303 | 307 | |
| 304 | 308 | /** |
| @@ -308,7 +312,7 @@ | ||
| 308 | 312 | * @return a newly built SELECT statement that selects from {@code table}. |
| 309 | 313 | */ |
| 310 | 314 | public Select from(TableMetadata table) { |
| 311 | - return new Select(cluster, table, columnNames, isDistinct); | |
| 315 | + return new Select(protocolVersion, codecRegistry, table, columnNames, isDistinct); | |
| 312 | 316 | } |
| 313 | 317 | } |
| 314 | 318 | |
| @@ -317,8 +321,8 @@ | ||
| 317 | 321 | */ |
| 318 | 322 | public static abstract class Selection extends Builder { |
| 319 | 323 | |
| 320 | - Selection(Cluster cluster) { | |
| 321 | - super(cluster); | |
| 324 | + Selection(ProtocolVersion protocolVersion, CodecRegistry codecRegistry) { | |
| 325 | + super(protocolVersion, codecRegistry); | |
| 322 | 326 | } |
| 323 | 327 | |
| 324 | 328 | /** |
| @@ -405,8 +409,8 @@ | ||
| 405 | 409 | |
| 406 | 410 | private Object previousSelection; |
| 407 | 411 | |
| 408 | - SelectionOrAlias(Cluster cluster) { | |
| 409 | - super(cluster); | |
| 412 | + SelectionOrAlias(ProtocolVersion protocolVersion, CodecRegistry codecRegistry) { | |
| 413 | + super(protocolVersion, codecRegistry); | |
| 410 | 414 | } |
| 411 | 415 | |
| 412 | 416 | /** |
modified driver-core/src/main/java/com/datastax/driver/core/querybuilder/Truncate.java +6 −4
| @@ -18,6 +18,8 @@ | ||
| 18 | 18 | import java.util.List; |
| 19 | 19 | |
| 20 | 20 | import com.datastax.driver.core.Cluster; |
| 21 | +import com.datastax.driver.core.CodecRegistry; | |
| 22 | +import com.datastax.driver.core.ProtocolVersion; | |
| 21 | 23 | import com.datastax.driver.core.TableMetadata; |
| 22 | 24 | |
| 23 | 25 | /** |
| @@ -27,13 +29,13 @@ | ||
| 27 | 29 | |
| 28 | 30 | private final String table; |
| 29 | 31 | |
| 30 | - Truncate(Cluster cluster, String keyspace, String table) { | |
| 31 | - super(keyspace, cluster); | |
| 32 | + Truncate(ProtocolVersion protocolVersion, CodecRegistry codecRegistry, String keyspace, String table) { | |
| 33 | + super(keyspace, protocolVersion, codecRegistry); | |
| 32 | 34 | this.table = table; |
| 33 | 35 | } |
| 34 | 36 | |
| 35 | - Truncate(Cluster cluster, TableMetadata table) { | |
| 36 | - super(table, cluster); | |
| 37 | + Truncate(ProtocolVersion protocolVersion, CodecRegistry codecRegistry, TableMetadata table) { | |
| 38 | + super(table, protocolVersion, codecRegistry); | |
| 37 | 39 | this.table = escapeId(table.getName()); |
| 38 | 40 | } |
| 39 | 41 |
modified driver-core/src/main/java/com/datastax/driver/core/querybuilder/Update.java +5 −4
| @@ -20,6 +20,7 @@ | ||
| 20 | 20 | |
| 21 | 21 | import com.datastax.driver.core.Cluster; |
| 22 | 22 | import com.datastax.driver.core.CodecRegistry; |
| 23 | +import com.datastax.driver.core.ProtocolVersion; | |
| 23 | 24 | import com.datastax.driver.core.TableMetadata; |
| 24 | 25 | import com.datastax.driver.core.querybuilder.Assignment.CounterAssignment; |
| 25 | 26 | |
| @@ -34,8 +35,8 @@ | ||
| 34 | 35 | private final Options usings; |
| 35 | 36 | private final Conditions conditions; |
| 36 | 37 | |
| 37 | - Update(Cluster cluster, String keyspace, String table) { | |
| 38 | - super(keyspace, cluster); | |
| 38 | + Update(ProtocolVersion protocolVersion, CodecRegistry codecRegistry, String keyspace, String table) { | |
| 39 | + super(keyspace, protocolVersion, codecRegistry); | |
| 39 | 40 | this.table = table; |
| 40 | 41 | this.assignments = new Assignments(this); |
| 41 | 42 | this.where = new Where(this); |
| @@ -43,8 +44,8 @@ | ||
| 43 | 44 | this.conditions = new Conditions(this); |
| 44 | 45 | } |
| 45 | 46 | |
| 46 | - Update(Cluster cluster, TableMetadata table) { | |
| 47 | - super(table, cluster); | |
| 47 | + Update(ProtocolVersion protocolVersion, CodecRegistry codecRegistry, TableMetadata table) { | |
| 48 | + super(table, protocolVersion, codecRegistry); | |
| 48 | 49 | this.table = escapeId(table.getName()); |
| 49 | 50 | this.assignments = new Assignments(this); |
| 50 | 51 | this.where = new Where(this); |