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

Subscribers

People subscribed via source and target branches