@@ -672,18 +672,69 @@ private IdHolder doHstoreRangeIndexQuery(IndexLabel indexLabel,
672672 ConditionQuery query ) {
673673 if (!query .paging ()) {
674674 Set <Id > ids = this .querySortedRangeIndexIds (indexLabel , query );
675- return new FixedIdHolder (query , ids ) {
676- @ Override
677- public boolean keepOrder () {
678- return true ;
679- }
680- };
675+ return this .newSortedRangeIndexBatchHolder (query , ids );
681676 }
682677 return new PagingIdHolder (query , q -> {
683678 return this .querySortedRangeIndexPage (indexLabel , q );
684679 });
685680 }
686681
682+ private BatchIdHolder newSortedRangeIndexBatchHolder (ConditionQuery query ,
683+ Set <Id > ids ) {
684+ List <Id > idList = new ArrayList <>(ids );
685+ return new BatchIdHolder (query , Collections .emptyIterator (), batch -> {
686+ throw new IllegalStateException ("Unexpected sorted index fetcher" );
687+ }) {
688+ private int offset = 0 ;
689+
690+ @ Override
691+ public boolean hasNext () {
692+ return this .offset < idList .size ();
693+ }
694+
695+ @ Override
696+ public IdHolder next () {
697+ if (!this .hasNext ()) {
698+ throw new java .util .NoSuchElementException ();
699+ }
700+ return this ;
701+ }
702+
703+ @ Override
704+ public PageIds fetchNext (String page , long batchSize ) {
705+ E .checkArgument (page == null ,
706+ "Not support page parameter by BatchIdHolder" );
707+ if (!this .hasNext ()) {
708+ return PageIds .EMPTY ;
709+ }
710+
711+ int end ;
712+ if (batchSize == Query .NO_LIMIT ) {
713+ end = idList .size ();
714+ } else {
715+ end = (int ) Math .min ((long ) idList .size (),
716+ this .offset + batchSize );
717+ }
718+ Set <Id > batchIds = InsertionOrderUtil .newSet ();
719+ batchIds .addAll (idList .subList (this .offset , end ));
720+ this .offset = end ;
721+ return new PageIds (batchIds , PageState .EMPTY );
722+ }
723+
724+ @ Override
725+ public Set <Id > all () {
726+ Set <Id > allIds = InsertionOrderUtil .newSet ();
727+ allIds .addAll (idList );
728+ return allIds ;
729+ }
730+
731+ @ Override
732+ public void close () {
733+ this .offset = idList .size ();
734+ }
735+ };
736+ }
737+
687738 private Set <Id > querySortedRangeIndexIds (IndexLabel indexLabel ,
688739 ConditionQuery query ) {
689740 List <HugeIndex > indexes = this .querySortedRangeIndexes (indexLabel ,
0 commit comments