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

Colin Patrick McCabe commented on HADOOP-7824:
----------------------------------------------

Hmm.  I don't think there is a lot of "cut and paste boilerplate" associated 
with doing it as function calls.  The only thing I can think of is the "if 
(failed)..." check after each function call.  Personally, I prefer seeing that, 
though, since it makes the control flow clearer to me.  And surely using 
function calls is just as reusable by other Hadoop components as using a 
table-driven approach?  Code being at the top of the file versus the middle of 
the file seems like an odd argument to make.  I don't think it matters where in 
the file the code is.

Mainly, what I don't like about the table-driven approach is that it involves a 
clunky "parallel type system" (CT_BOOL, CT_INT,  CT_LONG) and a set of somewhat 
complex macros.  I also find it confusing to have a bunch of types that start 
with "const" like {{const_type}}, {{const_signature}}, etc.... but are not 
{{const}} in the C sense of the word!  I think this code may depend on C99 as 
well... did C89 support  { .bool_val=C } and so forth?

It seems much simpler to just call a function to do what you want.  If you 
really find it cumbersome to have an "if" statement after each function call, 
how about having something like this:
{code}
jthrowable jthr = NULL;
setIntConstant("O_RDONLY", O_RDONLY, &jthr);
setBooleanConstant("fadvisePossible", HAVE_POSIX_FADVISE, &jthr);
...
if (jthr) {
  (*env)->Throw(env, jthr);
}
{code}
And have some code in the functions which just returns and does nothing if jthr 
is set.

> Native IO uses wrong constants almost everywhere
> ------------------------------------------------
>
>                 Key: HADOOP-7824
>                 URL: https://issues.apache.org/jira/browse/HADOOP-7824
>             Project: Hadoop Common
>          Issue Type: Sub-task
>          Components: native
>    Affects Versions: 0.20.204.0, 0.20.205.0, 1.0.3, 0.23.0, 2.0.0-alpha, 3.0.0
>         Environment: Mac OS X, Linux, Solaris, Windows, ... 
>            Reporter: Dmytro Shteflyuk
>            Assignee: Martin Walsh
>              Labels: hadoop
>             Fix For: 2.8.0
>
>         Attachments: HADOOP-7824.001.patch, HADOOP-7824.002.patch, 
> HADOOP-7824.patch, HADOOP-7824.patch, hadoop-7824.txt
>
>
> Constants like O_CREAT, O_EXCL, etc. have different values on OS X and many 
> other operating systems.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to