Skip to content

Commit 367b6ac

Browse files
samueldlightfootmp911de
authored andcommitted
Extend supported fields for query options.
We now accept idempotent, routingKey, and routingKeyspace options. Closes #1220
1 parent 68ddb12 commit 367b6ac

File tree

9 files changed

+319
-26
lines changed

9 files changed

+319
-26
lines changed

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

Lines changed: 36 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;
@@ -289,6 +292,16 @@ public DeleteOptionsBuilder withTracing() {
289292
return this;
290293
}
291294

295+
/* (non-Javadoc)
296+
* @see org.springframework.data.cassandra.core.cql.WriteOptions.WriteOptionsBuilder#idempotent(boolean)
297+
*/
298+
@Override
299+
public DeleteOptionsBuilder idempotent(boolean idempotent) {
300+
301+
super.idempotent(idempotent);
302+
return this;
303+
}
304+
292305
/* (non-Javadoc)
293306
* @see org.springframework.data.cassandra.core.cql.WriteOptions.WriteOptionsBuilder#ttl(int)
294307
*/
@@ -318,6 +331,25 @@ public DeleteOptionsBuilder timestamp(Instant timestamp) {
318331
return this;
319332
}
320333

334+
/* (non-Javadoc)
335+
* @see org.springframework.data.cassandra.core.cql.QueryOptions.QueryOptionsBuilder#routingKeyspace(com.datastax.oss.driver.api.core.CqlIdentifier)
336+
*/
337+
@Override
338+
public DeleteOptionsBuilder routingKeyspace(CqlIdentifier routingKeyspace) {
339+
340+
super.routingKeyspace(routingKeyspace);
341+
return this;
342+
}
343+
344+
/* (non-Javadoc)
345+
* @see org.springframework.data.cassandra.core.cql.QueryOptions.QueryOptionsBuilder#routingKeyspace(java.nio.ByteBuffer)
346+
*/
347+
@Override
348+
public DeleteOptionsBuilder routingKey(ByteBuffer routingKey) {
349+
350+
super.routingKey(routingKey);
351+
return this;
352+
}
321353

322354
/**
323355
* Use light-weight transactions by applying {@code IF EXISTS}. Replaces a previous {@link #ifCondition(Filter)}.
@@ -382,7 +414,7 @@ public DeleteOptions build() {
382414

383415
return new DeleteOptions(this.consistencyLevel, this.executionProfileResolver, this.keyspace, this.pageSize,
384416
this.serialConsistencyLevel, this.timeout, this.ttl, this.timestamp, this.tracing, this.ifExists,
385-
this.ifCondition);
417+
this.ifCondition, this.idempotent, this.routingKeyspace, this.routingKey);
386418
}
387419
}
388420
}

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

Lines changed: 37 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;
@@ -317,6 +320,36 @@ public InsertOptionsBuilder timestamp(Instant timestamp) {
317320
return this;
318321
}
319322

323+
/* (non-Javadoc)
324+
* @see org.springframework.data.cassandra.core.cql.QueryOptions.QueryOptionsBuilder#idempotent(boolean)
325+
*/
326+
@Override
327+
public InsertOptionsBuilder idempotent(boolean idempotent) {
328+
329+
super.idempotent(idempotent);
330+
return this;
331+
}
332+
333+
/* (non-Javadoc)
334+
* @see org.springframework.data.cassandra.core.cql.QueryOptions.QueryOptionsBuilder#routingKeyspace(com.datastax.oss.driver.api.core.CqlIdentifier)
335+
*/
336+
@Override
337+
public InsertOptionsBuilder routingKeyspace(CqlIdentifier routingKeyspace) {
338+
339+
super.routingKeyspace(routingKeyspace);
340+
return this;
341+
}
342+
343+
/* (non-Javadoc)
344+
* @see org.springframework.data.cassandra.core.cql.QueryOptions.QueryOptionsBuilder#routingKeyspace(java.nio.ByteBuffer)
345+
*/
346+
@Override
347+
public InsertOptionsBuilder routingKey(ByteBuffer routingKey) {
348+
349+
super.routingKey(routingKey);
350+
return this;
351+
}
352+
320353
/**
321354
* Use light-weight transactions by applying {@code IF NOT EXISTS}.
322355
*
@@ -375,7 +408,7 @@ public InsertOptionsBuilder withInsertNulls(boolean insertNulls) {
375408
public InsertOptions build() {
376409
return new InsertOptions(this.consistencyLevel, this.executionProfileResolver, this.keyspace, this.pageSize,
377410
this.serialConsistencyLevel, this.timeout, this.ttl, this.timestamp, this.tracing, this.ifNotExists,
378-
this.insertNulls);
411+
this.insertNulls, this.idempotent, this.routingKeyspace, this.routingKey);
379412
}
380413
}
381414
}

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

Lines changed: 37 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;
@@ -296,6 +299,16 @@ public UpdateOptionsBuilder withTracing() {
296299
return this;
297300
}
298301

302+
/* (non-Javadoc)
303+
* @see org.springframework.data.cassandra.core.cql.WriteOptions.WriteOptionsBuilder#idempotent(boolean)
304+
*/
305+
@Override
306+
public UpdateOptionsBuilder idempotent(boolean idempotent) {
307+
308+
super.idempotent(idempotent);
309+
return this;
310+
}
311+
299312
/* (non-Javadoc)
300313
* @see org.springframework.data.cassandra.core.cql.WriteOptions.WriteOptionsBuilder#ttl(int)
301314
*/
@@ -325,6 +338,26 @@ public UpdateOptionsBuilder timestamp(Instant timestamp) {
325338
return this;
326339
}
327340

341+
/* (non-Javadoc)
342+
* @see org.springframework.data.cassandra.core.cql.QueryOptions.QueryOptionsBuilder#routingKeyspace(com.datastax.oss.driver.api.core.CqlIdentifier)
343+
*/
344+
@Override
345+
public UpdateOptionsBuilder routingKeyspace(CqlIdentifier routingKeyspace) {
346+
347+
super.routingKeyspace(routingKeyspace);
348+
return this;
349+
}
350+
351+
/* (non-Javadoc)
352+
* @see org.springframework.data.cassandra.core.cql.QueryOptions.QueryOptionsBuilder#routingKeyspace(java.nio.ByteBuffer)
353+
*/
354+
@Override
355+
public UpdateOptionsBuilder routingKey(ByteBuffer routingKey) {
356+
357+
super.routingKey(routingKey);
358+
return this;
359+
}
360+
328361
/**
329362
* Use light-weight transactions by applying {@code IF EXISTS}. Replaces a previous {@link #ifCondition(Filter)}.
330363
*
@@ -389,7 +422,7 @@ public UpdateOptionsBuilder ifCondition(Filter condition) {
389422
public UpdateOptions build() {
390423
return new UpdateOptions(this.consistencyLevel, this.executionProfileResolver, this.keyspace, this.pageSize,
391424
this.serialConsistencyLevel, this.timeout, this.ttl, this.timestamp, this.tracing, this.ifExists,
392-
this.ifCondition);
425+
this.ifCondition, this.idempotent, this.routingKeyspace, this.routingKey);
393426
}
394427
}
395428
}

0 commit comments

Comments
 (0)