commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matthew Flaschen (JIRA)" <j...@apache.org>
Subject [jira] Updated: (IO-170) Scalable Iterator for files, better than FileUtils.iterateFiles
Date Sun, 26 Apr 2009 21:01:30 GMT

     [ https://issues.apache.org/jira/browse/IO-170?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Matthew Flaschen updated IO-170:
--------------------------------

    Attachment: real_iterators.patch

Okay, this is a first draft of a direct iterator implementation of iterateFiles.  It basically
uses the same traversal technique as the existing functions (and borrows code from them),
but it doesn't create any LinkedList.  It uses chains of iterators, specifically apache.commons.collections.iterators.IteratorChain
and apache.commons.collections.iterators.ObjectArrayIterator (if this dependency is unacceptable,
neither of these are overly complex classes, so they can be reimplemented or imported).

As is the code is a bit redundant, because the list code is doing the same thing as the iterator
code.  Once the iterator code is tested and considered correct, the list functions can be
implemented using iterators.  E.g.:

public static Collection<File> listFiles(
            File directory, IOFileFilter fileFilter, IOFileFilter dirFilter) {
Iterator<File> iter = iterateFiles(directory, fileFilter, dirFilter);
LinkedList<File> list = new LinkedList<File>();
while(iter.hasNext())
list.add(iter.next());
return list;
}

or similar.  I'm glad to refine the patch more as needed.

> Scalable Iterator for files, better than FileUtils.iterateFiles
> ---------------------------------------------------------------
>
>                 Key: IO-170
>                 URL: https://issues.apache.org/jira/browse/IO-170
>             Project: Commons IO
>          Issue Type: Improvement
>          Components: Utilities
>    Affects Versions: 1.4
>         Environment: generic file systems
>            Reporter: Damian Noseda
>            Priority: Minor
>             Fix For: 2.x
>
>         Attachments: real_iterators.patch
>
>   Original Estimate: 5h
>  Remaining Estimate: 5h
>
> Improve the way that iterateFiles generate an iterator. The current way it not scale.
It's try to add all files in a list and then return the iterator of that list. A better way
it would be create an customize Iterator<File> with a stack of arrays of File to go
up and down in the directory tree.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message