Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

fixed get_kv_table_rows issues #9743

Merged
merged 2 commits into from
Dec 7, 2020
Merged

fixed get_kv_table_rows issues #9743

merged 2 commits into from
Dec 7, 2020

Conversation

kimjh2005
Copy link
Contributor

@kimjh2005 kimjh2005 commented Dec 4, 2020

Change Description

Fixed issues:
-fixed a crash when --reverse and --index_value used at the same time.
-fixed the behavior or end range to be inclusive as in other get_table apis.
Before upper was exclusive [lower, upper), now inclusive [lower, upper]
-fixed a incorrect end of range problem when iterator doesn't have an exact match

Change Type

Select ONE

  • Documentation
  • Stability bug fix
  • Other
  • Other - special case

Consensus Changes

  • Consensus Changes

API Changes

  • API Changes

Range is now inclusive on both ends like in get_table_rows.
--lower value1 --upper value2 : Return result from value1 to value2 (now value2 is included)
ex) data set:1, 2, 3, 4, 5
--lower 1 --upper 3 will return [1, 2, 3] instead of [1, 2]

-r -lower value1 --upper value2 : In reverse mode, return result from value2 to value1 (value1 is included)
ex) data set:1, 2, 3, 4, 5
-r --lower 1 --upper 3 will return [3, 2, 1] instead of [3, 2]

Documentation Additions

  • Documentation Additions

@@ -2219,6 +2220,7 @@ read_only::get_table_rows_result read_only::get_kv_table_rows_context( const rea
const string &index_value = *p.index_value;
p.lower_bound = p.index_value;
unbounded = true;
p.reverse = false;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This fixes the crash when --reverse is enabled with --index_value.

Copy link
Contributor

Choose a reason for hiding this comment

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

I like your review comment explaining how it fixes a particular problem.

if( p.reverse && !point_query && !exact_match ) {
status_ub = ub_itr->kv_it_prev(&ub_key_size, &ub_value_size);
if( !point_query && !exact_match ) {
status_ub = ub_itr->kv_it_prev(&ub_key_size, &ub_value_size);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This fixes the incorrect end iterator resulting empty set.

@@ -2326,7 +2328,7 @@ read_only::get_table_rows_result read_only::get_kv_table_rows_context( const rea
}

unsigned int count = 0;
for( count = 0; cur_time <= end_time && count < p.limit && cmp < 0; cur_time = fc::time_point::now() ) {
for( count = 0; cur_time <= end_time && count < p.limit && cmp <= 0; cur_time = fc::time_point::now() ) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

cmp<=0 for inclusive range

@@ -2219,6 +2220,7 @@ read_only::get_table_rows_result read_only::get_kv_table_rows_context( const rea
const string &index_value = *p.index_value;
p.lower_bound = p.index_value;
unbounded = true;
p.reverse = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

I like your review comment explaining how it fixes a particular problem.

@kimjh2005 kimjh2005 merged commit 64ff4ef into develop Dec 7, 2020
@heifner heifner deleted the fix_get_kv_table_518 branch June 10, 2021 16:56
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants