1 21 22 package org.apache.derby.impl.store.access.sort; 23 24 import org.apache.derby.iapi.services.sanity.SanityManager; 25 26 import org.apache.derby.iapi.error.StandardException; 27 import org.apache.derby.iapi.store.access.ScanController; 28 import org.apache.derby.iapi.store.access.conglomerate.TransactionManager; 29 30 35 36 public class SortBufferScan extends SortScan 37 { 38 41 protected SortBuffer sortBuffer; 42 43 46 47 SortBufferScan( 48 MergeSort sort, 49 TransactionManager tran, 50 SortBuffer sortBuffer, 51 boolean hold) 52 { 53 super(sort, tran, hold); 54 55 if (SanityManager.DEBUG) 56 SanityManager.ASSERT(sortBuffer != null); 57 58 this.sortBuffer = sortBuffer; 59 } 60 61 64 65 69 public boolean next() 70 throws StandardException 71 { 72 if (SanityManager.DEBUG) 73 { 74 SanityManager.ASSERT( 75 sortBuffer != null, 76 "next() called on scan after scan was closed."); 77 } 78 79 super.current = sortBuffer.removeFirst(); 80 return (super.current != null); 81 } 82 83 86 public boolean closeForEndTransaction(boolean closeHeldScan) 87 { 88 if (closeHeldScan || !hold) 89 { 90 close(); 91 return(true); 92 } 93 else 94 { 95 return(false); 96 } 97 98 } 99 100 104 public void close() 105 { 106 if (super.sort != null) 107 { 108 sort.doneScanning(this, sortBuffer); 109 sortBuffer = null; 110 } 111 super.close(); 112 } 113 114 } 115 | Popular Tags |