@@ -245,6 +245,15 @@ pub struct ResultSet<T> {
245
245
client_cursor : usize ,
246
246
}
247
247
248
+ impl < T > ResultSet < T > {
249
+ /// Get the length of the batch returned by Iroha.
250
+ ///
251
+ /// This is controlled by `fetch_size` parameter of the query.
252
+ pub fn batch_len ( & self ) -> usize {
253
+ self . iter . len ( )
254
+ }
255
+ }
256
+
248
257
impl < T : Clone > Iterator for ResultSet < T >
249
258
where
250
259
Vec < T > : QueryOutput ,
@@ -374,6 +383,7 @@ impl QueryRequest {
374
383
query : Vec :: default ( ) ,
375
384
sorting : Sorting :: default ( ) ,
376
385
pagination : Pagination :: default ( ) ,
386
+ fetch_size : FetchSize :: default ( ) ,
377
387
} ,
378
388
) ,
379
389
}
@@ -389,6 +399,7 @@ impl QueryRequest {
389
399
iroha_data_model:: query:: QueryRequest :: Query ( query_with_params) => builder
390
400
. params ( query_with_params. sorting ( ) . clone ( ) . into_query_parameters ( ) )
391
401
. params ( query_with_params. pagination ( ) . into_query_parameters ( ) )
402
+ . params ( query_with_params. fetch_size ( ) . into_query_parameters ( ) )
392
403
. body ( query_with_params. query ( ) . clone ( ) ) ,
393
404
iroha_data_model:: query:: QueryRequest :: Cursor ( cursor) => {
394
405
builder. params ( Vec :: from ( cursor) )
@@ -798,6 +809,7 @@ impl Client {
798
809
filter : PredicateBox ,
799
810
pagination : Pagination ,
800
811
sorting : Sorting ,
812
+ fetch_size : FetchSize ,
801
813
) -> Result < ( DefaultRequestBuilder , QueryResponseHandler < R :: Output > ) >
802
814
where
803
815
<R :: Output as TryFrom < Value > >:: Error : Into < eyre:: Error > ,
@@ -809,7 +821,9 @@ impl Client {
809
821
torii_url : self . torii_url . clone ( ) ,
810
822
headers : self . headers . clone ( ) ,
811
823
request : iroha_data_model:: query:: QueryRequest :: Query (
812
- iroha_data_model:: query:: QueryWithParameters :: new ( request, sorting, pagination) ,
824
+ iroha_data_model:: query:: QueryWithParameters :: new (
825
+ request, sorting, pagination, fetch_size,
826
+ ) ,
813
827
) ,
814
828
} ;
815
829
@@ -827,6 +841,7 @@ impl Client {
827
841
& self ,
828
842
request : R ,
829
843
pagination : Pagination ,
844
+ fetch_size : FetchSize ,
830
845
sorting : Sorting ,
831
846
filter : PredicateBox ,
832
847
) -> QueryResult < <R :: Output as QueryOutput >:: Target >
@@ -836,7 +851,7 @@ impl Client {
836
851
{
837
852
iroha_logger:: trace!( ?request, %pagination, ?sorting, ?filter) ;
838
853
let ( req, mut resp_handler) =
839
- self . prepare_query_request :: < R > ( request, filter, pagination, sorting) ?;
854
+ self . prepare_query_request :: < R > ( request, filter, pagination, sorting, fetch_size ) ?;
840
855
841
856
let response = req. build ( ) ?. send ( ) ?;
842
857
let value = resp_handler. handle ( & response) ?;
0 commit comments