Merge lp:~kaaveeacs/drizzle/privatized-members-of-NestedJoin into lp:~drizzle-trunk/drizzle/development

Proposed by Kaaveea C S
Status: Merged
Approved by: Brian Aker
Approved revision: 2269
Merged at revision: 2290
Proposed branch: lp:~kaaveeacs/drizzle/privatized-members-of-NestedJoin
Merge into: lp:~drizzle-trunk/drizzle/development
Diff against target: 114 lines (+67/-10)
1 file modified
drizzled/nested_join.h (+67/-10)
To merge this branch: bzr merge lp:~kaaveeacs/drizzle/privatized-members-of-NestedJoin
Reviewer Review Type Date Requested Status
Stewart Smith (community) Needs Fixing
Olaf van der Spek Pending
Monty Taylor Pending
Vijay Samuel Pending
Review via email: mp+57940@code.launchpad.net

This proposal supersedes a proposal from 2011-04-14.

To post a comment you must log in.
Revision history for this message
Olaf van der Spek (olafvdspek) wrote : Posted in a previous version of this proposal

> List<Item> getSjOuterExprList() const
> void setSjOuterExprList(List<Item> in_sj_outer_expr_list)

Should this be by reference?

Don't forget coding style: first public, than private members.
Also, no need for this:
> join_list(),

review: Needs Fixing
Revision history for this message
Monty Taylor (mordred) wrote : Posted in a previous version of this proposal

Hi, and thanks for the patch!

There is a random "y" on a line by itself.

there are two getSjCorrTables instead of a getSjCorrTables and a setSjCorrTables

many of the setters should probably be taking their params by const reference

review: Needs Fixing
Revision history for this message
Andrew Hutchings (linuxjedi) wrote : Posted in a previous version of this proposal

Why is the 'y' on a line on it's own on line 59 of the diff?

Revision history for this message
Vijay Samuel (vjsamuel) wrote : Posted in a previous version of this proposal

Hi Kaaveea,
  Awesome work on your first branch. Please make sure that your constructor code matches our coding standards. Welcome to Drizzle.

Revision history for this message
Olaf van der Spek (olafvdspek) wrote : Posted in a previous version of this proposal

Hi Kaaveea ,

On Thu, Apr 14, 2011 at 9:42 PM, Kaaveea C S <email address hidden> wrote:
> +  /*
> +    This constructor serves for creation of NestedJoin instances
> +  */
> +  NestedJoin()
> +  :
> +  join_list(),

Is it necessary to list join_list here?
Is the constructor needed at all?

> +  List<Item> getSjOuterExprList() const

Shouldn't this be returned by const&?

Greetings,

--
Olaf

Revision history for this message
Vijay Samuel (vjsamuel) wrote : Posted in a previous version of this proposal

Looks good. Awesome job. Got everything right this time. :)

review: Approve
Revision history for this message
Olaf van der Spek (olafvdspek) wrote : Posted in a previous version of this proposal

See my previous comment.

review: Needs Fixing
Revision history for this message
Monty Taylor (mordred) wrote : Posted in a previous version of this proposal

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/14/2011 12:45 PM, Olaf van der Spek wrote:
> Hi Kaaveea ,
>
> On Thu, Apr 14, 2011 at 9:42 PM, Kaaveea C S <email address hidden> wrote:
>> + /*
>> + This constructor serves for creation of NestedJoin instances
>> + */
>> + NestedJoin()
>> + :
>> + join_list(),
>
> Is it necessary to list join_list here?
> Is the constructor needed at all?

Scott Meyers Effective C++ recommendations are to explicitly list all
data members in the initialization list. If you don't list it there,
it's still going to do the constructor, but you may forget that fact.

>> + List<Item> getSjOuterExprList() const
>
> Shouldn't this be returned by const&?

Yes. Yes it should be:

const List<Item>& getSjOuterExprList() const

Monty

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk2ohk8ACgkQ2Jv7/VK1RgEsnwCguHX4lPEdyjhiM5psnmVWRSJK
26kAoMIzM+cJ37vr8h7y0Jhqj+e4mW8r
=iEcT
-----END PGP SIGNATURE-----

Revision history for this message
Olaf van der Spek (olafvdspek) wrote : Posted in a previous version of this proposal

On Fri, Apr 15, 2011 at 7:59 PM, Monty Taylor <email address hidden> >
Scott Meyers Effective C++ recommendations are to explicitly list all
> data members in the initialization list. If you don't list it there,
> it's still going to do the constructor, but you may forget that fact.

Is that a problem?
--
Olaf

