lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Noll <dan...@nuix.com>
Subject Re: Directory.list() deprecation
Date Sun, 08 Nov 2009 21:58:15 GMT
On Fri, Nov 6, 2009 at 20:26, Michael McCandless
<lucene@mikemccandless.com> wrote:
> Well... you can use oal.index.IndexFileNameFilter.getFilter() to
> filter for only the Lucene index files, or, you could filter for the
> additional files you know you've placed in the index directory?

This is the workaround we're currently using, but it's pretty obvious
why it's less than ideal:

    FileNameFilter filter = IndexFileNameFilter.getFilter();
    List<String> results = new ArrayList<String>();
    for (String candidate : dir.listAll()) {
        if (filter.accept(null, candidate)) {  // <--
            results.add(candidate);
        }
    }

The biggest issue here is that the FileNameFilter forces us to provide
a File for the first parameter even though the index may not even be
stored on disk.  We can pass null and hope that the filter won't have
an issue with that, which works ... *for now*.

> The motivation for this change was that Directory is the wrong place
> to have "smarts" about what is & isn't an index file: it's too
> low-level (and, different Directory impls were inconsistent).
> Especially with flexible indexing coming, where a codec can write
> whatever files it wants, the Directory has no way know.

This seems reasonable, but it would have been nice to have a list
method which accepted a filter so that there would at least be a
replacement for the old behaviour.  The way it is now, Lucene has
deprecated a method people were using while providing no replacement
except for "write it yourself", the same as what happened when Hits
got canned.

Daniel


-- 
Daniel Noll                            Forensic and eDiscovery Software
Senior Developer                              The world's most advanced
Nuix                                                email data analysis
http://nuix.com/                                and eDiscovery software

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message