This is an automated email from the ASF dual-hosted git repository.
alexey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
The following commit(s) were added to refs/heads/master by this push:
new ed5d5a11e KUDU-2671 update
Add{ExclusiveUpper,Lower}BoundPartitionKeyRaw
ed5d5a11e is described below
commit ed5d5a11e54211c46560e3136bece6532e6d3b72
Author: Alexey Serbin <[email protected]>
AuthorDate: Mon Jun 20 12:00:17 2022 -0700
KUDU-2671 update Add{ExclusiveUpper,Lower}BoundPartitionKeyRaw
Since we don't allow for variable number of hash dimensions in
range-specific hash schemas for a table, this patch updates the code
in KuduScanner::AddExclusiveUpperBoundPartitionKeyRaw() and
KuduScanner::AddLowerBoundPartitionKeyRaw() to enable using them
for tables having custom hash schemas per range.
This is a follow-up to 6998193e69eeda497f912d1d806470c95b591ad4.
Change-Id: I1323e494733c9c082dedc12d941811f4175dbeab
Reviewed-on: http://gerrit.cloudera.org:8080/18640
Reviewed-by: Mahesh Reddy <[email protected]>
Tested-by: Kudu Jenkins
Reviewed-by: Abhishek Chennaka <[email protected]>
Reviewed-by: Attila Bukor <[email protected]>
---
src/kudu/client/client.cc | 41 ++++++++++++++++++++++-------------------
1 file changed, 22 insertions(+), 19 deletions(-)
diff --git a/src/kudu/client/client.cc b/src/kudu/client/client.cc
index 7d11315f4..1e9c75a50 100644
--- a/src/kudu/client/client.cc
+++ b/src/kudu/client/client.cc
@@ -1783,30 +1783,33 @@ Status KuduScanner::AddExclusiveUpperBoundRaw(const
Slice& key) {
}
Status KuduScanner::AddLowerBoundPartitionKeyRaw(const Slice& partition_key) {
- // TODO(aserbin): use move semantics to pass PartitionKey arguments
- if (const auto& table = GetKuduTable();
- table->data_->partition_schema_.HasCustomHashSchemas()) {
- return Status::InvalidArgument(Substitute(
- "$0: cannot use AddLowerBoundPartitionKeyRaw() because "
- "the table has custom per-range hash schemas", table->name()));
- }
+ // The number of hash dimensions in all hash schemas of a table is an
+ // invariant and checked throughout the code. With that, the table-wide hash
+ // schema is used as a proxy to find the number of hash dimensions to
separate
+ // the hash-related prefix from the rest of the encoded partition key in the
+ // code below.
+ //
+ // TODO(KUDU-2671) update this code if allowing for different number of
+ // dimensions in range-specific hash schemas
const auto& hash_schema = GetKuduTable()->partition_schema().hash_schema();
- auto pkey = Partition::StringToPartitionKey(partition_key.ToString(),
- hash_schema.size());
- return data_->mutable_configuration()->AddLowerBoundPartitionKeyRaw(pkey);
+ return data_->mutable_configuration()->AddLowerBoundPartitionKeyRaw(
+ Partition::StringToPartitionKey(partition_key.ToString(),
+ hash_schema.size()));
}
Status KuduScanner::AddExclusiveUpperBoundPartitionKeyRaw(const Slice&
partition_key) {
- if (const auto& table = GetKuduTable();
- table->data_->partition_schema_.HasCustomHashSchemas()) {
- return Status::InvalidArgument(Substitute(
- "$0: cannot use AddExclusiveUpperBoundPartitionKeyRaw() because "
- "the table has custom per-range hash schemas", table->name()));
- }
+ // The number of hash dimensions in all hash schemas of a table is an
+ // invariant and checked throughout the code. With that, the table-wide hash
+ // schema is used as a proxy to find the number of hash dimensions to
separate
+ // the hash-related prefix from the rest of the encoded partition key in the
+ // code below.
+ //
+ // TODO(KUDU-2671) update this code if allowing for different number of
+ // dimensions in range-specific hash schemas
const auto& hash_schema = GetKuduTable()->partition_schema().hash_schema();
- auto pkey = Partition::StringToPartitionKey(partition_key.ToString(),
- hash_schema.size());
- return data_->mutable_configuration()->AddUpperBoundPartitionKeyRaw(pkey);
+ return data_->mutable_configuration()->AddUpperBoundPartitionKeyRaw(
+ Partition::StringToPartitionKey(partition_key.ToString(),
+ hash_schema.size()));
}
Status KuduScanner::SetCacheBlocks(bool cache_blocks) {