Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

Introduce queries pagination #1927

Merged
merged 16 commits into from
Dec 12, 2018
Merged

Introduce queries pagination #1927

merged 16 commits into from
Dec 12, 2018

Conversation

nickaleks
Copy link
Contributor

Description of the Change

This Pull Request adds pagination to several queries. This allows to work on large data sets without returning all the data in a single request

Benefits

Better interface for queries

Possible Drawbacks

Nonne

kamilsa and others added 12 commits November 30, 2018 11:52
* Add transactions page response

Signed-off-by: kamilsa <kamilsa16@gmail.com>
* Add transactions page response

Signed-off-by: kamilsa <kamilsa16@gmail.com>
* tx pagination in proto
* shared_model::interface::TxPaginationMeta class
* shared_model::proto::TxPaginationMeta class
* make PrettyStringBuilder constants static
* fix validators module tests
* added pagination_meta to queries' toString()

Signed-off-by: Mikhail Boldyrev <miboldyrev@gmail.com>
* FieldValidator::validateTxPaginationMeta
* validation::TxPaginationMetaValidator
* updated the paged query building

Signed-off-by: Mikhail Boldyrev <miboldyrev@gmail.com>
merged commits add:
* Pimpl for QueryResponse
* ITF: PortGuard

Signed-off-by: Mikhail Boldyrev <miboldyrev@gmail.com>
* removed TxPaginationMetaValidator
* constref first_hash

Signed-off-by: Mikhail Boldyrev <miboldyrev@gmail.com>
Signed-off-by: Nikita Alekseev <n.alekseev2104@gmail.com>
Signed-off-by: Nikita Alekseev <n.alekseev2104@gmail.com>
…or_test (#1915)

* postgres_query_executor_test: common tx pagination tests

Signed-off-by: Mikhail Boldyrev <miboldyrev@gmail.com>
* Add documentation for queries pagination

Signed-off-by: kamilsa <kamilsa16@gmail.com>
…rledger/iroha into trunk/tx-queries-pagination

Signed-off-by: Nikita Alekseev <n.alekseev2104@gmail.com>
% first_hash->hex())
.str();
// TODO: IR-82 nickaleks 7.12.18
// add status code for invalid pagination
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove TODO please

Copy link
Contributor

@lebdron lebdron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, the issue with bindings can be ignored, but a warning note will definitely be useful.

#ifndef IROHA_SHARED_MODEL_PROTO_TRANSACTION_PAGE_RESPONSE_HPP
#define IROHA_SHARED_MODEL_PROTO_TRANSACTION_PAGE_RESPONSE_HPP

#include "backend/protobuf/common_objects/trivial_proto.hpp"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#include "interfaces/query_responses/transactions_page_response.hpp"

#include "backend/protobuf/common_objects/trivial_proto.hpp"
#include "backend/protobuf/transaction.hpp"
#include "interfaces/common_objects/types.hpp"
#include "qry_responses.pb.h"


namespace shared_model {
namespace proto {
class TransactionsPageResponse final
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

File has to be renamed to proto_transactions_page_response.hpp

@@ -124,6 +124,34 @@ namespace shared_model {
transactions,
const crypto::Hash &query_hash) const = 0;

/**
* Create response for transactions pagination query
* @param transactions to be inserted into the response
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really necessary to list the parameters with copied "x to be inserted into the response"? Please add some description to fields, or merge them into something like "Create response for transactions pagination query with given transactions, next_tx_hash..."
Same for method below.

.append("page_size", std::to_string(pageSize()));
auto first_tx_hash = firstTxHash();
if (first_tx_hash) {
pretty_builder = std::move(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

String builder is mutable, so there is no need to reassign it. append should be enough.

: public ModelPrimitive<TransactionsPageResponse> {
public:
/**
* @return Attached transactions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this method require a doc while other methods do not?

: CopyableProto(std::forward<QueryResponseType>(queryResponse)),
transactionPageResponse_{proto_->transactions_page_response()},
transactions_{[this] {
return std::vector<proto::Transaction>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like lambda can be removed.

return ModelQueryBuilder(builder_.getAccountTransactions(account_id));
const interface::types::AccountIdType &account_id,
interface::types::TransactionsNumberType page_size,
const boost::optional<interface::types::HashType> &first_hash) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is highly likely that optional is not wrapped with SWIG in an expected way. Please check java bindings and comment if it was successful or not.

}

bool TransactionsPageResponse::operator==(const ModelType &rhs) const {
return transactions() == rhs.transactions();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is it not required to also compare nextTxHash and allTransactionsSize?


// old compilers fail to deduce that a variant contains reference
template <typename T, typename Variant>
ConstRef<T> getRef(Variant &&v) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method is unused, please remove.

.build());

template <typename T>
using ConstRef = const T &;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same with unused, please remove.

Signed-off-by: Nikita Alekseev <n.alekseev2104@gmail.com>
Signed-off-by: Nikita Alekseev <n.alekseev2104@gmail.com>
@nickaleks nickaleks merged commit 265ab6f into dev Dec 12, 2018
@lebdron lebdron deleted the trunk/tx-queries-pagination branch December 18, 2018 05:54
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants