[ 
https://issues.apache.org/jira/browse/AVRO-1316?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13648053#comment-13648053
 ] 

Micah Huff commented on AVRO-1316:
----------------------------------

You are correct. I mis-spoke in my comment attached. I take the string 
representation of the object passed in, split it into multiple 64K chunks (not 
65 as I said), and return those. For our particular use-case (the one 
[~trochee] mentions above) using this approach resolved our issue and the java 
code compiles correctly.

The resulting code looks like this in the case where the protocol / schema is 
too large:
{code}
public static final String part1 = "......";
public static final String part2 = "......";
public static final org.apache.avro.Protocol PROTOCOL = 
org.apache.avro.Protocol.parse(new String[] {part1, part2});
{code}

Unfortunately, using the static{} block as you suggested above won't work for 
the protocol case unless we converted that from an interface to an abstract 
class. Also, I can't just concatenate the parts together to make a single 
variable -- same error of "constant too long" is emitted by javac. I decided to 
go down the route of multiple part variables to make the line that actually 
parses the whole thing very readable.

                
> IDL code-generation generates too-long literals for very large schemas
> ----------------------------------------------------------------------
>
>                 Key: AVRO-1316
>                 URL: https://issues.apache.org/jira/browse/AVRO-1316
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.7.5
>            Reporter: Jeremy Kahn
>            Priority: Minor
>              Labels: patch
>         Attachments: AVRO-1316.patch
>
>
> When I work from a very large IDL schema, the Java code generated includes a 
> schema JSON literal that exceeds the length of the maximum allowed literal 
> string ([65535 
> characters|http://stackoverflow.com/questions/8323082/size-of-initialisation-string-in-java]).
>   
> This creates weird Maven errors like: {{[ERROR] ...FooProtocol.java:[13,89] 
> constant string too long}}.
> It might seem a little crazy, but a 64-kilobyte JSON protocol isn't 
> outrageous at all for some of the more involved data structures, especially 
> if we're including documentation strings etc.
> I believe the fix should be a bit more sensitivity to the length of the JSON 
> literal (and a willingness to split it into more than one literal, joined by 
> {{+}}), but I haven't figured out where that change needs to go. Has anyone 
> else encountered this problem?

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to