Merge lp:~mmcm/akiban-server/hkey-row-cache into lp:~akiban-technologies/akiban-server/trunk

Proposed by Mike McMahon
Status: Merged
Approved by: Thomas Jones-Low
Approved revision: 2711
Merged at revision: 2711
Proposed branch: lp:~mmcm/akiban-server/hkey-row-cache
Merge into: lp:~akiban-technologies/akiban-server/trunk
Diff against target: 106 lines (+10/-10)
3 files modified
src/main/java/com/akiban/qp/operator/HKeyUnion_Ordered.java (+3/-2)
src/main/java/com/akiban/server/service/text/FullTextCursor.java (+4/-4)
src/main/java/com/akiban/server/service/text/FullTextIndexServiceImpl.java (+3/-4)
To merge this branch: bzr merge lp:~mmcm/akiban-server/hkey-row-cache
Reviewer Review Type Date Requested Status
Thomas Jones-Low Approve
Review via email: mp+176824@code.launchpad.net

Description of the change

Fix scope of HKeyRow's HKeyCache.

Each HKeyRow needs its own HKeyCache, whose purpose is to give out the same HKey for a given table. However, it takes the HKeyCache in the constructor, since it cannot make one without a StoreAdapter, which it does not have. (I suppose it could take the StoreAdapter in the constructor for this purpose.)

This led to HKeyUnion_Ordered having one cache for all the rows that it gives out, which means that two rows could share component HKeys. It could implement the unsharedRow pattern and reuse the combination, but right now it makes a new row each time. So it must make a new cache.

This mistake was then copied for the full text cursor, which also makes HKey rows, and then to full text maintanence. Make them create new caches for new rows, too.

To post a comment you must log in.
Revision history for this message
Thomas Jones-Low (tjoneslo) wrote :

As described.

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/qp/operator/HKeyUnion_Ordered.java'
2--- src/main/java/com/akiban/qp/operator/HKeyUnion_Ordered.java 2013-07-15 22:01:49 +0000
3+++ src/main/java/com/akiban/qp/operator/HKeyUnion_Ordered.java 2013-07-25 00:22:29 +0000
4@@ -251,6 +251,7 @@
5 close();
6 } else if (previousHKey == null || !previousHKey.prefixOf(nextRow.hKey())) {
7 HKey nextHKey = outputHKey(nextRow);
8+ HKeyCache<HKey> hKeyCache = new HKeyCache<>(adapter);
9 nextRow = new HKeyRow(outputHKeyRowType, nextHKey, hKeyCache);
10 previousHKey = nextHKey;
11 } else {
12@@ -348,7 +349,7 @@
13 this.bindingsCursor = multiple;
14 this.leftInput = left.cursor(context, multiple.newCursor());
15 this.rightInput = right.cursor(context, multiple.newCursor());
16- hKeyCache = new HKeyCache<>(context.getStore());
17+ adapter = context.getStore();
18 }
19
20 // For use by this class
21@@ -404,7 +405,7 @@
22 private final Cursor rightInput;
23 private final ShareHolder<Row> leftRow = new ShareHolder<>();
24 private final ShareHolder<Row> rightRow = new ShareHolder<>();
25- private final HKeyCache<HKey> hKeyCache;
26+ private final StoreAdapter adapter;
27 private HKey previousHKey;
28 private boolean closed = true;
29 }
30
31=== modified file 'src/main/java/com/akiban/server/service/text/FullTextCursor.java'
32--- src/main/java/com/akiban/server/service/text/FullTextCursor.java 2013-07-09 17:26:33 +0000
33+++ src/main/java/com/akiban/server/service/text/FullTextCursor.java 2013-07-25 00:22:29 +0000
34@@ -20,6 +20,7 @@
35 import com.akiban.qp.operator.RowCursor;
36 import com.akiban.qp.operator.CursorLifecycle;
37 import com.akiban.qp.operator.QueryContext;
38+import com.akiban.qp.operator.StoreAdapter;
39 import com.akiban.qp.persistitadapter.PersistitHKey;
40 import com.akiban.qp.row.HKey;
41 import com.akiban.qp.row.HKeyRow;
42@@ -52,7 +53,7 @@
43 private final SearcherManager searcherManager;
44 private final Query query;
45 private final int limit;
46- private final HKeyCache<HKey> hKeyCache;
47+ private final StoreAdapter adapter;
48 private IndexSearcher searcher;
49 private TopDocs results;
50 private int position;
51@@ -70,8 +71,7 @@
52 this.searcherManager = searcherManager;
53 this.query = query;
54 this.limit = limit;
55- hKeyCache = new HKeyCache<>(context.getStore());
56-
57+ adapter = context.getStore();
58 searcher = searcherManager.acquire();
59 }
60
61@@ -110,7 +110,7 @@
62 throw new AkibanInternalException("Error reading document", ex);
63 }
64 HKey hkey = hkey(doc.get(IndexedField.KEY_FIELD));
65- Row row = new HKeyRow(rowType, hkey, hKeyCache);
66+ Row row = new HKeyRow(rowType, hkey, new HKeyCache<HKey>(adapter));
67 logger.debug("FullTextCursor: yield {}", row);
68 return row;
69 }
70
71=== modified file 'src/main/java/com/akiban/server/service/text/FullTextIndexServiceImpl.java'
72--- src/main/java/com/akiban/server/service/text/FullTextIndexServiceImpl.java 2013-07-11 14:20:38 +0000
73+++ src/main/java/com/akiban/server/service/text/FullTextIndexServiceImpl.java 2013-07-25 00:22:29 +0000
74@@ -284,7 +284,6 @@
75 adapter = store.createAdapter(session, indexInfo.getSchema());
76 QueryContext queryContext = new SimpleQueryContext(adapter);
77 QueryBindings queryBindings = queryContext.createBindings();
78- HKeyCache<com.akiban.qp.row.HKey> cache = new HKeyCache<>(adapter);
79 IndexWriter writer = indexInfo.getIndexer().getWriter();
80
81 Cursor cursor = null;
82@@ -295,7 +294,7 @@
83 Iterator<byte[]> it = rows.iterator();
84 while(it.hasNext()) {
85 byte[] row = it.next();
86- HKeyRow hkeyRow = toHKeyRow(row, indexInfo.getHKeyRowType(), adapter, cache);
87+ HKeyRow hkeyRow = toHKeyRow(row, indexInfo.getHKeyRowType(), adapter);
88 queryBindings.setRow(0, hkeyRow);
89 cursor = API.cursor(operator, queryContext, queryBindings);
90 rowIndexer.updateDocument(cursor, row);
91@@ -699,13 +698,13 @@
92 private volatile boolean populateEnabled = false;
93
94 private HKeyRow toHKeyRow(byte rowBytes[], HKeyRowType hKeyRowType,
95- StoreAdapter store, HKeyCache<com.akiban.qp.row.HKey> cache)
96+ StoreAdapter store)
97 {
98 PersistitHKey hkey = store.newHKey(hKeyRowType.hKey());
99 Key key = hkey.key();
100 key.setEncodedSize(rowBytes.length);
101 System.arraycopy(rowBytes, 0, key.getEncodedBytes(), 0, rowBytes.length);
102- return new HKeyRow(hKeyRowType, hkey, cache);
103+ return new HKeyRow(hKeyRowType, hkey, new HKeyCache<com.akiban.qp.row.HKey>(store));
104 }
105
106 public HKeyBytesStream getChangedRows(Session session) {

Subscribers

People subscribed via source and target branches