Merge lp:~mmcm/akiban-server/construct-hkey-positions into lp:~akiban-technologies/akiban-server/trunk

Proposed by Mike McMahon
Status: Merged
Approved by: Nathan Williams
Approved revision: 2729
Merged at revision: 2728
Proposed branch: lp:~mmcm/akiban-server/construct-hkey-positions
Merge into: lp:~akiban-technologies/akiban-server/trunk
Diff against target: 138 lines (+122/-0)
2 files modified
src/main/java/com/akiban/server/store/AbstractStore.java (+1/-0)
src/test/java/com/akiban/server/test/it/bugs/bug1208930/PartialCascadeHKeyIT.java (+121/-0)
To merge this branch: bzr merge lp:~mmcm/akiban-server/construct-hkey-positions
Reviewer Review Type Date Requested Status
Nathan Williams Approve
Review via email: mp+178837@code.launchpad.net

Description of the change

Fix construction of partially cascading hkeys.

The problem was that the IndexToHKey map was only built when first used. But a running index into the hkey was not initialized at that time. It was therefore wrong in the case where some earlier hkey positions came from the row and a later one from a parent, as in the partial cascading case in the bug report and the new IT.

To post a comment you must log in.
Revision history for this message
Nathan Williams (nwilliams) wrote :

I think all of the fans of lazy evaluation in the AIS may be gone. Removal thoughts?