Revision history for this message
Monty Taylor (mordred) wrote : Posted in a previous version of this proposal

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/15/2011 11:22 AM, Olaf van der Spek wrote:
> On Fri, Apr 15, 2011 at 7:59 PM, Monty Taylor <email address hidden> >
> Scott Meyers Effective C++ recommendations are to explicitly list all
>> data members in the initialization list. If you don't list it there,
>> it's still going to do the constructor, but you may forget that fact.
>
> Is that a problem?

Don't know if it's purely a problem - that's just the justification of
the rule in general as I understand it. But for the most part, we try to
follow Scott Meyers' suggestions as best as we can. At some point in the
future (once our code is much cleaner) we'd like to be able to turn on
the -Weffc++ warning, which will throw a warning/error on not listing
data members in constructor initialization lists.

Monty
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk2okQYACgkQ2Jv7/VK1RgGPBwCeO1ZEoT6//+uHrXq5+Kdo/OZ3
oqgAn2iT1Lq2ubssdScGH7/OWbp5gFVw
=lSb7
-----END PGP SIGNATURE-----

Revision history for this message
Kaaveea C S (kaaveeacs) wrote : Posted in a previous version of this proposal

Ive made the changes (retruning a const reference).

Kindly review.

On Fri, Apr 15, 2011 at 10:42 PM, Monty Taylor <email address hidden> wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>
>
> On 04/15/2011 11:22 AM, Olaf van der Spek wrote:
> > On Fri, Apr 15, 2011 at 7:59 PM, Monty Taylor <email address hidden> >
> > Scott Meyers Effective C++ recommendations are to explicitly list all
> >> data members in the initialization list. If you don't list it there,
> >> it's still going to do the constructor, but you may forget that fact.
> >
> > Is that a problem?
>
> Don't know if it's purely a problem - that's just the justification of
> the rule in general as I understand it. But for the most part, we try to
> follow Scott Meyers' suggestions as best as we can. At some point in the
> future (once our code is much cleaner) we'd like to be able to turn on
> the -Weffc++ warning, which will throw a warning/error on not listing
> data members in constructor initialization lists.
>
> Monty
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.11 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAk2okQYACgkQ2Jv7/VK1RgGPBwCeO1ZEoT6//+uHrXq5+Kdo/OZ3
> oqgAn2iT1Lq2ubssdScGH7/OWbp5gFVw
> =lSb7
> -----END PGP SIGNATURE-----
>
> --
>
> https://code.launchpad.net/~kaaveeacs/drizzle/privatized-members-of-NestedJoin/+merge/57762<https://code.launchpad.net/%7Ekaaveeacs/drizzle/privatized-members-of-NestedJoin/+merge/57762>
> You are the owner of
> lp:~kaaveeacs/drizzle/privatized-members-of-NestedJoin.
>

--
Kaaveea :)

Revision history for this message
Vijay Samuel (vjsamuel) wrote : Posted in a previous version of this proposal

Third times the charm I guess. Looks good.

review: Approve
Revision history for this message
Olaf van der Spek (olafvdspek) wrote : Posted in a previous version of this proposal

On Fri, Apr 15, 2011 at 8:42 PM, Monty Taylor <email address hidden> wrote:
>> Scott Meyers Effective C++ recommendations are to explicitly list all
>>> data members in the initialization list. If you don't list it there,
>>> it's still going to do the constructor, but you may forget that fact.
>>
>> Is that a problem?
>
> Don't know if it's purely a problem - that's just the justification of
> the rule in general as I understand it. But for the most part, we try to
> follow Scott Meyers' suggestions as best as we can. At some point in the
> future (once our code is much cleaner) we'd like to be able to turn on
> the -Weffc++ warning, which will throw a warning/error on not listing
> data members in constructor initialization lists.

What concrete advantages will enabling that warning give us?

Olaf

Revision history for this message
Monty Taylor (mordred) wrote : Posted in a previous version of this proposal

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/15/2011 04:07 PM, Olaf van der Spek wrote:
> On Fri, Apr 15, 2011 at 8:42 PM, Monty Taylor <email address hidden> wrote:
>>> Scott Meyers Effective C++ recommendations are to explicitly list all
>>>> data members in the initialization list. If you don't list it there,
>>>> it's still going to do the constructor, but you may forget that fact.
>>>
>>> Is that a problem?
>>
>> Don't know if it's purely a problem - that's just the justification of
>> the rule in general as I understand it. But for the most part, we try to
>> follow Scott Meyers' suggestions as best as we can. At some point in the
>> future (once our code is much cleaner) we'd like to be able to turn on
>> the -Weffc++ warning, which will throw a warning/error on not listing
>> data members in constructor initialization lists.
>
> What concrete advantages will enabling that warning give us?

