@@ -42,68 +42,8 @@ namespace NTable {
42
42
}
43
43
}
44
44
45
- bool Do (const TRowId row1, const TRowId row2,
45
+ TResult Do (const TCells key1, const TCells key2, const TRowId row1, const TRowId row2,
46
46
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
107
47
{
108
48
auto index = Index.TryLoadRaw ();
109
49
if (!index ) {
@@ -164,14 +104,14 @@ namespace NTable {
164
104
}
165
105
}
166
106
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);
168
109
169
110
return { ready, overshot };
170
111
}
171
112
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
175
115
{
176
116
auto index = Index.TryLoadRaw ();
177
117
if (!index ) {
@@ -237,7 +177,8 @@ namespace NTable {
237
177
}
238
178
}
239
179
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);
241
182
242
183
return { ready, overshot };
243
184
}
@@ -254,10 +195,8 @@ namespace NTable {
254
195
*
255
196
* If @param key1Page specified, @param first should be the same.
256
197
*/
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,
261
200
const TKeyCellDefaults &keyDefaults, ui64 itemsLimit, ui64 bytesLimit) const noexcept
262
201
{
263
202
bool ready = true ;
@@ -352,10 +291,8 @@ namespace NTable {
352
291
*
353
292
* If @param key1Page specified, @param first should be the same.
354
293
*/
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,
359
296
const TKeyCellDefaults &keyDefaults, ui64 itemsLimit, ui64 bytesLimit) const noexcept
360
297
{
361
298
bool ready = true ;
@@ -562,8 +499,8 @@ namespace NTable {
562
499
/* *
563
500
* Precharges pages that contain row1 to row2 inclusive
564
501
*/
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 ();
567
504
if (!groupIndex) {
568
505
if (bytes) {
569
506
// Note: we can't continue if we have bytes limit
@@ -574,29 +511,29 @@ namespace NTable {
574
511
575
512
bool ready = true ;
576
513
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 )) {
580
517
// Looks like row1 doesn't even exist
581
- g .LastRowId = Max<TRowId>();
518
+ group .LastRowId = Max<TRowId>();
582
519
return ready;
583
520
}
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 );
588
525
}
589
526
590
- while (g .LastRowId < row2) {
591
- if (!++g .Index ) {
527
+ while (group .LastRowId < row2) {
528
+ if (!++group .Index ) {
592
529
// Looks like row2 doesn't even exist
593
- g .LastRowId = Max<TRowId>();
530
+ group .LastRowId = Max<TRowId>();
594
531
return ready;
595
532
}
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 );
600
537
}
601
538
602
539
return ready;
@@ -605,8 +542,8 @@ namespace NTable {
605
542
/* *
606
543
* Precharges pages that contain row1 to row2 inclusive in reverse
607
544
*/
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 ();
610
547
if (!groupIndex) {
611
548
if (bytes) {
612
549
// Note: we can't continue if we have bytes limit
@@ -617,29 +554,29 @@ namespace NTable {
617
554
618
555
bool ready = true ;
619
556
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 )) {
623
560
// Looks like row1 doesn't even exist
624
- g .LastRowId = Max<TRowId>();
561
+ group .LastRowId = Max<TRowId>();
625
562
return ready;
626
563
}
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 );
631
568
}
632
569
633
- while (g .Index ->GetRowId () > row2) {
634
- if (g .Index .Off () == 0 ) {
570
+ while (group .Index ->GetRowId () > row2) {
571
+ if (group .Index .Off () == 0 ) {
635
572
// This was the last page we could precharge
636
573
return ready;
637
574
}
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 );
643
580
}
644
581
645
582
return ready;
0 commit comments