Repository: hbase-site Updated Branches: refs/heads/asf-site 18d1bfea6 -> b63bb380b
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/b63bb380/devapidocs/src-html/org/apache/hadoop/hbase/KeyValue.RowOnlyComparator.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/KeyValue.RowOnlyComparator.html b/devapidocs/src-html/org/apache/hadoop/hbase/KeyValue.RowOnlyComparator.html index cced781..d27f757 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/KeyValue.RowOnlyComparator.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/KeyValue.RowOnlyComparator.html @@ -1245,1583 +1245,1584 @@ <span class="sourceLineNo">1237</span> //---------------------------------------------------------------------------<a name="line.1237"></a> <span class="sourceLineNo">1238</span><a name="line.1238"></a> <span class="sourceLineNo">1239</span> /**<a name="line.1239"></a> -<span class="sourceLineNo">1240</span> * @return The byte array backing this KeyValue.<a name="line.1240"></a> -<span class="sourceLineNo">1241</span> * @deprecated Since 0.98.0. Use Cell Interface instead. Do not presume single backing buffer.<a name="line.1241"></a> -<span class="sourceLineNo">1242</span> */<a name="line.1242"></a> -<span class="sourceLineNo">1243</span> @Deprecated<a name="line.1243"></a> -<span class="sourceLineNo">1244</span> public byte [] getBuffer() {<a name="line.1244"></a> -<span class="sourceLineNo">1245</span> return this.bytes;<a name="line.1245"></a> -<span class="sourceLineNo">1246</span> }<a name="line.1246"></a> -<span class="sourceLineNo">1247</span><a name="line.1247"></a> -<span class="sourceLineNo">1248</span> /**<a name="line.1248"></a> -<span class="sourceLineNo">1249</span> * @return Offset into {@link #getBuffer()} at which this KeyValue starts.<a name="line.1249"></a> -<span class="sourceLineNo">1250</span> */<a name="line.1250"></a> -<span class="sourceLineNo">1251</span> public int getOffset() {<a name="line.1251"></a> -<span class="sourceLineNo">1252</span> return this.offset;<a name="line.1252"></a> -<span class="sourceLineNo">1253</span> }<a name="line.1253"></a> -<span class="sourceLineNo">1254</span><a name="line.1254"></a> -<span class="sourceLineNo">1255</span> /**<a name="line.1255"></a> -<span class="sourceLineNo">1256</span> * @return Length of bytes this KeyValue occupies in {@link #getBuffer()}.<a name="line.1256"></a> -<span class="sourceLineNo">1257</span> */<a name="line.1257"></a> -<span class="sourceLineNo">1258</span> public int getLength() {<a name="line.1258"></a> -<span class="sourceLineNo">1259</span> return length;<a name="line.1259"></a> -<span class="sourceLineNo">1260</span> }<a name="line.1260"></a> -<span class="sourceLineNo">1261</span><a name="line.1261"></a> -<span class="sourceLineNo">1262</span> //---------------------------------------------------------------------------<a name="line.1262"></a> -<span class="sourceLineNo">1263</span> //<a name="line.1263"></a> -<span class="sourceLineNo">1264</span> // Length and Offset Calculators<a name="line.1264"></a> -<span class="sourceLineNo">1265</span> //<a name="line.1265"></a> -<span class="sourceLineNo">1266</span> //---------------------------------------------------------------------------<a name="line.1266"></a> -<span class="sourceLineNo">1267</span><a name="line.1267"></a> -<span class="sourceLineNo">1268</span> /**<a name="line.1268"></a> -<span class="sourceLineNo">1269</span> * Determines the total length of the KeyValue stored in the specified<a name="line.1269"></a> -<span class="sourceLineNo">1270</span> * byte array and offset. Includes all headers.<a name="line.1270"></a> -<span class="sourceLineNo">1271</span> * @param bytes byte array<a name="line.1271"></a> -<span class="sourceLineNo">1272</span> * @param offset offset to start of the KeyValue<a name="line.1272"></a> -<span class="sourceLineNo">1273</span> * @return length of entire KeyValue, in bytes<a name="line.1273"></a> -<span class="sourceLineNo">1274</span> */<a name="line.1274"></a> -<span class="sourceLineNo">1275</span> private static int getLength(byte [] bytes, int offset) {<a name="line.1275"></a> -<span class="sourceLineNo">1276</span> int klength = ROW_OFFSET + Bytes.toInt(bytes, offset);<a name="line.1276"></a> -<span class="sourceLineNo">1277</span> int vlength = Bytes.toInt(bytes, offset + Bytes.SIZEOF_INT);<a name="line.1277"></a> -<span class="sourceLineNo">1278</span> return klength + vlength;<a name="line.1278"></a> -<span class="sourceLineNo">1279</span> }<a name="line.1279"></a> -<span class="sourceLineNo">1280</span><a name="line.1280"></a> -<span class="sourceLineNo">1281</span> /**<a name="line.1281"></a> -<span class="sourceLineNo">1282</span> * @return Key offset in backing buffer..<a name="line.1282"></a> -<span class="sourceLineNo">1283</span> */<a name="line.1283"></a> -<span class="sourceLineNo">1284</span> public int getKeyOffset() {<a name="line.1284"></a> -<span class="sourceLineNo">1285</span> return this.offset + ROW_OFFSET;<a name="line.1285"></a> -<span class="sourceLineNo">1286</span> }<a name="line.1286"></a> -<span class="sourceLineNo">1287</span><a name="line.1287"></a> -<span class="sourceLineNo">1288</span> public String getKeyString() {<a name="line.1288"></a> -<span class="sourceLineNo">1289</span> return Bytes.toStringBinary(getBuffer(), getKeyOffset(), getKeyLength());<a name="line.1289"></a> -<span class="sourceLineNo">1290</span> }<a name="line.1290"></a> -<span class="sourceLineNo">1291</span><a name="line.1291"></a> -<span class="sourceLineNo">1292</span> /**<a name="line.1292"></a> -<span class="sourceLineNo">1293</span> * @return Length of key portion.<a name="line.1293"></a> -<span class="sourceLineNo">1294</span> */<a name="line.1294"></a> -<span class="sourceLineNo">1295</span> public int getKeyLength() {<a name="line.1295"></a> -<span class="sourceLineNo">1296</span> return Bytes.toInt(this.bytes, this.offset);<a name="line.1296"></a> -<span class="sourceLineNo">1297</span> }<a name="line.1297"></a> -<span class="sourceLineNo">1298</span><a name="line.1298"></a> -<span class="sourceLineNo">1299</span> /**<a name="line.1299"></a> -<span class="sourceLineNo">1300</span> * @return the backing array of the entire KeyValue (all KeyValue fields are in a single array)<a name="line.1300"></a> -<span class="sourceLineNo">1301</span> */<a name="line.1301"></a> -<span class="sourceLineNo">1302</span> @Override<a name="line.1302"></a> -<span class="sourceLineNo">1303</span> public byte[] getValueArray() {<a name="line.1303"></a> -<span class="sourceLineNo">1304</span> return bytes;<a name="line.1304"></a> -<span class="sourceLineNo">1305</span> }<a name="line.1305"></a> -<span class="sourceLineNo">1306</span><a name="line.1306"></a> -<span class="sourceLineNo">1307</span> /**<a name="line.1307"></a> -<span class="sourceLineNo">1308</span> * @return the value offset<a name="line.1308"></a> -<span class="sourceLineNo">1309</span> */<a name="line.1309"></a> -<span class="sourceLineNo">1310</span> @Override<a name="line.1310"></a> -<span class="sourceLineNo">1311</span> public int getValueOffset() {<a name="line.1311"></a> -<span class="sourceLineNo">1312</span> int voffset = getKeyOffset() + getKeyLength();<a name="line.1312"></a> -<span class="sourceLineNo">1313</span> return voffset;<a name="line.1313"></a> -<span class="sourceLineNo">1314</span> }<a name="line.1314"></a> -<span class="sourceLineNo">1315</span><a name="line.1315"></a> -<span class="sourceLineNo">1316</span> /**<a name="line.1316"></a> -<span class="sourceLineNo">1317</span> * @return Value length<a name="line.1317"></a> -<span class="sourceLineNo">1318</span> */<a name="line.1318"></a> -<span class="sourceLineNo">1319</span> @Override<a name="line.1319"></a> -<span class="sourceLineNo">1320</span> public int getValueLength() {<a name="line.1320"></a> -<span class="sourceLineNo">1321</span> int vlength = Bytes.toInt(this.bytes, this.offset + Bytes.SIZEOF_INT);<a name="line.1321"></a> -<span class="sourceLineNo">1322</span> return vlength;<a name="line.1322"></a> -<span class="sourceLineNo">1323</span> }<a name="line.1323"></a> -<span class="sourceLineNo">1324</span><a name="line.1324"></a> -<span class="sourceLineNo">1325</span> /**<a name="line.1325"></a> -<span class="sourceLineNo">1326</span> * @return the backing array of the entire KeyValue (all KeyValue fields are in a single array)<a name="line.1326"></a> -<span class="sourceLineNo">1327</span> */<a name="line.1327"></a> -<span class="sourceLineNo">1328</span> @Override<a name="line.1328"></a> -<span class="sourceLineNo">1329</span> public byte[] getRowArray() {<a name="line.1329"></a> -<span class="sourceLineNo">1330</span> return bytes;<a name="line.1330"></a> -<span class="sourceLineNo">1331</span> }<a name="line.1331"></a> -<span class="sourceLineNo">1332</span><a name="line.1332"></a> -<span class="sourceLineNo">1333</span> /**<a name="line.1333"></a> -<span class="sourceLineNo">1334</span> * @return Row offset<a name="line.1334"></a> -<span class="sourceLineNo">1335</span> */<a name="line.1335"></a> -<span class="sourceLineNo">1336</span> @Override<a name="line.1336"></a> -<span class="sourceLineNo">1337</span> public int getRowOffset() {<a name="line.1337"></a> -<span class="sourceLineNo">1338</span> return this.offset + ROW_KEY_OFFSET;<a name="line.1338"></a> -<span class="sourceLineNo">1339</span> }<a name="line.1339"></a> -<span class="sourceLineNo">1340</span><a name="line.1340"></a> -<span class="sourceLineNo">1341</span> /**<a name="line.1341"></a> -<span class="sourceLineNo">1342</span> * @return Row length<a name="line.1342"></a> -<span class="sourceLineNo">1343</span> */<a name="line.1343"></a> -<span class="sourceLineNo">1344</span> @Override<a name="line.1344"></a> -<span class="sourceLineNo">1345</span> public short getRowLength() {<a name="line.1345"></a> -<span class="sourceLineNo">1346</span> return Bytes.toShort(this.bytes, getKeyOffset());<a name="line.1346"></a> -<span class="sourceLineNo">1347</span> }<a name="line.1347"></a> -<span class="sourceLineNo">1348</span><a name="line.1348"></a> -<span class="sourceLineNo">1349</span> /**<a name="line.1349"></a> -<span class="sourceLineNo">1350</span> * @return the backing array of the entire KeyValue (all KeyValue fields are in a single array)<a name="line.1350"></a> -<span class="sourceLineNo">1351</span> */<a name="line.1351"></a> -<span class="sourceLineNo">1352</span> @Override<a name="line.1352"></a> -<span class="sourceLineNo">1353</span> public byte[] getFamilyArray() {<a name="line.1353"></a> -<span class="sourceLineNo">1354</span> return bytes;<a name="line.1354"></a> -<span class="sourceLineNo">1355</span> }<a name="line.1355"></a> -<span class="sourceLineNo">1356</span><a name="line.1356"></a> -<span class="sourceLineNo">1357</span> /**<a name="line.1357"></a> -<span class="sourceLineNo">1358</span> * @return Family offset<a name="line.1358"></a> -<span class="sourceLineNo">1359</span> */<a name="line.1359"></a> -<span class="sourceLineNo">1360</span> @Override<a name="line.1360"></a> -<span class="sourceLineNo">1361</span> public int getFamilyOffset() {<a name="line.1361"></a> -<span class="sourceLineNo">1362</span> return getFamilyOffset(getRowLength());<a name="line.1362"></a> -<span class="sourceLineNo">1363</span> }<a name="line.1363"></a> -<span class="sourceLineNo">1364</span><a name="line.1364"></a> -<span class="sourceLineNo">1365</span> /**<a name="line.1365"></a> -<span class="sourceLineNo">1366</span> * @return Family offset<a name="line.1366"></a> -<span class="sourceLineNo">1367</span> */<a name="line.1367"></a> -<span class="sourceLineNo">1368</span> private int getFamilyOffset(int rlength) {<a name="line.1368"></a> -<span class="sourceLineNo">1369</span> return this.offset + ROW_KEY_OFFSET + rlength + Bytes.SIZEOF_BYTE;<a name="line.1369"></a> -<span class="sourceLineNo">1370</span> }<a name="line.1370"></a> -<span class="sourceLineNo">1371</span><a name="line.1371"></a> -<span class="sourceLineNo">1372</span> /**<a name="line.1372"></a> -<span class="sourceLineNo">1373</span> * @return Family length<a name="line.1373"></a> -<span class="sourceLineNo">1374</span> */<a name="line.1374"></a> -<span class="sourceLineNo">1375</span> @Override<a name="line.1375"></a> -<span class="sourceLineNo">1376</span> public byte getFamilyLength() {<a name="line.1376"></a> -<span class="sourceLineNo">1377</span> return getFamilyLength(getFamilyOffset());<a name="line.1377"></a> -<span class="sourceLineNo">1378</span> }<a name="line.1378"></a> -<span class="sourceLineNo">1379</span><a name="line.1379"></a> -<span class="sourceLineNo">1380</span> /**<a name="line.1380"></a> -<span class="sourceLineNo">1381</span> * @return Family length<a name="line.1381"></a> -<span class="sourceLineNo">1382</span> */<a name="line.1382"></a> -<span class="sourceLineNo">1383</span> public byte getFamilyLength(int foffset) {<a name="line.1383"></a> -<span class="sourceLineNo">1384</span> return this.bytes[foffset-1];<a name="line.1384"></a> -<span class="sourceLineNo">1385</span> }<a name="line.1385"></a> -<span class="sourceLineNo">1386</span><a name="line.1386"></a> -<span class="sourceLineNo">1387</span> /**<a name="line.1387"></a> -<span class="sourceLineNo">1388</span> * @return the backing array of the entire KeyValue (all KeyValue fields are in a single array)<a name="line.1388"></a> -<span class="sourceLineNo">1389</span> */<a name="line.1389"></a> -<span class="sourceLineNo">1390</span> @Override<a name="line.1390"></a> -<span class="sourceLineNo">1391</span> public byte[] getQualifierArray() {<a name="line.1391"></a> -<span class="sourceLineNo">1392</span> return bytes;<a name="line.1392"></a> -<span class="sourceLineNo">1393</span> }<a name="line.1393"></a> -<span class="sourceLineNo">1394</span><a name="line.1394"></a> -<span class="sourceLineNo">1395</span> /**<a name="line.1395"></a> -<span class="sourceLineNo">1396</span> * @return Qualifier offset<a name="line.1396"></a> -<span class="sourceLineNo">1397</span> */<a name="line.1397"></a> -<span class="sourceLineNo">1398</span> @Override<a name="line.1398"></a> -<span class="sourceLineNo">1399</span> public int getQualifierOffset() {<a name="line.1399"></a> -<span class="sourceLineNo">1400</span> return getQualifierOffset(getFamilyOffset());<a name="line.1400"></a> -<span class="sourceLineNo">1401</span> }<a name="line.1401"></a> -<span class="sourceLineNo">1402</span><a name="line.1402"></a> -<span class="sourceLineNo">1403</span> /**<a name="line.1403"></a> -<span class="sourceLineNo">1404</span> * @return Qualifier offset<a name="line.1404"></a> -<span class="sourceLineNo">1405</span> */<a name="line.1405"></a> -<span class="sourceLineNo">1406</span> private int getQualifierOffset(int foffset) {<a name="line.1406"></a> -<span class="sourceLineNo">1407</span> return foffset + getFamilyLength(foffset);<a name="line.1407"></a> -<span class="sourceLineNo">1408</span> }<a name="line.1408"></a> -<span class="sourceLineNo">1409</span><a name="line.1409"></a> -<span class="sourceLineNo">1410</span> /**<a name="line.1410"></a> -<span class="sourceLineNo">1411</span> * @return Qualifier length<a name="line.1411"></a> -<span class="sourceLineNo">1412</span> */<a name="line.1412"></a> -<span class="sourceLineNo">1413</span> @Override<a name="line.1413"></a> -<span class="sourceLineNo">1414</span> public int getQualifierLength() {<a name="line.1414"></a> -<span class="sourceLineNo">1415</span> return getQualifierLength(getRowLength(),getFamilyLength());<a name="line.1415"></a> -<span class="sourceLineNo">1416</span> }<a name="line.1416"></a> -<span class="sourceLineNo">1417</span><a name="line.1417"></a> -<span class="sourceLineNo">1418</span> /**<a name="line.1418"></a> -<span class="sourceLineNo">1419</span> * @return Qualifier length<a name="line.1419"></a> -<span class="sourceLineNo">1420</span> */<a name="line.1420"></a> -<span class="sourceLineNo">1421</span> private int getQualifierLength(int rlength, int flength) {<a name="line.1421"></a> -<span class="sourceLineNo">1422</span> return getKeyLength() - (int) getKeyDataStructureSize(rlength, flength, 0);<a name="line.1422"></a> -<span class="sourceLineNo">1423</span> }<a name="line.1423"></a> -<span class="sourceLineNo">1424</span><a name="line.1424"></a> -<span class="sourceLineNo">1425</span> /**<a name="line.1425"></a> -<span class="sourceLineNo">1426</span> * @return Timestamp offset<a name="line.1426"></a> -<span class="sourceLineNo">1427</span> */<a name="line.1427"></a> -<span class="sourceLineNo">1428</span> public int getTimestampOffset() {<a name="line.1428"></a> -<span class="sourceLineNo">1429</span> return getTimestampOffset(getKeyLength());<a name="line.1429"></a> -<span class="sourceLineNo">1430</span> }<a name="line.1430"></a> -<span class="sourceLineNo">1431</span><a name="line.1431"></a> -<span class="sourceLineNo">1432</span> /**<a name="line.1432"></a> -<span class="sourceLineNo">1433</span> * @param keylength Pass if you have it to save on a int creation.<a name="line.1433"></a> -<span class="sourceLineNo">1434</span> * @return Timestamp offset<a name="line.1434"></a> -<span class="sourceLineNo">1435</span> */<a name="line.1435"></a> -<span class="sourceLineNo">1436</span> private int getTimestampOffset(final int keylength) {<a name="line.1436"></a> -<span class="sourceLineNo">1437</span> return getKeyOffset() + keylength - TIMESTAMP_TYPE_SIZE;<a name="line.1437"></a> -<span class="sourceLineNo">1438</span> }<a name="line.1438"></a> -<span class="sourceLineNo">1439</span><a name="line.1439"></a> -<span class="sourceLineNo">1440</span> /**<a name="line.1440"></a> -<span class="sourceLineNo">1441</span> * @return True if this KeyValue has a LATEST_TIMESTAMP timestamp.<a name="line.1441"></a> -<span class="sourceLineNo">1442</span> */<a name="line.1442"></a> -<span class="sourceLineNo">1443</span> public boolean isLatestTimestamp() {<a name="line.1443"></a> -<span class="sourceLineNo">1444</span> return Bytes.equals(getBuffer(), getTimestampOffset(), Bytes.SIZEOF_LONG,<a name="line.1444"></a> -<span class="sourceLineNo">1445</span> HConstants.LATEST_TIMESTAMP_BYTES, 0, Bytes.SIZEOF_LONG);<a name="line.1445"></a> -<span class="sourceLineNo">1446</span> }<a name="line.1446"></a> -<span class="sourceLineNo">1447</span><a name="line.1447"></a> -<span class="sourceLineNo">1448</span> /**<a name="line.1448"></a> -<span class="sourceLineNo">1449</span> * @param now Time to set into <code>this</code> IFF timestamp ==<a name="line.1449"></a> -<span class="sourceLineNo">1450</span> * {@link HConstants#LATEST_TIMESTAMP} (else, its a noop).<a name="line.1450"></a> -<span class="sourceLineNo">1451</span> * @return True is we modified this.<a name="line.1451"></a> -<span class="sourceLineNo">1452</span> */<a name="line.1452"></a> -<span class="sourceLineNo">1453</span> public boolean updateLatestStamp(final byte [] now) {<a name="line.1453"></a> -<span class="sourceLineNo">1454</span> if (this.isLatestTimestamp()) {<a name="line.1454"></a> -<span class="sourceLineNo">1455</span> int tsOffset = getTimestampOffset();<a name="line.1455"></a> -<span class="sourceLineNo">1456</span> System.arraycopy(now, 0, this.bytes, tsOffset, Bytes.SIZEOF_LONG);<a name="line.1456"></a> -<span class="sourceLineNo">1457</span> // clear cache or else getTimestamp() possibly returns an old value<a name="line.1457"></a> -<span class="sourceLineNo">1458</span> return true;<a name="line.1458"></a> -<span class="sourceLineNo">1459</span> }<a name="line.1459"></a> -<span class="sourceLineNo">1460</span> return false;<a name="line.1460"></a> -<span class="sourceLineNo">1461</span> }<a name="line.1461"></a> -<span class="sourceLineNo">1462</span><a name="line.1462"></a> -<span class="sourceLineNo">1463</span> @Override<a name="line.1463"></a> -<span class="sourceLineNo">1464</span> public void setTimestamp(long ts) {<a name="line.1464"></a> -<span class="sourceLineNo">1465</span> Bytes.putBytes(this.bytes, this.getTimestampOffset(), Bytes.toBytes(ts), 0, Bytes.SIZEOF_LONG);<a name="line.1465"></a> -<span class="sourceLineNo">1466</span> }<a name="line.1466"></a> -<span class="sourceLineNo">1467</span><a name="line.1467"></a> -<span class="sourceLineNo">1468</span> @Override<a name="line.1468"></a> -<span class="sourceLineNo">1469</span> public void setTimestamp(byte[] ts, int tsOffset) {<a name="line.1469"></a> -<span class="sourceLineNo">1470</span> Bytes.putBytes(this.bytes, this.getTimestampOffset(), ts, tsOffset, Bytes.SIZEOF_LONG);<a name="line.1470"></a> -<span class="sourceLineNo">1471</span> }<a name="line.1471"></a> -<span class="sourceLineNo">1472</span><a name="line.1472"></a> -<span class="sourceLineNo">1473</span> //---------------------------------------------------------------------------<a name="line.1473"></a> -<span class="sourceLineNo">1474</span> //<a name="line.1474"></a> -<span class="sourceLineNo">1475</span> // Methods that return copies of fields<a name="line.1475"></a> -<span class="sourceLineNo">1476</span> //<a name="line.1476"></a> -<span class="sourceLineNo">1477</span> //---------------------------------------------------------------------------<a name="line.1477"></a> -<span class="sourceLineNo">1478</span><a name="line.1478"></a> -<span class="sourceLineNo">1479</span> /**<a name="line.1479"></a> -<span class="sourceLineNo">1480</span> * Do not use unless you have to. Used internally for compacting and testing. Use<a name="line.1480"></a> -<span class="sourceLineNo">1481</span> * {@link #getRowArray()}, {@link #getFamilyArray()}, {@link #getQualifierArray()}, and<a name="line.1481"></a> -<span class="sourceLineNo">1482</span> * {@link #getValueArray()} if accessing a KeyValue client-side.<a name="line.1482"></a> -<span class="sourceLineNo">1483</span> * @return Copy of the key portion only.<a name="line.1483"></a> -<span class="sourceLineNo">1484</span> */<a name="line.1484"></a> -<span class="sourceLineNo">1485</span> public byte [] getKey() {<a name="line.1485"></a> -<span class="sourceLineNo">1486</span> int keylength = getKeyLength();<a name="line.1486"></a> -<span class="sourceLineNo">1487</span> byte [] key = new byte[keylength];<a name="line.1487"></a> -<span class="sourceLineNo">1488</span> System.arraycopy(getBuffer(), getKeyOffset(), key, 0, keylength);<a name="line.1488"></a> -<span class="sourceLineNo">1489</span> return key;<a name="line.1489"></a> -<span class="sourceLineNo">1490</span> }<a name="line.1490"></a> -<span class="sourceLineNo">1491</span><a name="line.1491"></a> -<span class="sourceLineNo">1492</span> /**<a name="line.1492"></a> -<span class="sourceLineNo">1493</span> *<a name="line.1493"></a> -<span class="sourceLineNo">1494</span> * @return Timestamp<a name="line.1494"></a> -<span class="sourceLineNo">1495</span> */<a name="line.1495"></a> -<span class="sourceLineNo">1496</span> @Override<a name="line.1496"></a> -<span class="sourceLineNo">1497</span> public long getTimestamp() {<a name="line.1497"></a> -<span class="sourceLineNo">1498</span> return getTimestamp(getKeyLength());<a name="line.1498"></a> -<span class="sourceLineNo">1499</span> }<a name="line.1499"></a> -<span class="sourceLineNo">1500</span><a name="line.1500"></a> -<span class="sourceLineNo">1501</span> /**<a name="line.1501"></a> -<span class="sourceLineNo">1502</span> * @param keylength Pass if you have it to save on a int creation.<a name="line.1502"></a> -<span class="sourceLineNo">1503</span> * @return Timestamp<a name="line.1503"></a> -<span class="sourceLineNo">1504</span> */<a name="line.1504"></a> -<span class="sourceLineNo">1505</span> long getTimestamp(final int keylength) {<a name="line.1505"></a> -<span class="sourceLineNo">1506</span> int tsOffset = getTimestampOffset(keylength);<a name="line.1506"></a> -<span class="sourceLineNo">1507</span> return Bytes.toLong(this.bytes, tsOffset);<a name="line.1507"></a> -<span class="sourceLineNo">1508</span> }<a name="line.1508"></a> -<span class="sourceLineNo">1509</span><a name="line.1509"></a> -<span class="sourceLineNo">1510</span> /**<a name="line.1510"></a> -<span class="sourceLineNo">1511</span> * @return Type of this KeyValue.<a name="line.1511"></a> -<span class="sourceLineNo">1512</span> */<a name="line.1512"></a> -<span class="sourceLineNo">1513</span> @Deprecated<a name="line.1513"></a> -<span class="sourceLineNo">1514</span> public byte getType() {<a name="line.1514"></a> -<span class="sourceLineNo">1515</span> return getTypeByte();<a name="line.1515"></a> -<span class="sourceLineNo">1516</span> }<a name="line.1516"></a> -<span class="sourceLineNo">1517</span><a name="line.1517"></a> -<span class="sourceLineNo">1518</span> /**<a name="line.1518"></a> -<span class="sourceLineNo">1519</span> * @return KeyValue.TYPE byte representation<a name="line.1519"></a> -<span class="sourceLineNo">1520</span> */<a name="line.1520"></a> -<span class="sourceLineNo">1521</span> @Override<a name="line.1521"></a> -<span class="sourceLineNo">1522</span> public byte getTypeByte() {<a name="line.1522"></a> -<span class="sourceLineNo">1523</span> return this.bytes[this.offset + getKeyLength() - 1 + ROW_OFFSET];<a name="line.1523"></a> -<span class="sourceLineNo">1524</span> }<a name="line.1524"></a> -<span class="sourceLineNo">1525</span><a name="line.1525"></a> -<span class="sourceLineNo">1526</span> /**<a name="line.1526"></a> -<span class="sourceLineNo">1527</span> * @return True if a delete type, a {@link KeyValue.Type#Delete} or<a name="line.1527"></a> -<span class="sourceLineNo">1528</span> * a {KeyValue.Type#DeleteFamily} or a {@link KeyValue.Type#DeleteColumn}<a name="line.1528"></a> -<span class="sourceLineNo">1529</span> * KeyValue type.<a name="line.1529"></a> -<span class="sourceLineNo">1530</span> */<a name="line.1530"></a> -<span class="sourceLineNo">1531</span> @Deprecated // use CellUtil#isDelete<a name="line.1531"></a> -<span class="sourceLineNo">1532</span> public boolean isDelete() {<a name="line.1532"></a> -<span class="sourceLineNo">1533</span> return KeyValue.isDelete(getType());<a name="line.1533"></a> -<span class="sourceLineNo">1534</span> }<a name="line.1534"></a> -<span class="sourceLineNo">1535</span><a name="line.1535"></a> -<span class="sourceLineNo">1536</span> /**<a name="line.1536"></a> -<span class="sourceLineNo">1537</span> * This returns the offset where the tag actually starts.<a name="line.1537"></a> -<span class="sourceLineNo">1538</span> */<a name="line.1538"></a> -<span class="sourceLineNo">1539</span> @Override<a name="line.1539"></a> -<span class="sourceLineNo">1540</span> public int getTagsOffset() {<a name="line.1540"></a> -<span class="sourceLineNo">1541</span> int tagsLen = getTagsLength();<a name="line.1541"></a> -<span class="sourceLineNo">1542</span> if (tagsLen == 0) {<a name="line.1542"></a> -<span class="sourceLineNo">1543</span> return this.offset + this.length;<a name="line.1543"></a> -<span class="sourceLineNo">1544</span> }<a name="line.1544"></a> -<span class="sourceLineNo">1545</span> return this.offset + this.length - tagsLen;<a name="line.1545"></a> -<span class="sourceLineNo">1546</span> }<a name="line.1546"></a> -<span class="sourceLineNo">1547</span><a name="line.1547"></a> -<span class="sourceLineNo">1548</span> /**<a name="line.1548"></a> -<span class="sourceLineNo">1549</span> * This returns the total length of the tag bytes<a name="line.1549"></a> -<span class="sourceLineNo">1550</span> */<a name="line.1550"></a> -<span class="sourceLineNo">1551</span> @Override<a name="line.1551"></a> -<span class="sourceLineNo">1552</span> public int getTagsLength() {<a name="line.1552"></a> -<span class="sourceLineNo">1553</span> int tagsLen = this.length - (getKeyLength() + getValueLength() + KEYVALUE_INFRASTRUCTURE_SIZE);<a name="line.1553"></a> -<span class="sourceLineNo">1554</span> if (tagsLen > 0) {<a name="line.1554"></a> -<span class="sourceLineNo">1555</span> // There are some Tag bytes in the byte[]. So reduce 2 bytes which is added to denote the tags<a name="line.1555"></a> -<span class="sourceLineNo">1556</span> // length<a name="line.1556"></a> -<span class="sourceLineNo">1557</span> tagsLen -= TAGS_LENGTH_SIZE;<a name="line.1557"></a> -<span class="sourceLineNo">1558</span> }<a name="line.1558"></a> -<span class="sourceLineNo">1559</span> return tagsLen;<a name="line.1559"></a> -<span class="sourceLineNo">1560</span> }<a name="line.1560"></a> -<span class="sourceLineNo">1561</span><a name="line.1561"></a> -<span class="sourceLineNo">1562</span> /**<a name="line.1562"></a> -<span class="sourceLineNo">1563</span> * Returns any tags embedded in the KeyValue. Used in testcases.<a name="line.1563"></a> -<span class="sourceLineNo">1564</span> * @return The tags<a name="line.1564"></a> -<span class="sourceLineNo">1565</span> */<a name="line.1565"></a> -<span class="sourceLineNo">1566</span> public List<Tag> getTags() {<a name="line.1566"></a> -<span class="sourceLineNo">1567</span> int tagsLength = getTagsLength();<a name="line.1567"></a> -<span class="sourceLineNo">1568</span> if (tagsLength == 0) {<a name="line.1568"></a> -<span class="sourceLineNo">1569</span> return EMPTY_ARRAY_LIST;<a name="line.1569"></a> -<span class="sourceLineNo">1570</span> }<a name="line.1570"></a> -<span class="sourceLineNo">1571</span> return TagUtil.asList(getTagsArray(), getTagsOffset(), tagsLength);<a name="line.1571"></a> -<span class="sourceLineNo">1572</span> }<a name="line.1572"></a> -<span class="sourceLineNo">1573</span><a name="line.1573"></a> -<span class="sourceLineNo">1574</span> /**<a name="line.1574"></a> -<span class="sourceLineNo">1575</span> * @return the backing array of the entire KeyValue (all KeyValue fields are in a single array)<a name="line.1575"></a> -<span class="sourceLineNo">1576</span> */<a name="line.1576"></a> -<span class="sourceLineNo">1577</span> @Override<a name="line.1577"></a> -<span class="sourceLineNo">1578</span> public byte[] getTagsArray() {<a name="line.1578"></a> -<span class="sourceLineNo">1579</span> return bytes;<a name="line.1579"></a> -<span class="sourceLineNo">1580</span> }<a name="line.1580"></a> -<span class="sourceLineNo">1581</span><a name="line.1581"></a> -<span class="sourceLineNo">1582</span> /**<a name="line.1582"></a> -<span class="sourceLineNo">1583</span> * Creates a new KeyValue that only contains the key portion (the value is<a name="line.1583"></a> -<span class="sourceLineNo">1584</span> * set to be null).<a name="line.1584"></a> -<span class="sourceLineNo">1585</span> *<a name="line.1585"></a> -<span class="sourceLineNo">1586</span> * TODO only used by KeyOnlyFilter -- move there.<a name="line.1586"></a> -<span class="sourceLineNo">1587</span> * @param lenAsVal replace value with the actual value length (false=empty)<a name="line.1587"></a> -<span class="sourceLineNo">1588</span> */<a name="line.1588"></a> -<span class="sourceLineNo">1589</span> public KeyValue createKeyOnly(boolean lenAsVal) {<a name="line.1589"></a> -<span class="sourceLineNo">1590</span> // KV format: <keylen:4><valuelen:4><key:keylen><value:valuelen><a name="line.1590"></a> -<span class="sourceLineNo">1591</span> // Rebuild as: <keylen:4><0:4><key:keylen><a name="line.1591"></a> -<span class="sourceLineNo">1592</span> int dataLen = lenAsVal? Bytes.SIZEOF_INT : 0;<a name="line.1592"></a> -<span class="sourceLineNo">1593</span> byte [] newBuffer = new byte[getKeyLength() + ROW_OFFSET + dataLen];<a name="line.1593"></a> -<span class="sourceLineNo">1594</span> System.arraycopy(this.bytes, this.offset, newBuffer, 0,<a name="line.1594"></a> -<span class="sourceLineNo">1595</span> Math.min(newBuffer.length,this.length));<a name="line.1595"></a> -<span class="sourceLineNo">1596</span> Bytes.putInt(newBuffer, Bytes.SIZEOF_INT, dataLen);<a name="line.1596"></a> -<span class="sourceLineNo">1597</span> if (lenAsVal) {<a name="line.1597"></a> -<span class="sourceLineNo">1598</span> Bytes.putInt(newBuffer, newBuffer.length - dataLen, this.getValueLength());<a name="line.1598"></a> -<span class="sourceLineNo">1599</span> }<a name="line.1599"></a> -<span class="sourceLineNo">1600</span> return new KeyValue(newBuffer);<a name="line.1600"></a> -<span class="sourceLineNo">1601</span> }<a name="line.1601"></a> -<span class="sourceLineNo">1602</span><a name="line.1602"></a> -<span class="sourceLineNo">1603</span> /**<a name="line.1603"></a> -<span class="sourceLineNo">1604</span> * Splits a column in {@code family:qualifier} form into separate byte arrays. An empty qualifier<a name="line.1604"></a> -<span class="sourceLineNo">1605</span> * (ie, {@code fam:}) is parsed as <code>{ fam, EMPTY_BYTE_ARRAY }</code> while no delimiter (ie,<a name="line.1605"></a> -<span class="sourceLineNo">1606</span> * {@code fam}) is parsed as an array of one element, <code>{ fam }</code>.<a name="line.1606"></a> -<span class="sourceLineNo">1607</span> * <p><a name="line.1607"></a> -<span class="sourceLineNo">1608</span> * Don't forget, HBase DOES support empty qualifiers. (see HBASE-9549)<a name="line.1608"></a> -<span class="sourceLineNo">1609</span> * </p><a name="line.1609"></a> -<span class="sourceLineNo">1610</span> * <p><a name="line.1610"></a> -<span class="sourceLineNo">1611</span> * Not recommend to be used as this is old-style API.<a name="line.1611"></a> -<span class="sourceLineNo">1612</span> * </p><a name="line.1612"></a> -<span class="sourceLineNo">1613</span> * @param c The column.<a name="line.1613"></a> -<span class="sourceLineNo">1614</span> * @return The parsed column.<a name="line.1614"></a> -<span class="sourceLineNo">1615</span> */<a name="line.1615"></a> -<span class="sourceLineNo">1616</span> public static byte [][] parseColumn(byte [] c) {<a name="line.1616"></a> -<span class="sourceLineNo">1617</span> final int index = getDelimiter(c, 0, c.length, COLUMN_FAMILY_DELIMITER);<a name="line.1617"></a> -<span class="sourceLineNo">1618</span> if (index == -1) {<a name="line.1618"></a> -<span class="sourceLineNo">1619</span> // If no delimiter, return array of size 1<a name="line.1619"></a> -<span class="sourceLineNo">1620</span> return new byte [][] { c };<a name="line.1620"></a> -<span class="sourceLineNo">1621</span> } else if(index == c.length - 1) {<a name="line.1621"></a> -<span class="sourceLineNo">1622</span> // family with empty qualifier, return array size 2<a name="line.1622"></a> -<span class="sourceLineNo">1623</span> byte [] family = new byte[c.length-1];<a name="line.1623"></a> -<span class="sourceLineNo">1624</span> System.arraycopy(c, 0, family, 0, family.length);<a name="line.1624"></a> -<span class="sourceLineNo">1625</span> return new byte [][] { family, HConstants.EMPTY_BYTE_ARRAY};<a name="line.1625"></a> -<span class="sourceLineNo">1626</span> }<a name="line.1626"></a> -<span class="sourceLineNo">1627</span> // Family and column, return array size 2<a name="line.1627"></a> -<span class="sourceLineNo">1628</span> final byte [][] result = new byte [2][];<a name="line.1628"></a> -<span class="sourceLineNo">1629</span> result[0] = new byte [index];<a name="line.1629"></a> -<span class="sourceLineNo">1630</span> System.arraycopy(c, 0, result[0], 0, index);<a name="line.1630"></a> -<span class="sourceLineNo">1631</span> final int len = c.length - (index + 1);<a name="line.1631"></a> -<span class="sourceLineNo">1632</span> result[1] = new byte[len];<a name="line.1632"></a> -<span class="sourceLineNo">1633</span> System.arraycopy(c, index + 1 /* Skip delimiter */, result[1], 0, len);<a name="line.1633"></a> -<span class="sourceLineNo">1634</span> return result;<a name="line.1634"></a> -<span class="sourceLineNo">1635</span> }<a name="line.1635"></a> -<span class="sourceLineNo">1636</span><a name="line.1636"></a> -<span class="sourceLineNo">1637</span> /**<a name="line.1637"></a> -<span class="sourceLineNo">1638</span> * Makes a column in family:qualifier form from separate byte arrays.<a name="line.1638"></a> -<span class="sourceLineNo">1639</span> * <p><a name="line.1639"></a> -<span class="sourceLineNo">1640</span> * Not recommended for usage as this is old-style API.<a name="line.1640"></a> -<span class="sourceLineNo">1641</span> * @param family<a name="line.1641"></a> -<span class="sourceLineNo">1642</span> * @param qualifier<a name="line.1642"></a> -<span class="sourceLineNo">1643</span> * @return family:qualifier<a name="line.1643"></a> -<span class="sourceLineNo">1644</span> */<a name="line.1644"></a> -<span class="sourceLineNo">1645</span> public static byte [] makeColumn(byte [] family, byte [] qualifier) {<a name="line.1645"></a> -<span class="sourceLineNo">1646</span> return Bytes.add(family, COLUMN_FAMILY_DELIM_ARRAY, qualifier);<a name="line.1646"></a> -<span class="sourceLineNo">1647</span> }<a name="line.1647"></a> -<span class="sourceLineNo">1648</span><a name="line.1648"></a> -<span class="sourceLineNo">1649</span> /**<a name="line.1649"></a> -<span class="sourceLineNo">1650</span> * @param b<a name="line.1650"></a> -<span class="sourceLineNo">1651</span> * @param delimiter<a name="line.1651"></a> -<span class="sourceLineNo">1652</span> * @return Index of delimiter having started from start of <code>b</code><a name="line.1652"></a> -<span class="sourceLineNo">1653</span> * moving rightward.<a name="line.1653"></a> -<span class="sourceLineNo">1654</span> */<a name="line.1654"></a> -<span class="sourceLineNo">1655</span> public static int getDelimiter(final byte [] b, int offset, final int length,<a name="line.1655"></a> -<span class="sourceLineNo">1656</span> final int delimiter) {<a name="line.1656"></a> -<span class="sourceLineNo">1657</span> if (b == null) {<a name="line.1657"></a> -<span class="sourceLineNo">1658</span> throw new IllegalArgumentException("Passed buffer is null");<a name="line.1658"></a> -<span class="sourceLineNo">1659</span> }<a name="line.1659"></a> -<span class="sourceLineNo">1660</span> int result = -1;<a name="line.1660"></a> -<span class="sourceLineNo">1661</span> for (int i = offset; i < length + offset; i++) {<a name="line.1661"></a> -<span class="sourceLineNo">1662</span> if (b[i] == delimiter) {<a name="line.1662"></a> -<span class="sourceLineNo">1663</span> result = i;<a name="line.1663"></a> -<span class="sourceLineNo">1664</span> break;<a name="line.1664"></a> -<span class="sourceLineNo">1665</span> }<a name="line.1665"></a> -<span class="sourceLineNo">1666</span> }<a name="line.1666"></a> -<span class="sourceLineNo">1667</span> return result;<a name="line.1667"></a> -<span class="sourceLineNo">1668</span> }<a name="line.1668"></a> -<span class="sourceLineNo">1669</span><a name="line.1669"></a> -<span class="sourceLineNo">1670</span> /**<a name="line.1670"></a> -<span class="sourceLineNo">1671</span> * Find index of passed delimiter walking from end of buffer backwards.<a name="line.1671"></a> -<span class="sourceLineNo">1672</span> * @param b<a name="line.1672"></a> -<span class="sourceLineNo">1673</span> * @param delimiter<a name="line.1673"></a> -<span class="sourceLineNo">1674</span> * @return Index of delimiter<a name="line.1674"></a> -<span class="sourceLineNo">1675</span> */<a name="line.1675"></a> -<span class="sourceLineNo">1676</span> public static int getDelimiterInReverse(final byte [] b, final int offset,<a name="line.1676"></a> -<span class="sourceLineNo">1677</span> final int length, final int delimiter) {<a name="line.1677"></a> -<span class="sourceLineNo">1678</span> if (b == null) {<a name="line.1678"></a> -<span class="sourceLineNo">1679</span> throw new IllegalArgumentException("Passed buffer is null");<a name="line.1679"></a> -<span class="sourceLineNo">1680</span> }<a name="line.1680"></a> -<span class="sourceLineNo">1681</span> int result = -1;<a name="line.1681"></a> -<span class="sourceLineNo">1682</span> for (int i = (offset + length) - 1; i >= offset; i--) {<a name="line.1682"></a> -<span class="sourceLineNo">1683</span> if (b[i] == delimiter) {<a name="line.1683"></a> -<span class="sourceLineNo">1684</span> result = i;<a name="line.1684"></a> -<span class="sourceLineNo">1685</span> break;<a name="line.1685"></a> -<span class="sourceLineNo">1686</span> }<a name="line.1686"></a> -<span class="sourceLineNo">1687</span> }<a name="line.1687"></a> -<span class="sourceLineNo">1688</span> return result;<a name="line.1688"></a> -<span class="sourceLineNo">1689</span> }<a name="line.1689"></a> -<span class="sourceLineNo">1690</span><a name="line.1690"></a> -<span class="sourceLineNo">1691</span> /**<a name="line.1691"></a> -<span class="sourceLineNo">1692</span> * A {@link KVComparator} for <code>hbase:meta</code> catalog table<a name="line.1692"></a> -<span class="sourceLineNo">1693</span> * {@link KeyValue}s.<a name="line.1693"></a> -<span class="sourceLineNo">1694</span> * @deprecated : {@link CellComparator#META_COMPARATOR} to be used<a name="line.1694"></a> -<span class="sourceLineNo">1695</span> */<a name="line.1695"></a> -<span class="sourceLineNo">1696</span> @Deprecated<a name="line.1696"></a> -<span class="sourceLineNo">1697</span> public static class MetaComparator extends KVComparator {<a name="line.1697"></a> -<span class="sourceLineNo">1698</span> /**<a name="line.1698"></a> -<span class="sourceLineNo">1699</span> * Compare key portion of a {@link KeyValue} for keys in <code>hbase:meta</code><a name="line.1699"></a> -<span class="sourceLineNo">1700</span> * table.<a name="line.1700"></a> -<span class="sourceLineNo">1701</span> */<a name="line.1701"></a> -<span class="sourceLineNo">1702</span> @Override<a name="line.1702"></a> -<span class="sourceLineNo">1703</span> public int compare(final Cell left, final Cell right) {<a name="line.1703"></a> -<span class="sourceLineNo">1704</span> return CellComparator.META_COMPARATOR.compareKeyIgnoresMvcc(left, right);<a name="line.1704"></a> -<span class="sourceLineNo">1705</span> }<a name="line.1705"></a> -<span class="sourceLineNo">1706</span><a name="line.1706"></a> -<span class="sourceLineNo">1707</span> @Override<a name="line.1707"></a> -<span class="sourceLineNo">1708</span> public int compareOnlyKeyPortion(Cell left, Cell right) {<a name="line.1708"></a> -<span class="sourceLineNo">1709</span> return compare(left, right);<a name="line.1709"></a> -<span class="sourceLineNo">1710</span> }<a name="line.1710"></a> -<span class="sourceLineNo">1711</span><a name="line.1711"></a> -<span class="sourceLineNo">1712</span> @Override<a name="line.1712"></a> -<span class="sourceLineNo">1713</span> public int compareRows(byte [] left, int loffset, int llength,<a name="line.1713"></a> -<span class="sourceLineNo">1714</span> byte [] right, int roffset, int rlength) {<a name="line.1714"></a> -<span class="sourceLineNo">1715</span> int leftDelimiter = getDelimiter(left, loffset, llength,<a name="line.1715"></a> -<span class="sourceLineNo">1716</span> HConstants.DELIMITER);<a name="line.1716"></a> -<span class="sourceLineNo">1717</span> int rightDelimiter = getDelimiter(right, roffset, rlength,<a name="line.1717"></a> -<span class="sourceLineNo">1718</span> HConstants.DELIMITER);<a name="line.1718"></a> -<span class="sourceLineNo">1719</span> // Compare up to the delimiter<a name="line.1719"></a> -<span class="sourceLineNo">1720</span> int lpart = (leftDelimiter < 0 ? llength :leftDelimiter - loffset);<a name="line.1720"></a> -<span class="sourceLineNo">1721</span> int rpart = (rightDelimiter < 0 ? rlength :rightDelimiter - roffset);<a name="line.1721"></a> -<span class="sourceLineNo">1722</span> int result = Bytes.compareTo(left, loffset, lpart, right, roffset, rpart);<a name="line.1722"></a> -<span class="sourceLineNo">1723</span> if (result != 0) {<a name="line.1723"></a> -<span class="sourceLineNo">1724</span> return result;<a name="line.1724"></a> -<span class="sourceLineNo">1725</span> } else {<a name="line.1725"></a> -<span class="sourceLineNo">1726</span> if (leftDelimiter < 0 && rightDelimiter >= 0) {<a name="line.1726"></a> -<span class="sourceLineNo">1727</span> return -1;<a name="line.1727"></a> -<span class="sourceLineNo">1728</span> } else if (rightDelimiter < 0 && leftDelimiter >= 0) {<a name="line.1728"></a> -<span class="sourceLineNo">1729</span> return 1;<a name="line.1729"></a> -<span class="sourceLineNo">1730</span> } else if (leftDelimiter < 0 && rightDelimiter < 0) {<a name="line.1730"></a> -<span class="sourceLineNo">1731</span> return 0;<a name="line.1731"></a> -<span class="sourceLineNo">1732</span> }<a name="line.1732"></a> -<span class="sourceLineNo">1733</span> }<a name="line.1733"></a> -<span class="sourceLineNo">1734</span> // Compare middle bit of the row.<a name="line.1734"></a> -<span class="sourceLineNo">1735</span> // Move past delimiter<a name="line.1735"></a> -<span class="sourceLineNo">1736</span> leftDelimiter++;<a name="line.1736"></a> -<span class="sourceLineNo">1737</span> rightDelimiter++;<a name="line.1737"></a> -<span class="sourceLineNo">1738</span> int leftFarDelimiter = getDelimiterInReverse(left, leftDelimiter,<a name="line.1738"></a> -<span class="sourceLineNo">1739</span> llength - (leftDelimiter - loffset), HConstants.DELIMITER);<a name="line.1739"></a> -<span class="sourceLineNo">1740</span> int rightFarDelimiter = getDelimiterInReverse(right,<a name="line.1740"></a> -<span class="sourceLineNo">1741</span> rightDelimiter, rlength - (rightDelimiter - roffset),<a name="line.1741"></a> -<span class="sourceLineNo">1742</span> HConstants.DELIMITER);<a name="line.1742"></a> -<span class="sourceLineNo">1743</span> // Now compare middlesection of row.<a name="line.1743"></a> -<span class="sourceLineNo">1744</span> lpart = (leftFarDelimiter < 0 ? llength + loffset: leftFarDelimiter) - leftDelimiter;<a name="line.1744"></a> -<span class="sourceLineNo">1745</span> rpart = (rightFarDelimiter < 0 ? rlength + roffset: rightFarDelimiter)- rightDelimiter;<a name="line.1745"></a> -<span class="sourceLineNo">1746</span> result = super.compareRows(left, leftDelimiter, lpart, right, rightDelimiter, rpart);<a name="line.1746"></a> -<span class="sourceLineNo">1747</span> if (result != 0) {<a name="line.1747"></a> -<span class="sourceLineNo">1748</span> return result;<a name="line.1748"></a> -<span class="sourceLineNo">1749</span> } else {<a name="line.1749"></a> -<span class="sourceLineNo">1750</span> if (leftDelimiter < 0 && rightDelimiter >= 0) {<a name="line.1750"></a> -<span class="sourceLineNo">1751</span> return -1;<a name="line.1751"></a> -<span class="sourceLineNo">1752</span> } else if (rightDelimiter < 0 && leftDelimiter >= 0) {<a name="line.1752"></a> -<span class="sourceLineNo">1753</span> return 1;<a name="line.1753"></a> -<span class="sourceLineNo">1754</span> } else if (leftDelimiter < 0 && rightDelimiter < 0) {<a name="line.1754"></a> -<span class="sourceLineNo">1755</span> return 0;<a name="line.1755"></a> -<span class="sourceLineNo">1756</span> }<a name="line.1756"></a> -<span class="sourceLineNo">1757</span> }<a name="line.1757"></a> -<span class="sourceLineNo">1758</span> // Compare last part of row, the rowid.<a name="line.1758"></a> -<span class="sourceLineNo">1759</span> leftFarDelimiter++;<a name="line.1759"></a> -<span class="sourceLineNo">1760</span> rightFarDelimiter++;<a name="line.1760"></a> -<span class="sourceLineNo">1761</span> result = Bytes.compareTo(left, leftFarDelimiter, llength - (leftFarDelimiter - loffset),<a name="line.1761"></a> -<span class="sourceLineNo">1762</span> right, rightFarDelimiter, rlength - (rightFarDelimiter - roffset));<a name="line.1762"></a> -<span class="sourceLineNo">1763</span> return result;<a name="line.1763"></a> -<span class="sourceLineNo">1764</span> }<a name="line.1764"></a> -<span class="sourceLineNo">1765</span><a name="line.1765"></a> -<span class="sourceLineNo">1766</span> /**<a name="line.1766"></a> -<span class="sourceLineNo">1767</span> * Don't do any fancy Block Index splitting tricks.<a name="line.1767"></a> -<span class="sourceLineNo">1768</span> */<a name="line.1768"></a> -<span class="sourceLineNo">1769</span> @Override<a name="line.1769"></a> -<span class="sourceLineNo">1770</span> public byte[] getShortMidpointKey(final byte[] leftKey, final byte[] rightKey) {<a name="line.1770"></a> -<span class="sourceLineNo">1771</span> return Arrays.copyOf(rightKey, rightKey.length);<a name="line.1771"></a> -<span class="sourceLineNo">1772</span> }<a name="line.1772"></a> -<span class="sourceLineNo">1773</span><a name="line.1773"></a> -<span class="sourceLineNo">1774</span> /**<a name="line.1774"></a> -<span class="sourceLineNo">1775</span> * The HFileV2 file format's trailer contains this class name. We reinterpret this and<a name="line.1775"></a> -<span class="sourceLineNo">1776</span> * instantiate the appropriate comparator.<a name="line.1776"></a> -<span class="sourceLineNo">1777</span> * TODO: With V3 consider removing this.<a name="line.1777"></a> -<span class="sourceLineNo">1778</span> * @return legacy class name for FileFileTrailer#comparatorClassName<a name="line.1778"></a> -<span class="sourceLineNo">1779</span> */<a name="line.1779"></a> -<span class="sourceLineNo">1780</span> @Override<a name="line.1780"></a> -<span class="sourceLineNo">1781</span> public String getLegacyKeyComparatorName() {<a name="line.1781"></a> -<span class="sourceLineNo">1782</span> return "org.apache.hadoop.hbase.KeyValue$MetaKeyComparator";<a name="line.1782"></a> -<span class="sourceLineNo">1783</span> }<a name="line.1783"></a> -<span class="sourceLineNo">1784</span><a name="line.1784"></a> -<span class="sourceLineNo">1785</span> @Override<a name="line.1785"></a> -<span class="sourceLineNo">1786</span> protected Object clone() throws CloneNotSupportedException {<a name="line.1786"></a> -<span class="sourceLineNo">1787</span> return new MetaComparator();<a name="line.1787"></a> -<span class="sourceLineNo">1788</span> }<a name="line.1788"></a> -<span class="sourceLineNo">1789</span><a name="line.1789"></a> -<span class="sourceLineNo">1790</span> /**<a name="line.1790"></a> -<span class="sourceLineNo">1791</span> * Override the row key comparison to parse and compare the meta row key parts.<a name="line.1791"></a> -<span class="sourceLineNo">1792</span> */<a name="line.1792"></a> -<span class="sourceLineNo">1793</span> @Override<a name="line.1793"></a> -<span class="sourceLineNo">1794</span> protected int compareRowKey(final Cell l, final Cell r) {<a name="line.1794"></a> -<span class="sourceLineNo">1795</span> byte[] left = l.getRowArray();<a name="line.1795"></a> -<span class="sourceLineNo">1796</span> int loffset = l.getRowOffset();<a name="line.1796"></a> -<span class="sourceLineNo">1797</span> int llength = l.getRowLength();<a name="line.1797"></a> -<span class="sourceLineNo">1798</span> byte[] right = r.getRowArray();<a name="line.1798"></a> -<span class="sourceLineNo">1799</span> int roffset = r.getRowOffset();<a name="line.1799"></a> -<span class="sourceLineNo">1800</span> int rlength = r.getRowLength();<a name="line.1800"></a> -<span class="sourceLineNo">1801</span> return compareRows(left, loffset, llength, right, roffset, rlength);<a name="line.1801"></a> -<span class="sourceLineNo">1802</span> }<a name="line.1802"></a> -<span class="sourceLineNo">1803</span> }<a name="line.1803"></a> -<span class="sourceLineNo">1804</span><a name="line.1804"></a> -<span class="sourceLineNo">1805</span> /**<a name="line.1805"></a> -<span class="sourceLineNo">1806</span> * Compare KeyValues. When we compare KeyValues, we only compare the Key<a name="line.1806"></a> -<span class="sourceLineNo">1807</span> * portion. This means two KeyValues with same Key but different Values are<a name="line.1807"></a> -<span class="sourceLineNo">1808</span> * considered the same as far as this Comparator is concerned.<a name="line.1808"></a> -<span class="sourceLineNo">1809</span> * @deprecated : Use {@link CellComparator}.<a name="line.1809"></a> -<span class="sourceLineNo">1810</span> */<a name="line.1810"></a> -<span class="sourceLineNo">1811</span> @Deprecated<a name="line.1811"></a> -<span class="sourceLineNo">1812</span> public static class KVComparator implements RawComparator<Cell>, SamePrefixComparator<byte[]> {<a name="line.1812"></a> -<span class="sourceLineNo">1813</span><a name="line.1813"></a> -<span class="sourceLineNo">1814</span> /**<a name="line.1814"></a> -<span class="sourceLineNo">1815</span> * The HFileV2 file format's trailer contains this class name. We reinterpret this and<a name="line.1815"></a> -<span class="sourceLineNo">1816</span> * instantiate the appropriate comparator.<a name="line.1816"></a> -<span class="sourceLineNo">1817</span> * TODO: With V3 consider removing this.<a name="line.1817"></a> -<span class="sourceLineNo">1818</span> * @return legacy class name for FileFileTrailer#comparatorClassName<a name="line.1818"></a> -<span class="sourceLineNo">1819</span> */<a name="line.1819"></a> -<span class="sourceLineNo">1820</span> public String getLegacyKeyComparatorName() {<a name="line.1820"></a> -<span class="sourceLineNo">1821</span> return "org.apache.hadoop.hbase.KeyValue$KeyComparator";<a name="line.1821"></a> -<span class="sourceLineNo">1822</span> }<a name="line.1822"></a> -<span class="sourceLineNo">1823</span><a name="line.1823"></a> -<span class="sourceLineNo">1824</span> @Override // RawComparator<a name="line.1824"></a> -<span class="sourceLineNo">1825</span> public int compare(byte[] l, int loff, int llen, byte[] r, int roff, int rlen) {<a name="line.1825"></a> -<span class="sourceLineNo">1826</span> return compareFlatKey(l,loff,llen, r,roff,rlen);<a name="line.1826"></a> -<span class="sourceLineNo">1827</span> }<a name="line.1827"></a> -<span class="sourceLineNo">1828</span><a name="line.1828"></a> +<span class="sourceLineNo">1240</span> * To be used only in tests where the Cells are clearly assumed to be of type KeyValue<a name="line.1240"></a> +<span class="sourceLineNo">1241</span> * and that we need access to the backing array to do some test case related assertions.<a name="line.1241"></a> +<span class="sourceLineNo">1242</span> * @return The byte array backing this KeyValue.<a name="line.1242"></a> +<span class="sourceLineNo">1243</span> */<a name="line.1243"></a> +<span class="sourceLineNo">1244</span> @VisibleForTesting<a name="line.1244"></a> +<span class="sourceLineNo">1245</span> public byte [] getBuffer() {<a name="line.1245"></a> +<span class="sourceLineNo">1246</span> return this.bytes;<a name="line.1246"></a> +<span class="sourceLineNo">1247</span> }<a name="line.1247"></a> +<span class="sourceLineNo">1248</span><a name="line.1248"></a> +<span class="sourceLineNo">1249</span> /**<a name="line.1249"></a> +<span class="sourceLineNo">1250</span> * @return Offset into {@link #getBuffer()} at which this KeyValue starts.<a name="line.1250"></a> +<span class="sourceLineNo">1251</span> */<a name="line.1251"></a> +<span class="sourceLineNo">1252</span> public int getOffset() {<a name="line.1252"></a> +<span class="sourceLineNo">1253</span> return this.offset;<a name="line.1253"></a> +<span class="sourceLineNo">1254</span> }<a name="line.1254"></a> +<span class="sourceLineNo">1255</span><a name="line.1255"></a> +<span class="sourceLineNo">1256</span> /**<a name="line.1256"></a> +<span class="sourceLineNo">1257</span> * @return Length of bytes this KeyValue occupies in {@link #getBuffer()}.<a name="line.1257"></a> +<span class="sourceLineNo">1258</span> */<a name="line.1258"></a> +<span class="sourceLineNo">1259</span> public int getLength() {<a name="line.1259"></a> +<span class="sourceLineNo">1260</span> return length;<a name="line.1260"></a> +<span class="sourceLineNo">1261</span> }<a name="line.1261"></a> +<span class="sourceLineNo">1262</span><a name="line.1262"></a> +<span class="sourceLineNo">1263</span> //---------------------------------------------------------------------------<a name="line.1263"></a> +<span class="sourceLineNo">1264</span> //<a name="line.1264"></a> +<span class="sourceLineNo">1265</span> // Length and Offset Calculators<a name="line.1265"></a> +<span class="sourceLineNo">1266</span> //<a name="line.1266"></a> +<span class="sourceLineNo">1267</span> //---------------------------------------------------------------------------<a name="line.1267"></a> +<span class="sourceLineNo">1268</span><a name="line.1268"></a> +<span class="sourceLineNo">1269</span> /**<a name="line.1269"></a> +<span class="sourceLineNo">1270</span> * Determines the total length of the KeyValue stored in the specified<a name="line.1270"></a> +<span class="sourceLineNo">1271</span> * byte array and offset. Includes all headers.<a name="line.1271"></a> +<span class="sourceLineNo">1272</span> * @param bytes byte array<a name="line.1272"></a> +<span class="sourceLineNo">1273</span> * @param offset offset to start of the KeyValue<a name="line.1273"></a> +<span class="sourceLineNo">1274</span> * @return length of entire KeyValue, in bytes<a name="line.1274"></a> +<span class="sourceLineNo">1275</span> */<a name="line.1275"></a> +<span class="sourceLineNo">1276</span> private static int getLength(byte [] bytes, int offset) {<a name="line.1276"></a> +<span class="sourceLineNo">1277</span> int klength = ROW_OFFSET + Bytes.toInt(bytes, offset);<a name="line.1277"></a> +<span class="sourceLineNo">1278</span> int vlength = Bytes.toInt(bytes, offset + Bytes.SIZEOF_INT);<a name="line.1278"></a> +<span class="sourceLineNo">1279</span> return klength + vlength;<a name="line.1279"></a> +<span class="sourceLineNo">1280</span> }<a name="line.1280"></a> +<span class="sourceLineNo">1281</span><a name="line.1281"></a> +<span class="sourceLineNo">1282</span> /**<a name="line.1282"></a> +<span class="sourceLineNo">1283</span> * @return Key offset in backing buffer..<a name="line.1283"></a> +<span class="sourceLineNo">1284</span> */<a name="line.1284"></a> +<span class="sourceLineNo">1285</span> public int getKeyOffset() {<a name="line.1285"></a> +<span class="sourceLineNo">1286</span> return this.offset + ROW_OFFSET;<a name="line.1286"></a> +<span class="sourceLineNo">1287</span> }<a name="line.1287"></a> +<span class="sourceLineNo">1288</span><a name="line.1288"></a> +<span class="sourceLineNo">1289</span> public String getKeyString() {<a name="line.1289"></a> +<span class="sourceLineNo">1290</span> return Bytes.toStringBinary(getBuffer(), getKeyOffset(), getKeyLength());<a name="line.1290"></a> +<span class="sourceLineNo">1291</span> }<a name="line.1291"></a> +<span class="sourceLineNo">1292</span><a name="line.1292"></a> +<span class="sourceLineNo">1293</span> /**<a name="line.1293"></a> +<span class="sourceLineNo">1294</span> * @return Length of key portion.<a name="line.1294"></a> +<span class="sourceLineNo">1295</span> */<a name="line.1295"></a> +<span class="sourceLineNo">1296</span> public int getKeyLength() {<a name="line.1296"></a> +<span class="sourceLineNo">1297</span> return Bytes.toInt(this.bytes, this.offset);<a name="line.1297"></a> +<span class="sourceLineNo">1298</span> }<a name="line.1298"></a> +<span class="sourceLineNo">1299</span><a name="line.1299"></a> +<span class="sourceLineNo">1300</span> /**<a name="line.1300"></a> +<span class="sourceLineNo">1301</span> * @return the backing array of the entire KeyValue (all KeyValue fields are in a single array)<a name="line.1301"></a> +<span class="sourceLineNo">1302</span> */<a name="line.1302"></a> +<span class="sourceLineNo">1303</span> @Override<a name="line.1303"></a> +<span class="sourceLineNo">1304</span> public byte[] getValueArray() {<a name="line.1304"></a> +<span class="sourceLineNo">1305</span> return bytes;<a name="line.1305"></a> +<span class="sourceLineNo">1306</span> }<a name="line.1306"></a> +<span class="sourceLineNo">1307</span><a name="line.1307"></a> +<span class="sourceLineNo">1308</span> /**<a name="line.1308"></a> +<span class="sourceLineNo">1309</span> * @return the value offset<a name="line.1309"></a> +<span class="sourceLineNo">1310</span> */<a name="line.1310"></a> +<span class="sourceLineNo">1311</span> @Override<a name="line.1311"></a> +<span class="sourceLineNo">1312</span> public int getValueOffset() {<a name="line.1312"></a> +<span class="sourceLineNo">1313</span> int voffset = getKeyOffset() + getKeyLength();<a name="line.1313"></a> +<span class="sourceLineNo">1314</span> return voffset;<a name="line.1314"></a> +<span class="sourceLineNo">1315</span> }<a name="line.1315"></a> +<span class="sourceLineNo">1316</span><a name="line.1316"></a> +<span class="sourceLineNo">1317</span> /**<a name="line.1317"></a> +<span class="sourceLineNo">1318</span> * @return Value length<a name="line.1318"></a> +<span class="sourceLineNo">1319</span> */<a name="line.1319"></a> +<span class="sourceLineNo">1320</span> @Override<a name="line.1320"></a> +<span class="sourceLineNo">1321</span> public int getValueLength() {<a name="line.1321"></a> +<span class="sourceLineNo">1322</span> int vlength = Bytes.toInt(this.bytes, this.offset + Bytes.SIZEOF_INT);<a name="line.1322"></a> +<span class="sourceLineNo">1323</span> return vlength;<a name="line.1323"></a> +<span class="sourceLineNo">1324</span> }<a name="line.1324"></a> +<span class="sourceLineNo">1325</span><a name="line.1325"></a> +<span class="sourceLineNo">1326</span> /**<a name="line.1326"></a> +<span class="sourceLineNo">1327</span> * @return the backing array of the entire KeyValue (all KeyValue fields are in a single array)<a name="line.1327"></a> +<span class="sourceLineNo">1328</span> */<a name="line.1328"></a> +<span class="sourceLineNo">1329</span> @Override<a name="line.1329"></a> +<span class="sourceLineNo">1330</span> public byte[] getRowArray() {<a name="line.1330"></a> +<span class="sourceLineNo">1331</span> return bytes;<a name="line.1331"></a> +<span class="sourceLineNo">1332</span> }<a name="line.1332"></a> +<span class="sourceLineNo">1333</span><a name="line.1333"></a> +<span class="sourceLineNo">1334</span> /**<a name="line.1334"></a> +<span class="sourceLineNo">1335</span> * @return Row offset<a name="line.1335"></a> +<span class="sourceLineNo">1336</span> */<a name="line.1336"></a> +<span class="sourceLineNo">1337</span> @Override<a name="line.1337"></a> +<span class="sourceLineNo">1338</span> public int getRowOffset() {<a name="line.1338"></a> +<span class="sourceLineNo">1339</span> return this.offset + ROW_KEY_OFFSET;<a name="line.1339"></a> +<span class="sourceLineNo">1340</span> }<a name="line.1340"></a> +<span class="sourceLineNo">1341</span><a name="line.1341"></a> +<span class="sourceLineNo">1342</span> /**<a name="line.1342"></a> +<span class="sourceLineNo">1343</span> * @return Row length<a name="line.1343"></a> +<span class="sourceLineNo">1344</span> */<a name="line.1344"></a> +<span class="sourceLineNo">1345</span> @Override<a name="line.1345"></a> +<span class="sourceLineNo">1346</span> public short getRowLength() {<a name="line.1346"></a> +<span class="sourceLineNo">1347</span> return Bytes.toShort(this.bytes, getKeyOffset());<a name="line.1347"></a> +<span class="sourceLineNo">1348</span> }<a name="line.1348"></a> +<span class="sourceLineNo">1349</span><a name="line.1349"></a> +<span class="sourceLineNo">1350</span> /**<a name="line.1350"></a> +<span class="sourceLineNo">1351</span> * @return the backing array of the entire KeyValue (all KeyValue fields are in a single array)<a name="line.1351"></a> +<span class="sourceLineNo">1352</span> */<a name="line.1352"></a> +<span class="sourceLineNo">1353</span> @Override<a name="line.1353"></a> +<span class="sourceLineNo">1354</span> public byte[] getFamilyArray() {<a name="line.1354"></a> +<span class="sourceLineNo">1355</span> return bytes;<a name="line.1355"></a> +<span class="sourceLineNo">1356</span> }<a name="line.1356"></a> +<span class="sourceLineNo">1357</span><a name="line.1357"></a> +<span class="sourceLineNo">1358</span> /**<a name="line.1358"></a> +<span class="sourceLineNo">1359</span> * @return Family offset<a name="line.1359"></a> +<span class="sourceLineNo">1360</span> */<a name="line.1360"></a> +<span class="sourceLineNo">1361</span> @Override<a name="line.1361"></a> +<span class="sourceLineNo">1362</span> public int getFamilyOffset() {<a name="line.1362"></a> +<span class="sourceLineNo">1363</span> return getFamilyOffset(getRowLength());<a name="line.1363"></a> +<span class="sourceLineNo">1364</span> }<a name="line.1364"></a> +<span class="sourceLineNo">1365</span><a name="line.1365"></a> +<span class="sourceLineNo">1366</span> /**<a name="line.1366"></a> +<span class="sourceLineNo">1367</span> * @return Family offset<a name="line.1367"></a> +<span class="sourceLineNo">1368</span> */<a name="line.1368"></a> +<span class="sourceLineNo">1369</span> private int getFamilyOffset(int rlength) {<a name="line.1369"></a> +<span class="sourceLineNo">1370</span> return this.offset + ROW_KEY_OFFSET + rlength + Bytes.SIZEOF_BYTE;<a name="line.1370"></a> +<span class="sourceLineNo">1371</span> }<a name="line.1371"></a> +<span class="sourceLineNo">1372</span><a name="line.1372"></a> +<span class="sourceLineNo">1373</span> /**<a name="line.1373"></a> +<span class="sourceLineNo">1374</span> * @return Family length<a name="line.1374"></a> +<span class="sourceLineNo">1375</span> */<a name="line.1375"></a> +<span class="sourceLineNo">1376</span> @Override<a name="line.1376"></a> +<span class="sourceLineNo">1377</span> public byte getFamilyLength() {<a name="line.1377"></a> +<span class="sourceLineNo">1378</span> return getFamilyLength(getFamilyOffset());<a name="line.1378"></a> +<span class="sourceLineNo">1379</span> }<a name="line.1379"></a> +<span class="sourceLineNo">1380</span><a name="line.1380"></a> +<span class="sourceLineNo">1381</span> /**<a name="line.1381"></a> +<span class="sourceLineNo">1382</span> * @return Family length<a name="line.1382"></a> +<span class="sourceLineNo">1383</span> */<a name="line.1383"></a> +<span class="sourceLineNo">1384</span> public byte getFamilyLength(int foffset) {<a name="line.1384"></a> +<span class="sourceLineNo">1385</span> return this.bytes[foffset-1];<a name="line.1385"></a> +<span class="sourceLineNo">1386</span> }<a name="line.1386"></a> +<span class="sourceLineNo">1387</span><a name="line.1387"></a> +<span class="sourceLineNo">1388</span> /**<a name="line.1388"></a> +<span class="sourceLineNo">1389</span> * @return the backing array of the entire KeyValue (all KeyValue fields are in a single array)<a name="line.1389"></a> +<span class="sourceLineNo">1390</span> */<a name="line.1390"></a> +<span class="sourceLineNo">1391</span> @Override<a name="line.1391"></a> +<span class="sourceLineNo">1392</span> public byte[] getQualifierArray() {<a name="line.1392"></a> +<span class="sourceLineNo">1393</span> return bytes;<a name="line.1393"></a> +<span class="sourceLineNo">1394</span> }<a name="line.1394"></a> +<span class="sourceLineNo">1395</span><a name="line.1395"></a> +<span class="sourceLineNo">1396</span> /**<a name="line.1396"></a> +<span class="sourceLineNo">1397</span> * @return Qualifier offset<a name="line.1397"></a> +<span class="sourceLineNo">1398</span> */<a name="line.1398"></a> +<span class="sourceLineNo">1399</span> @Override<a name="line.1399"></a> +<span class="sourceLineNo">1400</span> public int getQualifierOffset() {<a name="line.1400"></a> +<span class="sourceLineNo">1401</span> return getQualifierOffset(getFamilyOffset());<a name="line.1401"></a> +<span class="sourceLineNo">1402</span> }<a name="line.1402"></a> +<span class="sourceLineNo">1403</span><a name="line.1403"></a> +<span class="sourceLineNo">1404</span> /**<a name="line.1404"></a> +<span class="sourceLineNo">1405</span> * @return Qualifier offset<a name="line.1405"></a> +<span class="sourceLineNo">1406</span> */<a name="line.1406"></a> +<span class="sourceLineNo">1407</span> private int getQualifierOffset(int foffset) {<a name="line.1407"></a> +<span class="sourceLineNo">1408</span> return foffset + getFamilyLength(foffset);<a name="line.1408"></a> +<span class="sourceLineNo">1409</span> }<a name="line.1409"></a> +<span class="sourceLineNo">1410</span><a name="line.1410"></a> +<span class="sourceLineNo">1411</span> /**<a name="line.1411"></a> +<span class="sourceLineNo">1412</span> * @return Qualifier length<a name="line.1412"></a> +<span class="sourceLineNo">1413</span> */<a name="line.1413"></a> +<span class="sourceLineNo">1414</span> @Override<a name="line.1414"></a> +<span class="sourceLineNo">1415</span> public int getQualifierLength() {<a name="line.1415"></a> +<span class="sourceLineNo">1416</span> return getQualifierLength(getRowLength(),getFamilyLength());<a name="line.1416"></a> +<span class="sourceLineNo">1417</span> }<a name="line.1417"></a> +<span class="sourceLineNo">1418</span><a name="line.1418"></a> +<span class="sourceLineNo">1419</span> /**<a name="line.1419"></a> +<span class="sourceLineNo">1420</span> * @return Qualifier length<a name="line.1420"></a> +<span class="sourceLineNo">1421</span> */<a name="line.1421"></a> +<span class="sourceLineNo">1422</span> private int getQualifierLength(int rlength, int flength) {<a name="line.1422"></a> +<span class="sourceLineNo">1423</span> return getKeyLength() - (int) getKeyDataStructureSize(rlength, flength, 0);<a name="line.1423"></a> +<span class="sourceLineNo">1424</span> }<a name="line.1424"></a> +<span class="sourceLineNo">1425</span><a name="line.1425"></a> +<span class="sourceLineNo">1426</span> /**<a name="line.1426"></a> +<span class="sourceLineNo">1427</span> * @return Timestamp offset<a name="line.1427"></a> +<span class="sourceLineNo">1428</span> */<a name="line.1428"></a> +<span class="sourceLineNo">1429</span> public int getTimestampOffset() {<a name="line.1429"></a> +<span class="sourceLineNo">1430</span> return getTimestampOffset(getKeyLength());<a name="line.1430"></a> +<span class="sourceLineNo">1431</span> }<a name="line.1431"></a> +<span class="sourceLineNo">1432</span><a name="line.1432"></a> +<span class="sourceLineNo">1433</span> /**<a name="line.1433"></a> +<span class="sourceLineNo">1434</span> * @param keylength Pass if you have it to save on a int creation.<a name="line.1434"></a> +<span class="sourceLineNo">1435</span> * @return Timestamp offset<a name="line.1435"></a> +<span class="sourceLineNo">1436</span> */<a name="line.1436"></a> +<span class="sourceLineNo">1437</span> private int getTimestampOffset(final int keylength) {<a name="line.1437"></a> +<span class="sourceLineNo">1438</span> return getKeyOffset() + keylength - TIMESTAMP_TYPE_SIZE;<a name="line.1438"></a> +<span class="sourceLineNo">1439</span> }<a name="line.1439"></a> +<span class="sourceLineNo">1440</span><a name="line.1440"></a> +<span class="sourceLineNo">1441</span> /**<a name="line.1441"></a> +<span class="sourceLineNo">1442</span> * @return True if this KeyValue has a LATEST_TIMESTAMP timestamp.<a name="line.1442"></a> +<span class="sourceLineNo">1443</span> */<a name="line.1443"></a> +<span class="sourceLineNo">1444</span> public boolean isLatestTimestamp() {<a name="line.1444"></a> +<span class="sourceLineNo">1445</span> return Bytes.equals(getBuffer(), getTimestampOffset(), Bytes.SIZEOF_LONG,<a name="line.1445"></a> +<span class="sourceLineNo">1446</span> HConstants.LATEST_TIMESTAMP_BYTES, 0, Bytes.SIZEOF_LONG);<a name="line.1446"></a> +<span class="sourceLineNo">1447</span> }<a name="line.1447"></a> +<span class="sourceLineNo">1448</span><a name="line.1448"></a> +<span class="sourceLineNo">1449</span> /**<a name="line.1449"></a> +<span class="sourceLineNo">1450</span> * @param now Time to set into <code>this</code> IFF timestamp ==<a name="line.1450"></a> +<span class="sourceLineNo">1451</span> * {@link HConstants#LATEST_TIMESTAMP} (else, its a noop).<a name="line.1451"></a> +<span class="sourceLineNo">1452</span> * @return True is we modified this.<a name="line.1452"></a> +<span class="sourceLineNo">1453</span> */<a name="line.1453"></a> +<span class="sourceLineNo">1454</span> public boolean updateLatestStamp(final byte [] now) {<a name="line.1454"></a> +<span class="sourceLineNo">1455</span> if (this.isLatestTimestamp()) {<a name="line.1455"></a> +<span class="sourceLineNo">1456</span> int tsOffset = getTimestampOffset();<a name="line.1456"></a> +<span class="sourceLineNo">1457</span> System.arraycopy(now, 0, this.bytes, tsOffset, Bytes.SIZEOF_LONG);<a name="line.1457"></a> +<span class="sourceLineNo">1458</span> // clear cache or else getTimestamp() possibly returns an old value<a name="line.1458"></a> +<span class="sourceLineNo">1459</span> return true;<a name="line.1459"></a> +<span class="sourceLineNo">1460</span> }<a name="line.1460"></a> +<span class="sourceLineNo">1461</span> return false;<a name="line.1461"></a> +<span class="sourceLineNo">1462</span> }<a name="line.1462"></a> +<span class="sourceLineNo">1463</span><a name="line.1463"></a> +<span class="sourceLineNo">1464</span> @Override<a name="line.1464"></a> +<span class="sourceLineNo">1465</span> public void setTimestamp(long ts) {<a name="line.1465"></a> +<span class="sourceLineNo">1466</span> Bytes.putBytes(this.bytes, this.getTimestampOffset(), Bytes.toBytes(ts), 0, Bytes.SIZEOF_LONG);<a name="line.1466"></a> +<span class="sourceLineNo">1467</span> }<a name="line.1467"></a> +<span class="sourceLineNo">1468</span><a name="line.1468"></a> +<span class="sourceLineNo">1469</span> @Override<a name="line.1469"></a> +<span class="sourceLineNo">1470</span> public void setTimestamp(byte[] ts, int tsOffset) {<a name="line.1470"></a> +<span class="sourceLineNo">1471</span> Bytes.putBytes(this.bytes, this.getTimestampOffset(), ts, tsOffset, Bytes.SIZEOF_LONG);<a name="line.1471"></a> +<span class="sourceLineNo">1472</span> }<a name="line.1472"></a> +<span class="sourceLineNo">1473</span><a name="line.1473"></a> +<span class="sourceLineNo">1474</span> //---------------------------------------------------------------------------<a name="line.1474"></a> +<span class="sourceLineNo">1475</span> //<a name="line.1475"></a> +<span class="sourceLineNo">1476</span> // Methods that return copies of fields<a name="line.1476"></a> +<span class="sourceLineNo">1477</span> //<a name="line.1477"></a> +<span class="sourceLineNo">1478</span> //---------------------------------------------------------------------------<a name="line.1478"></a> +<span class="sourceLineNo">1479</span><a name="line.1479"></a> +<span class="sourceLineNo">1480</span> /**<a name="line.1480"></a> +<span class="sourceLineNo">1481</span> * Do not use unless you have to. Used internally for compacting and testing. Use<a name="line.1481"></a> +<span class="sourceLineNo">1482</span> * {@link #getRowArray()}, {@link #getFamilyArray()}, {@link #getQualifierArray()}, and<a name="line.1482"></a> +<span class="sourceLineNo">1483</span> * {@link #getValueArray()} if accessing a KeyValue client-side.<a name="line.1483"></a> +<span class="sourceLineNo">1484</span> * @return Copy of the key portion only.<a name="line.1484"></a> +<span class="sourceLineNo">1485</span> */<a name="line.1485"></a> +<span class="sourceLineNo">1486</span> public byte [] getKey() {<a name="line.1486"></a> +<span class="sourceLineNo">1487</span> int keylength = getKeyLength();<a name="line.1487"></a> +<span class="sourceLineNo">1488</span> byte [] key = new byte[keylength];<a name="line.1488"></a> +<span class="sourceLineNo">1489</span> System.arraycopy(getBuffer(), getKeyOffset(), key, 0, keylength);<a name="line.1489"></a> +<span class="sourceLineNo">1490</span> return key;<a name="line.1490"></a> +<span class="sourceLineNo">1491</span> }<a name="line.1491"></a> +<span class="sourceLineNo">1492</span><a name="line.1492"></a> +<span class="sourceLineNo">1493</span> /**<a name="line.1493"></a> +<span class="sourceLineNo">1494</span> *<a name="line.1494"></a> +<span class="sourceLineNo">1495</span> * @return Timestamp<a name="line.1495"></a> +<span class="sourceLineNo">1496</span> */<a name="line.1496"></a> +<span class="sourceLineNo">1497</span> @Override<a name="line.1497"></a> +<span class="sourceLineNo">1498</span> public long getTimestamp() {<a name="line.1498"></a> +<span class="sourceLineNo">1499</span> return getTimestamp(getKeyLength());<a name="line.1499"></a> +<span class="sourceLineNo">1500</span> }<a name="line.1500"></a> +<span class="sourceLineNo">1501</span><a name="line.1501"></a> +<span class="sourceLineNo">1502</span> /**<a name="line.1502"></a> +<span class="sourceLineNo">1503</span> * @param keylength Pass if you have it to save on a int creation.<a name="line.1503"></a> +<span class="sourceLineNo">1504</span> * @return Timestamp<a name="line.1504"></a> +<span class="sourceLineNo">1505</span> */<a name="line.1505"></a> +<span class="sourceLineNo">1506</span> long getTimestamp(final int keylength) {<a name="line.1506"></a> +<span class="sourceLineNo">1507</span> int tsOffset = getTimestampOffset(keylength);<a name="line.1507"></a> +<span class="sourceLineNo">1508</span> return Bytes.toLong(this.bytes, tsOffset);<a name="line.1508"></a> +<span class="sourceLineNo">1509</span> }<a name="line.1509"></a> +<span class="sourceLineNo">1510</span><a name="line.1510"></a> +<span class="sourceLineNo">1511</span> /**<a name="line.1511"></a> +<span class="sourceLineNo">1512</span> * @return Type of this KeyValue.<a name="line.1512"></a> +<span class="sourceLineNo">1513</span> */<a name="line.1513"></a> +<span class="sourceLineNo">1514</span> @Deprecated<a name="line.1514"></a> +<span class="sourceLineNo">1515</span> public byte getType() {<a name="line.1515"></a> +<span class="sourceLineNo">1516</span> return getTypeByte();<a name="line.1516"></a> +<span class="sourceLineNo">1517</span> }<a name="line.1517"></a> +<span class="sourceLineNo">1518</span><a name="line.1518"></a> +<span class="sourceLineNo">1519</span> /**<a name="line.1519"></a> +<span class="sourceLineNo">1520</span> * @return KeyValue.TYPE byte representation<a name="line.1520"></a> +<span class="sourceLineNo">1521</span> */<a name="line.1521"></a> +<span class="sourceLineNo">1522</span> @Override<a name="line.1522"></a> +<span class="sourceLineNo">1523</span> public byte getTypeByte() {<a name="line.1523"></a> +<span class="sourceLineNo">1524</span> return this.bytes[this.offset + getKeyLength() - 1 + ROW_OFFSET];<a name="line.1524"></a> +<span class="sourceLineNo">1525</span> }<a name="line.1525"></a> +<span class="sourceLineNo">1526</span><a name="line.1526"></a> +<span class="sourceLineNo">1527</span> /**<a name="line.1527"></a> +<span class="sourceLineNo">1528</span> * @return True if a delete type, a {@link KeyValue.Type#Delete} or<a name="line.1528"></a> +<span class="sourceLineNo">1529</span> * a {KeyValue.Type#DeleteFamily} or a {@link KeyValue.Type#DeleteColumn}<a name="line.1529"></a> +<span class="sourceLineNo">1530</span> * KeyValue type.<a name="line.1530"></a> +<span class="sourceLineNo">1531</span> */<a name="line.1531"></a> +<span class="sourceLineNo">1532</span> @Deprecated // use CellUtil#isDelete<a name="line.1532"></a> +<span class="sourceLineNo">1533</span> public boolean isDelete() {<a name="line.1533"></a> +<span class="sourceLineNo">1534</span> return KeyValue.isDelete(getType());<a name="line.1534"></a> +<span class="sourceLineNo">1535</span> }<a name="line.1535"></a> +<span class="sourceLineNo">1536</span><a name="line.1536"></a> +<span class="sourceLineNo">1537</span> /**<a name="line.1537"></a> +<span class="sourceLineNo">1538</span> * This returns the offset where the tag actually starts.<a name="line.1538"></a> +<span class="sourceLineNo">1539</span> */<a name="line.1539"></a> +<span class="sourceLineNo">1540</span> @Override<a name="line.1540"></a> +<span class="sourceLineNo">1541</span> public int getTagsOffset() {<a name="line.1541"></a> +<span class="sourceLineNo">1542</span> int tagsLen = getTagsLength();<a name="line.1542"></a> +<span class="sourceLineNo">1543</span> if (tagsLen == 0) {<a name="line.1543"></a> +<span class="sourceLineNo">1544</span> return this.offset + this.length;<a name="line.1544"></a> +<span class="sourceLineNo">1545</span> }<a name="line.1545"></a> +<span class="sourceLineNo">1546</span> return this.offset + this.length - tagsLen;<a name="line.1546"></a> +<span class="sourceLineNo">1547</span> }<a name="line.1547"></a> +<span class="sourceLineNo">1548</span><a name="line.1548"></a> +<span class="sourceLineNo">1549</span> /**<a name="line.1549"></a> +<span class="sourceLineNo">1550</span> * This returns the total length of the tag bytes<a name="line.1550"></a> +<span class="sourceLineNo">1551</span> */<a name="line.1551"></a> +<span class="sourceLineNo">1552</span> @Override<a name="line.1552"></a> +<span class="sourceLineNo">1553</span> public int getTagsLength() {<a name="line.1553"></a> +<span class="sourceLineNo">1554</span> int tagsLen = this.length - (getKeyLength() + getValueLength() + KEYVALUE_INFRASTRUCTURE_SIZE);<a name="line.1554"></a> +<span class="sourceLineNo">1555</span> if (tagsLen > 0) {<a name="line.1555"></a> +<span class="sourceLineNo">1556</span> // There are some Tag bytes in the byte[]. So reduce 2 bytes which is added to denote the tags<a name="line.1556"></a> +<span class="sourceLineNo">1557</span> // length<a name="line.1557"></a> +<span class="sourceLineNo">1558</span> tagsLen -= TAGS_LENGTH_SIZE;<a name="line.1558"></a> +<span class="sourceLineNo">1559</span> }<a name="line.1559"></a> +<span class="sourceLineNo">1560</span> return tagsLen;<a name="line.1560"></a> +<span class="sourceLineNo">1561</span> }<a name="line.1561"></a> +<span class="sourceLineNo">1562</span><a name="line.1562"></a> +<span class="sourceLineNo">1563</span> /**<a name="line.1563"></a> +<span class="sourceLineNo">1564</span> * Returns any tags embedded in the KeyValue. Used in testcases.<a name="line.1564"></a> +<span class="sourceLineNo">1565</span> * @return The tags<a name="line.1565"></a> +<span class="sourceLineNo">1566</span> */<a name="line.1566"></a> +<span class="sourceLineNo">1567</span> public List<Tag> getTags() {<a name="line.1567"></a> +<span class="sourceLineNo">1568</span> int tagsLength = getTagsLength();<a name="line.1568"></a> +<span class="sourceLineNo">1569</span> if (tagsLength == 0) {<a name="line.1569"></a> +<span class="sourceLineNo">1570</span> return EMPTY_ARRAY_LIST;<a name="line.1570"></a> +<span class="sourceLineNo">1571</span> }<a name="line.1571"></a> +<span class="sourceLineNo">1572</span> return TagUtil.asList(getTagsArray(), getTagsOffset(), tagsLength);<a name="line.1572"></a> +<span class="sourceLineNo">1573</span> }<a name="line.1573"></a> +<span class="sourceLineNo">1574</span><a name="line.1574"></a> +<span class="sourceLineNo">1575</span> /**<a name="line.1575"></a> +<span class="sourceLineNo">1576</span> * @return the backing array of the entire KeyValue (all KeyValue fields are in a single array)<a name="line.1576"></a> +<span class="sourceLineNo">1577</span> */<a name="line.1577"></a> +<span class="sourceLineNo">1578</span> @Override<a name="line.1578"></a> +<span class="sourceLineNo">1579</span> public byte[] getTagsArray() {<a name="line.1579"></a> +<span class="sourceLineNo">1580</span> return bytes;<a name="line.1580"></a> +<span class="sourceLineNo">1581</span> }<a name="line.1581"></a> +<span class="sourceLineNo">1582</span><a name="line.1582"></a> +<span class="sourceLineNo">1583</span> /**<a name="line.1583"></a> +<span class="sourceLineNo">1584</span> * Creates a new KeyValue that only contains the key portion (the value is<a name="line.1584"></a> +<span class="sourceLineNo">1585</span> * set to be null).<a name="line.1585"></a> +<span class="sourceLineNo">1586</span> *<a name="line.1586"></a> +<span class="sourceLineNo">1587</span> * TODO only used by KeyOnlyFilter -- move there.<a name="line.1587"></a> +<span class="sourceLineNo">1588</span> * @param lenAsVal replace value with the actual value length (false=empty)<a name="line.1588"></a> +<span class="sourceLineNo">1589</span> */<a name="line.1589"></a> +<span class="sourceLineNo">1590</span> public KeyValue createKeyOnly(boolean lenAsVal) {<a name="line.1590"></a> +<span class="sourceLineNo">1591</span> // KV format: <keylen:4><valuelen:4><key:keylen><value:valuelen><a name="line.1591"></a> +<span class="sourceLineNo">1592</span> // Rebuild as: <keylen:4><0:4><key:keylen><a name="line.1592"></a> +<span class="sourceLineNo">1593</span> int dataLen = lenAsVal? Bytes.SIZEOF_INT : 0;<a name="line.1593"></a> +<span class="sourceLineNo">1594</span> byte [] newBuffer = new byte[getKeyLength() + ROW_OFFSET + dataLen];<a name="line.1594"></a> +<span class="sourceLineNo">1595</span> System.arraycopy(this.bytes, this.offset, newBuffer, 0,<a name="line.1595"></a> +<span class="sourceLineNo">1596</span> Math.min(newBuffer.length,this.length));<a name="line.1596"></a> +<span class="sourceLineNo">1597</span> Bytes.putInt(newBuffer, Bytes.SIZEOF_INT, dataLen);<a name="line.1597"></a> +<span class="sourceLineNo">1598</span> if (lenAsVal) {<a name="line.1598"></a> +<span class="sourceLineNo">1599</span> Bytes.putInt(newBuffer, newBuffer.length - dataLen, this.getValueLength());<a name="line.1599"></a> +<span class="sourceLineNo">1600</span> }<a name="line.1600"></a> +<span class="sourceLineNo">1601</span> return new KeyValue(newBuffer);<a name="line.1601"></a> +<span class="sourceLineNo">1602</span> }<a name="line.1602"></a> +<span class="sourceLineNo">1603</span><a name="line.1603"></a> +<span class="sourceLineNo">1604</span> /**<a name="line.1604"></a> +<span class="sourceLineNo">1605</span> * Splits a column in {@code family:qualifier} form into separate byte arrays. An empty qualifier<a name="line.1605"></a> +<span class="sourceLineNo">1606</span> * (ie, {@code fam:}) is parsed as <code>{ fam, EMPTY_BYTE_ARRAY }</code> while no delimiter (ie,<a name="line.1606"></a> +<span class="sourceLineNo">1607</span> * {@code fam}) is parsed as an array of one element, <code>{ fam }</code>.<a name="line.1607"></a> +<span class="sourceLineNo">1608</span> * <p><a name="line.1608"></a> +<span class="sourceLineNo">1609</span> * Don't forget, HBase DOES support empty qualifiers. (see HBASE-9549)<a name="line.1609"></a> +<span class="sourceLineNo">1610</span> * </p><a name="line.1610"></a> +<span class="sourceLineNo">1611</span> * <p><a name="line.1611"></a> +<span class="sourceLineNo">1612</span> * Not recommend to be used as this is old-style API.<a name="line.1612"></a> +<span class="sourceLineNo">1613</span> * </p><a name="line.1613"></a> +<span class="sourceLineNo">1614</span> * @param c The column.<a name="line.1614"></a> +<span class="sourceLineNo">1615</span> * @return The parsed column.<a name="line.1615"></a> +<span class="sourceLineNo">1616</span> */<a name="line.1616"></a> +<span class="sourceLineNo">1617</span> public static byte [][] parseColumn(byte [] c) {<a name="line.1617"></a> +<span class="sourceLineNo">1618</span> final int index = getDelimiter(c, 0, c.length, COLUMN_FAMILY_DELIMITER);<a name="line.1618"></a> +<span class="sourceLineNo">1619</span> if (index == -1) {<a <TRUNCATED>