Skip to content

Commit 00857c2

Browse files
committed
Add fields option to ProxySpace
Closes #236
1 parent d5fcb3e commit 00857c2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+767
-33
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
- Added options parameter to Tarantool Space API ([#266](https://github.com/tarantool/cartridge-java/pull/266))
4646
- Added bucket id parameter to Tarantool Space API ([#270](https://github.com/tarantool/cartridge-java/pull/270))
4747
- Added support for insert_many and replace_many CRUD operations ([#259](https://github.com/tarantool/cartridge-java/issues/259))
48+
- Added `fields` option to ProxySpace ([#236](https://github.com/tarantool/cartridge-java/pull/236))
4849

4950
## [0.8.2] - 2022-09-16
5051

src/main/java/io/tarantool/driver/api/space/TarantoolSpaceOperations.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ default CompletableFuture<R> replaceMany(Collection<T> tuples, ReplaceManyOption
139139
}
140140

141141
/**
142-
* Select tuples matching the specified query with options.
142+
* Search for a tuple or a set of tuples with a specific conditions.
143143
*
144144
* @param conditions query with options
145145
* @return a future that will contain all corresponding tuples once completed
@@ -148,7 +148,7 @@ default CompletableFuture<R> replaceMany(Collection<T> tuples, ReplaceManyOption
148148
CompletableFuture<R> select(Conditions conditions) throws TarantoolClientException;
149149

150150
/**
151-
* Select tuples matching the specified query with specified conditions and options.
151+
* Search for a tuple or a set of tuples with a specific conditions and additional options.
152152
*
153153
* @param conditions specified conditions
154154
* @param options operation options

src/main/java/io/tarantool/driver/api/space/options/DeleteOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
* @author Artyom Dubinin
77
* @author Alexey Kuzin
88
*/
9-
public interface DeleteOptions extends OperationWithBucketIdOptions {
9+
public interface DeleteOptions extends OperationWithBucketIdOptions, OperationWithFieldsOptions {
1010
}

src/main/java/io/tarantool/driver/api/space/options/InsertManyOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* @author Alexey Kuzin
99
*/
10-
public interface InsertManyOptions extends OperationWithTimeoutOptions {
10+
public interface InsertManyOptions extends OperationWithFieldsOptions {
1111
/**
1212
* Return whether all changes should not be saved if any tuple insertion
1313
* was unsuccesful.

src/main/java/io/tarantool/driver/api/space/options/InsertOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
* @author Artyom Dubinin
77
* @author Alexey Kuzin
88
*/
9-
public interface InsertOptions extends OperationWithBucketIdOptions {
9+
public interface InsertOptions extends OperationWithBucketIdOptions, OperationWithFieldsOptions {
1010
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package io.tarantool.driver.api.space.options;
2+
3+
import java.util.List;
4+
import java.util.Optional;
5+
6+
/**
7+
* Base interface for all operation options that may have a configurable return.
8+
*
9+
* @author Artyom Dubinin
10+
*/
11+
public interface OperationWithFieldsOptions extends OperationWithTimeoutOptions {
12+
/**
13+
* Return list of fields names for getting only a subset of fields.
14+
*
15+
* @return list of fields string names
16+
*/
17+
Optional<List> getFields();
18+
}

src/main/java/io/tarantool/driver/api/space/options/ReplaceManyOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
* @author Alexey Kuzin
99
*/
10-
public interface ReplaceManyOptions extends OperationWithTimeoutOptions {
10+
public interface ReplaceManyOptions extends OperationWithFieldsOptions {
1111
/**
1212
* Return whether all changes should not be saved if any tuple replace
1313
* was unsuccesful.

src/main/java/io/tarantool/driver/api/space/options/ReplaceOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
* @author Artyom Dubinin
77
* @author Alexey Kuzin
88
*/
9-
public interface ReplaceOptions extends OperationWithBucketIdOptions {
9+
public interface ReplaceOptions extends OperationWithBucketIdOptions, OperationWithFieldsOptions {
1010
}

src/main/java/io/tarantool/driver/api/space/options/SelectOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @author Artyom Dubinin
99
* @author Alexey Kuzin
1010
*/
11-
public interface SelectOptions extends OperationWithBucketIdOptions {
11+
public interface SelectOptions extends OperationWithBucketIdOptions, OperationWithFieldsOptions {
1212
/**
1313
* Return the internal size of batch for transferring data between
1414
* storage and router nodes.

src/main/java/io/tarantool/driver/api/space/options/UpdateOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
* @author Artyom Dubinin
77
* @author Alexey Kuzin
88
*/
9-
public interface UpdateOptions extends OperationWithBucketIdOptions {
9+
public interface UpdateOptions extends OperationWithBucketIdOptions, OperationWithFieldsOptions {
1010
}

src/main/java/io/tarantool/driver/api/space/options/UpsertOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
* @author Artyom Dubinin
77
* @author Alexey Kuzin
88
*/
9-
public interface UpsertOptions extends OperationWithBucketIdOptions {
9+
public interface UpsertOptions extends OperationWithBucketIdOptions, OperationWithFieldsOptions {
1010
}

src/main/java/io/tarantool/driver/api/space/options/proxy/ProxyDeleteOptions.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import io.tarantool.driver.api.space.options.DeleteOptions;
44

5+
import java.util.List;
6+
import java.util.Optional;
7+
58
/**
69
* Represent options for delete cluster proxy operation
710
*
@@ -10,6 +13,8 @@
1013
*/
1114
public final class ProxyDeleteOptions extends ProxyBucketIdOptions<ProxyDeleteOptions> implements DeleteOptions {
1215

16+
public static final String FIELDS = "fields";
17+
1318
private ProxyDeleteOptions() {
1419
}
1520

@@ -22,8 +27,25 @@ public static ProxyDeleteOptions create() {
2227
return new ProxyDeleteOptions();
2328
}
2429

30+
/**
31+
* Specifies list of fields names for getting only a subset of fields.
32+
* By default, all fields are returned.
33+
*
34+
* @param fields list of string field names
35+
* @return this options instance
36+
*/
37+
public ProxyDeleteOptions withFields(List<String> fields) {
38+
addOption(FIELDS, fields);
39+
return self();
40+
}
41+
2542
@Override
2643
protected ProxyDeleteOptions self() {
2744
return this;
2845
}
46+
47+
@Override
48+
public Optional<List> getFields() {
49+
return getOption(FIELDS, List.class);
50+
}
2951
}

src/main/java/io/tarantool/driver/api/space/options/proxy/ProxyInsertManyOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
* @author Alexey Kuzin
1111
*/
12-
public final class ProxyInsertManyOptions extends ProxyBaseOptions<ProxyInsertManyOptions>
12+
public final class ProxyInsertManyOptions extends ProxyReturnOptions<ProxyInsertManyOptions>
1313
implements InsertManyOptions {
1414

1515
public static final String ROLLBACK_ON_ERROR = "rollback_on_error";

src/main/java/io/tarantool/driver/api/space/options/proxy/ProxyInsertOptions.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import io.tarantool.driver.api.space.options.InsertOptions;
44

5+
import java.util.List;
6+
import java.util.Optional;
7+
58
/**
69
* Represent options for insert cluster proxy operation
710
*
@@ -10,6 +13,8 @@
1013
*/
1114
public final class ProxyInsertOptions extends ProxyBucketIdOptions<ProxyInsertOptions> implements InsertOptions {
1215

16+
public static final String FIELDS = "fields";
17+
1318
private ProxyInsertOptions() {
1419
}
1520

@@ -22,8 +27,25 @@ public static ProxyInsertOptions create() {
2227
return new ProxyInsertOptions();
2328
}
2429

30+
/**
31+
* Specifies list of fields names for getting only a subset of fields.
32+
* By default, all fields are returned.
33+
*
34+
* @param fields list of string field names
35+
* @return this options instance
36+
*/
37+
public ProxyInsertOptions withFields(List<String> fields) {
38+
addOption(FIELDS, fields);
39+
return self();
40+
}
41+
2542
@Override
2643
protected ProxyInsertOptions self() {
2744
return this;
2845
}
46+
47+
@Override
48+
public Optional<List> getFields() {
49+
return getOption(FIELDS, List.class);
50+
}
2951
}

src/main/java/io/tarantool/driver/api/space/options/proxy/ProxyReplaceManyOptions.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
* @author Alexey Kuzin
1111
*/
12-
public final class ProxyReplaceManyOptions extends ProxyBaseOptions<ProxyReplaceManyOptions>
12+
public final class ProxyReplaceManyOptions extends ProxyReturnOptions<ProxyReplaceManyOptions>
1313
implements ReplaceManyOptions {
1414

1515
public static final String ROLLBACK_ON_ERROR = "rollback_on_error";

src/main/java/io/tarantool/driver/api/space/options/proxy/ProxyReplaceOptions.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import io.tarantool.driver.api.space.options.ReplaceOptions;
44

5+
import java.util.List;
6+
import java.util.Optional;
7+
58
/**
69
* Represent options for replace cluster proxy operation
710
*
@@ -10,6 +13,8 @@
1013
*/
1114
public final class ProxyReplaceOptions extends ProxyBucketIdOptions<ProxyReplaceOptions> implements ReplaceOptions {
1215

16+
public static final String FIELDS = "fields";
17+
1318
private ProxyReplaceOptions() {
1419
}
1520

@@ -22,8 +27,25 @@ public static ProxyReplaceOptions create() {
2227
return new ProxyReplaceOptions();
2328
}
2429

30+
/**
31+
* Specifies list of fields names for getting only a subset of fields.
32+
* By default, all fields are returned.
33+
*
34+
* @param fields list of string field names
35+
* @return this options instance
36+
*/
37+
public ProxyReplaceOptions withFields(List<String> fields) {
38+
addOption(FIELDS, fields);
39+
return self();
40+
}
41+
2542
@Override
2643
protected ProxyReplaceOptions self() {
2744
return this;
2845
}
46+
47+
@Override
48+
public Optional<List> getFields() {
49+
return getOption(FIELDS, List.class);
50+
}
2951
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package io.tarantool.driver.api.space.options.proxy;
2+
3+
import io.tarantool.driver.api.space.options.OperationWithFieldsOptions;
4+
5+
import java.util.List;
6+
import java.util.Optional;
7+
8+
/**
9+
* Represent options for functions which return values.
10+
*
11+
* @author Alexey Kuzin
12+
* @author Artyom Dubinin
13+
*/
14+
abstract class ProxyReturnOptions<B extends ProxyReturnOptions<B>> extends ProxyBaseOptions<B>
15+
implements OperationWithFieldsOptions {
16+
17+
public static final String FIELDS = "fields";
18+
19+
/**
20+
* Specifies list of fields names for getting only a subset of fields.
21+
* By default, all fields are returned.
22+
*
23+
* @param fields list of string field names
24+
* @return this options instance
25+
*/
26+
public B withFields(List<String> fields) {
27+
addOption(FIELDS, fields);
28+
return self();
29+
}
30+
31+
@Override
32+
public Optional<List> getFields() {
33+
return getOption(FIELDS, List.class);
34+
}
35+
}

src/main/java/io/tarantool/driver/api/space/options/proxy/ProxySelectOptions.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import io.tarantool.driver.api.space.options.SelectOptions;
44

5+
import java.util.List;
56
import java.util.Optional;
67

78
/**
@@ -13,6 +14,7 @@
1314
public final class ProxySelectOptions extends ProxyBucketIdOptions<ProxySelectOptions> implements SelectOptions {
1415

1516
public static final String BATCH_SIZE = "batch_size";
17+
public static final String FIELDS = "fields";
1618

1719
private ProxySelectOptions() {
1820
}
@@ -40,6 +42,18 @@ public ProxySelectOptions withBatchSize(int batchSize) {
4042
return self();
4143
}
4244

45+
/**
46+
* Specifies list of fields names for getting only a subset of fields.
47+
* By default, all fields are returned.
48+
*
49+
* @param fields list of string field names
50+
* @return this options instance
51+
*/
52+
public ProxySelectOptions withFields(List<String> fields) {
53+
addOption(FIELDS, fields);
54+
return self();
55+
}
56+
4357
@Override
4458
protected ProxySelectOptions self() {
4559
return this;
@@ -49,4 +63,9 @@ protected ProxySelectOptions self() {
4963
public Optional<Integer> getBatchSize() {
5064
return getOption(BATCH_SIZE, Integer.class);
5165
}
66+
67+
@Override
68+
public Optional<List> getFields() {
69+
return getOption(FIELDS, List.class);
70+
}
5271
}

src/main/java/io/tarantool/driver/api/space/options/proxy/ProxyUpdateOptions.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import io.tarantool.driver.api.space.options.UpdateOptions;
44

5+
import java.util.List;
6+
import java.util.Optional;
7+
58
/**
69
* Represent options for update cluster proxy operation
710
*
@@ -10,6 +13,8 @@
1013
*/
1114
public final class ProxyUpdateOptions extends ProxyBucketIdOptions<ProxyUpdateOptions> implements UpdateOptions {
1215

16+
public static final String FIELDS = "fields";
17+
1318
private ProxyUpdateOptions() {
1419
}
1520

@@ -22,8 +27,25 @@ public static ProxyUpdateOptions create() {
2227
return new ProxyUpdateOptions();
2328
}
2429

30+
/**
31+
* Specifies list of fields names for getting only a subset of fields.
32+
* By default, all fields are returned.
33+
*
34+
* @param fields list of string field names
35+
* @return this options instance
36+
*/
37+
public ProxyUpdateOptions withFields(List<String> fields) {
38+
addOption(FIELDS, fields);
39+
return self();
40+
}
41+
2542
@Override
2643
protected ProxyUpdateOptions self() {
2744
return this;
2845
}
46+
47+
@Override
48+
public Optional<List> getFields() {
49+
return getOption(FIELDS, List.class);
50+
}
2951
}

0 commit comments

Comments
 (0)