@@ -42,68 +42,8 @@ namespace NTable {
4242 }
4343 }
4444
45- bool Do (const TRowId row1, const TRowId row2,
45+ TResult Do (const TCells key1, const TCells key2, const TRowId row1, const TRowId row2,
4646 const TKeyCellDefaults &keyDefaults, ui64 itemsLimit, ui64 bytesLimit) const noexcept override
47- {
48- auto index = Index.TryLoadRaw ();
49- if (!index) {
50- return false ;
51- }
52-
53- auto startRow = row1;
54- auto endRow = row2;
55-
56- // Page that contains row1
57- auto first = index->LookupRow (row1);
58- if (Y_UNLIKELY (!first)) {
59- return true ; // already out of bounds, nothing to precharge
60- }
61-
62- // Page that contains row2
63- auto last = index->LookupRow (row2, first);
64- if (Y_UNLIKELY (last < first)) {
65- last = first;
66- endRow = Min (endRow, index->GetLastRowId (last));
67- }
68-
69- return DoPrecharge (TCells{}, TCells{}, TIter{}, TIter{}, first, last, startRow, endRow, keyDefaults, itemsLimit, bytesLimit);
70- }
71-
72- bool DoReverse (const TRowId row1, const TRowId row2,
73- const TKeyCellDefaults &keyDefaults, ui64 itemsLimit, ui64 bytesLimit) const noexcept override
74- {
75- auto index = Index.TryLoadRaw ();
76- if (!index) {
77- return false ;
78- }
79-
80- auto startRow = row1;
81- auto endRow = row2;
82-
83- // Page that contains row1
84- auto first = index->LookupRow (row1);
85- if (Y_UNLIKELY (!first)) {
86- // Looks like row1 is out of bounds, start from the last row
87- startRow = Min (row1, index->GetEndRowId () - 1 );
88- first = --(*index)->End ();
89- if (Y_UNLIKELY (!first)) {
90- return true ; // empty index?
91- }
92- }
93-
94- // Page that contains row2
95- auto last = index->LookupRow (row2, first);
96- if (Y_UNLIKELY (last > first)) {
97- last = first; // will not go past the first page
98- endRow = Max (endRow, last->GetRowId ());
99- }
100-
101- return DoPrechargeReverse (TCells{}, TCells{}, TIter{}, TIter{}, first, last, startRow, endRow, keyDefaults, itemsLimit, bytesLimit);
102- }
103-
104- TResult Do (const TCells key1, const TCells key2, const TRowId row1,
105- const TRowId row2, const TKeyCellDefaults &keyDefaults, ui64 itemsLimit,
106- ui64 bytesLimit) const noexcept override
10747 {
10848 auto index = Index.TryLoadRaw ();
10949 if (!index) {
@@ -164,14 +104,14 @@ namespace NTable {
164104 }
165105 }
166106
167- bool ready = DoPrecharge (key1, key2, key1Page, key2Page, first, last, startRow, endRow, keyDefaults, itemsLimit, bytesLimit);
107+ bool ready = DoPrecharge (key1, key2, key1Page, key2Page, first, last,
108+ startRow, endRow, keyDefaults, itemsLimit, bytesLimit);
168109
169110 return { ready, overshot };
170111 }
171112
172- TResult DoReverse (const TCells key1, const TCells key2, const TRowId row1,
173- const TRowId row2, const TKeyCellDefaults &keyDefaults, ui64 itemsLimit,
174- ui64 bytesLimit) const noexcept override
113+ TResult DoReverse (const TCells key1, const TCells key2, const TRowId row1, const TRowId row2,
114+ const TKeyCellDefaults &keyDefaults, ui64 itemsLimit, ui64 bytesLimit) const noexcept override
175115 {
176116 auto index = Index.TryLoadRaw ();
177117 if (!index) {
@@ -237,7 +177,8 @@ namespace NTable {
237177 }
238178 }
239179
240- bool ready = DoPrechargeReverse (key1, key2, key1Page, key2Page, first, last, startRow, endRow, keyDefaults, itemsLimit, bytesLimit);
180+ bool ready = DoPrechargeReverse (key1, key2, key1Page, key2Page, first, last,
181+ startRow, endRow, keyDefaults, itemsLimit, bytesLimit);
241182
242183 return { ready, overshot };
243184 }
@@ -254,10 +195,8 @@ namespace NTable {
254195 *
255196 * If @param key1Page specified, @param first should be the same.
256197 */
257- bool DoPrecharge (const TCells key1, const TCells key2,
258- const TIter key1Page, const TIter key2Page,
259- const TIter first, const TIter last,
260- TRowId startRowId, TRowId endRowId,
198+ bool DoPrecharge (const TCells key1, const TCells key2, const TIter key1Page, const TIter key2Page,
199+ const TIter first, const TIter last, TRowId startRowId, TRowId endRowId,
261200 const TKeyCellDefaults &keyDefaults, ui64 itemsLimit, ui64 bytesLimit) const noexcept
262201 {
263202 bool ready = true ;
@@ -352,10 +291,8 @@ namespace NTable {
352291 *
353292 * If @param key1Page specified, @param first should be the same.
354293 */
355- bool DoPrechargeReverse (const TCells key1, const TCells key2,
356- const TIter key1Page, const TIter key2Page,
357- TIter first, TIter last,
358- TRowId startRowId, TRowId endRowId,
294+ bool DoPrechargeReverse (const TCells key1, const TCells key2, const TIter key1Page, const TIter key2Page,
295+ TIter first, TIter last, TRowId startRowId, TRowId endRowId,
359296 const TKeyCellDefaults &keyDefaults, ui64 itemsLimit, ui64 bytesLimit) const noexcept
360297 {
361298 bool ready = true ;
@@ -562,8 +499,8 @@ namespace NTable {
562499 /* *
563500 * Precharges pages that contain row1 to row2 inclusive
564501 */
565- bool DoPrechargeGroup (TGroupState& g , TRowId row1, TRowId row2, ui64& bytes) const noexcept {
566- auto groupIndex = g .GroupIndex .TryLoadRaw ();
502+ bool DoPrechargeGroup (TGroupState& group , TRowId row1, TRowId row2, ui64& bytes) const noexcept {
503+ auto groupIndex = group .GroupIndex .TryLoadRaw ();
567504 if (!groupIndex) {
568505 if (bytes) {
569506 // Note: we can't continue if we have bytes limit
@@ -574,29 +511,29 @@ namespace NTable {
574511
575512 bool ready = true ;
576513
577- if (!g .Index || row1 < g .Index ->GetRowId () || row1 > g .LastRowId ) {
578- g .Index = groupIndex->LookupRow (row1, g .Index );
579- if (Y_UNLIKELY (!g .Index )) {
514+ if (!group .Index || row1 < group .Index ->GetRowId () || row1 > group .LastRowId ) {
515+ group .Index = groupIndex->LookupRow (row1, group .Index );
516+ if (Y_UNLIKELY (!group .Index )) {
580517 // Looks like row1 doesn't even exist
581- g .LastRowId = Max<TRowId>();
518+ group .LastRowId = Max<TRowId>();
582519 return ready;
583520 }
584- g .LastRowId = groupIndex->GetLastRowId (g .Index );
585- auto pageId = g .Index ->GetPageId ();
586- ready &= bool (Env->TryGetPage (Part, pageId, g .GroupId ));
587- bytes += Part->GetPageSize (pageId, g .GroupId );
521+ group .LastRowId = groupIndex->GetLastRowId (group .Index );
522+ auto pageId = group .Index ->GetPageId ();
523+ ready &= bool (Env->TryGetPage (Part, pageId, group .GroupId ));
524+ bytes += Part->GetPageSize (pageId, group .GroupId );
588525 }
589526
590- while (g .LastRowId < row2) {
591- if (!++g .Index ) {
527+ while (group .LastRowId < row2) {
528+ if (!++group .Index ) {
592529 // Looks like row2 doesn't even exist
593- g .LastRowId = Max<TRowId>();
530+ group .LastRowId = Max<TRowId>();
594531 return ready;
595532 }
596- g .LastRowId = groupIndex->GetLastRowId (g .Index );
597- auto pageId = g .Index ->GetPageId ();
598- ready &= bool (Env->TryGetPage (Part, pageId, g .GroupId ));
599- bytes += Part->GetPageSize (pageId, g .GroupId );
533+ group .LastRowId = groupIndex->GetLastRowId (group .Index );
534+ auto pageId = group .Index ->GetPageId ();
535+ ready &= bool (Env->TryGetPage (Part, pageId, group .GroupId ));
536+ bytes += Part->GetPageSize (pageId, group .GroupId );
600537 }
601538
602539 return ready;
@@ -605,8 +542,8 @@ namespace NTable {
605542 /* *
606543 * Precharges pages that contain row1 to row2 inclusive in reverse
607544 */
608- bool DoPrechargeGroupReverse (TGroupState& g , TRowId row1, TRowId row2, ui64& bytes) const noexcept {
609- auto groupIndex = g .GroupIndex .TryLoadRaw ();
545+ bool DoPrechargeGroupReverse (TGroupState& group , TRowId row1, TRowId row2, ui64& bytes) const noexcept {
546+ auto groupIndex = group .GroupIndex .TryLoadRaw ();
610547 if (!groupIndex) {
611548 if (bytes) {
612549 // Note: we can't continue if we have bytes limit
@@ -617,29 +554,29 @@ namespace NTable {
617554
618555 bool ready = true ;
619556
620- if (!g .Index || row1 < g .Index ->GetRowId () || row1 > g .LastRowId ) {
621- g .Index = groupIndex->LookupRow (row1, g .Index );
622- if (Y_UNLIKELY (!g .Index )) {
557+ if (!group .Index || row1 < group .Index ->GetRowId () || row1 > group .LastRowId ) {
558+ group .Index = groupIndex->LookupRow (row1, group .Index );
559+ if (Y_UNLIKELY (!group .Index )) {
623560 // Looks like row1 doesn't even exist
624- g .LastRowId = Max<TRowId>();
561+ group .LastRowId = Max<TRowId>();
625562 return ready;
626563 }
627- g .LastRowId = groupIndex->GetLastRowId (g .Index );
628- auto pageId = g .Index ->GetPageId ();
629- ready &= bool (Env->TryGetPage (Part, pageId, g .GroupId ));
630- bytes += Part->GetPageSize (pageId, g .GroupId );
564+ group .LastRowId = groupIndex->GetLastRowId (group .Index );
565+ auto pageId = group .Index ->GetPageId ();
566+ ready &= bool (Env->TryGetPage (Part, pageId, group .GroupId ));
567+ bytes += Part->GetPageSize (pageId, group .GroupId );
631568 }
632569
633- while (g .Index ->GetRowId () > row2) {
634- if (g .Index .Off () == 0 ) {
570+ while (group .Index ->GetRowId () > row2) {
571+ if (group .Index .Off () == 0 ) {
635572 // This was the last page we could precharge
636573 return ready;
637574 }
638- g .LastRowId = g .Index ->GetRowId () - 1 ;
639- --g .Index ;
640- auto pageId = g .Index ->GetPageId ();
641- ready &= bool (Env->TryGetPage (Part, pageId, g .GroupId ));
642- bytes += Part->GetPageSize (pageId, g .GroupId );
575+ group .LastRowId = group .Index ->GetRowId () - 1 ;
576+ --group .Index ;
577+ auto pageId = group .Index ->GetPageId ();
578+ ready &= bool (Env->TryGetPage (Part, pageId, group .GroupId ));
579+ bytes += Part->GetPageSize (pageId, group .GroupId );
643580 }
644581
645582 return ready;
0 commit comments