Vijay Samuel's Blog

Getting into the code :)

Posted on: May 10, 2010

This is all that I’ve come up with so far. Now, initially we have to replace the my_long_options with program_options::options_description. So I propose to completely remove the my_long_options[] and place the program_options::options_description globally so that several functions may call upon it as and when necessary.

Values of the options in the program have to be stored in program_options::options_description as follows.

Data member in struct option        Value Syntax/Semantic in                        Option_Description

name                    option name(straight forward)
id                          short version(again straight forward)
comment             description(again straight forward)
def_value            default_value()
var_type              value<var_type>()

arg_type              use zero_tokens(),multi_tokens()

**value    and **u_max_value        value<var_type>(address of value)

I couldn’t come up with solutions for min_value,max_value,less_value and block_size. Instead of having the program describe all the attributes of an option I propose to use a central configuration file that takes care of this so that the size of the program_options::options_description is minimum. If this is feasible then we could just have the above stated data members in the options_description and store the rest in the configuration file.

Apart from all this I ran some basic ack-grep searches for some of the usage of the data members of struct option and I think you would find the results quite interesting on some of the members.
Issue no 1.
ack-grep app_type

drizzled/option.h
70:  void       *app_type;                 /* To be used by an application */

//This is the declaration fo app_type in option.h

drizzled/plugin/loader.cc
1601:    options->app_type= opt;

Only one place uses the data member app_type and all definitions of the struct option set the value of app_type to the value 0 so I propose to scrap the data member app_type and find an aternative to replace the line “options->app_type=opt;”.

Issue no 2.
I ran an ack-grep search on option.h to see how many files depend on option.h and I got this:
ack-grep option.h

client/client_priv.h
plugin/archive/archive_performance.cc
plugin/archive/concurrency_test.cc
plugin/archive/archive_reader.cc
plugin/archive/archive_test.cc
plugin/myisam/mi_check.cc
plugin/myisam/ha_myisam.cc
drizzled/option.cc
drizzled/set_var.cc
drizzled/plugin/loader.cc
drizzled/drizzled.cc
drizzled/parser.h
drizzled/statement/set_option.cc
drizzled/internal/default.cc
Makefile
tests/resolve_stack_dump.cc
gnulib/getopt.c
extra/my_print_defaults.cc

After that I went into each file and did searches on key words like “option”,”struct option” and strangely in certain files I couldn’t find any. The code files were independent of the file “option.h” yet they seem to be have included. I tried commenting out the include statements and re running the test and the tests ran perfectly. The files which are independent are stated below:

i)plugin/archive/archive_performance.cc
ii)plugin/archive/archive_test.cc
iii)plugin/myisam/mi_check.cc
iv)plugin/archive/concurrency_test.cc

If you think the above issue has been well explained we could remove the includes from those files permanently to avoid confusion for developers who use the code at later stages.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

My Timeline

May 2010
M T W T F S S
« Apr   Jun »
 12
3456789
10111213141516
17181920212223
24252627282930
31  

I, Me and Myself

My Blog Stats

  • 6,257 hits

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 4 other followers

%d bloggers like this: