mavibot/src/main/java/org/apache/directory/mavibot/btree/memory/BulkDataSorter.java [184:271]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                    if ( available == null )
                    {
                        available = heads[i];
                        candidatePos = i;
                    }
                    else
                    {
                        if ( ( available != null ) && ( heads[i] != null ) )
                        {
                            int comp = tupleComparator.compare( heads[i], available );
                            if ( comp <= 0 )
                            {
                                available = heads[i];
                                candidatePos = i;
                            }
                        }
                    }
                }

                heads[candidatePos] = null;

                if ( available == null )
                {
                    for ( int i = 0; i < streams.length; i++ )
                    {
                        if ( heads[i] != null )
                        {
                            available = heads[i];
                            heads[i] = readerWriter.readUnsortedTuple( streams[i] );
                            break;
                        }
                    }
                }

                if ( available != null )
                {
                    candidate = available;
                    return true;
                }

                // finally close the streams
                for ( DataInputStream in : streams )
                {
                    try
                    {
                        in.close();
                    }
                    catch ( Exception e )
                    {
                        e.printStackTrace();
                    }
                }

                closed = true;

                return false;
            }


            @Override
            public Tuple<K, V> next()
            {
                if ( candidate == null )
                {
                    if ( !closed )
                    {
                        hasNext();
                    }
                }

                if ( candidate == null )
                {
                    throw new NoSuchElementException( "No tuples found" );
                }

                return candidate;
            }


            @Override
            public void remove()
            {
                throw new UnsupportedOperationException( "Not supported" );
            }

        };

        return itr;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



mavibot/src/main/java/org/apache/directory/mavibot/btree/persisted/BulkDataSorter.java [184:271]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
                    if ( available == null )
                    {
                        available = heads[i];
                        candidatePos = i;
                    }
                    else
                    {
                        if ( ( available != null ) && ( heads[i] != null ) )
                        {
                            int comp = tupleComparator.compare( heads[i], available );
                            if ( comp <= 0 )
                            {
                                available = heads[i];
                                candidatePos = i;
                            }
                        }
                    }
                }

                heads[candidatePos] = null;

                if ( available == null )
                {
                    for ( int i = 0; i < streams.length; i++ )
                    {
                        if ( heads[i] != null )
                        {
                            available = heads[i];
                            heads[i] = readerWriter.readUnsortedTuple( streams[i] );
                            break;
                        }
                    }
                }

                if ( available != null )
                {
                    candidate = available;
                    return true;
                }

                // finally close the streams
                for ( DataInputStream in : streams )
                {
                    try
                    {
                        in.close();
                    }
                    catch ( Exception e )
                    {
                        e.printStackTrace();
                    }
                }

                closed = true;

                return false;
            }


            @Override
            public Tuple<K, V> next()
            {
                if ( candidate == null )
                {
                    if ( !closed )
                    {
                        hasNext();
                    }
                }

                if ( candidate == null )
                {
                    throw new NoSuchElementException( "No tuples found" );
                }

                return candidate;
            }


            @Override
            public void remove()
            {
                throw new UnsupportedOperationException( "Not supported" );
            }

        };

        return itr;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



