/** * Insert rows while we keep getting duplicates from the merge run whose scan is in the open scan * array entry indexed by scanindex. */ void mergeARow(int scanindex) throws StandardException { if (SanityManager.DEBUG) { // Unless there's a bug, the scan index will refer // to an open scan. That's because we never put // a scan index for a closed scan into the sort // buffer (via setNextAux). SanityManager.ASSERT(openScans[scanindex] != null); } DataValueDescriptor[] row; // Read rows from the merge run and stuff them into the // sort buffer for as long as we encounter duplicates. do { row = sortObserver.getArrayClone(); // Fetch the row from the merge run. if (!openScans[scanindex].fetchNext(row)) { // If we're out of rows in the merge run, close the scan. openScans[scanindex].close(); openScans[scanindex] = null; return; } // Save the index of this merge run with // the row we're putting in the sort buffer. sortBuffer.setNextAux(scanindex); } while (sortBuffer.insert(row) == SortBuffer.INSERT_DUPLICATE); }