Looks good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/main/java/com/akiban/server/store/AbstractStore.java'
2--- src/main/java/com/akiban/server/store/AbstractStore.java 2013-07-27 00:43:54 +0000
3+++ src/main/java/com/akiban/server/store/AbstractStore.java 2013-08-06 20:16:26 +0000
4@@ -212,6 +212,7 @@
5 indexToHKey = parentPkIndex.indexToHKey();
6 parentStoreData = createStoreData(session, parentPkIndex.indexDef());
7 parentPKIndexRow = readIndexRow(session, parentPkIndex, parentStoreData, rowDef, rowData);
8+ i2hPosition = hKeyColumn.positionInHKey();
9 }
10 if(indexToHKey.isOrdinal(i2hPosition)) {
11 assert indexToHKey.getOrdinal(i2hPosition) == segmentRowDef.userTable().getOrdinal() : hKeyColumn;
12
13=== added directory 'src/test/java/com/akiban/server/test/it/bugs/bug1208930'
14=== added file 'src/test/java/com/akiban/server/test/it/bugs/bug1208930/PartialCascadeHKeyIT.java'
15--- src/test/java/com/akiban/server/test/it/bugs/bug1208930/PartialCascadeHKeyIT.java 1970-01-01 00:00:00 +0000
16+++ src/test/java/com/akiban/server/test/it/bugs/bug1208930/PartialCascadeHKeyIT.java 2013-08-06 20:16:26 +0000
17@@ -0,0 +1,121 @@
18+/**
19+ * Copyright (C) 2009-2013 Akiban Technologies, Inc.
20+ *
21+ * This program is free software: you can redistribute it and/or modify
22+ * it under the terms of the GNU Affero General Public License as published by
23+ * the Free Software Foundation, either version 3 of the License, or
24+ * (at your option) any later version.
25+ *
26+ * This program is distributed in the hope that it will be useful,
27+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
28+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
29+ * GNU Affero General Public License for more details.
30+ *
31+ * You should have received a copy of the GNU Affero General Public License
32+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
33+ */
34+
35+package com.akiban.server.test.it.bug1208930;
36+
37+import com.akiban.ais.model.Group;
38+import com.akiban.qp.operator.API;
39+import com.akiban.qp.operator.Operator;
40+import com.akiban.qp.row.RowBase;
41+import com.akiban.qp.rowtype.UserTableRowType;
42+import com.akiban.server.api.dml.scan.NewRow;
43+import com.akiban.server.test.it.qp.OperatorITBase;
44+
45+import org.junit.Test;
46+
47+public class PartialCascadeHKeyIT extends OperatorITBase
48+{
49+ @Override
50+ protected void setupCreateSchema()
51+ {
52+ w = createTable(
53+ "s", "w",
54+ "wid INT NOT NULL",
55+ "PRIMARY KEY(wid)");
56+ d = createTable(
57+ "s", "d",
58+ "wid INT NOT NULL",
59+ "did INT NOT NULL",
60+ "PRIMARY KEY(wid, did)",
61+ "GROUPING FOREIGN KEY(wid) REFERENCES w(wid)");
62+ c = createTable(
63+ "s", "c",
64+ "wid INT NOT NULL",
65+ "did INT NOT NULL",
66+ "cid INT NOT NULL",
67+ "PRIMARY KEY(wid, did, cid)",
68+ "GROUPING FOREIGN KEY(wid, did) REFERENCES d(wid, did)");
69+ o = createTable(
70+ "s", "o",
71+ "wid INT NOT NULL",
72+ "did INT NOT NULL",
73+ "cid INT NOT NULL",
74+ "oid INT NOT NULL",
75+ "PRIMARY KEY(wid, did, oid)",
76+ "GROUPING FOREIGN KEY(wid, did, cid) REFERENCES c(wid, did, cid)");
77+ i = createTable(
78+ "s", "i",
79+ "wid INT NOT NULL",
80+ "did INT NOT NULL",
81+ "oid INT NOT NULL",
82+ "iid INT NOT NULL",
83+ "PRIMARY KEY(wid, did, iid)",
84+ "GROUPING FOREIGN KEY(wid, did, oid) REFERENCES o(wid, did, oid)");
85+ }
86+
87+ @Override
88+ protected void setupPostCreateSchema()
89+ {
90+ schema = new com.akiban.qp.rowtype.Schema(ais());
91+ wRowType = schema.userTableRowType(userTable(w));
92+ dRowType = schema.userTableRowType(userTable(d));
93+ cRowType = schema.userTableRowType(userTable(c));
94+ oRowType = schema.userTableRowType(userTable(o));
95+ iRowType = schema.userTableRowType(userTable(i));
96+ wOrdinal = ddl().getTable(session(), w).getOrdinal();
97+ dOrdinal = ddl().getTable(session(), d).getOrdinal();
98+ cOrdinal = ddl().getTable(session(), c).getOrdinal();
99+ oOrdinal = ddl().getTable(session(), o).getOrdinal();
100+ iOrdinal = ddl().getTable(session(), i).getOrdinal();
101+ group = group(c);
102+ adapter = newStoreAdapter(schema);
103+ queryContext = queryContext(adapter);
104+ queryBindings = queryContext.createBindings();
105+ loadDatabase();
106+ }
107+
108+ private void loadDatabase()
109+ {
110+ db = new NewRow[] {
111+ createNewRow(w, 1L),
112+ createNewRow(d, 1L, 11L),
113+ createNewRow(c, 1L, 11L, 111L),
114+ createNewRow(o, 1L, 11L, 111L, 1111L),
115+ createNewRow(i, 1L, 11L, 1111L, 11111L),
116+ };
117+ use(db);
118+ }
119+
120+ @Test
121+ public void testHKeys()
122+ {
123+ Operator plan = API.groupScan_Default(group);
124+ RowBase[] expected = new RowBase[] {
125+ row("{1,(long)1}", wRowType, 1L),
126+ row("{1,(long)1,2,(long)11}", dRowType, 1L, 11L),
127+ row("{1,(long)1,2,(long)11,3,(long)111}", cRowType, 1L, 11L, 111L),
128+ row("{1,(long)1,2,(long)11,3,(long)111,4,(long)1111}", oRowType, 1L, 11L, 111L, 1111L),
129+ row("{1,(long)1,2,(long)11,3,(long)111,4,(long)1111,5,(long)11111}", iRowType, 1L, 11L, 1111L, 11111L),
130+ };
131+ compareRows(expected, API.cursor(plan, queryContext, queryBindings));
132+ }
133+
134+ private int w, d, c, o, i;
135+ private UserTableRowType wRowType, dRowType, cRowType, oRowType, iRowType;
136+ private Group group;
137+ private int wOrdinal, dOrdinal, cOrdinal, oOrdinal, iOrdinal;
138+}

Subscribers

People subscribed via source and target branches