You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@gora.apache.org by Furkan KAMACI <fu...@gmail.com> on 2015/08/21 16:46:38 UTC

Logic Bug at LogAnalytics.java

There is a piece of code at LogAnalytics:

public static void main(String[] args) throws Exception {
  if(args.length < 2) {
    System.err.println(USAGE);
    System.exit(1);
  }

  //run as any other MR job
  int ret = ToolRunner.run(new LogAnalytics(), args);
  System.exit(ret);

}

However at run method it says that:

if(args.length > 0) {

  String dataStoreClass = args[0];
  inStore = DataStoreFactory.
      getDataStore(dataStoreClass, Long.class, Pageview.class, conf);
  if(args.length > 1) {
    dataStoreClass = args[1];
  }
  outStore = DataStoreFactory.
      getDataStore(dataStoreClass, String.class, MetricDatum.class, conf);
} else {
 inStore = DataStoreFactory.getDataStore(Long.class, Pageview.class, conf);
 outStore = DataStoreFactory.getDataStore(String.class,
MetricDatum.class, conf);
}

So, when you check *run* method after *main*, args do not need to be
greater or equal to 2?

I can commit a patch for it?

Kind Regards,

Furkan KAMACI

Re: Logic Bug at LogAnalytics.java

Posted by Alfonso Nishikawa <al...@gmail.com>.
Hi, Furkan.
For me it's ok your suggestion, maybe would be ok to maintain something
like:

if first arg is "help" then show the help

although I find much useful show the help if no arg is passed.
Anyway, I don't use LogAnalytics, so if the ones who uses that features
(including you and if even if you are the only one) think it is better the
other way, for me it's ok :)


2015-08-21 14:51 GMT-01:00 Furkan KAMACI <fu...@gmail.com>:

> It is OK for *run* method if you do not pass any data store. It uses
> default data store for reading and writing. It may be nice to give same
> behavior to main method.
>
> On Fri, Aug 21, 2015 at 6:16 PM, Alfonso Nishikawa <
> alfonso.nishikawa@gmail.com> wrote:
>
> > Hi!
> > I suppose that you can run the LogAnalytics from other places with
> > mandatory arguments, but if you run it from Main it is mandatory to put 1
> > argument. I don't find it inherently wrong if you don't consider the only
> > execution being from main.
> >
> > I actually don't use it, so I don't know wether the default values in the
> > else make sense or not.
> >
> > By the way, I believe that it is forced to 1 argument in the main to be
> > shown the help in some way... (and not having to use a command "help").
> >
> > Regards,
> >
> > Alfonso Nishikawa
> >
> >
> >
> >
> > 2015-08-21 13:46 GMT-01:00 Furkan KAMACI <fu...@gmail.com>:
> >
> > > There is a piece of code at LogAnalytics:
> > >
> > > public static void main(String[] args) throws Exception {
> > >   if(args.length < 2) {
> > >     System.err.println(USAGE);
> > >     System.exit(1);
> > >   }
> > >
> > >   //run as any other MR job
> > >   int ret = ToolRunner.run(new LogAnalytics(), args);
> > >   System.exit(ret);
> > >
> > > }
> > >
> > > However at run method it says that:
> > >
> > > if(args.length > 0) {
> > >
> > >   String dataStoreClass = args[0];
> > >   inStore = DataStoreFactory.
> > >       getDataStore(dataStoreClass, Long.class, Pageview.class, conf);
> > >   if(args.length > 1) {
> > >     dataStoreClass = args[1];
> > >   }
> > >   outStore = DataStoreFactory.
> > >       getDataStore(dataStoreClass, String.class, MetricDatum.class,
> > conf);
> > > } else {
> > >  inStore = DataStoreFactory.getDataStore(Long.class, Pageview.class,
> > conf);
> > >  outStore = DataStoreFactory.getDataStore(String.class,
> > > MetricDatum.class, conf);
> > > }
> > >
> > > So, when you check *run* method after *main*, args do not need to be
> > > greater or equal to 2?
> > >
> > > I can commit a patch for it?
> > >
> > > Kind Regards,
> > >
> > > Furkan KAMACI
> > >
> >
>

