[
https://issues.apache.org/jira/browse/IGNITE-25403?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Eduard Rakhmankulov updated IGNITE-25403:
-----------------------------------------
Description:
All transactional API methods accept a Transaction. In real use, most of the
time that parameter is null making all API calls starting with (null, ... which
doesn't look good and is generally confusing. While this was to done to make
sure the user doesn't forget to pass the transaction to all methods, it looks
like this makes the API safe but too inconvenient.
It is better to add overloads for at least some of the API methods that don't
need the Transaction. It's the same as passing null.
It's OK not to add these overloads to every single method. For example, if foo
an operation foo there are two methods now
{{foo(tx, args, opts)
foo(tx, args)}}
it's OK to only add one additional convenience method
{{foo(args)}}
i.e. not to add another overload to the more detailed method that also accepts
operation options.
Compilation time conflict because of adding new overloads:
{code:java}
KeyValueView.java:
1. remove[Async](K,V) == remove[Async](Transaction, K) | example:
remove(/*Transaction*/null, /*K*/key) | unlikely | in case when typeof(K) ==
typeof(V)
2. removeAll[Async](Collection<K>) == removeAll[Async](Transaction) | example:
removeAll(/*Transaction*/ null) | CONFLICT |
3. replace[Async](K,V,V) == replace[Async](Transaction, K, V) | example:
replace(/*Transaction*/ null, key, newVal) | unlikely | in case when typeof(K)
== typeof(V)
RecordView.java:
1. deleteAll[Async](Collection<R>) == deleteAll[Async](Transaction) | example
deleteAll(/*Transaction*/ null) | CONFLICT
2. relpace[Async](R,R) == replace[Async](Transaction, R) | example
replace(/*Transaction*/ null, record) | CONFLICT
CriteriaQuerySource.java
1. query[Async](Criteria, String) == query[Async](Transaction, Criteria) |
example query(/*Transaction*/ null, /*Criteria*/) | CONFLICT
2. query[Async](Criteria, String, CriteriaOptions) == query[Async](Transaction,
Criteria, String) | example query(/*Transaction*/ null, /*Criteria*/ null,
/*String*/ null) | CONFLICT
IgniteSql.java
01. execute[Async](CancellationToken, String, Object...) ==
execute[Async](Transaction, String, Object...) | example
execute[Async](/*Transaction*/ null, qry, args) | CONFLICT
02. execute[Async](CancellationToken, Statement, Object...) ==
execute[Async](Transaction, Statement, Object...) | example
execute[Async](/*Transaction*/ null, stmt, args) | CONFLICT
03. execute[Async](CancellationToken, Mapper<T>, String, Object...) ==
execute[Async](Transaction, Mapper<T>, String, Object...) | example
execute[Async](/*Transaction*/ null, mapper, qry, args) | CONFLICT
04. execute[Async](CancellationToken, Mapper<T>, Statement, Object...) ==
execute[Async](Transaction, Mapper<T>, Statement, Object...) | example
execute[Async](/*Transaction*/ null, mapper, stmt, args) | CONFLICT
05. execute[Async](Mapper<T>, String, Object...) == execute[Async](Transaction,
String, Object...) | example execute[Async](/*Transaction*/ null, qry, args) |
CONFLICT
06. execute[Async](Mapper<T>, Statement, Object...) ==
execute[Async](Transaction, Statement, Object...) | example
execute[Async](/*Transaction*/ null, stmt, args) | CONFLICT
07. execute[Async](String, Object...) == execute[Async](Transaction, String,
Object...) | example execute[Async](/*Transaction*/ null, qry, arg0, arg1) |
CONFLICT
08. execute[Async](Statement, Object...) == execute[Async](Transaction, String,
Object...) | example execute[Async](/*Transaction*/ null, qry, arg0, arg1) |
CONFLICT
09. execute[Async](String, Object...) == execute[Async](Transaction, Statement,
Object...) | example execute[Async](/*Transaction*/ null, stmt, arg0, arg1) |
CONFLICT
10. execute[Async](Statement, Object...) == execute[Async](Transaction,
Statement, Object...) | example execute[Async](/*Transaction*/ null, stmt,
arg0, arg1) | CONFLICT
-------AND MORE with execute[Async]------
20. executeBatch[Async](CancellationToken, String, BatchedArguments) ==
execute[Async](Transaction, String, BatchedArguments) | example
executeBatch[Async](/*Transaction*/ null, qry, args) | CONFLICT
21. executeBatch[Async](CancellationToken, Statement, BatchedArguments) ==
execute[Async](Transaction, Statement, BatchedArguments) | example
executeBatch[Async](/*Transaction*/ null, stmt, args) | CONFLICT{code}
was:
All transactional API methods accept a Transaction. In real use, most of the
time that parameter is null making all API calls starting with (null, ... which
doesn't look good and is generally confusing. While this was to done to make
sure the user doesn't forget to pass the transaction to all methods, it looks
like this makes the API safe but too inconvenient.
It is better to add overloads for at least some of the API methods that don't
need the Transaction. It's the same as passing null.
It's OK not to add these overloads to every single method. For example, if foo
an operation foo there are two methods now
{{foo(tx, args, opts)
foo(tx, args)}}
it's OK to only add one additional convenience method
{{foo(args)}}
i.e. not to add another overload to the more detailed method that also accepts
operation options.
Compilation time conflict because of adding new overloads:
{code:java}
KeyValueView.java:
1. remove[Async](K,V) == remove[Async](Transaction, K) | example:
remove(/*Transaction*/null, /*K*/key) | unlikely | in case when typeof(K) ==
typeof(V)
2. removeAll[Async](Collection<K>) == removeAll[Async](Transaction) | example:
removeAll(/*Transaction*/ null) | CONFLICT |
3. replace[Async](K,V,V) == replace[Async](Transaction, K, V) | example:
replace(/*Transaction*/ null, key, newVal) | unlikely | in case when typeof(K)
== typeof(V)
RecordView.java:
1. deleteAll[Async](Collection<R>) == deleteAll[Async](Transaction) | example
deleteAll(/*Transaction*/ null) | CONFLICT
2. relpace[Async](R,R) == replace[Async](Transaction, R) | example
replace(/*Transaction*/ null, record) | CONFLICT {code}
> Add overloads for common API methods that don't accept Transaction
> ------------------------------------------------------------------
>
> Key: IGNITE-25403
> URL: https://issues.apache.org/jira/browse/IGNITE-25403
> Project: Ignite
> Issue Type: Improvement
> Reporter: Eduard Rakhmankulov
> Assignee: Eduard Rakhmankulov
> Priority: Major
> Time Spent: 0.5h
> Remaining Estimate: 0h
>
> All transactional API methods accept a Transaction. In real use, most of the
> time that parameter is null making all API calls starting with (null, ...
> which doesn't look good and is generally confusing. While this was to done to
> make sure the user doesn't forget to pass the transaction to all methods, it
> looks like this makes the API safe but too inconvenient.
> It is better to add overloads for at least some of the API methods that don't
> need the Transaction. It's the same as passing null.
> It's OK not to add these overloads to every single method. For example, if
> foo an operation foo there are two methods now
>
> {{foo(tx, args, opts)
> foo(tx, args)}}
> it's OK to only add one additional convenience method
>
> {{foo(args)}}
> i.e. not to add another overload to the more detailed method that also
> accepts operation options.
>
> Compilation time conflict because of adding new overloads:
> {code:java}
> KeyValueView.java:
> 1. remove[Async](K,V) == remove[Async](Transaction, K) | example:
> remove(/*Transaction*/null, /*K*/key) | unlikely | in case when typeof(K) ==
> typeof(V)
> 2. removeAll[Async](Collection<K>) == removeAll[Async](Transaction) |
> example: removeAll(/*Transaction*/ null) | CONFLICT |
> 3. replace[Async](K,V,V) == replace[Async](Transaction, K, V) | example:
> replace(/*Transaction*/ null, key, newVal) | unlikely | in case when
> typeof(K) == typeof(V)
> RecordView.java:
> 1. deleteAll[Async](Collection<R>) == deleteAll[Async](Transaction) | example
> deleteAll(/*Transaction*/ null) | CONFLICT
> 2. relpace[Async](R,R) == replace[Async](Transaction, R) | example
> replace(/*Transaction*/ null, record) | CONFLICT
> CriteriaQuerySource.java
> 1. query[Async](Criteria, String) == query[Async](Transaction, Criteria) |
> example query(/*Transaction*/ null, /*Criteria*/) | CONFLICT
> 2. query[Async](Criteria, String, CriteriaOptions) ==
> query[Async](Transaction, Criteria, String) | example query(/*Transaction*/
> null, /*Criteria*/ null, /*String*/ null) | CONFLICT
> IgniteSql.java
> 01. execute[Async](CancellationToken, String, Object...) ==
> execute[Async](Transaction, String, Object...) | example
> execute[Async](/*Transaction*/ null, qry, args) | CONFLICT
> 02. execute[Async](CancellationToken, Statement, Object...) ==
> execute[Async](Transaction, Statement, Object...) | example
> execute[Async](/*Transaction*/ null, stmt, args) | CONFLICT
> 03. execute[Async](CancellationToken, Mapper<T>, String, Object...) ==
> execute[Async](Transaction, Mapper<T>, String, Object...) | example
> execute[Async](/*Transaction*/ null, mapper, qry, args) | CONFLICT
> 04. execute[Async](CancellationToken, Mapper<T>, Statement, Object...) ==
> execute[Async](Transaction, Mapper<T>, Statement, Object...) | example
> execute[Async](/*Transaction*/ null, mapper, stmt, args) | CONFLICT
> 05. execute[Async](Mapper<T>, String, Object...) ==
> execute[Async](Transaction, String, Object...) | example
> execute[Async](/*Transaction*/ null, qry, args) | CONFLICT
> 06. execute[Async](Mapper<T>, Statement, Object...) ==
> execute[Async](Transaction, Statement, Object...) | example
> execute[Async](/*Transaction*/ null, stmt, args) | CONFLICT
> 07. execute[Async](String, Object...) == execute[Async](Transaction, String,
> Object...) | example execute[Async](/*Transaction*/ null, qry, arg0, arg1) |
> CONFLICT
> 08. execute[Async](Statement, Object...) == execute[Async](Transaction,
> String, Object...) | example execute[Async](/*Transaction*/ null, qry, arg0,
> arg1) | CONFLICT
> 09. execute[Async](String, Object...) == execute[Async](Transaction,
> Statement, Object...) | example execute[Async](/*Transaction*/ null, stmt,
> arg0, arg1) | CONFLICT
> 10. execute[Async](Statement, Object...) == execute[Async](Transaction,
> Statement, Object...) | example execute[Async](/*Transaction*/ null, stmt,
> arg0, arg1) | CONFLICT
> -------AND MORE with execute[Async]------
> 20. executeBatch[Async](CancellationToken, String, BatchedArguments) ==
> execute[Async](Transaction, String, BatchedArguments) | example
> executeBatch[Async](/*Transaction*/ null, qry, args) | CONFLICT
> 21. executeBatch[Async](CancellationToken, Statement, BatchedArguments) ==
> execute[Async](Transaction, Statement, BatchedArguments) | example
> executeBatch[Async](/*Transaction*/ null, stmt, args) | CONFLICT{code}
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)