You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pylucene-dev@lucene.apache.org by csrickle <cs...@gmail.com> on 2012/08/17 12:43:41 UTC

JCC access to a nested iteration class

Hello,

This is a redirection attempt, as I used the jira tool incorrectly.  Please consider the original PYLUCENE-21 issue and the following additional comment.

I did exclude my jcc invocation. This is a snapshot, where I paired down the pylucene Makefile and adapted to a simple Maven archetype generated project: 

python -m jcc.__main__ --arch x86_64 --jar /Users/crickle/jcc/jcc-hello/target/jcc-hello-1.0-SNAPSHOT.jar --rename home.App\$Embedded=AppEmbedded --package java.lang java.lang.System java.lang.Runtime java.lang.IllegalStateException java.lang.IndexOutOfBoundsException --package java.util java.util.Arrays java.util.HashMap java.util.HashSet java.util.No 
SuchElementException java.text.SimpleDateFormat java.text.DecimalFormat java.text.Collator --package java.util.regex --package java.io java.io.StringReader java.io.InputStreamRea 
der java.io.FileInputStream --python jcchello --mapping java.util.Properties 'getProperty:(Ljava/lang/String;)Ljava/lang/String;' --sequence java.util.AbstractList 'size:()I' 'ge 
t:(I)Ljava/lang/Object;' --version 1.0 --files 4 --install 

 I replicated it and understand a few points that I was missing. In the above invocation, am I equivalently asking for wrapping by specifying the --jar option for the archive that contains the code to be wrapped? Do I still need --classpath per your provided example? 

For now, I have arrived at a solution that is working for us that uses a supplemental function (as described in my initial question) to provide the iteration over the query result set. So far, we haven't really found any problem with this approach, except that the logic spans python and java. 

This is an Apache Accumulo interface. The particular class containing the nested class, analogous to App.Embedded.hello2(), is TabletServerBatchReaderIterator: 

http://svn.apache.org/viewvc/accumulo/tags/1.4.1/src/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReaderIterator.java?view=markup 

Getting jcc to recognize MyEntry (listed below) is the actual problem I'm still hoping to solve. 

  private static class MyEntry implements Entry<Key,Value> { 
98	
99	 private Key key; 
100	 private Value value; 
101	
102	 MyEntry(Key key, Value value) { 
103	 this.key = key; 
104	 this.value = value; 
105	 } 
106	
107	 @Override 
108	 public Key getKey() { 
109	 return key; 
110	 } 
111	
112	 @Override 
113	 public Value getValue() { 
114	 return value; 
115	 } 
116	
117	 @Override 
118	 public Value setValue(Value value) { 
119	 throw new UnsupportedOperationException(); 
120	 } 
121	
122	 } 

If this class is contained within a specified --jar argument in the jcc invocation, can I then add a --rename command such that I can refer to the "private" and "static" MyEntry class. 

Thanks again for your kind consideration. 
Craig

Re: JCC access to a nested iteration class

Posted by Andi Vajda <va...@apache.org>.
On Fri, 17 Aug 2012, csrickle wrote:

>...
>
> This is an Apache Accumulo interface. The particular class containing the 
> nested class, analogous to App.Embedded.hello2(), is 
> TabletServerBatchReaderIterator:
>
> http://svn.apache.org/viewvc/accumulo/tags/1.4.1/src/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchReaderIterator.java?view=markup
>
> Getting jcc to recognize MyEntry (listed below) is the actual problem I'm 
> still hoping to solve.
>
>  private static class MyEntry implements Entry<Key,Value> {
> 98
> 99	 private Key key;
> 100	 private Value value;
> 101
> 102	 MyEntry(Key key, Value value) {
> 103	 this.key = key;
> 104	 this.value = value;
> 105	 }
> 106
> 107	 @Override
> 108	 public Key getKey() {
> 109	 return key;
> 110	 }
> 111
> 112	 @Override
> 113	 public Value getValue() {
> 114	 return value;
> 115	 }
> 116
> 117	 @Override
> 118	 public Value setValue(Value value) {
> 119	 throw new UnsupportedOperationException();
> 120	 }
> 121
> 122	 }
>
> If this class is contained within a specified --jar argument in the jcc 
> invocation, can I then add a --rename command such that I can refer to the 
> "private" and "static" MyEntry class.

When using --jar, only public classes are wrapped. The reason is that 
non-public classes are not meant to be accessed from the outside and that 
this offers a great way to reduce the amount of code generated by JCC.

This is also why you should carefully consider which --package flags to use 
so that dependencies to classes outside the set you'd like to wrap also get 
wrapped. By default, methods whose signature refers to classes outside your 
wrap-set that are not in a package listed with --package are skipped.

If JCC was greedy in its wrapping by default, you'd very quickly end up 
wrapping the entire JRE.

Now, to your question more specifically: to wrap a non-public class, just 
list their name on the jcc command line.

For example, if you change your jcchello Embedded class to private and give 
it a public constructor, then your earlier example still works as before, 
you can still call AppEmbedded(App()).hello2(). If you don't give it a 
public constructor, you won't be able to instantiate Embedded from the 
outside, as only public methods and constructors are wrapped, for similar 
reasons.

Andi..