@@ -162,25 +162,52 @@ class TScanActorBase : public TActorBootstrapped<TDerived> {
162162 SendBatch (std::move (batch));
163163 }
164164
165- std::optional<TCell> GetCellFrom (size_t index) const {
166- return GetCell (TableRange.From .GetCells (), index);
167- }
168-
169- std::optional<TCell> GetCellTo (size_t index) const {
170- return GetCell (TableRange.To .GetCells (), index);
171- }
172-
173- bool OneCellStringKeyIsInTableRange (const TString value) const {
174- if (auto pathFrom = GetCellFrom (0 ); pathFrom) {
175- if (int cmp = pathFrom->AsBuf ().compare (value); cmp > 0 || cmp == 0 && !TableRange.FromInclusive ) {
165+ bool StringKeyIsInTableRange (const TVector<TString>& key) const {
166+ {
167+ bool equalPrefixes = true ;
168+ for (size_t index : xrange (Min (TableRange.From .GetCells ().size (), key.size ()))) {
169+ if (auto cellFrom = TableRange.From .GetCells ()[index]; !cellFrom.IsNull ()) {
170+ int cmp = cellFrom.AsBuf ().compare (key[index]);
171+ if (cmp < 0 ) {
172+ equalPrefixes = false ;
173+ break ;
174+ }
175+ if (cmp > 0 ) {
176+ return false ;
177+ }
178+ // cmp == 0, prefixes are equal, go further
179+ } else {
180+ equalPrefixes = false ;
181+ break ;
182+ }
183+ }
184+ if (equalPrefixes && !TableRange.FromInclusive ) {
176185 return false ;
177186 }
178187 }
179- if (auto pathTo = GetCellTo (0 ); pathTo) {
180- if (int cmp = pathTo->AsBuf ().compare (value); cmp < 0 || cmp == 0 && !TableRange.ToInclusive ) {
188+
189+ if (TableRange.To .GetCells ().size ()) {
190+ bool equalPrefixes = true ;
191+ for (size_t index : xrange (Min (TableRange.To .GetCells ().size (), key.size ()))) {
192+ if (auto cellTo = TableRange.To .GetCells ()[index]; !cellTo.IsNull ()) {
193+ int cmp = cellTo.AsBuf ().compare (key[index]);
194+ if (cmp > 0 ) {
195+ equalPrefixes = false ;
196+ break ;
197+ }
198+ if (cmp < 0 ) {
199+ return false ;
200+ }
201+ // cmp == 0, prefixes are equal, go further
202+ } else {
203+ break ;
204+ }
205+ }
206+ if (equalPrefixes && !TableRange.ToInclusive ) {
181207 return false ;
182208 }
183209 }
210+
184211 return true ;
185212 }
186213
@@ -331,13 +358,6 @@ class TScanActorBase : public TActorBootstrapped<TDerived> {
331358 }
332359 }
333360
334- std::optional<TCell> GetCell (TConstArrayRef<TCell> cells, size_t index) const {
335- if (index < cells.size () && !cells[index].IsNull ()) {
336- return cells[index];
337- }
338- return {};
339- }
340-
341361protected:
342362 static constexpr TDuration Timeout = TDuration::Seconds(60 );
343363
0 commit comments