HBASE-11901 Improve the value size of the reference cell in mob column.(Jingcheng Du)

This commit is contained in:
anoopsjohn 2014-09-06 09:59:55 +05:30
parent 5c14f749b3
commit e8938c40d6
5 changed files with 11 additions and 8 deletions

View File

@ -251,7 +251,7 @@ public class MobUtils {
// find the original mob files by this table name. For details please see cloning
// snapshot for mob files.
existingTags.add(tableNameTag);
long valueLength = kv.getValueLength();
int valueLength = kv.getValueLength();
byte[] refValue = Bytes.add(Bytes.toBytes(valueLength), fileName);
KeyValue reference = new KeyValue(kv.getRowArray(), kv.getRowOffset(), kv.getRowLength(),
kv.getFamilyArray(), kv.getFamilyOffset(), kv.getFamilyLength(), kv.getQualifierArray(),

View File

@ -219,9 +219,9 @@ public class HMobStore extends HStore {
*/
public Cell resolve(Cell reference, boolean cacheBlocks) throws IOException {
Cell result = null;
if (reference.getValueLength() > Bytes.SIZEOF_LONG) {
if (reference.getValueLength() > Bytes.SIZEOF_INT) {
String fileName = Bytes.toString(reference.getValueArray(), reference.getValueOffset()
+ Bytes.SIZEOF_LONG, reference.getValueLength() - Bytes.SIZEOF_LONG);
+ Bytes.SIZEOF_INT, reference.getValueLength() - Bytes.SIZEOF_INT);
Path targetPath = new Path(mobFamilyPath, fileName);
MobFile file = null;
try {

View File

@ -213,7 +213,7 @@ public class TestDeleteMobTable {
Result r = rs.next();
Assert.assertNotNull(r);
byte[] value = r.getValue(FAMILY, QF);
String fileName = Bytes.toString(value, Bytes.SIZEOF_LONG, value.length - Bytes.SIZEOF_LONG);
String fileName = Bytes.toString(value, Bytes.SIZEOF_INT, value.length - Bytes.SIZEOF_INT);
Path filePath = new Path(
MobUtils.getMobFamilyPath(TEST_UTIL.getConfiguration(), tn, familyName), fileName);
FileSystem fs = TEST_UTIL.getTestFileSystem();

View File

@ -169,9 +169,9 @@ public class TestHMobStore {
mobWriter.append(key3);
mobWriter.close();
long valueLength1 = key1.getValueLength();
long valueLength2 = key2.getValueLength();
long valueLength3 = key3.getValueLength();
int valueLength1 = key1.getValueLength();
int valueLength2 = key2.getValueLength();
int valueLength3 = key3.getValueLength();
String targetPathName = MobUtils.formatDate(currentDate);
byte[] referenceValue =

View File

@ -307,7 +307,10 @@ public class TestMobStoreScanner {
Assert.assertFalse(Bytes.toString(value).equals(
Bytes.toString(CellUtil.cloneValue(cell))));
byte[] referenceValue = CellUtil.cloneValue(cell);
String fileName = Bytes.toString(referenceValue, 8, referenceValue.length-8);
String fileName = Bytes.toString(referenceValue, Bytes.SIZEOF_INT,
referenceValue.length - Bytes.SIZEOF_INT);
int valLen = Bytes.toInt(referenceValue, 0, Bytes.SIZEOF_INT);
Assert.assertEquals(value.length, valLen);
Path mobFamilyPath;
mobFamilyPath = new Path(MobUtils.getMobRegionPath(TEST_UTIL.getConfiguration(),
TableName.valueOf(TN)), hcd.getNameAsString());