The same advantages that enabling the other warnings we enable gives us
- - a stricter compiler environment, which sometimes helps to find
mistakes at compile time. While there are many times when the warnings
emitted by the compiler can be safely ignored, we have found that a
general policy of keeping the tree warning clean has led to cleaner code
and has actually found bugs before. On the other hand, there is no
particular benefit that we've found to relaxing warnings or ignoring
best practices.

It's one of the things that makes us special and fun!

In the case of this particular warning, if we could get to the point
where we could enable it, warning about missing data members in
initialization list can help to catch things that you forgot to
initialize. It also warns about classes with pointer members which don't
define a copy constructor or an operator= - which is quite dangerous.
Monty
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk2pCF4ACgkQ2Jv7/VK1RgHKUACfWs5CF5PbTkwumOK3Uk78SUmX
StMAnjRsDzP3LjmuRqahyBw2BPtAiXH4
=M2Mc
-----END PGP SIGNATURE-----

Revision history for this message
Olaf van der Spek (olafvdspek) wrote : Posted in a previous version of this proposal

On Sat, Apr 16, 2011 at 5:13 AM, Monty Taylor <email address hidden> wrote:
> and has actually found bugs before. On the other hand, there is no
> particular benefit that we've found to relaxing warnings or ignoring
> best practices.

In this case I was wondering why those members were being default
initialized. To me, that's unnecessary so I was thinking something
strange was going on.

> It's one of the things that makes us special and fun!
>
> In the case of this particular warning, if we could get to the point
> where we could enable it, warning about missing data members in
> initialization list can help to catch things that you forgot to
> initialize. It also warns about classes with pointer members which don't
> define a copy constructor or an operator= - which is quite dangerous.

Not really, unless it's a ptr to a resource owned by that class.

--
Olaf

Revision history for this message
Monty Taylor (mordred) wrote : Posted in a previous version of this proposal

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 04/18/2011 09:03 AM, Olaf van der Spek wrote:
> On Sat, Apr 16, 2011 at 5:13 AM, Monty Taylor <email address hidden> wrote:
>> and has actually found bugs before. On the other hand, there is no
>> particular benefit that we've found to relaxing warnings or ignoring
>> best practices.
>
> In this case I was wondering why those members were being default
> initialized. To me, that's unnecessary so I was thinking something
> strange was going on.

Unless I'm wrong, I'm pretty sure those members are going to be default
initialized whether they are listed in the initializer list or not. No?

>> It's one of the things that makes us special and fun!
>>
>> In the case of this particular warning, if we could get to the point
>> where we could enable it, warning about missing data members in
>> initialization list can help to catch things that you forgot to
>> initialize. It also warns about classes with pointer members which don't
>> define a copy constructor or an operator= - which is quite dangerous.
>
> Not really, unless it's a ptr to a resource owned by that class.

Yup - but the compiler doesn't know the difference, and it certainly
doesn't hurt to define a copy ctor - so as a rule of thumb, having the
compiler to remind you to define one when you have a pointer data
members doesn't hurt and is a safeguard against a potentially bad mistake.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk2sdJEACgkQ2Jv7/VK1RgFZAACg54ixyvPtSwEJOJ9jPYAK+Es4
dvoAoI8tz9+sYuZTlOSW+hoExW4pqvns
=N+H/
-----END PGP SIGNATURE-----

Revision history for this message
Olaf van der Spek (olafvdspek) wrote : Posted in a previous version of this proposal

On Mon, Apr 18, 2011 at 7:31 PM, Monty Taylor <email address hidden> wrote:
> Unless I'm wrong, I'm pretty sure those members are going to be default
> initialized whether they are listed in the initializer list or not. No?

Yes. But since those members would normally not be listed, it looks
like something else is happening.

>>> It's one of the things that makes us special and fun!
>>>
>>> In the case of this particular warning, if we could get to the point
>>> where we could enable it, warning about missing data members in
>>> initialization list can help to catch things that you forgot to
>>> initialize. It also warns about classes with pointer members which don't
>>> define a copy constructor or an operator= - which is quite dangerous.
>>
>> Not really, unless it's a ptr to a resource owned by that class.
>
> Yup - but the compiler doesn't know the difference, and it certainly
> doesn't hurt to define a copy ctor - so as a rule of thumb, having the

It does. More code, more complexity, higher chance of bugs. It might
also be slower.

> compiler to remind you to define one when you have a pointer data
> members doesn't hurt and is a safeguard against a potentially bad mistake.

Since such mistakes cause a sure crash the mistake is easily detected anyway.

Olaf

Revision history for this message
Stewart Smith (stewart) wrote :

