-
Notifications
You must be signed in to change notification settings - Fork 12
Add 'fields' parameter to ProxySpace #263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I liked it overall, but I believe that there's a better way. Please take a look at the comments below.
I think that Options
should be much like the Conditions
class, which is actually a builder and it is convenient to call a select method like space.select(Conditions.any())
, for example. We should have something like that for Options
. Of course, in this case, we'll have to tell the user if any actual options aren't supported by the particular client instance (in the same way as we do in Conditions). Serialization of Options
instances will happen internally, no need to force users to use additional builder instances and call build()
, that's ugly. But the difference will be that we can have different Options
classes for each operation. So for select
it will be SelectOptions
, for insertMany
it will be InsertManyOptions
etc.
An example of how the Options
class can be used:
space.select(
Conditions.any(),
SelectOptions.withTimeout(100500).withBatchSize(1000).withFields(Arrays.asList("id"))
)
Here SelectOptions
inherit some base class that provides withTimeout
and withFields
methods.
P.S. I think we further will replace the single Conditions
class in the methods where it is passed with a hierarchy, like PrimaryIndexConditions
(or just PrimaryIndex
) for the methods that support only it and full Conditions
(or IndexConditions
?) for select
.
/** | ||
* Select tuples matching the specified query with specified conditions and options. | ||
* | ||
* @param conditions specified conditions |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make the doc more descriptive. query with options
or something better for conditions
, and more words for options
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
|
||
public T withTimeout(int timeout) { | ||
this.timeout = timeout; | ||
return self(); | ||
} | ||
|
||
public T withOptions(Options options) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that timeout
should be a part of Options
. Therefore we'll be able to specify a custom timeout for each operation. This will be also useful for the box interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In merged PR withTimeout
is using as default parameter(to pass config.timeout) and withOptions -> timeout
as custom timeout
* @author Alexey Kuzin | ||
* @author Artyom Dubinin | ||
*/ | ||
class CRUDFunctionOptions extends CRUDBaseOptions { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this name very much, it is confusing. And why do we have here a duplication of ProxyFunctionOptions
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In merged PR we've discussed to name CRUDReturnOptions
src/main/java/io/tarantool/driver/core/space/ProxyTarantoolSpace.java
Outdated
Show resolved
Hide resolved
src/main/java/io/tarantool/driver/core/space/options/Options.java
Outdated
Show resolved
Hide resolved
/** | ||
* This class is not part of the public API. | ||
* | ||
* Represent options for cluster proxy operations which returns fields. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Represent options for cluster proxy operations which returns fields. | |
* Represent options for cluster proxy operations that return fields. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It has been rewritten
/** | ||
* @author Artyom Dubinin | ||
*/ | ||
public class ProxyTarantoolSpaceIT extends SharedCartridgeContainer { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need a new test class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added some classes in merged PR. I did this because the main class ProxyAPI
is overloaded with many testcases, I wanted more precision test classes
I see only one way how to implement this, we should have all abstract classes except leaf in inheritance hierarchy. Leaf implement SelectOptions.create().withTimeout(100500).withBatchSize(1000).withFields(Arrays.asList("id")) |
314b478
to
2b0a3d3
Compare
2b0a3d3
to
57f8356
Compare
57f8356
to
a15eed3
Compare
894e8a3
to
1618cfe
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost good, the questions are mostly about the docstrings.
/** | ||
* Return list of fields. | ||
* | ||
* @return timeout, in milliseconds. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not timeout, fields
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
*/ | ||
public interface OperationWithFieldsOptions extends OperationWithTimeoutOptions { | ||
/** | ||
* Return list of fields. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to have a more full description (what is this list for?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
|
||
public static final String FIELDS = "fields"; | ||
|
||
/** TODO: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doc TODO?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
} | ||
|
||
@Override | ||
public Optional<List> getFields() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need List<String>
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can't have List<String>
here, because we can't pass List<String>.class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we can't? Looks like we can change method interface methods signature
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah we can change method signature, but in the inner implementation we need to do a hack to cast to List<String>.class
. The problem is about we are storing any option types in a Map with generic Object type
|
||
public static final String BATCH_STOP_ON_ERROR = "stop_on_error"; | ||
public static final String BATCH_ROLLBACK_ON_ERROR = "rollback_on_error"; | ||
|
||
protected | ||
<T extends AbstractBuilder<T>> | ||
CRUDBatchOptions(AbstractBuilder<T> builder) { | ||
<O extends CRUDBatchOptions, B extends AbstractBuilder<O, B>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CRUDBatchOptions
is a final class, we don't need a generic for Options here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
/** | ||
* This class is not part of the public API. | ||
* <p> | ||
* Represent options for cluster proxy operations which returns fields |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's reformulate it. Something like operations for that the set of fields returned in the result tuples can be specified
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has been rewritten to
* Represent returned options for cluster proxy operations.
* The return set of fields of the tuples can be specified.
|
||
public static final String SELECT_LIMIT = "first"; | ||
public static final String SELECT_AFTER = "after"; | ||
public static final String SELECT_BATCH_SIZE = "batch_size"; | ||
|
||
private <T extends AbstractBuilder<T>> | ||
CRUDSelectOptions(AbstractBuilder<T> builder) { | ||
private <O extends CRUDSelectOptions, B extends AbstractBuilder<O, B>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
THis class is final, the generic for Options
is redundant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
Yeah, that is reason why I've converted PR to Draft |
<O extends CRUDBaseOptions, T extends AbstractBuilder<O, T>> | ||
CRUDBaseOptions(AbstractBuilder<O, T> builder) { | ||
<O extends CRUDBaseOptions, B extends AbstractBuilder<O, B>> | ||
CRUDBaseOptions(AbstractBuilder<O, B> builder) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess this case should be excluded from checkstyle only one line, current format looks not readable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added, please check and give your opinion how to do it correctly
class AbstractBuilder<O extends CRUDBaseOptions, T extends AbstractBuilder<O, T>> | ||
extends CRUDAbstractOperationOptions.AbstractBuilder<O, T> { | ||
class AbstractBuilder<O extends CRUDBaseOptions, B extends AbstractBuilder<O, B>> | ||
extends CRUDAbstractOperationOptions.AbstractBuilder<O, B> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think. looks better
protected abstract static class AbstractBuilder<O extends CRUDBaseOptions, B extends AbstractBuilder<O, B>>
extends CRUDAbstractOperationOptions.AbstractBuilder<O, B> {
protected Optional<Integer> timeout = Optional.empty();
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
protected <O extends CRUDReturnOptions, B extends AbstractBuilder<O, B>> | ||
CRUDReturnOptions(CRUDReturnOptions.AbstractBuilder<O, B> builder) { | ||
super(builder); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove space
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
db9c4f4
to
0ce821a
Compare
0ce821a
to
d82b697
Compare
Blocked by #272 because driver should parse metadata from crud. We can't get field by field name if we don't know position and It will frustrate users |
00857c2
to
77f358d
Compare
77f358d
to
87f9179
Compare
Add
fields
option to crud proxy methodsCloses #236