lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Uwe Schindler (JIRA)" <j...@apache.org>
Subject [jira] Issue Comment Edited: (LUCENE-2339) Allow Directory.copy() to accept a collection of file names to be copied
Date Tue, 23 Mar 2010 07:18:27 GMT

    [ https://issues.apache.org/jira/browse/LUCENE-2339?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12848591#action_12848591
] 

Uwe Schindler edited comment on LUCENE-2339 at 3/23/10 7:17 AM:
----------------------------------------------------------------

bq. I just wanted to avoid converting arrays to a Collection, just so that they can be iterated
on. 

Sorry, for the dumb question: In which JDK do arrays implement Iterable? From my knowledge
and a quick check with Java 5, it does not. Passing an array to a method taking Iterable does
not work. Arrays only work in extended for statement, but not because they are Itearble. The
generated code by javac is also totally different (and more effective than creating an iterator,
it just uses the conventional for(i=0; i<length; i++) approach - try it out with javac
and decompiling with jad or whatever)! Also arrays of native types can hardly implement Iterable
without autoboxing.

See:
- [http://stackoverflow.com/questions/1160081/why-is-an-array-not-assignable-to-iterable]
- [http://72.5.124.102/thread.jspa?threadID=558036&tstart=607]

And where is the waste of calling Arrays.asList()? This is exactly the same overhead like
creating an iterator() if arrays were Iterable, both are just "views" on the array, so no
copy involved.

      was (Author: thetaphi):
    bq. I just wanted to avoid converting arrays to a Collection, just so that they can be
iterated on. 

Sorry, for the dumb question: In which JDK do arrays implement Iterable? From my knowledge
and a quick check with Java 5, it does not. Passing an array to a method taking Iterable does
not work. Arrays only work in extended for statement, but not because they are Itearble. The
generated code by javac is also totally different (and more effective than creating an iterator,
it just uses the conventional for(i=0; i<length; i++) approach - try it out with javac
and decompiling with jad or whatever)! Also arrays of native types can hardly implement Iterable
without autoboxing.

See:
- [http://stackoverflow.com/questions/1160081/why-is-an-array-not-assignable-to-iterable]
- [http://72.5.124.102/thread.jspa?threadID=558036&tstart=607]
  
> Allow Directory.copy() to accept a collection of file names to be copied
> ------------------------------------------------------------------------
>
>                 Key: LUCENE-2339
>                 URL: https://issues.apache.org/jira/browse/LUCENE-2339
>             Project: Lucene - Java
>          Issue Type: Improvement
>            Reporter: Earwin Burrfoot
>            Assignee: Michael McCandless
>         Attachments: LUCENE-2339.patch, LUCENE-2339.patch, LUCENE-2339.patch
>
>
> Par example, I want to copy files pertaining to a certain commit, and not everything
there is in a Directory.

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


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


Mime
View raw message