Skip to content

Commit 96d7e9f

Browse files
samueldlightfootmp911de
authored andcommitted
Extend supported fields for query options.
We now accept idempotent, routingKey, and routingKeyspace options. Closes #1220
1 parent 93f7c57 commit 96d7e9f

File tree

10 files changed

+283
-27
lines changed

10 files changed

+283
-27
lines changed

spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/DeleteOptions.java

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2019-2021 the original author or authors.
2+
* Copyright 2019-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
1515
*/
1616
package org.springframework.data.cassandra.core;
1717

18+
import java.nio.ByteBuffer;
1819
import java.time.Duration;
1920
import java.time.Instant;
2021
import java.util.concurrent.TimeUnit;
@@ -35,6 +36,7 @@
3536
*
3637
* @author Mark Paluch
3738
* @author Tomasz Lelek
39+
* @author Sam Lightfoot
3840
* @since 2.2
3941
*/
4042
public class DeleteOptions extends WriteOptions {
@@ -48,10 +50,11 @@ public class DeleteOptions extends WriteOptions {
4850
private DeleteOptions(@Nullable ConsistencyLevel consistencyLevel, ExecutionProfileResolver executionProfileResolver,
4951
@Nullable CqlIdentifier keyspace, @Nullable Integer pageSize, @Nullable ConsistencyLevel serialConsistencyLevel,
5052
Duration timeout, Duration ttl, @Nullable Long timestamp, @Nullable Boolean tracing, boolean ifExists,
51-
@Nullable Filter ifCondition) {
53+
@Nullable Filter ifCondition, @Nullable Boolean idempotent, @Nullable CqlIdentifier routingKeyspace,
54+
@Nullable ByteBuffer routingKey) {
5255

5356
super(consistencyLevel, executionProfileResolver, keyspace, pageSize, serialConsistencyLevel, timeout, ttl,
54-
timestamp, tracing);
57+
timestamp, tracing, idempotent, routingKeyspace, routingKey);
5558

5659
this.ifExists = ifExists;
5760
this.ifCondition = ifCondition;
@@ -242,6 +245,13 @@ public DeleteOptionsBuilder withTracing() {
242245
return this;
243246
}
244247

248+
@Override
249+
public DeleteOptionsBuilder idempotent(boolean idempotent) {
250+
251+
super.idempotent(idempotent);
252+
return this;
253+
}
254+
245255
public DeleteOptionsBuilder ttl(int ttl) {
246256

247257
super.ttl(ttl);
@@ -262,6 +272,19 @@ public DeleteOptionsBuilder timestamp(Instant timestamp) {
262272
return this;
263273
}
264274

275+
@Override
276+
public DeleteOptionsBuilder routingKeyspace(CqlIdentifier routingKeyspace) {
277+
278+
super.routingKeyspace(routingKeyspace);
279+
return this;
280+
}
281+
282+
@Override
283+
public DeleteOptionsBuilder routingKey(ByteBuffer routingKey) {
284+
285+
super.routingKey(routingKey);
286+
return this;
287+
}
265288

266289
/**
267290
* Use light-weight transactions by applying {@code IF EXISTS}. Replaces a previous {@link #ifCondition(Filter)}.
@@ -326,7 +349,7 @@ public DeleteOptions build() {
326349

327350
return new DeleteOptions(this.consistencyLevel, this.executionProfileResolver, this.keyspace, this.pageSize,
328351
this.serialConsistencyLevel, this.timeout, this.ttl, this.timestamp, this.tracing, this.ifExists,
329-
this.ifCondition);
352+
this.ifCondition, this.idempotent, this.routingKeyspace, this.routingKey);
330353
}
331354
}
332355
}

spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/InsertOptions.java

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2021 the original author or authors.
2+
* Copyright 2017-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
1515
*/
1616
package org.springframework.data.cassandra.core;
1717

18+
import java.nio.ByteBuffer;
1819
import java.time.Duration;
1920
import java.time.Instant;
2021
import java.util.concurrent.TimeUnit;
@@ -32,6 +33,7 @@
3233
* @author Mark Paluch
3334
* @author Lukasz Antoniak
3435
* @author Tomasz Lelek
36+
* @author Sam Lightfoot
3537
* @since 2.0
3638
*/
3739
public class InsertOptions extends WriteOptions {
@@ -45,10 +47,11 @@ public class InsertOptions extends WriteOptions {
4547
private InsertOptions(@Nullable ConsistencyLevel consistencyLevel, ExecutionProfileResolver executionProfileResolver,
4648
@Nullable CqlIdentifier keyspace, @Nullable Integer pageSize, @Nullable ConsistencyLevel serialConsistencyLevel,
4749
Duration timeout, Duration ttl, @Nullable Long timestamp, @Nullable Boolean tracing, boolean ifNotExists,
48-
boolean insertNulls) {
50+
boolean insertNulls, @Nullable Boolean idempotent, @Nullable CqlIdentifier routingKeyspace,
51+
@Nullable ByteBuffer routingKey) {
4952

5053
super(consistencyLevel, executionProfileResolver, keyspace, pageSize, serialConsistencyLevel, timeout, ttl,
51-
timestamp, tracing);
54+
timestamp, tracing, idempotent, routingKeyspace, routingKey);
5255

5356
this.ifNotExists = ifNotExists;
5457
this.insertNulls = insertNulls;
@@ -261,6 +264,27 @@ public InsertOptionsBuilder timestamp(Instant timestamp) {
261264
return this;
262265
}
263266

267+
@Override
268+
public InsertOptionsBuilder idempotent(boolean idempotent) {
269+
270+
super.idempotent(idempotent);
271+
return this;
272+
}
273+
274+
@Override
275+
public InsertOptionsBuilder routingKeyspace(CqlIdentifier routingKeyspace) {
276+
277+
super.routingKeyspace(routingKeyspace);
278+
return this;
279+
}
280+
281+
@Override
282+
public InsertOptionsBuilder routingKey(ByteBuffer routingKey) {
283+
284+
super.routingKey(routingKey);
285+
return this;
286+
}
287+
264288
/**
265289
* Use light-weight transactions by applying {@code IF NOT EXISTS}.
266290
*
@@ -319,7 +343,7 @@ public InsertOptionsBuilder withInsertNulls(boolean insertNulls) {
319343
public InsertOptions build() {
320344
return new InsertOptions(this.consistencyLevel, this.executionProfileResolver, this.keyspace, this.pageSize,
321345
this.serialConsistencyLevel, this.timeout, this.ttl, this.timestamp, this.tracing, this.ifNotExists,
322-
this.insertNulls);
346+
this.insertNulls, this.idempotent, this.routingKeyspace, this.routingKey);
323347
}
324348
}
325349
}

spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/UpdateOptions.java

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2021 the original author or authors.
2+
* Copyright 2017-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
1515
*/
1616
package org.springframework.data.cassandra.core;
1717

18+
import java.nio.ByteBuffer;
1819
import java.time.Duration;
1920
import java.time.Instant;
2021
import java.util.concurrent.TimeUnit;
@@ -36,6 +37,7 @@
3637
* @author Mark Paluch
3738
* @author Lukasz Antoniak
3839
* @author Tomasz Lelek
40+
* @author Sam Lightfoot
3941
* @since 2.0
4042
*/
4143
public class UpdateOptions extends WriteOptions {
@@ -49,10 +51,11 @@ public class UpdateOptions extends WriteOptions {
4951
private UpdateOptions(@Nullable ConsistencyLevel consistencyLevel, ExecutionProfileResolver executionProfileResolver,
5052
@Nullable CqlIdentifier keyspace, @Nullable Integer pageSize, @Nullable ConsistencyLevel serialConsistencyLevel,
5153
Duration timeout, Duration ttl, @Nullable Long timestamp, @Nullable Boolean tracing, boolean ifExists,
52-
@Nullable Filter ifCondition) {
54+
@Nullable Filter ifCondition, @Nullable Boolean idempotent, @Nullable CqlIdentifier routingKeyspace,
55+
@Nullable ByteBuffer routingKey) {
5356

5457
super(consistencyLevel, executionProfileResolver, keyspace, pageSize, serialConsistencyLevel, timeout, ttl,
55-
timestamp, tracing);
58+
timestamp, tracing, idempotent, routingKeyspace, routingKey);
5659

5760
this.ifExists = ifExists;
5861
this.ifCondition = ifCondition;
@@ -249,6 +252,13 @@ public UpdateOptionsBuilder withTracing() {
249252
return this;
250253
}
251254

255+
@Override
256+
public UpdateOptionsBuilder idempotent(boolean idempotent) {
257+
258+
super.idempotent(idempotent);
259+
return this;
260+
}
261+
252262
public UpdateOptionsBuilder ttl(int ttl) {
253263

254264
super.ttl(ttl);
@@ -269,6 +279,20 @@ public UpdateOptionsBuilder timestamp(Instant timestamp) {
269279
return this;
270280
}
271281

282+
@Override
283+
public UpdateOptionsBuilder routingKeyspace(CqlIdentifier routingKeyspace) {
284+
285+
super.routingKeyspace(routingKeyspace);
286+
return this;
287+
}
288+
289+
@Override
290+
public UpdateOptionsBuilder routingKey(ByteBuffer routingKey) {
291+
292+
super.routingKey(routingKey);
293+
return this;
294+
}
295+
272296
/**
273297
* Use light-weight transactions by applying {@code IF EXISTS}. Replaces a previous {@link #ifCondition(Filter)}.
274298
*
@@ -333,7 +357,7 @@ public UpdateOptionsBuilder ifCondition(Filter condition) {
333357
public UpdateOptions build() {
334358
return new UpdateOptions(this.consistencyLevel, this.executionProfileResolver, this.keyspace, this.pageSize,
335359
this.serialConsistencyLevel, this.timeout, this.ttl, this.timestamp, this.tracing, this.ifExists,
336-
this.ifCondition);
360+
this.ifCondition, this.idempotent, this.routingKeyspace, this.routingKey);
337361
}
338362
}
339363
}

spring-data-cassandra/src/main/java/org/springframework/data/cassandra/core/cql/CqlTemplate.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,6 @@ public <T> Collection<T> describeRing(HostMapper<T> hostMapper) throws DataAcces
529529
return hostMapper.mapHosts(getHosts());
530530
}
531531

532-
/* (non-Javadoc) */
533532
private Collection<Node> getHosts() {
534533
return getCurrentSession().getMetadata().getNodes().values();
535534
}

0 commit comments

Comments
 (0)