@@ -635,8 +635,17 @@ ObHTableRowIterator::ObHTableRowIterator(const ObTableQuery &query)
635635 cell_count_(0 ),
636636 count_per_row_(0 ),
637637 has_more_cells_(true ),
638- is_first_result_(true )
639- {}
638+ is_first_result_(true ),
639+ allow_partial_results_(false ),
640+ is_cache_block_(true ),
641+ scanner_context_(NULL )
642+ {
643+ if (query.get_ob_params ().ob_params_ !=nullptr ) {
644+ ObHBaseParams* hbase_params =dynamic_cast <ObHBaseParams*> (query.get_ob_params ().ob_params_ );
645+ allow_partial_results_ = hbase_params->allow_partial_results_ ;
646+ is_cache_block_ = hbase_params->is_cache_block_ ;
647+ }
648+ }
640649
641650ObHTableRowIterator::~ObHTableRowIterator ()
642651{
@@ -772,6 +781,10 @@ int ObHTableRowIterator::get_next_result(ObTableQueryResult *&out_result)
772781 count_per_row_ =0 ;
773782 ret = matcher_->set_to_new_row (curr_cell_);
774783 }
784+ if (OB_SUCC (ret) && allow_partial_results_) {
785+ scanner_context_->limits_ .set_size_scope (LimitScope::Scope::BETWEEN_CELLS);
786+ scanner_context_->limits_ .set_time_scope (LimitScope::Scope::BETWEEN_CELLS);
787+ }
775788bool loop =true ;
776789if (OB_SUCC (ret)) {
777790if (NULL == matcher_->get_curr_row ()) {
@@ -865,6 +878,8 @@ int ObHTableRowIterator::get_next_result(ObTableQueryResult *&out_result)
865878if (OB_FAIL (out_result->add_row (*(curr_cell_.get_ob_row ())))) {
866879LOG_WARN (" failed to add row to result" ,K (ret));
867880 }else {
881+ scanner_context_->increment_batch_progress (1 );
882+ scanner_context_->increment_size_progress (curr_cell_.get_ob_row ()->get_serialize_size ());
868883 ++cell_count_;
869884LOG_DEBUG (" [yzfdebug] add cell" ,K_ (cell_count),K_ (curr_cell),
870885K_ (count_per_row),K_ (offset_per_row_per_cf));
@@ -909,7 +924,7 @@ int ObHTableRowIterator::get_next_result(ObTableQueryResult *&out_result)
909924 }
910925 }
911926if (OB_SUCC (ret)) {
912- if (reach_batch_limit () || reach_size_limit ( )) {
927+ if (scanner_context_-> check_any_limit (LimitScope::Scope::BETWEEN_CELLS )) {
913928 loop =false ;
914929 }
915930 }else if (OB_ITER_END == ret) {
@@ -1040,11 +1055,23 @@ ObHTableFilterOperator::ObHTableFilterOperator(const ObTableQuery &query,
10401055 row_iterator_(query),
10411056 one_result_(&one_result),
10421057 hfilter_(NULL ),
1043- batch_size_ (query.get_batch()),
1058+ caching_ (query.get_batch()),
10441059 max_result_size_(std::min(query.get_max_result_size(),
10451060 static_cast<int64_t>(ObTableQueryResult::get_max_packet_buffer_length() - 1024))),
1046- is_first_result_(true )
1061+ is_first_result_(true ),
1062+ check_existence_only_(false ),
1063+ scanner_context_()
10471064{
1065+ if (query.get_ob_params ().ob_params_ !=nullptr ) {
1066+ ObHBaseParams* hbase_params =dynamic_cast <ObHBaseParams*> (query.get_ob_params ().ob_params_ );
1067+ scanner_context_.limits_ .set_fields (hbase_params->batch_ , max_result_size_, hbase_params->call_timeout_ ,LimitScope (LimitScope::Scope::BETWEEN_ROWS));
1068+ check_existence_only_ = hbase_params->check_existence_only_ ;
1069+ }
1070+ row_iterator_.set_scanner_context (&scanner_context_);
1071+ }
1072+
1073+ bool ObHTableFilterOperator::reach_caching_limit (int num_of_row) {
1074+ return (caching_ >=0 && num_of_row < caching_) || caching_ <0 ;
10481075}
10491076
10501077// @param one_result for one batch
@@ -1059,8 +1086,12 @@ int ObHTableFilterOperator::get_next_result(ObTableQueryResult *&next_result)
10591086// ObObj first_entity_cells[4];
10601087// first_entity.cells_ = first_entity_cells;
10611088// first_entity.count_ = 4;
1089+ int num_of_row =0 ;
1090+ scanner_context_.progress_ .reset ();
10621091while (OB_SUCC (ret) && row_iterator_.has_more_result ()
1063- &&OB_SUCC (row_iterator_.get_next_result (htable_row))) {
1092+ &&reach_caching_limit (num_of_row)
1093+ &&OB_SUCC (row_iterator_.get_next_result (htable_row)
1094+ )) {
10641095LOG_DEBUG (" [yzfdebug] got one row" ," cells_count" , htable_row->get_row_count ());
10651096bool is_empty_row = (htable_row->get_row_count () ==0 );
10661097if (is_empty_row) {
@@ -1107,14 +1138,21 @@ int ObHTableFilterOperator::get_next_result(ObTableQueryResult *&next_result)
11071138 }
11081139/* @todo check batch limit and size limit*/
11091140// We have got one hbase row, store it to this batch
1141+ if (check_existence_only_) {
1142+ one_result_->check_exists_only (*htable_row);
1143+ htable_row->reset ();
1144+ break ;
1145+ }
11101146if (OB_FAIL (one_result_->add_all_row (*htable_row))) {
11111147LOG_WARN (" failed to add cells to row" ,K (ret));
11121148 }
11131149if (NULL != hfilter_) {
11141150 hfilter_->reset ();
11151151 }
11161152if (OB_SUCC (ret)) {
1117- if (one_result_->reach_batch_size_or_result_size (batch_size_, max_result_size_)) {
1153+ num_of_row +=1 ;
1154+ scanner_context_.increment_size_progress (htable_row->get_serialize_size_ ());
1155+ if (scanner_context_.check_any_limit (LimitScope::Scope::BETWEEN_ROWS)) {
11181156break ;
11191157 }
11201158 }
@@ -1152,3 +1190,47 @@ int ObHTableFilterOperator::parse_filter_string(common::ObIAllocator* allocator)
11521190 }
11531191return ret;
11541192}
1193+
1194+ ScannerContext::ScannerContext () {
1195+ limits_.set_fields (-1 , -1 , -1 , LimitScope::Scope::BETWEEN_ROWS);
1196+ progress_.set_fields (0 ,0 ,0 , LimitScope::Scope::BETWEEN_ROWS);
1197+ }
1198+
1199+ ScannerContext::ScannerContext (int32_t batch,int64_t size,int64_t time, LimitScope limit_scope) {
1200+ limits_.set_fields (batch, size, time, limit_scope);
1201+ }
1202+
1203+ void ScannerContext::increment_batch_progress (int32_t batch) {
1204+ int32_t current_batch = progress_.get_batch ();
1205+ progress_.set_batch (current_batch + batch);
1206+ }
1207+
1208+ void ScannerContext::increment_size_progress (int64_t size) {
1209+ int64_t current_size = progress_.get_size ();
1210+ progress_.set_size (current_size + size);
1211+ }
1212+
1213+ bool ScannerContext::check_batch_limit (LimitScope checker_scope) {
1214+ if (limits_.can_enforce_batch_from_scope (checker_scope) && limits_.get_batch () >0 ) {
1215+ return progress_.get_batch () >= limits_.get_batch ();
1216+ }
1217+ return false ;
1218+ }
1219+
1220+ bool ScannerContext::check_size_limit (LimitScope checker_scope) {
1221+ if (limits_.can_enforce_size_from_scope (checker_scope) && limits_.get_size () >0 ){
1222+ return progress_.get_size () >= limits_.get_size ();
1223+ }
1224+ return false ;
1225+ }
1226+
1227+ bool ScannerContext::check_time_limit (LimitScope checker_scope) {
1228+ if (limits_.can_enforce_time_from_scope (checker_scope) && limits_.get_time () >0 ) {
1229+ return progress_.get_time () >= limits_.get_time ();
1230+ }
1231+ return false ;
1232+ }
1233+
1234+ bool ScannerContext::check_any_limit (LimitScope checker_scope) {
1235+ return check_batch_limit (checker_scope) ||check_size_limit (checker_scope) ||check_time_limit (checker_scope);
1236+ }