@@ -909,7 +909,9 @@ private boolean hasNextOverlappedPage() throws IOException {
909909
910910 TsBlockBuilder builder = new TsBlockBuilder (getTsDataTypeList ());
911911 long currentPageEndPointTime =
912- Math .max (mergeReader .getCurrentReadStopTime (), initialEndPointTime );
912+ orderUtils .getAscending ()
913+ ? Math .max (mergeReader .getCurrentReadStopTime (), initialEndPointTime )
914+ : Math .min (mergeReader .getCurrentReadStopTime (), initialEndPointTime );
913915 while (mergeReader .hasNextTimeValuePair ()) {
914916
915917 /*
@@ -1064,20 +1066,28 @@ private long calculateInitialEndPointTime(long currentReadStopTime) {
10641066 && orderUtils .isOverlapped (currentReadStopTime , firstPageReader .getStatistics ())) {
10651067 if (orderUtils .getAscending ()) {
10661068 currentReadStopTime =
1067- Math .max (currentReadStopTime , firstPageReader .getStatistics ().getEndTime ());
1069+ Math .max (
1070+ currentReadStopTime ,
1071+ orderUtils .getOverlapCheckTime (firstPageReader .getStatistics ()));
10681072 } else {
10691073 currentReadStopTime =
1070- Math .min (currentReadStopTime , firstPageReader .getStatistics ().getStartTime ());
1074+ Math .min (
1075+ currentReadStopTime ,
1076+ orderUtils .getOverlapCheckTime (firstPageReader .getStatistics ()));
10711077 }
10721078 }
10731079 for (IVersionPageReader unSeqPageReader : unSeqPageReaders ) {
10741080 if (orderUtils .isOverlapped (currentReadStopTime , unSeqPageReader .getStatistics ())) {
10751081 if (orderUtils .getAscending ()) {
10761082 currentReadStopTime =
1077- Math .max (currentReadStopTime , unSeqPageReader .getStatistics ().getEndTime ());
1083+ Math .max (
1084+ currentReadStopTime ,
1085+ orderUtils .getOverlapCheckTime (unSeqPageReader .getStatistics ()));
10781086 } else {
10791087 currentReadStopTime =
1080- Math .min (currentReadStopTime , unSeqPageReader .getStatistics ().getStartTime ());
1088+ Math .min (
1089+ currentReadStopTime ,
1090+ orderUtils .getOverlapCheckTime (unSeqPageReader .getStatistics ()));
10811091 }
10821092 } else {
10831093 break ;
0 commit comments