Re: Logic Bug at LogAnalytics.java

Posted by Furkan KAMACI <fu...@gmail.com>.
It is OK for *run* method if you do not pass any data store. It uses
default data store for reading and writing. It may be nice to give same
behavior to main method.

On Fri, Aug 21, 2015 at 6:16 PM, Alfonso Nishikawa <
alfonso.nishikawa@gmail.com> wrote:

> Hi!
> I suppose that you can run the LogAnalytics from other places with
> mandatory arguments, but if you run it from Main it is mandatory to put 1
> argument. I don't find it inherently wrong if you don't consider the only
> execution being from main.
>
> I actually don't use it, so I don't know wether the default values in the
> else make sense or not.
>
> By the way, I believe that it is forced to 1 argument in the main to be
> shown the help in some way... (and not having to use a command "help").
>
> Regards,
>
> Alfonso Nishikawa
>
>
>
>
> 2015-08-21 13:46 GMT-01:00 Furkan KAMACI <fu...@gmail.com>:
>
> > There is a piece of code at LogAnalytics:
> >
> > public static void main(String[] args) throws Exception {
> >   if(args.length < 2) {
> >     System.err.println(USAGE);
> >     System.exit(1);
> >   }
> >
> >   //run as any other MR job
> >   int ret = ToolRunner.run(new LogAnalytics(), args);
> >   System.exit(ret);
> >
> > }
> >
> > However at run method it says that:
> >
> > if(args.length > 0) {
> >
> >   String dataStoreClass = args[0];
> >   inStore = DataStoreFactory.
> >       getDataStore(dataStoreClass, Long.class, Pageview.class, conf);
> >   if(args.length > 1) {
> >     dataStoreClass = args[1];
> >   }
> >   outStore = DataStoreFactory.
> >       getDataStore(dataStoreClass, String.class, MetricDatum.class,
> conf);
> > } else {
> >  inStore = DataStoreFactory.getDataStore(Long.class, Pageview.class,
> conf);
> >  outStore = DataStoreFactory.getDataStore(String.class,
> > MetricDatum.class, conf);
> > }
> >
> > So, when you check *run* method after *main*, args do not need to be
> > greater or equal to 2?
> >
> > I can commit a patch for it?
> >
> > Kind Regards,
> >
> > Furkan KAMACI
> >
>

Re: Logic Bug at LogAnalytics.java

Posted by Alfonso Nishikawa <al...@gmail.com>.
Hi!
I suppose that you can run the LogAnalytics from other places with
mandatory arguments, but if you run it from Main it is mandatory to put 1
argument. I don't find it inherently wrong if you don't consider the only
execution being from main.

I actually don't use it, so I don't know wether the default values in the
else make sense or not.

By the way, I believe that it is forced to 1 argument in the main to be
shown the help in some way... (and not having to use a command "help").

Regards,

Alfonso Nishikawa




2015-08-21 13:46 GMT-01:00 Furkan KAMACI <fu...@gmail.com>:

> There is a piece of code at LogAnalytics:
>
> public static void main(String[] args) throws Exception {
>   if(args.length < 2) {
>     System.err.println(USAGE);
>     System.exit(1);
>   }
>
>   //run as any other MR job
>   int ret = ToolRunner.run(new LogAnalytics(), args);
>   System.exit(ret);
>
> }
>
> However at run method it says that:
>
> if(args.length > 0) {
>
>   String dataStoreClass = args[0];
>   inStore = DataStoreFactory.
>       getDataStore(dataStoreClass, Long.class, Pageview.class, conf);
>   if(args.length > 1) {
>     dataStoreClass = args[1];
>   }
>   outStore = DataStoreFactory.
>       getDataStore(dataStoreClass, String.class, MetricDatum.class, conf);
> } else {
>  inStore = DataStoreFactory.getDataStore(Long.class, Pageview.class, conf);
>  outStore = DataStoreFactory.getDataStore(String.class,
> MetricDatum.class, conf);
> }
>
> So, when you check *run* method after *main*, args do not need to be
> greater or equal to 2?
>
> I can commit a patch for it?
>
> Kind Regards,
>
> Furkan KAMACI
>