are these called anywhere? I can't see any calling of the new methods. Please use the code somewhere.

review: Needs Fixing
Revision history for this message
Vijay Samuel (vjsamuel) wrote :

Hey Stewart,
  This code is not being used anywhere in the code. Thought it would be
something to get your feet wet with as far as revision control and coding
standards is concerned

Cheers,
 -Vijay

On Wed, Apr 20, 2011 at 6:09 AM, Stewart Smith <email address hidden>wrote:

> Review: Needs Fixing
> are these called anywhere? I can't see any calling of the new methods.
> Please use the code somewhere.
> --
>
> https://code.launchpad.net/~kaaveeacs/drizzle/privatized-members-of-NestedJoin/+merge/57940
> You are requested to review the proposed merge of
> lp:~kaaveeacs/drizzle/privatized-members-of-NestedJoin into lp:drizzle.
>

Revision history for this message
Olaf van der Spek (olafvdspek) wrote :

On Wed, Apr 20, 2011 at 5:10 PM, Vijay Samuel <email address hidden> wrote:
> Hey Stewart,
>  This code is not being used anywhere in the code. Thought it would be
> something to get your feet wet with as far as revision control and coding
> standards is concerned

That's a shame, as it's likely to be deleted then.

Olaf

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'drizzled/nested_join.h'
2--- drizzled/nested_join.h 2011-03-28 22:16:45 +0000
3+++ drizzled/nested_join.h 2011-04-15 19:08:29 +0000
4@@ -30,12 +30,28 @@
5 class NestedJoin
6 {
7 public:
8+ /*
9+ This constructor serves for creation of NestedJoin instances
10+ */
11+ NestedJoin()
12+ :
13+ join_list(),
14+ used_tables(),
15+ not_null_tables(),
16+ first_nested(NULL),
17+ counter_(0),
18+ nj_map(),
19+ sj_depends_on(),
20+ sj_corr_tables(),
21+ sj_outer_expr_list()
22+ { }
23+
24 /* list of elements in the nested join */
25 List<TableList> join_list;
26
27 /* bitmap of tables in the nested join */
28 table_map used_tables;
29-
30+
31 /* tables that rejects nulls */
32 table_map not_null_tables;
33
34@@ -49,30 +65,71 @@
35 by the join optimizer.
36 Before each use the counters are zeroed by reset_nj_counters.
37 */
38+
39 uint32_t counter_;
40
41 /* Bit used to identify this nested join*/
42 std::bitset<64> nj_map;
43
44 /*
45+ True if this join nest node is completely covered by the query execution
46+ plan. This means two things.
47+
48+ 1. All tables on its @c join_list are covered by the plan.
49+
50+ 2. All child join nest nodes are fully covered.
51+ */
52+
53+ bool is_fully_covered() const { return join_list.size() == counter_; }
54+
55+ /* To get the table_map sj_depends_on */
56+ table_map getSjDependsOn() const
57+ {
58+ return sj_depends_on;
59+ }
60+
61+ /* To set the table_map sj_depends_on */
62+ void setSjDependsOn(const table_map &in_sj_depends_on)
63+ {
64+ sj_depends_on= in_sj_depends_on;
65+ }
66+
67+ /* To get the table_map sj_corr_tables */
68+ table_map getSjCorrTables() const
69+ {
70+ return sj_corr_tables;
71+ }
72+
73+ /* To set the table_map sj_corr_tables */
74+ void setSjCorrTables(const table_map &in_sj_corr_tables)
75+ {
76+ sj_corr_tables= in_sj_corr_tables;
77+ }
78+
79+ /* To get the List sj_outer_expr_list */
80+ const List<Item>& getSjOuterExprList() const
81+ {
82+ return sj_outer_expr_list;
83+ }
84+
85+ /* To set the List sj_outer_expr_list */
86+ void setSjOuterExprList(const List<Item> &in_sj_outer_expr_list)
87+ {
88+ sj_outer_expr_list= in_sj_outer_expr_list;
89+ }
90+
91+private:
92+ /*
93 (Valid only for semi-join nests) Bitmap of tables outside the semi-join
94 that are used within the semi-join's ON condition.
95 */
96 table_map sj_depends_on;
97+
98 /* Outer non-trivially correlated tables */
99 table_map sj_corr_tables;
100
101 List<Item> sj_outer_expr_list;
102
103- /**
104- True if this join nest node is completely covered by the query execution
105- plan. This means two things.
106-
107- 1. All tables on its @c join_list are covered by the plan.
108-
109- 2. All child join nest nodes are fully covered.
110- */
111- bool is_fully_covered() const { return join_list.size() == counter_; }
112 };
113
114 } /* namespace drizzled */