http://git-wip-us.apache.org/repos/asf/hbase-site/blob/f30982bd/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.html b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.html index 289df25..2470b8f 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/ScanQueryMatcher.html @@ -101,7 +101,7 @@ <span class="sourceLineNo">093</span> /* row is not private for tests */<a name="line.93"></a> <span class="sourceLineNo">094</span> /** Row the query is on */<a name="line.94"></a> <span class="sourceLineNo">095</span> Cell curCell;<a name="line.95"></a> -<span class="sourceLineNo">096</span> <a name="line.96"></a> +<span class="sourceLineNo">096</span><a name="line.96"></a> <span class="sourceLineNo">097</span> /**<a name="line.97"></a> <span class="sourceLineNo">098</span> * Oldest put in any of the involved store files<a name="line.98"></a> <span class="sourceLineNo">099</span> * Used to decide whether it is ok to delete<a name="line.99"></a> @@ -127,7 +127,7 @@ <span class="sourceLineNo">119</span> * first column.<a name="line.119"></a> <span class="sourceLineNo">120</span> * */<a name="line.120"></a> <span class="sourceLineNo">121</span> private boolean hasNullColumn = true;<a name="line.121"></a> -<span class="sourceLineNo">122</span> <a name="line.122"></a> +<span class="sourceLineNo">122</span><a name="line.122"></a> <span class="sourceLineNo">123</span> private RegionCoprocessorHost regionCoprocessorHost= null;<a name="line.123"></a> <span class="sourceLineNo">124</span><a name="line.124"></a> <span class="sourceLineNo">125</span> // By default, when hbase.hstore.time.to.purge.deletes is 0ms, a delete<a name="line.125"></a> @@ -148,22 +148,22 @@ <span class="sourceLineNo">140</span> // currently influencing. This is because Puts, that this delete can<a name="line.140"></a> <span class="sourceLineNo">141</span> // influence. may appear out of order.<a name="line.141"></a> <span class="sourceLineNo">142</span> private final long timeToPurgeDeletes;<a name="line.142"></a> -<span class="sourceLineNo">143</span> <a name="line.143"></a> +<span class="sourceLineNo">143</span><a name="line.143"></a> <span class="sourceLineNo">144</span> private final boolean isUserScan;<a name="line.144"></a> <span class="sourceLineNo">145</span><a name="line.145"></a> <span class="sourceLineNo">146</span> private final boolean isReversed;<a name="line.146"></a> <span class="sourceLineNo">147</span><a name="line.147"></a> <span class="sourceLineNo">148</span> /**<a name="line.148"></a> -<span class="sourceLineNo">149</span> * Construct a QueryMatcher for a scan<a name="line.149"></a> -<span class="sourceLineNo">150</span> * @param scan<a name="line.150"></a> -<span class="sourceLineNo">151</span> * @param scanInfo The store's immutable scan info<a name="line.151"></a> -<span class="sourceLineNo">152</span> * @param columns<a name="line.152"></a> -<span class="sourceLineNo">153</span> * @param scanType Type of the scan<a name="line.153"></a> -<span class="sourceLineNo">154</span> * @param earliestPutTs Earliest put seen in any of the store files.<a name="line.154"></a> -<span class="sourceLineNo">155</span> * @param oldestUnexpiredTS the oldest timestamp we are interested in,<a name="line.155"></a> -<span class="sourceLineNo">156</span> * based on TTL<a name="line.156"></a> -<span class="sourceLineNo">157</span> * @param regionCoprocessorHost <a name="line.157"></a> -<span class="sourceLineNo">158</span> * @throws IOException <a name="line.158"></a> +<span class="sourceLineNo">149</span> * True if we are doing a 'Get' Scan. Every Get is actually a one-row Scan.<a name="line.149"></a> +<span class="sourceLineNo">150</span> */<a name="line.150"></a> +<span class="sourceLineNo">151</span> private final boolean get;<a name="line.151"></a> +<span class="sourceLineNo">152</span><a name="line.152"></a> +<span class="sourceLineNo">153</span> /**<a name="line.153"></a> +<span class="sourceLineNo">154</span> * Construct a QueryMatcher for a scan<a name="line.154"></a> +<span class="sourceLineNo">155</span> * @param scanInfo The store's immutable scan info<a name="line.155"></a> +<span class="sourceLineNo">156</span> * @param scanType Type of the scan<a name="line.156"></a> +<span class="sourceLineNo">157</span> * @param earliestPutTs Earliest put seen in any of the store files.<a name="line.157"></a> +<span class="sourceLineNo">158</span> * @param oldestUnexpiredTS the oldest timestamp we are interested in, based on TTL<a name="line.158"></a> <span class="sourceLineNo">159</span> */<a name="line.159"></a> <span class="sourceLineNo">160</span> public ScanQueryMatcher(Scan scan, ScanInfo scanInfo, NavigableSet<byte[]> columns,<a name="line.160"></a> <span class="sourceLineNo">161</span> ScanType scanType, long readPointToUse, long earliestPutTs, long oldestUnexpiredTS,<a name="line.161"></a> @@ -174,518 +174,524 @@ <span class="sourceLineNo">166</span> } else {<a name="line.166"></a> <span class="sourceLineNo">167</span> this.tr = timeRange;<a name="line.167"></a> <span class="sourceLineNo">168</span> }<a name="line.168"></a> -<span class="sourceLineNo">169</span> this.rowComparator = scanInfo.getComparator();<a name="line.169"></a> -<span class="sourceLineNo">170</span> this.regionCoprocessorHost = regionCoprocessorHost;<a name="line.170"></a> -<span class="sourceLineNo">171</span> this.deletes = instantiateDeleteTracker();<a name="line.171"></a> -<span class="sourceLineNo">172</span> this.stopRow = scan.getStopRow();<a name="line.172"></a> -<span class="sourceLineNo">173</span> this.startKey = CellUtil.createFirstDeleteFamilyCellOnRow(scan.getStartRow(),<a name="line.173"></a> -<span class="sourceLineNo">174</span> scanInfo.getFamily());<a name="line.174"></a> -<span class="sourceLineNo">175</span> this.filter = scan.getFilter();<a name="line.175"></a> -<span class="sourceLineNo">176</span> this.earliestPutTs = earliestPutTs;<a name="line.176"></a> -<span class="sourceLineNo">177</span> this.oldestUnexpiredTS = oldestUnexpiredTS;<a name="line.177"></a> -<span class="sourceLineNo">178</span> this.now = now;<a name="line.178"></a> -<span class="sourceLineNo">179</span><a name="line.179"></a> -<span class="sourceLineNo">180</span> this.maxReadPointToTrackVersions = readPointToUse;<a name="line.180"></a> -<span class="sourceLineNo">181</span> this.timeToPurgeDeletes = scanInfo.getTimeToPurgeDeletes();<a name="line.181"></a> -<span class="sourceLineNo">182</span> this.ttl = oldestUnexpiredTS;<a name="line.182"></a> -<span class="sourceLineNo">183</span><a name="line.183"></a> -<span class="sourceLineNo">184</span> /* how to deal with deletes */<a name="line.184"></a> -<span class="sourceLineNo">185</span> this.isUserScan = scanType == ScanType.USER_SCAN;<a name="line.185"></a> -<span class="sourceLineNo">186</span> // keep deleted cells: if compaction or raw scan<a name="line.186"></a> -<span class="sourceLineNo">187</span> this.keepDeletedCells = scan.isRaw() ? KeepDeletedCells.TRUE :<a name="line.187"></a> -<span class="sourceLineNo">188</span> isUserScan ? KeepDeletedCells.FALSE : scanInfo.getKeepDeletedCells();<a name="line.188"></a> -<span class="sourceLineNo">189</span> // retain deletes: if minor compaction or raw scanisDone<a name="line.189"></a> -<span class="sourceLineNo">190</span> this.retainDeletesInOutput = scanType == ScanType.COMPACT_RETAIN_DELETES || scan.isRaw();<a name="line.190"></a> -<span class="sourceLineNo">191</span> // seePastDeleteMarker: user initiated scans<a name="line.191"></a> -<span class="sourceLineNo">192</span> this.seePastDeleteMarkers =<a name="line.192"></a> -<span class="sourceLineNo">193</span> scanInfo.getKeepDeletedCells() != KeepDeletedCells.FALSE && isUserScan;<a name="line.193"></a> -<span class="sourceLineNo">194</span><a name="line.194"></a> -<span class="sourceLineNo">195</span> int maxVersions =<a name="line.195"></a> -<span class="sourceLineNo">196</span> scan.isRaw() ? scan.getMaxVersions() : Math.min(scan.getMaxVersions(),<a name="line.196"></a> -<span class="sourceLineNo">197</span> scanInfo.getMaxVersions());<a name="line.197"></a> -<span class="sourceLineNo">198</span><a name="line.198"></a> -<span class="sourceLineNo">199</span> // Single branch to deal with two types of reads (columns vs all in family)<a name="line.199"></a> -<span class="sourceLineNo">200</span> if (columns == null || columns.size() == 0) {<a name="line.200"></a> -<span class="sourceLineNo">201</span> // there is always a null column in the wildcard column query.<a name="line.201"></a> -<span class="sourceLineNo">202</span> hasNullColumn = true;<a name="line.202"></a> -<span class="sourceLineNo">203</span><a name="line.203"></a> -<span class="sourceLineNo">204</span> // use a specialized scan for wildcard column tracker.<a name="line.204"></a> -<span class="sourceLineNo">205</span> this.columns = new ScanWildcardColumnTracker(<a name="line.205"></a> -<span class="sourceLineNo">206</span> scanInfo.getMinVersions(), maxVersions, oldestUnexpiredTS);<a name="line.206"></a> -<span class="sourceLineNo">207</span> } else {<a name="line.207"></a> -<span class="sourceLineNo">208</span> // whether there is null column in the explicit column query<a name="line.208"></a> -<span class="sourceLineNo">209</span> hasNullColumn = (columns.first().length == 0);<a name="line.209"></a> -<span class="sourceLineNo">210</span><a name="line.210"></a> -<span class="sourceLineNo">211</span> // We can share the ExplicitColumnTracker, diff is we reset<a name="line.211"></a> -<span class="sourceLineNo">212</span> // between rows, not between storefiles.<a name="line.212"></a> -<span class="sourceLineNo">213</span> this.columns = new ExplicitColumnTracker(columns, scanInfo.getMinVersions(), maxVersions,<a name="line.213"></a> -<span class="sourceLineNo">214</span> oldestUnexpiredTS);<a name="line.214"></a> -<span class="sourceLineNo">215</span> }<a name="line.215"></a> -<span class="sourceLineNo">216</span> this.isReversed = scan.isReversed();<a name="line.216"></a> -<span class="sourceLineNo">217</span> }<a name="line.217"></a> -<span class="sourceLineNo">218</span><a name="line.218"></a> -<span class="sourceLineNo">219</span> private DeleteTracker instantiateDeleteTracker() throws IOException {<a name="line.219"></a> -<span class="sourceLineNo">220</span> DeleteTracker tracker = new ScanDeleteTracker();<a name="line.220"></a> -<span class="sourceLineNo">221</span> if (regionCoprocessorHost != null) {<a name="line.221"></a> -<span class="sourceLineNo">222</span> tracker = regionCoprocessorHost.postInstantiateDeleteTracker(tracker);<a name="line.222"></a> -<span class="sourceLineNo">223</span> }<a name="line.223"></a> -<span class="sourceLineNo">224</span> return tracker;<a name="line.224"></a> -<span class="sourceLineNo">225</span> }<a name="line.225"></a> -<span class="sourceLineNo">226</span><a name="line.226"></a> -<span class="sourceLineNo">227</span> /**<a name="line.227"></a> -<span class="sourceLineNo">228</span> * Construct a QueryMatcher for a scan that drop deletes from a limited range of rows.<a name="line.228"></a> -<span class="sourceLineNo">229</span> * @param scan<a name="line.229"></a> -<span class="sourceLineNo">230</span> * @param scanInfo The store's immutable scan info<a name="line.230"></a> -<span class="sourceLineNo">231</span> * @param columns<a name="line.231"></a> -<span class="sourceLineNo">232</span> * @param earliestPutTs Earliest put seen in any of the store files.<a name="line.232"></a> -<span class="sourceLineNo">233</span> * @param oldestUnexpiredTS the oldest timestamp we are interested in, based on TTL<a name="line.233"></a> -<span class="sourceLineNo">234</span> * @param now the current server time<a name="line.234"></a> -<span class="sourceLineNo">235</span> * @param dropDeletesFromRow The inclusive left bound of the range; can be EMPTY_START_ROW.<a name="line.235"></a> -<span class="sourceLineNo">236</span> * @param dropDeletesToRow The exclusive right bound of the range; can be EMPTY_END_ROW.<a name="line.236"></a> -<span class="sourceLineNo">237</span> * @param regionCoprocessorHost <a name="line.237"></a> -<span class="sourceLineNo">238</span> * @throws IOException <a name="line.238"></a> -<span class="sourceLineNo">239</span> */<a name="line.239"></a> -<span class="sourceLineNo">240</span> public ScanQueryMatcher(Scan scan, ScanInfo scanInfo, NavigableSet<byte[]> columns,<a name="line.240"></a> -<span class="sourceLineNo">241</span> long readPointToUse, long earliestPutTs, long oldestUnexpiredTS, long now,<a name="line.241"></a> -<span class="sourceLineNo">242</span> byte[] dropDeletesFromRow, byte[] dropDeletesToRow,<a name="line.242"></a> -<span class="sourceLineNo">243</span> RegionCoprocessorHost regionCoprocessorHost) throws IOException {<a name="line.243"></a> -<span class="sourceLineNo">244</span> this(scan, scanInfo, columns, ScanType.COMPACT_RETAIN_DELETES, readPointToUse, earliestPutTs,<a name="line.244"></a> -<span class="sourceLineNo">245</span> oldestUnexpiredTS, now, regionCoprocessorHost);<a name="line.245"></a> -<span class="sourceLineNo">246</span> Preconditions.checkArgument((dropDeletesFromRow != null) && (dropDeletesToRow != null));<a name="line.246"></a> -<span class="sourceLineNo">247</span> this.dropDeletesFromRow = dropDeletesFromRow;<a name="line.247"></a> -<span class="sourceLineNo">248</span> this.dropDeletesToRow = dropDeletesToRow;<a name="line.248"></a> -<span class="sourceLineNo">249</span> }<a name="line.249"></a> -<span class="sourceLineNo">250</span><a name="line.250"></a> -<span class="sourceLineNo">251</span> /*<a name="line.251"></a> -<span class="sourceLineNo">252</span> * Constructor for tests<a name="line.252"></a> -<span class="sourceLineNo">253</span> */<a name="line.253"></a> -<span class="sourceLineNo">254</span> ScanQueryMatcher(Scan scan, ScanInfo scanInfo,<a name="line.254"></a> -<span class="sourceLineNo">255</span> NavigableSet<byte[]> columns, long oldestUnexpiredTS, long now) throws IOException {<a name="line.255"></a> -<span class="sourceLineNo">256</span> this(scan, scanInfo, columns, ScanType.USER_SCAN,<a name="line.256"></a> -<span class="sourceLineNo">257</span> Long.MAX_VALUE, /* max Readpoint to track versions */<a name="line.257"></a> -<span class="sourceLineNo">258</span> HConstants.LATEST_TIMESTAMP, oldestUnexpiredTS, now, null);<a name="line.258"></a> -<span class="sourceLineNo">259</span> }<a name="line.259"></a> -<span class="sourceLineNo">260</span><a name="line.260"></a> -<span class="sourceLineNo">261</span> /**<a name="line.261"></a> -<span class="sourceLineNo">262</span> *<a name="line.262"></a> -<span class="sourceLineNo">263</span> * @return whether there is an null column in the query<a name="line.263"></a> -<span class="sourceLineNo">264</span> */<a name="line.264"></a> -<span class="sourceLineNo">265</span> public boolean hasNullColumnInQuery() {<a name="line.265"></a> -<span class="sourceLineNo">266</span> return hasNullColumn;<a name="line.266"></a> -<span class="sourceLineNo">267</span> }<a name="line.267"></a> -<span class="sourceLineNo">268</span><a name="line.268"></a> -<span class="sourceLineNo">269</span> /**<a name="line.269"></a> -<span class="sourceLineNo">270</span> * Determines if the caller should do one of several things:<a name="line.270"></a> -<span class="sourceLineNo">271</span> * - seek/skip to the next row (MatchCode.SEEK_NEXT_ROW)<a name="line.271"></a> -<span class="sourceLineNo">272</span> * - seek/skip to the next column (MatchCode.SEEK_NEXT_COL)<a name="line.272"></a> -<span class="sourceLineNo">273</span> * - include the current KeyValue (MatchCode.INCLUDE)<a name="line.273"></a> -<span class="sourceLineNo">274</span> * - ignore the current KeyValue (MatchCode.SKIP)<a name="line.274"></a> -<span class="sourceLineNo">275</span> * - got to the next row (MatchCode.DONE)<a name="line.275"></a> -<span class="sourceLineNo">276</span> *<a name="line.276"></a> -<span class="sourceLineNo">277</span> * @param cell KeyValue to check<a name="line.277"></a> -<span class="sourceLineNo">278</span> * @return The match code instance.<a name="line.278"></a> -<span class="sourceLineNo">279</span> * @throws IOException in case there is an internal consistency problem<a name="line.279"></a> -<span class="sourceLineNo">280</span> * caused by a data corruption.<a name="line.280"></a> -<span class="sourceLineNo">281</span> */<a name="line.281"></a> -<span class="sourceLineNo">282</span> public MatchCode match(Cell cell) throws IOException {<a name="line.282"></a> -<span class="sourceLineNo">283</span> if (filter != null && filter.filterAllRemaining()) {<a name="line.283"></a> -<span class="sourceLineNo">284</span> return MatchCode.DONE_SCAN;<a name="line.284"></a> -<span class="sourceLineNo">285</span> }<a name="line.285"></a> -<span class="sourceLineNo">286</span> if (curCell != null) {<a name="line.286"></a> -<span class="sourceLineNo">287</span> int ret = this.rowComparator.compareRows(curCell, cell);<a name="line.287"></a> -<span class="sourceLineNo">288</span> if (!this.isReversed) {<a name="line.288"></a> -<span class="sourceLineNo">289</span> if (ret <= -1) {<a name="line.289"></a> -<span class="sourceLineNo">290</span> return MatchCode.DONE;<a name="line.290"></a> -<span class="sourceLineNo">291</span> } else if (ret >= 1) {<a name="line.291"></a> -<span class="sourceLineNo">292</span> // could optimize this, if necessary?<a name="line.292"></a> -<span class="sourceLineNo">293</span> // Could also be called SEEK_TO_CURRENT_ROW, but this<a name="line.293"></a> -<span class="sourceLineNo">294</span> // should be rare/never happens.<a name="line.294"></a> -<span class="sourceLineNo">295</span> return MatchCode.SEEK_NEXT_ROW;<a name="line.295"></a> -<span class="sourceLineNo">296</span> }<a name="line.296"></a> -<span class="sourceLineNo">297</span> } else {<a name="line.297"></a> -<span class="sourceLineNo">298</span> if (ret <= -1) {<a name="line.298"></a> -<span class="sourceLineNo">299</span> return MatchCode.SEEK_NEXT_ROW;<a name="line.299"></a> -<span class="sourceLineNo">300</span> } else if (ret >= 1) {<a name="line.300"></a> -<span class="sourceLineNo">301</span> return MatchCode.DONE;<a name="line.301"></a> -<span class="sourceLineNo">302</span> }<a name="line.302"></a> -<span class="sourceLineNo">303</span> }<a name="line.303"></a> -<span class="sourceLineNo">304</span> } else {<a name="line.304"></a> -<span class="sourceLineNo">305</span> // Since the curCell is null it means we are already sure that we have moved over to the next row<a name="line.305"></a> -<span class="sourceLineNo">306</span> return MatchCode.DONE;<a name="line.306"></a> -<span class="sourceLineNo">307</span> }<a name="line.307"></a> -<span class="sourceLineNo">308</span><a name="line.308"></a> -<span class="sourceLineNo">309</span> // optimize case.<a name="line.309"></a> -<span class="sourceLineNo">310</span> if (this.stickyNextRow) {<a name="line.310"></a> -<span class="sourceLineNo">311</span> return MatchCode.SEEK_NEXT_ROW;<a name="line.311"></a> -<span class="sourceLineNo">312</span> }<a name="line.312"></a> -<span class="sourceLineNo">313</span><a name="line.313"></a> -<span class="sourceLineNo">314</span> if (this.columns.done()) {<a name="line.314"></a> -<span class="sourceLineNo">315</span> stickyNextRow = true;<a name="line.315"></a> -<span class="sourceLineNo">316</span> return MatchCode.SEEK_NEXT_ROW;<a name="line.316"></a> -<span class="sourceLineNo">317</span> }<a name="line.317"></a> -<span class="sourceLineNo">318</span><a name="line.318"></a> -<span class="sourceLineNo">319</span> long timestamp = cell.getTimestamp();<a name="line.319"></a> -<span class="sourceLineNo">320</span> // check for early out based on timestamp alone<a name="line.320"></a> -<span class="sourceLineNo">321</span> if (columns.isDone(timestamp)) {<a name="line.321"></a> -<span class="sourceLineNo">322</span> return columns.getNextRowOrNextColumn(cell);<a name="line.322"></a> -<span class="sourceLineNo">323</span> }<a name="line.323"></a> -<span class="sourceLineNo">324</span> // check if the cell is expired by cell TTL<a name="line.324"></a> -<span class="sourceLineNo">325</span> if (HStore.isCellTTLExpired(cell, this.oldestUnexpiredTS, this.now)) {<a name="line.325"></a> -<span class="sourceLineNo">326</span> return MatchCode.SKIP;<a name="line.326"></a> -<span class="sourceLineNo">327</span> } <a name="line.327"></a> -<span class="sourceLineNo">328</span><a name="line.328"></a> -<span class="sourceLineNo">329</span> /*<a name="line.329"></a> -<span class="sourceLineNo">330</span> * The delete logic is pretty complicated now.<a name="line.330"></a> -<span class="sourceLineNo">331</span> * This is corroborated by the following:<a name="line.331"></a> -<span class="sourceLineNo">332</span> * 1. The store might be instructed to keep deleted rows around.<a name="line.332"></a> -<span class="sourceLineNo">333</span> * 2. A scan can optionally see past a delete marker now.<a name="line.333"></a> -<span class="sourceLineNo">334</span> * 3. If deleted rows are kept, we have to find out when we can<a name="line.334"></a> -<span class="sourceLineNo">335</span> * remove the delete markers.<a name="line.335"></a> -<span class="sourceLineNo">336</span> * 4. Family delete markers are always first (regardless of their TS)<a name="line.336"></a> -<span class="sourceLineNo">337</span> * 5. Delete markers should not be counted as version<a name="line.337"></a> -<span class="sourceLineNo">338</span> * 6. Delete markers affect puts of the *same* TS<a name="line.338"></a> -<span class="sourceLineNo">339</span> * 7. Delete marker need to be version counted together with puts<a name="line.339"></a> -<span class="sourceLineNo">340</span> * they affect<a name="line.340"></a> -<span class="sourceLineNo">341</span> */<a name="line.341"></a> -<span class="sourceLineNo">342</span> byte typeByte = cell.getTypeByte();<a name="line.342"></a> -<span class="sourceLineNo">343</span> long mvccVersion = cell.getSequenceId();<a name="line.343"></a> -<span class="sourceLineNo">344</span> if (CellUtil.isDelete(cell)) {<a name="line.344"></a> -<span class="sourceLineNo">345</span> if (keepDeletedCells == KeepDeletedCells.FALSE<a name="line.345"></a> -<span class="sourceLineNo">346</span> || (keepDeletedCells == KeepDeletedCells.TTL && timestamp < ttl)) {<a name="line.346"></a> -<span class="sourceLineNo">347</span> // first ignore delete markers if the scanner can do so, and the<a name="line.347"></a> -<span class="sourceLineNo">348</span> // range does not include the marker<a name="line.348"></a> -<span class="sourceLineNo">349</span> //<a name="line.349"></a> -<span class="sourceLineNo">350</span> // during flushes and compactions also ignore delete markers newer<a name="line.350"></a> -<span class="sourceLineNo">351</span> // than the readpoint of any open scanner, this prevents deleted<a name="line.351"></a> -<span class="sourceLineNo">352</span> // rows that could still be seen by a scanner from being collected<a name="line.352"></a> -<span class="sourceLineNo">353</span> boolean includeDeleteMarker = seePastDeleteMarkers ?<a name="line.353"></a> -<span class="sourceLineNo">354</span> tr.withinTimeRange(timestamp) :<a name="line.354"></a> -<span class="sourceLineNo">355</span> tr.withinOrAfterTimeRange(timestamp);<a name="line.355"></a> -<span class="sourceLineNo">356</span> if (includeDeleteMarker<a name="line.356"></a> -<span class="sourceLineNo">357</span> && mvccVersion <= maxReadPointToTrackVersions) {<a name="line.357"></a> -<span class="sourceLineNo">358</span> this.deletes.add(cell);<a name="line.358"></a> -<span class="sourceLineNo">359</span> }<a name="line.359"></a> -<span class="sourceLineNo">360</span> // Can't early out now, because DelFam come before any other keys<a name="line.360"></a> -<span class="sourceLineNo">361</span> }<a name="line.361"></a> -<span class="sourceLineNo">362</span> <a name="line.362"></a> -<span class="sourceLineNo">363</span> if ((!isUserScan)<a name="line.363"></a> -<span class="sourceLineNo">364</span> && timeToPurgeDeletes > 0<a name="line.364"></a> -<span class="sourceLineNo">365</span> && (EnvironmentEdgeManager.currentTime() - timestamp) <a name="line.365"></a> -<span class="sourceLineNo">366</span> <= timeToPurgeDeletes) {<a name="line.366"></a> -<span class="sourceLineNo">367</span> return MatchCode.INCLUDE;<a name="line.367"></a> -<span class="sourceLineNo">368</span> } else if (retainDeletesInOutput || mvccVersion > maxReadPointToTrackVersions) {<a name="line.368"></a> -<span class="sourceLineNo">369</span> // always include or it is not time yet to check whether it is OK<a name="line.369"></a> -<span class="sourceLineNo">370</span> // to purge deltes or not<a name="line.370"></a> -<span class="sourceLineNo">371</span> if (!isUserScan) {<a name="line.371"></a> -<span class="sourceLineNo">372</span> // if this is not a user scan (compaction), we can filter this deletemarker right here<a name="line.372"></a> -<span class="sourceLineNo">373</span> // otherwise (i.e. a "raw" scan) we fall through to normal version and timerange checking<a name="line.373"></a> -<span class="sourceLineNo">374</span> return MatchCode.INCLUDE;<a name="line.374"></a> -<span class="sourceLineNo">375</span> }<a name="line.375"></a> -<span class="sourceLineNo">376</span> } else if (keepDeletedCells == KeepDeletedCells.TRUE<a name="line.376"></a> -<span class="sourceLineNo">377</span> || (keepDeletedCells == KeepDeletedCells.TTL && timestamp >= ttl)) {<a name="line.377"></a> -<span class="sourceLineNo">378</span> if (timestamp < earliestPutTs) {<a name="line.378"></a> -<span class="sourceLineNo">379</span> // keeping delete rows, but there are no puts older than<a name="line.379"></a> -<span class="sourceLineNo">380</span> // this delete in the store files.<a name="line.380"></a> -<span class="sourceLineNo">381</span> return columns.getNextRowOrNextColumn(cell);<a name="line.381"></a> -<span class="sourceLineNo">382</span> }<a name="line.382"></a> -<span class="sourceLineNo">383</span> // else: fall through and do version counting on the<a name="line.383"></a> -<span class="sourceLineNo">384</span> // delete markers<a name="line.384"></a> -<span class="sourceLineNo">385</span> } else {<a name="line.385"></a> -<span class="sourceLineNo">386</span> return MatchCode.SKIP;<a name="line.386"></a> -<span class="sourceLineNo">387</span> }<a name="line.387"></a> -<span class="sourceLineNo">388</span> // note the following next else if...<a name="line.388"></a> -<span class="sourceLineNo">389</span> // delete marker are not subject to other delete markers<a name="line.389"></a> -<span class="sourceLineNo">390</span> } else if (!this.deletes.isEmpty()) {<a name="line.390"></a> -<span class="sourceLineNo">391</span> DeleteResult deleteResult = deletes.isDeleted(cell);<a name="line.391"></a> -<span class="sourceLineNo">392</span> switch (deleteResult) {<a name="line.392"></a> -<span class="sourceLineNo">393</span> case FAMILY_DELETED:<a name="line.393"></a> -<span class="sourceLineNo">394</span> case COLUMN_DELETED:<a name="line.394"></a> -<span class="sourceLineNo">395</span> return columns.getNextRowOrNextColumn(cell);<a name="line.395"></a> -<span class="sourceLineNo">396</span> case VERSION_DELETED:<a name="line.396"></a> -<span class="sourceLineNo">397</span> case FAMILY_VERSION_DELETED:<a name="line.397"></a> -<span class="sourceLineNo">398</span> return MatchCode.SKIP;<a name="line.398"></a> -<span class="sourceLineNo">399</span> case NOT_DELETED:<a name="line.399"></a> -<span class="sourceLineNo">400</span> break;<a name="line.400"></a> -<span class="sourceLineNo">401</span> default:<a name="line.401"></a> -<span class="sourceLineNo">402</span> throw new RuntimeException("UNEXPECTED");<a name="line.402"></a> -<span class="sourceLineNo">403</span> }<a name="line.403"></a> -<span class="sourceLineNo">404</span> }<a name="line.404"></a> -<span class="sourceLineNo">405</span><a name="line.405"></a> -<span class="sourceLineNo">406</span> int timestampComparison = tr.compare(timestamp);<a name="line.406"></a> -<span class="sourceLineNo">407</span> if (timestampComparison >= 1) {<a name="line.407"></a> -<span class="sourceLineNo">408</span> return MatchCode.SKIP;<a name="line.408"></a> -<span class="sourceLineNo">409</span> } else if (timestampComparison <= -1) {<a name="line.409"></a> -<span class="sourceLineNo">410</span> return columns.getNextRowOrNextColumn(cell);<a name="line.410"></a> -<span class="sourceLineNo">411</span> }<a name="line.411"></a> -<span class="sourceLineNo">412</span><a name="line.412"></a> -<span class="sourceLineNo">413</span> // STEP 1: Check if the column is part of the requested columns<a name="line.413"></a> -<span class="sourceLineNo">414</span> MatchCode colChecker = columns.checkColumn(cell, typeByte);<a name="line.414"></a> -<span class="sourceLineNo">415</span> if (colChecker == MatchCode.INCLUDE) {<a name="line.415"></a> -<span class="sourceLineNo">416</span> ReturnCode filterResponse = ReturnCode.SKIP;<a name="line.416"></a> -<span class="sourceLineNo">417</span> // STEP 2: Yes, the column is part of the requested columns. Check if filter is present<a name="line.417"></a> -<span class="sourceLineNo">418</span> if (filter != null) {<a name="line.418"></a> -<span class="sourceLineNo">419</span> // STEP 3: Filter the key value and return if it filters out<a name="line.419"></a> -<span class="sourceLineNo">420</span> filterResponse = filter.filterKeyValue(cell);<a name="line.420"></a> -<span class="sourceLineNo">421</span> switch (filterResponse) {<a name="line.421"></a> -<span class="sourceLineNo">422</span> case SKIP:<a name="line.422"></a> -<span class="sourceLineNo">423</span> return MatchCode.SKIP;<a name="line.423"></a> -<span class="sourceLineNo">424</span> case NEXT_COL:<a name="line.424"></a> -<span class="sourceLineNo">425</span> return columns.getNextRowOrNextColumn(cell);<a name="line.425"></a> -<span class="sourceLineNo">426</span> case NEXT_ROW:<a name="line.426"></a> -<span class="sourceLineNo">427</span> stickyNextRow = true;<a name="line.427"></a> -<span class="sourceLineNo">428</span> return MatchCode.SEEK_NEXT_ROW;<a name="line.428"></a> -<span class="sourceLineNo">429</span> case SEEK_NEXT_USING_HINT:<a name="line.429"></a> -<span class="sourceLineNo">430</span> return MatchCode.SEEK_NEXT_USING_HINT;<a name="line.430"></a> -<span class="sourceLineNo">431</span> default:<a name="line.431"></a> -<span class="sourceLineNo">432</span> //It means it is either include or include and seek next<a name="line.432"></a> -<span class="sourceLineNo">433</span> break;<a name="line.433"></a> -<span class="sourceLineNo">434</span> }<a name="line.434"></a> -<span class="sourceLineNo">435</span> }<a name="line.435"></a> -<span class="sourceLineNo">436</span> /*<a name="line.436"></a> -<span class="sourceLineNo">437</span> * STEP 4: Reaching this step means the column is part of the requested columns and either<a name="line.437"></a> -<span class="sourceLineNo">438</span> * the filter is null or the filter has returned INCLUDE or INCLUDE_AND_NEXT_COL response.<a name="line.438"></a> -<span class="sourceLineNo">439</span> * Now check the number of versions needed. This method call returns SKIP, INCLUDE,<a name="line.439"></a> -<span class="sourceLineNo">440</span> * INCLUDE_AND_SEEK_NEXT_ROW, INCLUDE_AND_SEEK_NEXT_COL.<a name="line.440"></a> -<span class="sourceLineNo">441</span> *<a name="line.441"></a> -<span class="sourceLineNo">442</span> * FilterResponse ColumnChecker Desired behavior<a name="line.442"></a> -<span class="sourceLineNo">443</span> * INCLUDE SKIP row has already been included, SKIP.<a name="line.443"></a> -<span class="sourceLineNo">444</span> * INCLUDE INCLUDE INCLUDE<a name="line.444"></a> -<span class="sourceLineNo">445</span> * INCLUDE INCLUDE_AND_SEEK_NEXT_COL INCLUDE_AND_SEEK_NEXT_COL<a name="line.445"></a> -<span class="sourceLineNo">446</span> * INCLUDE INCLUDE_AND_SEEK_NEXT_ROW INCLUDE_AND_SEEK_NEXT_ROW<a name="line.446"></a> -<span class="sourceLineNo">447</span> * INCLUDE_AND_SEEK_NEXT_COL SKIP row has already been included, SKIP.<a name="line.447"></a> -<span class="sourceLineNo">448</span> * INCLUDE_AND_SEEK_NEXT_COL INCLUDE INCLUDE_AND_SEEK_NEXT_COL<a name="line.448"></a> -<span class="sourceLineNo">449</span> * INCLUDE_AND_SEEK_NEXT_COL INCLUDE_AND_SEEK_NEXT_COL INCLUDE_AND_SEEK_NEXT_COL<a name="line.449"></a> -<span class="sourceLineNo">450</span> * INCLUDE_AND_SEEK_NEXT_COL INCLUDE_AND_SEEK_NEXT_ROW INCLUDE_AND_SEEK_NEXT_ROW<a name="line.450"></a> -<span class="sourceLineNo">451</span> *<a name="line.451"></a> -<span class="sourceLineNo">452</span> * In all the above scenarios, we return the column checker return value except for<a name="line.452"></a> -<span class="sourceLineNo">453</span> * FilterResponse (INCLUDE_AND_SEEK_NEXT_COL) and ColumnChecker(INCLUDE)<a name="line.453"></a> -<span class="sourceLineNo">454</span> */<a name="line.454"></a> -<span class="sourceLineNo">455</span> colChecker = columns.checkVersions(cell, timestamp, typeByte,<a name="line.455"></a> -<span class="sourceLineNo">456</span> mvccVersion > maxReadPointToTrackVersions);<a name="line.456"></a> -<span class="sourceLineNo">457</span> //Optimize with stickyNextRow<a name="line.457"></a> -<span class="sourceLineNo">458</span> boolean seekNextRowFromEssential = filterResponse == ReturnCode.INCLUDE_AND_SEEK_NEXT_ROW &&<a name="line.458"></a> -<span class="sourceLineNo">459</span> filter.isFamilyEssential(cell.getFamilyArray());<a name="line.459"></a> -<span class="sourceLineNo">460</span> if (colChecker == MatchCode.INCLUDE_AND_SEEK_NEXT_ROW || seekNextRowFromEssential) {<a name="line.460"></a> -<span class="sourceLineNo">461</span> stickyNextRow = true;<a name="line.461"></a> -<span class="sourceLineNo">462</span> }<a name="line.462"></a> -<span class="sourceLineNo">463</span> if (filterResponse == ReturnCode.INCLUDE_AND_SEEK_NEXT_ROW) {<a name="line.463"></a> -<span class="sourceLineNo">464</span> if (colChecker != MatchCode.SKIP) {<a name="line.464"></a> -<span class="sourceLineNo">465</span> return MatchCode.INCLUDE_AND_SEEK_NEXT_ROW;<a name="line.465"></a> -<span class="sourceLineNo">466</span> }<a name="line.466"></a> -<span class="sourceLineNo">467</span> return MatchCode.SEEK_NEXT_ROW;<a name="line.467"></a> -<span class="sourceLineNo">468</span> }<a name="line.468"></a> -<span class="sourceLineNo">469</span> return (filterResponse == ReturnCode.INCLUDE_AND_NEXT_COL &&<a name="line.469"></a> -<span class="sourceLineNo">470</span> colChecker == MatchCode.INCLUDE) ? MatchCode.INCLUDE_AND_SEEK_NEXT_COL<a name="line.470"></a> -<span class="sourceLineNo">471</span> : colChecker;<a name="line.471"></a> -<span class="sourceLineNo">472</span> }<a name="line.472"></a> -<span class="sourceLineNo">473</span> stickyNextRow = (colChecker == MatchCode.SEEK_NEXT_ROW) ? true<a name="line.473"></a> -<span class="sourceLineNo">474</span> : stickyNextRow;<a name="line.474"></a> -<span class="sourceLineNo">475</span> return colChecker;<a name="line.475"></a> -<span class="sourceLineNo">476</span> }<a name="line.476"></a> -<span class="sourceLineNo">477</span><a name="line.477"></a> -<span class="sourceLineNo">478</span> /** Handle partial-drop-deletes. As we match keys in order, when we have a range from which<a name="line.478"></a> -<span class="sourceLineNo">479</span> * we can drop deletes, we can set retainDeletesInOutput to false for the duration of this<a name="line.479"></a> -<span class="sourceLineNo">480</span> * range only, and maintain consistency. */<a name="line.480"></a> -<span class="sourceLineNo">481</span> private void checkPartialDropDeleteRange(Cell curCell) {<a name="line.481"></a> -<span class="sourceLineNo">482</span> // If partial-drop-deletes are used, initially, dropDeletesFromRow and dropDeletesToRow<a name="line.482"></a> -<span class="sourceLineNo">483</span> // are both set, and the matcher is set to retain deletes. We assume ordered keys. When<a name="line.483"></a> -<span class="sourceLineNo">484</span> // dropDeletesFromRow is leq current kv, we start dropping deletes and reset<a name="line.484"></a> -<span class="sourceLineNo">485</span> // dropDeletesFromRow; thus the 2nd "if" starts to apply.<a name="line.485"></a> -<span class="sourceLineNo">486</span> if ((dropDeletesFromRow != null)<a name="line.486"></a> -<span class="sourceLineNo">487</span> && (Arrays.equals(dropDeletesFromRow, HConstants.EMPTY_START_ROW) ||<a name="line.487"></a> -<span class="sourceLineNo">488</span> (CellComparator.COMPARATOR.compareRows(curCell, dropDeletesFromRow, 0,<a name="line.488"></a> -<span class="sourceLineNo">489</span> dropDeletesFromRow.length) >= 0))) {<a name="line.489"></a> -<span class="sourceLineNo">490</span> retainDeletesInOutput = false;<a name="line.490"></a> -<span class="sourceLineNo">491</span> dropDeletesFromRow = null;<a name="line.491"></a> -<span class="sourceLineNo">492</span> }<a name="line.492"></a> -<span class="sourceLineNo">493</span> // If dropDeletesFromRow is null and dropDeletesToRow is set, we are inside the partial-<a name="line.493"></a> -<span class="sourceLineNo">494</span> // drop-deletes range. When dropDeletesToRow is leq current kv, we stop dropping deletes,<a name="line.494"></a> -<span class="sourceLineNo">495</span> // and reset dropDeletesToRow so that we don't do any more compares.<a name="line.495"></a> -<span class="sourceLineNo">496</span> if ((dropDeletesFromRow == null)<a name="line.496"></a> -<span class="sourceLineNo">497</span> && (dropDeletesToRow != null)<a name="line.497"></a> -<span class="sourceLineNo">498</span> && !Arrays.equals(dropDeletesToRow, HConstants.EMPTY_END_ROW)<a name="line.498"></a> -<span class="sourceLineNo">499</span> && (CellComparator.COMPARATOR<a name="line.499"></a> -<span class="sourceLineNo">500</span> .compareRows(curCell, dropDeletesToRow, 0, dropDeletesToRow.length) >= 0)) {<a name="line.500"></a> -<span class="sourceLineNo">501</span> retainDeletesInOutput = true;<a name="line.501"></a> -<span class="sourceLineNo">502</span> dropDeletesToRow = null;<a name="line.502"></a> -<span class="sourceLineNo">503</span> }<a name="line.503"></a> -<span class="sourceLineNo">504</span> }<a name="line.504"></a> -<span class="sourceLineNo">505</span><a name="line.505"></a> -<span class="sourceLineNo">506</span> public boolean moreRowsMayExistAfter(Cell kv) {<a name="line.506"></a> -<span class="sourceLineNo">507</span> if (this.isReversed) {<a name="line.507"></a> -<span class="sourceLineNo">508</span> if (rowComparator.compareRows(kv, stopRow, 0, stopRow.length) <= 0) {<a name="line.508"></a> -<span class="sourceLineNo">509</span> return false;<a name="line.509"></a> -<span class="sourceLineNo">510</span> } else {<a name="line.510"></a> -<span class="sourceLineNo">511</span> return true;<a name="line.511"></a> -<span class="sourceLineNo">512</span> }<a name="line.512"></a> -<span class="sourceLineNo">513</span> }<a name="line.513"></a> -<span class="sourceLineNo">514</span> if (!Bytes.equals(stopRow , HConstants.EMPTY_END_ROW) &&<a name="line.514"></a> -<span class="sourceLineNo">515</span> rowComparator.compareRows(kv, stopRow, 0, stopRow.length) >= 0) {<a name="line.515"></a> -<span class="sourceLineNo">516</span> // KV >= STOPROW<a name="line.516"></a> -<span class="sourceLineNo">517</span> // then NO there is nothing left.<a name="line.517"></a> -<span class="sourceLineNo">518</span> return false;<a name="line.518"></a> -<span class="sourceLineNo">519</span> } else {<a name="line.519"></a> -<span class="sourceLineNo">520</span> return true;<a name="line.520"></a> -<span class="sourceLineNo">521</span> }<a name="line.521"></a> -<span class="sourceLineNo">522</span> }<a name="line.522"></a> -<span class="sourceLineNo">523</span><a name="line.523"></a> -<span class="sourceLineNo">524</span> /**<a name="line.524"></a> -<span class="sourceLineNo">525</span> * Set the row when there is change in row<a name="line.525"></a> -<span class="sourceLineNo">526</span> * @param curCell<a name="line.526"></a> -<span class="sourceLineNo">527</span> */<a name="line.527"></a> -<span class="sourceLineNo">528</span> public void setToNewRow(Cell curCell) {<a name="line.528"></a> -<span class="sourceLineNo">529</span> checkPartialDropDeleteRange(curCell);<a name="line.529"></a> -<span class="sourceLineNo">530</span> this.curCell = curCell;<a name="line.530"></a> -<span class="sourceLineNo">531</span> reset();<a name="line.531"></a> -<span class="sourceLineNo">532</span> }<a name="line.532"></a> -<span class="sourceLineNo">533</span><a name="line.533"></a> -<span class="sourceLineNo">534</span> public void reset() {<a name="line.534"></a> -<span class="sourceLineNo">535</span> this.deletes.reset();<a name="line.535"></a> -<span class="sourceLineNo">536</span> this.columns.reset();<a name="line.536"></a> -<span class="sourceLineNo">537</span><a name="line.537"></a> -<span class="sourceLineNo">538</span> stickyNextRow = false;<a name="line.538"></a> -<span class="sourceLineNo">539</span> }<a name="line.539"></a> -<span class="sourceLineNo">540</span><a name="line.540"></a> -<span class="sourceLineNo">541</span> /**<a name="line.541"></a> -<span class="sourceLineNo">542</span> *<a name="line.542"></a> -<span class="sourceLineNo">543</span> * @return the start key<a name="line.543"></a> -<span class="sourceLineNo">544</span> */<a name="line.544"></a> -<span class="sourceLineNo">545</span> public Cell getStartKey() {<a name="line.545"></a> -<span class="sourceLineNo">546</span> return this.startKey;<a name="line.546"></a> -<span class="sourceLineNo">547</span> }<a name="line.547"></a> -<span class="sourceLineNo">548</span><a name="line.548"></a> -<span class="sourceLineNo">549</span> /**<a name="line.549"></a> -<span class="sourceLineNo">550</span> *<a name="line.550"></a> -<span class="sourceLineNo">551</span> * @return the Filter<a name="line.551"></a> -<span class="sourceLineNo">552</span> */<a name="line.552"></a> -<span class="sourceLineNo">553</span> Filter getFilter() {<a name="line.553"></a> -<span class="sourceLineNo">554</span> return this.filter;<a name="line.554"></a> -<span class="sourceLineNo">555</span> }<a name="line.555"></a> -<span class="sourceLineNo">556</span><a name="line.556"></a> -<span class="sourceLineNo">557</span> public Cell getNextKeyHint(Cell kv) throws IOException {<a name="line.557"></a> -<span class="sourceLineNo">558</span> if (filter == null) {<a name="line.558"></a> -<span class="sourceLineNo">559</span> return null;<a name="line.559"></a> -<span class="sourceLineNo">560</span> } else {<a name="line.560"></a> -<span class="sourceLineNo">561</span> return filter.getNextCellHint(kv);<a name="line.561"></a> -<span class="sourceLineNo">562</span> }<a name="line.562"></a> -<span class="sourceLineNo">563</span> }<a name="line.563"></a> -<span class="sourceLineNo">564</span><a name="line.564"></a> -<span class="sourceLineNo">565</span> public Cell getKeyForNextColumn(Cell kv) {<a name="line.565"></a> -<span class="sourceLineNo">566</span> ColumnCount nextColumn = columns.getColumnHint();<a name="line.566"></a> -<span class="sourceLineNo">567</span> if (nextColumn == null) {<a name="line.567"></a> -<span class="sourceLineNo">568</span> return CellUtil.createLastOnRowCol(kv);<a name="line.568"></a> -<span class="sourceLineNo">569</span> } else {<a name="line.569"></a> -<span class="sourceLineNo">570</span> return CellUtil.createFirstOnRowCol(kv, nextColumn.getBuffer(), nextColumn.getOffset(),<a name="line.570"></a> -<span class="sourceLineNo">571</span> nextColumn.getLength());<a name="line.571"></a> -<span class="sourceLineNo">572</span> }<a name="line.572"></a> -<span class="sourceLineNo">573</span> }<a name="line.573"></a> -<span class="sourceLineNo">574</span><a name="line.574"></a> -<span class="sourceLineNo">575</span> public Cell getKeyForNextRow(Cell c) {<a name="line.575"></a> -<span class="sourceLineNo">576</span> return CellUtil.createLastOnRow(c);<a name="line.576"></a> -<span class="sourceLineNo">577</span> }<a name="line.577"></a> -<span class="sourceLineNo">578</span><a name="line.578"></a> -<span class="sourceLineNo">579</span> /**<a name="line.579"></a> -<span class="sourceLineNo">580</span> * @param nextIndexed the key of the next entry in the block index (if any)<a name="line.580"></a> -<span class="sourceLineNo">581</span> * @param kv The Cell we're using to calculate the seek key<a name="line.581"></a> -<span class="sourceLineNo">582</span> * @return result of the compare between the indexed key and the key portion of the passed cell<a name="line.582"></a> -<span class="sourceLineNo">583</span> */<a name="line.583"></a> -<span class="sourceLineNo">584</span> public int compareKeyForNextRow(Cell nextIndexed, Cell kv) {<a name="line.584"></a> -<span class="sourceLineNo">585</span> return rowComparator.compareKeyBasedOnColHint(nextIndexed, kv, 0, 0, null, 0, 0,<a name="line.585"></a> -<span class="sourceLineNo">586</span> HConstants.OLDEST_TIMESTAMP, Type.Minimum.getCode());<a name="line.586"></a> -<span class="sourceLineNo">587</span> }<a name="line.587"></a> -<span class="sourceLineNo">588</span><a name="line.588"></a> -<span class="sourceLineNo">589</span> /**<a name="line.589"></a> -<span class="sourceLineNo">590</span> * @param nextIndexed the key of the next entry in the block index (if any)<a name="line.590"></a> -<span class="sourceLineNo">591</span> * @param currentCell The Cell we're using to calculate the seek key<a name="line.591"></a> -<span class="sourceLineNo">592</span> * @return result of the compare between the indexed key and the key portion of the passed cell<a name="line.592"></a> -<span class="sourceLineNo">593</span> */<a name="line.593"></a> -<span class="sourceLineNo">594</span> public int compareKeyForNextColumn(Cell nextIndexed, Cell currentCell) {<a name="line.594"></a> -<span class="sourceLineNo">595</span> ColumnCount nextColumn = columns.getColumnHint();<a name="line.595"></a> -<span class="sourceLineNo">596</span> if (nextColumn == null) {<a name="line.596"></a> -<span class="sourceLineNo">597</span> return rowComparator.compareKeyBasedOnColHint(nextIndexed, currentCell, 0, 0, null, 0, 0,<a name="line.597"></a> -<span class="sourceLineNo">598</span> HConstants.OLDEST_TIMESTAMP, Type.Minimum.getCode());<a name="line.598"></a> -<span class="sourceLineNo">599</span> } else {<a name="line.599"></a> -<span class="sourceLineNo">600</span> return rowComparator.compareKeyBasedOnColHint(nextIndexed, currentCell,<a name="line.600"></a> -<span class="sourceLineNo">601</span> currentCell.getFamilyOffset(), currentCell.getFamilyLength(), nextColumn.getBuffer(),<a name="line.601"></a> -<span class="sourceLineNo">602</span> nextColumn.getOffset(), nextColumn.getLength(), HConstants.LATEST_TIMESTAMP,<a name="line.602"></a> -<span class="sourceLineNo">603</span> Type.Maximum.getCode());<a name="line.603"></a> -<span class="sourceLineNo">604</span> }<a name="line.604"></a> -<span class="sourceLineNo">605</span> }<a name="line.605"></a> -<span class="sourceLineNo">606</span><a name="line.606"></a> -<span class="sourceLineNo">607</span> //Used only for testing purposes<a name="line.607"></a> -<span class="sourceLineNo">608</span> static MatchCode checkColumn(ColumnTracker columnTracker, byte[] bytes, int offset,<a name="line.608"></a> -<span class="sourceLineNo">609</span> int length, long ttl, byte type, boolean ignoreCount) throws IOException {<a name="line.609"></a> -<span class="sourceLineNo">610</span> KeyValue kv = KeyValueUtil.createFirstOnRow(HConstants.EMPTY_BYTE_ARRAY, 0, 0,<a name="line.610"></a> -<span class="sourceLineNo">611</span> HConstants.EMPTY_BYTE_ARRAY, 0, 0, bytes, offset, length);<a name="line.611"></a> -<span class="sourceLineNo">612</span> MatchCode matchCode = columnTracker.checkColumn(kv, type);<a name="line.612"></a> -<span class="sourceLineNo">613</span> if (matchCode == MatchCode.INCLUDE) {<a name="line.613"></a> -<span class="sourceLineNo">614</span> return columnTracker.checkVersions(kv, ttl, type, ignoreCount);<a name="line.614"></a> -<span class="sourceLineNo">615</span> }<a name="line.615"></a> -<span class="sourceLineNo">616</span> return matchCode;<a name="line.616"></a> -<span class="sourceLineNo">617</span> }<a name="line.617"></a> -<span class="sourceLineNo">618</span><a name="line.618"></a> -<span class="sourceLineNo">619</span> /**<a name="line.619"></a> -<span class="sourceLineNo">620</span> * {@link #match} return codes. These instruct the scanner moving through<a name="line.620"></a> -<span class="sourceLineNo">621</span> * memstores and StoreFiles what to do with the current KeyValue.<a name="line.621"></a> -<span class="sourceLineNo">622</span> * <p><a name="line.622"></a> -<span class="sourceLineNo">623</span> * Additionally, this contains "early-out" language to tell the scanner to<a name="line.623"></a> -<span class="sourceLineNo">624</span> * move on to the next File (memstore or Storefile), or to return immediately.<a name="line.624"></a> -<span class="sourceLineNo">625</span> */<a name="line.625"></a> -<span class="sourceLineNo">626</span> public static enum MatchCode {<a name="line.626"></a> -<span class="sourceLineNo">627</span> /**<a name="line.627"></a> -<span class="sourceLineNo">628</span> * Include KeyValue in the returned result<a name="line.628"></a> -<span class="sourceLineNo">629</span> */<a name="line.629"></a> -<span class="sourceLineNo">630</span> INCLUDE,<a name="line.630"></a> -<span class="sourceLineNo">631</span><a name="line.631"></a> -<span class="sourceLineNo">632</span> /**<a name="line.632"></a> -<span class="sourceLineNo">633</span> * Do not include KeyValue in the returned result<a name="line.633"></a> -<span class="sourceLineNo">634</span> */<a name="line.634"></a> -<span class="sourceLineNo">635</span> SKIP,<a name="line.635"></a> -<span class="sourceLineNo">636</span><a name="line.636"></a> -<span class="sourceLineNo">637</span> /**<a name="line.637"></a> -<span class="sourceLineNo">638</span> * Do not include, jump to next StoreFile or memstore (in time order)<a name="line.638"></a> -<span class="sourceLineNo">639</span> */<a name="line.639"></a> -<span class="sourceLineNo">640</span> NEXT,<a name="line.640"></a> -<span class="sourceLineNo">641</span><a name="line.641"></a> -<span class="sourceLineNo">642</span> /**<a name="line.642"></a> -<span class="sourceLineNo">643</span> * Do not include, return current result<a name="line.643"></a> -<span class="sourceLineNo">644</span> */<a name="line.644"></a> -<span class="sourceLineNo">645</span> DONE,<a name="line.645"></a> -<span class="sourceLineNo">646</span><a name="line.646"></a> -<span class="sourceLineNo">647</span> /**<a name="line.647"></a> -<span class="sourceLineNo">648</span> * These codes are used by the ScanQueryMatcher<a name="line.648"></a> -<span class="sourceLineNo">649</span> */<a name="line.649"></a> -<span class="sourceLineNo">650</span><a name="line.650"></a> -<span class="sourceLineNo">651</span> /**<a name="line.651"></a> -<span class="sourceLineNo">652</span> * Done with the row, seek there.<a name="line.652"></a> -<span class="sourceLineNo">653</span> */<a name="line.653"></a> -<span class="sourceLineNo">654</span> SEEK_NEXT_ROW,<a name="line.654"></a> -<span class="sourceLineNo">655</span> /**<a name="line.655"></a> -<span class="sourceLineNo">656</span> * Done with column, seek to next.<a name="line.656"></a> -<span class="sourceLineNo">657</span> */<a name="line.657"></a> -<span class="sourceLineNo">658</span> SEEK_NEXT_COL,<a name="line.658"></a> -<span class="sourceLineNo">659</span><a name="line.659"></a> -<span class="sourceLineNo">660</span> /**<a name="line.660"></a> -<span class="sourceLineNo">661</span> * Done with scan, thanks to the row filter.<a name="line.661"></a> -<span class="sourceLineNo">662</span> */<a name="line.662"></a> -<span class="sourceLineNo">663</span> DONE_SCAN,<a name="line.663"></a> -<span class="sourceLineNo">664</span><a name="line.664"></a> -<span class="sourceLineNo">665</span> /*<a name="line.665"></a> -<span class="sourceLineNo">666</span> * Seek to next key which is given as hint.<a name="line.666"></a> -<span class="sourceLineNo">667</span> */<a name="line.667"></a> -<span class="sourceLineNo">668</span> SEEK_NEXT_USING_HINT,<a name="line.668"></a> -<span class="sourceLineNo">669</span><a name="line.669"></a> -<span class="sourceLineNo">670</span> /**<a name="line.670"></a> -<span class="sourceLineNo">671</span> * Include KeyValue and done with column, seek to next.<a name="line.671"></a> -<span class="sourceLineNo">672</span> */<a name="line.672"></a> -<span class="sourceLineNo">673</span> INCLUDE_AND_SEEK_NEXT_COL,<a name="line.673"></a> -<span class="sourceLineNo">674</span><a name="line.674"></a> -<span class="sourceLineNo">675</span> /**<a name="line.675"></a> -<span class="sourceLineNo">676</span> * Include KeyValue and done with row, seek to next.<a name="line.676"></a> -<span class="sourceLineNo">677</span> */<a name="line.677"></a> -<span class="sourceLineNo">678</span> INCLUDE_AND_SEEK_NEXT_ROW,<a name="line.678"></a> -<span class="sourceLineNo">679</span> }<a name="line.679"></a> -<span class="sourceLineNo">680</span>}<a name="line.680"></a> +<span class="sourceLineNo">169</span> this.get = scan.isGetScan();<a name="line.169"></a> +<span class="sourceLineNo">170</span> this.rowComparator = scanInfo.getComparator();<a name="line.170"></a> +<span class="sourceLineNo">171</span> this.regionCoprocessorHost = regionCoprocessorHost;<a name="line.171"></a> +<span class="sourceLineNo">172</span> this.deletes = instantiateDeleteTracker();<a name="line.172"></a> +<span class="sourceLineNo">173</span> this.stopRow = scan.getStopRow();<a name="line.173"></a> +<span class="sourceLineNo">174</span> this.startKey = CellUtil.createFirstDeleteFamilyCellOnRow(scan.getStartRow(),<a name="line.174"></a> +<span class="sourceLineNo">175</span> scanInfo.getFamily());<a name="line.175"></a> +<span class="sourceLineNo">176</span> this.filter = scan.getFilter();<a name="line.176"></a> +<span class="sourceLineNo">177</span> this.earliestPutTs = earliestPutTs;<a name="line.177"></a> +<span class="sourceLineNo">178</span> this.oldestUnexpiredTS = oldestUnexpiredTS;<a name="line.178"></a> +<span class="sourceLineNo">179</span> this.now = now;<a name="line.179"></a> +<span class="sourceLineNo">180</span><a name="line.180"></a> +<span class="sourceLineNo">181</span> this.maxReadPointToTrackVersions = readPointToUse;<a name="line.181"></a> +<span class="sourceLineNo">182</span> this.timeToPurgeDeletes = scanInfo.getTimeToPurgeDeletes();<a name="line.182"></a> +<span class="sourceLineNo">183</span> this.ttl = oldestUnexpiredTS;<a name="line.183"></a> +<span class="sourceLineNo">184</span><a name="line.184"></a> +<span class="sourceLineNo">185</span> /* how to deal with deletes */<a name="line.185"></a> +<span class="sourceLineNo">186</span> this.isUserScan = scanType == ScanType.USER_SCAN;<a name="line.186"></a> +<span class="sourceLineNo">187</span> // keep deleted cells: if compaction or raw scan<a name="line.187"></a> +<span class="sourceLineNo">188</span> this.keepDeletedCells = scan.isRaw() ? KeepDeletedCells.TRUE :<a name="line.188"></a> +<span class="sourceLineNo">189</span> isUserScan ? KeepDeletedCells.FALSE : scanInfo.getKeepDeletedCells();<a name="line.189"></a> +<span class="sourceLineNo">190</span> // retain deletes: if minor compaction or raw scanisDone<a name="line.190"></a> +<span class="sourceLineNo">191</span> this.retainDeletesInOutput = scanType == ScanType.COMPACT_RETAIN_DELETES || scan.isRaw();<a name="line.191"></a> +<span class="sourceLineNo">192</span> // seePastDeleteMarker: user initiated scans<a name="line.192"></a> +<span class="sourceLineNo">193</span> this.seePastDeleteMarkers =<a name="line.193"></a> +<span class="sourceLineNo">194</span> scanInfo.getKeepDeletedCells() != KeepDeletedCells.FALSE && isUserScan;<a name="line.194"></a> +<span class="sourceLineNo">195</span><a name="line.195"></a> +<span class="sourceLineNo">196</span> int maxVersions =<a name="line.196"></a> +<span class="sourceLineNo">197</span> scan.isRaw() ? scan.getMaxVersions() : Math.min(scan.getMaxVersions(),<a name="line.197"></a> +<span class="sourceLineNo">198</span> scanInfo.getMaxVersions());<a name="line.198"></a> +<span class="sourceLineNo">199</span><a name="line.199"></a> +<span class="sourceLineNo">200</span> // Single branch to deal with two types of reads (columns vs all in family)<a name="line.200"></a> +<span class="sourceLineNo">201</span> if (columns == null || columns.size() == 0) {<a name="line.201"></a> +<span class="sourceLineNo">202</span> // there is always a null column in the wildcard column query.<a name="line.202"></a> +<span class="sourceLineNo">203</span> hasNullColumn = true;<a name="line.203"></a> +<span class="sourceLineNo">204</span><a name="line.204"></a> +<span class="sourceLineNo">205</span> // use a specialized scan for wildcard column tracker.<a name="line.205"></a> +<span class="sourceLineNo">206</span> this.columns = new ScanWildcardColumnTracker(<a name="line.206"></a> +<span class="sourceLineNo">207</span> scanInfo.getMinVersions(), maxVersions, oldestUnexpiredTS);<a name="line.207"></a> +<span class="sourceLineNo">208</span> } else {<a name="line.208"></a> +<span class="sourceLineNo">209</span> // whether there is null column in the explicit column query<a name="line.209"></a> +<span class="sourceLineNo">210</span> hasNullColumn = (columns.first().length == 0);<a name="line.210"></a> +<span class="sourceLineNo">211</span><a name="line.211"></a> +<span class="sourceLineNo">212</span> // We can share the ExplicitColumnTracker, diff is we reset<a name="line.212"></a> +<span class="sourceLineNo">213</span> // between rows, not between storefiles.<a name="line.213"></a> +<span class="sourceLineNo">214</span> this.columns = new ExplicitColumnTracker(columns, scanInfo.getMinVersions(), maxVersions,<a name="line.214"></a> +<span class="sourceLineNo">215</span> oldestUnexpiredTS);<a name="line.215"></a> +<span class="sourceLineNo">216</span> }<a name="line.216"></a> +<span class="sourceLineNo">217</span> this.isReversed = scan.isReversed();<a name="line.217"></a> +<span class="sourceLineNo">218</span> }<a name="line.218"></a> +<span class="sourceLineNo">219</span><a name="line.219"></a> +<span class="sourceLineNo">220</span> private DeleteTracker instantiateDeleteTracker() throws IOException {<a name="line.220"></a> +<span class="sourceLineNo">221</span> DeleteTracker tracker = new ScanDeleteTracker();<a name="line.221"></a> +<span class="sourceLineNo">222</span> if (regionCoprocessorHost != null) {<a name="line.222"></a> +<span class="sourceLineNo">223</span> tracker = regionCoprocessorHost.postInstantiateDeleteTracker(tracker);<a name="line.223"></a> +<span class="sourceLineNo">224</span> }<a name="line.224"></a> +<span class="sourceLineNo">225</span> return tracker;<a name="line.225"></a> +<span class="sourceLineNo">226</span> }<a name="line.226"></a> +<span class="sourceLineNo">227</span><a name="line.227"></a> +<span class="sourceLineNo">228</span> /**<a name="line.228"></a> +<span class="sourceLineNo">229</span> * Construct a QueryMatcher for a scan that drop deletes from a limited range of rows.<a name="line.229"></a> +<span class="sourceLineNo">230</span> * @param scan<a name="line.230"></a> +<span class="sourceLineNo">231</span> * @param scanInfo The store's immutable scan info<a name="line.231"></a> +<span class="sourceLineNo">232</span> * @param columns<a name="line.232"></a> +<span class="sourceLineNo">233</span> * @param earliestPutTs Earliest put seen in any of the store files.<a name="line.233"></a> +<span class="sourceLineNo">234</span> * @param oldestUnexpiredTS the oldest timestamp we are interested in, based on TTL<a name="line.234"></a> +<span class="sourceLineNo">235</span> * @param now the current server time<a name="line.235"></a> +<span class="sourceLineNo">236</span> * @param dropDeletesFromRow The inclusive left bound of the range; can be EMPTY_START_ROW.<a name="line.236"></a> +<span class="sourceLineNo">237</span> * @param dropDeletesToRow The exclusive right bound of the range; can be EMPTY_END_ROW.<a name="line.237"></a> +<span class="sourceLineNo">238</span> * @param regionCoprocessorHost<a name="line.238"></a> +<span class="sourceLineNo">239</span> * @throws IOException<a name="line.239"></a> +<span class="sourceLineNo">240</span> */<a name="line.240"></a> +<span class="sourceLineNo">241</span> public ScanQueryMatcher(Scan scan, ScanInfo scanInfo, NavigableSet<byte[]> columns,<a name="line.241"></a> +<span class="sourceLineNo">242</span> long readPointToUse, long earliestPutTs, long oldestUnexpiredTS, long now,<a name="line.242"></a> +<span class="sourceLineNo">243</span> byte[] dropDeletesFromRow, byte[] dropDeletesToRow,<a name="line.243"></a> +<span class="sourceLineNo">244</span> RegionCoprocessorHost regionCoprocessorHost) throws IOException {<a name="line.244"></a> +<span class="sourceLineNo">245</span> this(scan, scanInfo, columns, ScanType.COMPACT_RETAIN_DELETES, readPointToUse, earliestPutTs,<a name="line.245"></a> +<span class="sourceLineNo">246</span> oldestUnexpiredTS, now, regionCoprocessorHost);<a name="line.246"></a> +<span class="sourceLineNo">247</span> Preconditions.checkArgument((dropDeletesFromRow != null) && (dropDeletesToRow != null));<a name="line.247"></a> +<span class="sourceLineNo">248</span> this.dropDeletesFromRow = dropDeletesFromRow;<a name="line.248"></a> +<span class="sourceLineNo">249</span> this.dropDeletesToRow = dropDeletesToRow;<a name="line.249"></a> +<span class="sourceLineNo">250</span> }<a name="line.250"></a> +<span class="sourceLineNo">251</span><a name="line.251"></a> +<span class="sourceLineNo">252</span> /*<a name="line.252"></a> +<span class="sourceLineNo">253</span> * Constructor for tests<a name="line.253"></a> +<span class="sourceLineNo">254</span> */<a name="line.254"></a> +<span class="sourceLineNo">255</span> ScanQueryMatcher(Scan scan, ScanInfo scanInfo,<a name="line.255"></a> +<span class="sourceLineNo">256</span> NavigableSet<byte[]> columns, long oldestUnexpiredTS, long now) throws IOException {<a name="line.256"></a> +<span class="sourceLineNo">257</span> this(scan, scanInfo, columns, ScanType.USER_SCAN,<a name="line.257"></a> +<span class="sourceLineNo">258</span> Long.MAX_VALUE, /* max Readpoint to track versions */<a name="line.258"></a> +<span class="sourceLineNo">259</span> HConstants.LATEST_TIMESTAMP, oldestUnexpiredTS, now, null);<a name="line.259"></a> +<span class="sourceLineNo">260</span> }<a name="line.260"></a> +<span class="sourceLineNo">261</span><a name="line.261"></a> +<span class="sourceLineNo">262</span> /**<a name="line.262"></a> +<span class="sourceLineNo">263</span> *<a name="line.263"></a> +<span class="sourceLineNo">264</span> * @return whether there is an null column in the query<a name="line.264"></a> +<span class="sourceLineNo">265</span> */<a name="line.265"></a> +<span class="sourceLineNo">266</span> public boolean hasNullColumnInQuery() {<a name="line.266"></a> +<span class="sourceLineNo">267</span> return hasNullColumn;<a name="line.267"></a> +<span class="sourceLineNo">268</span> }<a name="line.268"></a> +<span class="sourceLineNo">269</span><a name="line.269"></a> +<span class="sourceLineNo">270</span> /**<a name="line.270"></a> +<span class="sourceLineNo">271</span> * Determines if the caller should do one of several things:<a name="line.271"></a> +<span class="sourceLineNo">272</span> * - seek/skip to the next row (MatchCode.SEEK_NEXT_ROW)<a name="line.272"></a> +<span class="sourceLineNo">273</span> * - seek/skip to the next column (MatchCode.SEEK_NEXT_COL)<a name="line.273"></a> +<span class="sourceLineNo">274</span> * - include the current KeyValue (MatchCode.INCLUDE)<a name="line.274"></a> +<span class="sourceLineNo">275</span> * - ignore the current KeyValue (MatchCode.SKIP)<a name="line.275"></a> +<span class="sourceLineNo">276</span> * - got to the next row (MatchCode.DONE)<a name="line.276"></a> +<span class="sourceLineNo">277</span> *<a name="line.277"></a> +<span class="sourceLineNo">278</span> * @param cell KeyValue to check<a name="line.278"></a> +<span class="sourceLineNo">279</span> * @return The match code instance.<a name="line.279"></a> +<span class="sourceLineNo">280</span> * @throws IOException in case there is an internal consistency problem<a name="line.280"></a> +<span class="sourceLineNo">281</span> * caused by a data corruption.<a name="line.281"></a> +<span class="sourceLineNo">282</span> */<a name="line.282"></a> +<span class="sourceLineNo">283</span> public MatchCode match(Cell cell) throws IOException {<a name="line.283"></a> +<span class="sourceLineNo">284</span> if (filter != null && filter.filterAllRemaining()) {<a name="line.284"></a> +<span class="sourceLineNo">285</span> return MatchCode.DONE_SCAN;<a name="line.285"></a> +<span class="sourceLineNo">286</span> }<a name="line.286"></a> +<span class="sourceLineNo">287</span> if (curCell != null) {<a name="line.287"></a> +<span class="sourceLineNo">288</span> int ret = this.rowComparator.compareRows(curCell, cell);<a name="line.288"></a> +<span class="sourceLineNo">289</span> if (!this.isReversed) {<a name="line.289"></a> +<span class="sourceLineNo">290</span> if (ret <= -1) {<a name="line.290"></a> +<span class="sourceLineNo">291</span> return MatchCode.DONE;<a name="line.291"></a> +<span class="sourceLineNo">292</span> } else if (ret >= 1) {<a name="line.292"></a> +<span class="sourceLineNo">293</span> // could optimize this, if necessary?<a name="line.293"></a> +<span class="sourceLineNo">294</span> // Could also be called SEEK_TO_CURRENT_ROW, but this<a name="line.294"></a> +<span class="sourceLineNo">295</span> // should be rare/never happens.<a name="line.295"></a> +<span class="sourceLineNo">296</span> return MatchCode.SEEK_NEXT_ROW;<a name="line.296"></a> +<span class="sourceLineNo">297</span> }<a name="line.297"></a> +<span class="sourceLineNo">298</span> } else {<a name="line.298"></a> +<span class="sourceLineNo">299</span> if (ret <= -1) {<a name="line.299"></a> +<span class="sourceLineNo">300</span> return MatchCode.SEEK_NEXT_ROW;<a name="line.300"></a> +<span class="sourceLineNo">301</span> } else if (ret >= 1) {<a name="line.301"></a> +<span class="sourceLineNo">302</span> return MatchCode.DONE;<a name="line.302"></a> +<span class="sourceLineNo">303</span> }<a name="line.303"></a> +<span class="sourceLineNo">304</span> }<a name="line.304"></a> +<span class="sourceLineNo">305</span> } else {<a name="line.305"></a> +<span class="sourceLineNo">306</span> // Since the curCell is null it means we are already sure that we have moved over to the next row<a name="line.306"></a> +<span class="sourceLineNo">307</span> return MatchCode.DONE;<a name="line.307"></a> +<span class="sourceLineNo">308</span> }<a name="line.308"></a> +<span class="sourceLineNo">309</span><a name="line.309"></a> +<span class="sourceLineNo">310</span> // optimize case.<a name="line.310"></a> +<span class="sourceLineNo">311</span> if (this.stickyNextRow) {<a name="line.311"></a> +<span class="sourceLineNo">312</span> return MatchCode.SEEK_NEXT_ROW;<a name="line.312"></a> +<span class="sourceLineNo">313</span> }<a name="line.313"></a> +<span class="sourceLineNo">314</span><a name="line.314"></a> +<span class="sourceLineNo">315</span> if (this.columns.done()) {<a name="line.315"></a> +<span class="sourceLineNo">316</span> stickyNextRow = true;<a name="line.316"></a> +<span class="sourceLineNo">317</span> return MatchCode.SEEK_NEXT_ROW;<a name="line.317"></a> +<span class="sourceLineNo">318</span> }<a name="line.318"></a> +<span class="sourceLineNo">319</span><a name="line.319"></a> +<span class="sourceLineNo">320</span> long timestamp = cell.getTimestamp();<a name="line.320"></a> +<span class="sourceLineNo">321</span> // check for early out based on timestamp alone<a name="line.321"></a> +<span class="sourceLineNo">322</span> if (columns.isDone(timestamp)) {<a name="line.322"></a> +<span class="sourceLineNo">323</span> return columns.getNextRowOrNextColumn(cell);<a name="line.323"></a> +<span class="sourceLineNo">324</span> }<a name="line.324"></a> +<span class="sourceLineNo">325</span> // check if the cell is expired by cell TTL<a name="line.325"></a> +<span class="sourceLineNo">326</span> if (HStore.isCellTTLExpired(cell, this.oldestUnexpiredTS, this.now)) {<a name="line.326"></a> +<span class="sourceLineNo">327</span> return MatchCode.SKIP;<a name="line.327"></a> +<span class="sourceLineNo">328</span> }<a name="line.328"></a> +<span class="sourceLineNo">329</span><a name="line.329"></a> +<span class="sourceLineNo">330</span> /*<a name="line.330"></a> +<span class="sourceLineNo">331</span> * The delete logic is pretty complicated now.<a name="line.331"></a> +<span class="sourceLineNo">332</span> * This is corroborated by the following:<a name="line.332"></a> +<span class="sourceLineNo">333</span> * 1. The store might be instructed to keep deleted rows around.<a name="line.333"></a> +<span class="sourceLineNo">334</span> * 2. A scan can optionally see past a delete marker now.<a name="line.334"></a> +<span class="sourceLineNo">335</span> * 3. If deleted rows are kept, we have to find out when we can<a name="line.335"></a> +<span class="sourceLineNo">336</span> * remove the delete markers.<a name="line.336"></a> +<span class="sourceLineNo">337</span> * 4. Family delete markers are always first (regardless of their TS)<a name="line.337"></a> +<span class="sourceLineNo">338</span> * 5. Delete markers should not be counted as version<a name="line.338"></a> +<span class="sourceLineNo">339</span> * 6. Delete markers affect puts of the *same* TS<a name="line.339"></a> +<span class="sourceLineNo">340</span> * 7. Delete marker need to be version counted together with puts<a name="line.340"></a> +<span class="sourceLineNo">341</span> * they affect<a name="line.341"></a> +<span class="sourceLineNo">342</span> */<a name="line.342"></a> +<span class="sourceLineNo">343</span> byte typeByte = cell.getTypeByte();<a name="line.343"></a> +<span class="sourceLineNo">344</span> long mvccVersion = cell.getSequenceId();<a name="line.344"></a> +<span class="sourceLineNo">345</span> if (CellUtil.isDelete(cell)) {<a name="line.345"></a> +<span class="sourceLineNo">346</span> if (keepDeletedCells == KeepDeletedCells.FALSE<a name="line.346"></a> +<span class="sourceLineNo">347</span> || (keepDeletedCells == KeepDeletedCells.TTL && timestamp < ttl)) {<a name="line.347"></a> +<span class="sourceLineNo">348</span> // first ignore delete markers if the scanner can do so, and the<a name="line.348"></a> +<span class="sourceLineNo">349</span> // range does not include the marker<a name="line.349"></a> +<span class="sourceLineNo">350</span> //<a name="line.350"></a> +<span class="sourceLineNo">351</span> // during flushes and compactions also ignore delete markers newer<a name="line.351"></a> +<span class="sourceLineNo">352</span> // than the readpoint of any open scanner, this prevents deleted<a name="line.352"></a> +<span class="sourceLineNo">353</span> // rows that could still be seen by a scanner from being collected<a name="line.353"></a> +<span class="sourceLineNo">354</span> boolean includeDeleteMarker = seePastDeleteMarkers ?<a name="line.354"></a> +<span class="sourceLineNo">355</span> tr.withinTimeRange(timestamp) :<a name="line.355"></a> +<span class="sourceLineNo">356</span> tr.withinOrAfterTimeRange(timestamp);<a name="line.356"></a> +<span class="sourceLineNo">357</span> if (includeDeleteMarker<a name="line.357"></a> +<span class="sourceLineNo">358</span> && mvccVersion <= maxReadPointToTrackVersions) {<a name="line.358"></a> +<span class="sourceLineNo">359</span> this.deletes.add(cell);<a name="line.359"></a> +<span class="sourceLineNo">360</span> }<a name="line.360"></a> +<span class="sourceLineNo">361</span> // Can't early out now, because DelFam come before any other keys<a name="line.361"></a> +<span class="sourceLineNo">362</span> }<a name="line.362"></a> +<span class="sourceLineNo">363</span><a name="line.363"></a> +<span class="sourceLineNo">364</span> if ((!isUserScan)<a name="line.364"></a> +<span class="sourceLineNo">365</span> && timeToPurgeDeletes > 0<a name="line.365"></a> +<span class="sourceLineNo">366</span> && (EnvironmentEdgeManager.currentTime() - timestamp)<a name="line.366"></a> +<span class="sourceLineNo">367</span> <= timeToPurgeDeletes) {<a name="line.367"></a> +<span class="sourceLineNo">368</span> return MatchCode.INCLUDE;<a name="line.368"></a> +<span class="sourceLineNo">369</span> } else if (retainDeletesInOutput || mvccVersion > maxReadPointToTrackVersions) {<a name="line.369"></a> +<span class="sourceLineNo">370</span> // always include or it is not time yet to check whether it is OK<a name="line.370"></a> +<span class="sourceLineNo">371</span> // to purge deltes or not<a name="line.371"></a> +<span class="sourceLineNo">372</span> if (!isUserScan) {<a name="line.372"></a> +<span class="sourceLineNo">373</span> // if this is not a user scan (compaction), we can filter this deletemarker right here<a name="line.373"></a> +<span class="sourceLineNo">374</span> // otherwise (i.e. a "raw" scan) we fall through to normal version and timerange checking<a name="line.374"></a> +<span class="sourceLineNo">375</span> return MatchCode.INCLUDE;<a name="line.375"></a> +<span class="sourceLineNo">376</span> }<a name="line.376"></a> +<span class="sourceLineNo">377</span> } else if (keepDeletedCells == KeepDeletedCells.TRUE<a name="line.377"></a> +<span class="sourceLineNo">378</span> || (keepDeletedCells == KeepDeletedCells.TTL && timestamp >= ttl)) {<a name="line.378"></a> +<span class="sourceLineNo">379</span> if (timestamp < earliestPutTs) {<a name="line.379"></a> +<span class="sourceLineNo">380</span> // keeping delete rows, but there are no puts older than<a name="line.380"></a> +<span class="sourceLineNo">381</span> // this delete in the store files.<a name="line.381"></a> +<span class="sourceLineNo">382</span> return columns.getNextRowOrNextColumn(cell);<a name="line.382"></a> +<span class="sourceLineNo">383</span> }<a name="line.383"></a> +<span class="sourceLineNo">384</span> // else: fall through and do version counting on the<a name="line.384"></a> +<span class="sourceLineNo">385</span> // delete markers<a name="line.385"></a> +<span class="sourceLineNo">386</span> } else {<a name="line.386"></a> +<span class="sourceLineNo">387</span> return MatchCode.SKIP;<a name="line.387"></a> +<span class="sourceLineNo">388</span> }<a name="line.388"></a> +<span class="sourceLineNo">389</span> // note the following next else if...<a name="line.389"></a> +<span class="sourceLineNo">390</span> // delete marker are not subject to other delete markers<a name="line.390"></a> +<span class="sourceLineNo">391</span> } else if (!this.deletes.isEmpty()) {<a name="line.391"></a> +<span class="sourceLineNo">392</span> DeleteResult deleteResult = deletes.isDeleted(cell);<a name="line.392"></a> +<span class="sourceLineNo">393</span> switch (deleteResult) {<a name="line.393"></a> +<span class="sourceLineNo">394</span> case FAMILY_DELETED:<a name="line.394"></a> +<span class="sourceLineNo">395</span> case COLUMN_DELETED:<a name="line.395"></a> +<span class="sourceLineNo">396</span> return columns.getNextRowOrNextColumn(cell);<a name="line.396"></a> +<span class="sourceLineNo">397</span> case VERSION_DELETED:<a name="line.397"></a> +<span class="sourceLineNo">398</span> case FAMILY_VERSION_DELETED:<a name="line.398"></a> +<span class="sourceLineNo">399</span> return MatchCode.SKIP;<a name="line.399"></a> +<span class="sourceLineNo">400</span> case NOT_DELETED:<a name="line.400"></a> +<span class="sourceLineNo">401</span> break;<a name="line.401"></a> +<span class="sourceLineNo">402</span> default:<a name="line.402"></a> +<span class="sourceLineNo">403</span> throw new RuntimeException("UNEXPECTED");<a name="line.403"></a> +<span class="sourceLineNo">404</span> }<a name="line.404"></a> +<span class="sourceLineNo">405</span> }<a name="line.405"></a> +<span class="sourceLineNo">406</span><a name="line.406"></a> +<span class="sourceLineNo">407</span> int timestampComparison = tr.compare(timestamp);<a name="line.407"></a> +<span class="sourceLineNo">408</span> if (timestampComparison >= 1) {<a name="line.408"></a> +<span class="sourceLineNo">409</span> return MatchCode.SKIP;<a name="line.409"></a> +<span class="sourceLineNo">410</span> } else if (timestampComparison <= -1) {<a name="line.410"></a> +<span class="sourceLineNo">411</span> return columns.getNextRowOrNextColumn(cell);<a name="line.411"></a> +<span class="sourceLineNo">412</span> }<a name="line.412"></a> +<span class="sourceLineNo">413</span><a name="line.413"></a> +<span class="sourceLineNo">414</span> // STEP 1: Check if the column is part of the requested columns<a name="line.414"></a> +<span class="sourceLineNo">415</span> MatchCode colChecker = columns.checkColumn(cell, typeByte);<a name="line.415"></a> +<span class="sourceLineNo">416</span> if (colChecker == MatchCode.INCLUDE) {<a name="line.416"></a> +<span class="sourceLineNo">417</span> ReturnCode filterResponse = ReturnCode.SKIP;<a name="line.417"></a> +<span class="sourceLineNo">418</span> // STEP 2: Yes, the column is part of the requested columns. Check if filter is present<a name="line.418"></a> +<span class="sourceLineNo">419</span> if (filter != null) {<a name="line.419"></a> +<span class="sourceLineNo">420</span> // STEP 3: Filter the key value and return if it filters out<a name="line.420"></a> +<span class="sourceLineNo">421</span> filterResponse = filter.filterKeyValue(cell);<a name="line.421"></a> +<span class="sourceLineNo">422</span> switch (filterResponse) {<a name="line.422"></a> +<span class="sourceLineNo">423</span> case SKIP:<a name="line.423"></a> +<span class="sourceLineNo">424</span> return MatchCode.SKIP;<a name="line.424"></a> +<span class="sourceLineNo">425</span> case NEXT_COL:<a name="line.425"></a> +<span class="sourceLineNo">426</span> return columns.getNextRowOrNextColumn(cell);<a name="line.426"></a> +<span class="sourceLineNo">427</span> case NEXT_ROW:<a name="line.427"></a> +<span class="sourceLineNo">428</span> stickyNextRow = true;<a name="line.428"></a> +<span class="sourceLineNo">429</span> return MatchCode.SEEK_NEXT_ROW;<a name="line.429"></a> +<span class="sourceLineNo">430</span> case SEEK_NEXT_USING_HINT:<a name="line.430"></a> +<span class="sourceLineNo">431</span> return MatchCode.SEEK_NEXT_USING_HINT;<a name="line.431"></a> +<span class="sourceLineNo">432</span> default:<a name="line.432"></a> +<span class="sourceLineNo">433</span> //It means it is either include or include and seek next<a name="line.433"></a> +<span class="sourceLineNo">434</span> break;<a name="line.434"></a> +<span class="sourceLineNo">435</span> }<a name="line.435"></a> +<span class="sourceLineNo">436</span> }<a name="line.436"></a> +<span class="sourceLineNo">437</span> /*<a name="line.437"></a> +<span class="sourceLineNo">438</span> * STEP 4: Reaching this step means the column is part of the requested columns and either<a name="line.438"></a> +<span class="sourceLineNo">439</span> * the filter is null or the filter has returned INCLUDE or INCLUDE_AND_NEXT_COL response.<a name="line.439"></a> +<span class="sourceLineNo">440</span> * Now check the number of versions needed. This method call returns SKIP, INCLUDE,<a name="line.440"></a> +<span class="sourceLineNo">441</span> * INCLUDE_AND_SEEK_NEXT_ROW, INCLUDE_AND_SEEK_NEXT_COL.<a name="line.441"></a> +<span class="sourceLineNo">442</span> *<a name="line.442"></a> +<span class="sourceLineNo">443</span> * FilterResponse ColumnChecker Desired behavior<a name="line.443"></a> +<span class="sourceLineNo">444</span> * INCLUDE SKIP row has already been included, SKIP.<a name="line.444"></a> +<span class="sourceLineNo">445</span> * INCLUDE INCLUDE INCLUDE<a name="line.445"></a> +<span class="sourceLineNo">446</span> * INCLUDE INCLUDE_AND_SEEK_NEXT_COL INCLUDE_AND_SEEK_NEXT_COL<a name="line.446"></a> +<span class="sourceLineNo">447</span> * INCLUDE INCLUDE_AND_SEEK_NEXT_ROW INCLUDE_AND_SEEK_NEXT_ROW<a name="line.447"></a> +<span class="sourceLineNo">448</span> * INCLUDE_AND_SEEK_NEXT_COL SKIP row has already been included, SKIP.<a name="line.448"></a> +<span class="sourceLineNo">449</span> * INCLUDE_AND_SEEK_NEXT_COL INCLUDE INCLUDE_AND_SEEK_NEXT_COL<a name="line.449"></a> +<span class="sourceLineNo">450</span> * INCLUDE_AND_SEEK_NEXT_COL INCLUDE_AND_SEEK_NEXT_COL INCLUDE_AND_SEEK_NEXT_COL<a name="line.450"></a> +<span class="sourceLineNo">451</span> * INCLUDE_AND_SEEK_NEXT_COL INCLUDE_AND_SEEK_NEXT_ROW INCLUDE_AND_SEEK_NEXT_ROW<a name="line.451"></a> +<span class="sourceLineNo">452</span> *<a name="line.452"></a> +<span class="sourceLineNo">453</span> * In all the above scenarios, we return the column checker return value except for<a name="line.453"></a> +<span class="sourceLineNo">454</span> * FilterResponse (INCLUDE_AND_SEEK_NEXT_COL) and ColumnChecker(INCLUDE)<a name="line.454"></a> +<span class="sourceLineNo">455</span> */<a name="line.455"></a> +<span class="sourceLineNo">456</span> colChecker = columns.checkVersions(cell, timestamp, typeByte,<a name="line.456"></a> +<span class="sourceLineNo">457</span> mvccVersion > maxReadPointToTrackVersions);<a name="line.457"></a> +<span class="sourceLineNo">458</span> //Optimize with stickyNextRow<a name="line.458"></a> +<span class="sourceLineNo">459</span> boolean seekNextRowFromEssential = filterResponse == ReturnCode.INCLUDE_AND_SEEK_NEXT_ROW &&<a name="line.459"></a> +<span class="sourceLineNo">460</span> filter.isFamilyEssential(cell.getFamilyArray());<a name="line.460"></a> +<span class="sourceLineNo">461</span> if (colChecker == MatchCode.INCLUDE_AND_SEEK_NEXT_ROW || seekNextRowFromEssential) {<a name="line.461"></a> +<span class="sourceLineNo">462</span> stickyNextRow = true;<a name="line.462"></a> +<span class="sourceLineNo">463</span> }<a name="line.463"></a> +<span class="sourceLineNo">464</span> if (filterResponse == ReturnCode.INCLUDE_AND_SEEK_NEXT_ROW) {<a name="line.464"></a> +<span class="sourceLineNo">465</span> if (colChecker != MatchCode.SKIP) {<a name="line.465"></a> +<span class="sourceLineNo">466</span> return MatchCode.INCLUDE_AND_SEEK_NEXT_ROW;<a name="line.466"></a> +<span class="sourceLineNo">467</span> }<a name="line.467"></a> +<span class="sourceLineNo">468</span> return MatchCode.SEEK_NEXT_ROW;<a name="line.468"></a> +<span class="sourceLineNo">469</span> }<a name="line.469"></a> +<span class="sourceLineNo">470</span> return (filterResponse == ReturnCode.INCLUDE_AND_NEXT_COL &&<a name="line.470"></a> +<span class="sourceLineNo">471</span> colChecker == MatchCode.INCLUDE) ? MatchCode.INCLUDE_AND_SEEK_NEXT_COL<a name="line.471"></a> +<span class="sourceLineNo">472</span> : colChecker;<a name="line.472"></a> +<span class="sourceLineNo">473</span> }<a name="line.473"></a> +<span class="sourceLineNo">474</span> stickyNextRow = (colChecker == MatchCode.SEEK_NEXT_ROW) ? true<a name="line.474"></a> +<span class="sourceLineNo">475</span> : stickyNextRow;<a name="line.475"></a> +<span class="sourceLineNo">476</span> return colChecker;<a name="line.476"></a> +<span class="sourceLineNo">477</span> }<a name="line.477"></a> +<span class="sourceLineNo">478</span><a name="line.478"></a> +<span class="sourceLineNo">479</span> /** Handle partial-drop-deletes. As we match keys in order, when we have a range from which<a name="line.479"></a> +<span class="sourceLineNo">480</span> * we can drop deletes, we can set retainDeletesInOutput to false for the duration of this<a name="line.480"></a> +<span class="sourceLineNo">481</span> * range only, and maintain consistency. */<a name="line.481"></a> +<span class="sourceLineNo">482</span> private void checkPartialDropDeleteRange(Cell curCell) {<a name="line.482"></a> +<span class="sourceLineNo">483</span> // If partial-drop-deletes are used, initially, dropDeletesFromRow and dropDeletesToRow<a name="line.483"></a> +<span class="sourceLineNo">484</span> // are both set, and the matcher is set to retain deletes. We assume ordered keys. When<a name="line.484"></a> +<span class="sourceLineNo">485</span> // dropDeletesFromRow is leq current kv, we start dropping deletes and reset<a name="line.485"></a> +<span class="sourceLineNo">486</span> // dr
<TRUNCATED>