On Jul 21, 2010, at 23:10, Bill Janssen <jans...@parc.com> wrote:
Andi Vajda <va...@apache.org> wrote:
On Jul 21, 2010, at 19:59, Bill Janssen <jans...@parc.com> wrote:
Bill Janssen <jans...@parc.com> wrote:
What's crashing with PyLucene 2.9.3 is this code:
for field in x.getFields():
where "x" is an instance of org.apache.lucene.document.Document. I
can
print x and it looks OK, but an attempt to iterate over the list of
fields seems broken. Is this another iterator change?
I see that I also can't iterate over x.getFields().listIterator(),
presumably because, in the Java 1.4 that Lucene 2.9.x uses,
java.util.Iterator doesn't "implement" java.lang.Iterable. A tad
ridiculous.
Not ridiculous, impossible, since java.lang.Iterable appeared in Java
1.5 and Lucene 2.x claims Java 1.4 compatibility.
No, I mean it's ridiculous that I can't subscript or iterate, in
Python,
a value of java.util.List. You need something in jcc to support Java
1.4 sequence types
Yes, it can be done with --sequence
as well as the new code for 1.5 sequence types.
With 1.5, Iterable works like a charm.
I
presume that there will be a 2.9.4 in the future, right?
Maybe, maybe not. It depends on what Lucene Java does. I sure hope
that the 2.9 release series is winding down. There are just too many
release branches at the moment.
I looked at the jcc code a bit. In jcc/python.py, this bit
if env.java_version >= '1.5':
iterable = findClass('java/lang/Iterable')
iterator = findClass('java/util/Iterator')
else:
iterable = iterator = None
could perhaps become
if env.java_version >= '1.5':
iterable = findClass('java/lang/Iterable')
iterator = findClass('java/util/Iterator')
else:
iterable = findClass('java/lang/Object')
iterator = findClass('java/lang/Iterator')
Not sure. Probably more is required.
Certainly java.util.List should be a sequence of some sort.
It can be if declare it via the --sequence jcc command line flag.
So a change to the Makefile would be in order, for the 2.x branch.
Is there an auto-downcasting switch for jcc? That is, it would be
nice,
for sequences and mappings, if the "get" method would automatically
cast
the retrieved value to the Pythonic representation of the most
specific
type.
If that get() method is declared with that specific type, I expect it
to be used. Otherwise, this is what the 3.0 release is about (among
many other things), extensive use of Java 1.5, type parameters and
generics. Porting your stuff to 3.0 is thus highly recommended instead
of complaining about broken (my bad) long- deprecated APIs.
Andi..
Bill