You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@nutch.apache.org by "Alparslan Avcı (JIRA)" <ji...@apache.org> on 2014/01/23 13:03:38 UTC

[jira] [Commented] (NUTCH-1709) Generated classes o.a.n.storage.Host and o.a.n.storage.ProtocolStatus contain methods not defined in source .avsc

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

Alparslan Avcı commented on NUTCH-1709:
---------------------------------------

+1 on this issue. The Avro generated classes must not contain any changes from the orginal, since they provide data structure schemas. No logic has to be implemented in any of these classes. 
For these methods, we can carry their implementations into the places where they are used. 

> Generated classes o.a.n.storage.Host and o.a.n.storage.ProtocolStatus contain methods not defined in source .avsc
> -----------------------------------------------------------------------------------------------------------------
>
>                 Key: NUTCH-1709
>                 URL: https://issues.apache.org/jira/browse/NUTCH-1709
>             Project: Nutch
>          Issue Type: Bug
>            Reporter: Lewis John McGibbney
>             Fix For: 2.3
>
>
> When using the GoraCompiler currently packaged with gora-core-0.4-SNAPSHOT, the following methods are removed from o.a.n.storage.Host or o.a.n.storage.ProtocolStatus
> {code:title=Host.java|borderStyle=solid}
>   public boolean contains(String key) {
>     return metadata.containsKey(new Utf8(key));
>   }
>   
>   public String getValue(String key, String defaultValue) {
>     if (!contains(key)) return defaultValue;
>     return Bytes.toString(metadata.get(new Utf8(key)));
>   }
>   
>   public int getInt(String key, int defaultValue) {
>     if (!contains(key)) return defaultValue;
>     return Integer.parseInt(getValue(key,null));
>   }
>   public long getLong(String key, long defaultValue) {
>     if (!contains(key)) return defaultValue;
>     return Long.parseLong(getValue(key,null));
>   }
> {code}
> {code:title=ProtocolStatus.java|borderStyle=solid}
>   /**
>    * A convenience method which returns a successful {@link ProtocolStatus}.
>    * @return the {@link ProtocolStatus} value for 200 (success).
>    */
>   public boolean isSuccess() {
>     return code == ProtocolStatusUtils.SUCCESS; 
>   }
> {code}
> This results in compilation errors... I am not sure if it is good practice for non-default methods to be contained within generated Persistent classes. This is certainly the case with newer versions of Avro when using the Java API.
> compile-core:
>     [javac] Compiling 104 source files to /home/mary/Downloads/apache/2.x/build/classes
>     [javac] warning: [options] bootstrap class path not set in conjunction with -source 1.6
>     [javac] /home/mary/Downloads/apache/2.x/src/java/org/apache/nutch/fetcher/FetcherReducer.java:345: error: cannot find symbol
>     [javac]                                        host.getInt("q_mt", maxThreads),
>     [javac]                                            ^
>     [javac]   symbol:   method getInt(String,int)
>     [javac]   location: variable host of type Host
>     [javac] /home/mary/Downloads/apache/2.x/src/java/org/apache/nutch/fetcher/FetcherReducer.java:346: error: cannot find symbol
>     [javac]                                        host.getLong("q_cd", crawlDelay),
>     [javac]                                            ^
>     [javac]   symbol:   method getLong(String,long)
>     [javac]   location: variable host of type Host
>     [javac] /home/mary/Downloads/apache/2.x/src/java/org/apache/nutch/fetcher/FetcherReducer.java:347: error: cannot find symbol
>     [javac]                                        host.getLong("q_mcd", minCrawlDelay));
>     [javac]                                            ^
>     [javac]   symbol:   method getLong(String,long)
>     [javac]   location: variable host of type Host
>     [javac] /home/mary/Downloads/apache/2.x/src/java/org/apache/nutch/parse/ParserChecker.java:114: error: cannot find symbol
>     [javac]     if(!protocolOutput.getStatus().isSuccess()) {
>     [javac]                                   ^
>     [javac]   symbol:   method isSuccess()
>     [javac]   location: class ProtocolStatus
>     [javac] Note: /home/mary/Downloads/apache/2.x/src/java/org/apache/nutch/storage/Host.java uses unchecked or unsafe operations.
>     [javac] Note: Recompile with -Xlint:unchecked for details.
>     [javac] 4 errors
>     [javac] 1 warning
> I think it would be a good idea to find another home for such methods as it will undoubtedly avoid problems when we do Gora upgrades in the future.
> Right now I don't have a suggestion but will work on a solution non-the-less.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)