32
32
#include " GeoIndex/Covering.h"
33
33
#include " GeoIndex/Near.h"
34
34
#include " Logger/Logger.h"
35
+ #include " Logger/LogMacros.h"
35
36
#include " RocksDBEngine/RocksDBColumnFamilyManager.h"
36
37
#include " RocksDBEngine/RocksDBCommon.h"
37
38
#include " RocksDBEngine/RocksDBEngine.h"
@@ -365,7 +366,7 @@ class RDBNearIterator final : public IndexIterator {
365
366
if (!_iter->Valid ()) { // no more valid keys after this
366
367
break ;
367
368
} else if (cmp->Compare (_iter->key (), bds.end ()) > 0 ) {
368
- continue ; // beyond range already
369
+ continue ; // beyond the range already
369
370
} else if (cmp->Compare (bds.start (), _iter->key ()) <= 0 ) {
370
371
seek = false ; // already in range: min <= key <= max
371
372
TRI_ASSERT (cmp->Compare (_iter->key (), bds.end ()) <= 0 );
@@ -560,7 +561,7 @@ class RDBCoveringIterator final : public IndexIterator {
560
561
void performScan () {
561
562
rocksdb::Comparator const * cmp = _index->comparator ();
562
563
// list of sorted intervals to scan
563
- if (_gotIntervals) {
564
+ if (! _gotIntervals) {
564
565
_scan = _covering.intervals ();
565
566
_gotIntervals = true ;
566
567
_scanningInterval = 0 ;
@@ -577,9 +578,22 @@ class RDBCoveringIterator final : public IndexIterator {
577
578
if (_scanningInterval > 0 ) {
578
579
TRI_ASSERT (_scan[_scanningInterval - 1 ].range_max < it.range_min );
579
580
if (!_iter->Valid ()) { // no more valid keys after this
581
+ // Here is why we actually want to give up here:
582
+ // Intervals come from cells, two cells either do not intersect,
583
+ // or one is contained in the other, the same holds for the intervals.
584
+ // The iterator has an implicit upper bound on the column family, if
585
+ // we ever run past this for one interval I, then this means that
586
+ // there is nothing of interest in the index past the end of the
587
+ // interval I, and we have found everything we need in I.
588
+ // However, any later interval J will have a beginning which is
589
+ // greater or equal to the beginning of I, therefore nothing new
590
+ // can be found from interval J. Therefore:
591
+ _scanningInterval = _scan.size ();
592
+ // Besides, if we would not stop here we would have an endless loop.
580
593
break ;
581
594
} else if (cmp->Compare (_iter->key (), bds.end ()) > 0 ) {
582
- continue ; // beyond range already
595
+ ++_scanningInterval; // Move to the next interval, since we are
596
+ continue ; // beyond range already
583
597
} else if (cmp->Compare (bds.start (), _iter->key ()) <= 0 ) {
584
598
seek = false ; // already in range: min <= key <= max
585
599
TRI_ASSERT (cmp->Compare (_iter->key (), bds.end ()) <= 0 );
@@ -762,9 +776,10 @@ std::unique_ptr<IndexIterator> RocksDBGeoIndex::iteratorForCondition(
762
776
if (!params.sorted &&
763
777
(params.filterType == geo::FilterType::CONTAINS ||
764
778
params.filterType == geo::FilterType::INTERSECTS) &&
765
- (params.minDistanceRad () < geo::kRadEps &&
766
- params.maxDistanceRad () >
767
- geo::kMaxRadiansBetweenPoints - geo::kRadEps )) {
779
+ !params.distanceRestricted ) {
780
+ LOG_TOPIC (" 54612" , DEBUG, Logger::AQL)
781
+ << " Using RDBCoveringIterator for geo index query: "
782
+ << params.toString ();
768
783
return std::make_unique<RDBCoveringIterator>(monitor, &_collection, trx,
769
784
this , std::move (params));
770
785
}
@@ -794,6 +809,9 @@ std::unique_ptr<IndexIterator> RocksDBGeoIndex::iteratorForCondition(
794
809
params.cover .bestIndexedLevel = _coverParams.bestIndexedLevel ;
795
810
}
796
811
812
+ LOG_TOPIC (" 54613" , DEBUG, Logger::AQL)
813
+ << " Using RDBNearIterator for geo index query: " << params.toString ();
814
+
797
815
if (params.ascending ) {
798
816
return std::make_unique<RDBNearIterator<geo_index::DocumentsAscending>>(
799
817
monitor, &_collection, trx, this , std::move (params));
0 commit comments