HBASE-13739 Remove KeyValueUtil.ensureKeyValue(cell) from MOB code.(Jingcheng)

This commit is contained in:
anoopsjohn 2015-05-22 20:15:22 +05:30
parent 5098f365b4
commit 132f65ea1f
4 changed files with 12 additions and 21 deletions

View File

@ -31,7 +31,6 @@ import org.apache.hadoop.fs.Path;
import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.HConstants;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.KeyValueUtil;
import org.apache.hadoop.hbase.Tag;
import org.apache.hadoop.hbase.TagType;
import org.apache.hadoop.hbase.monitoring.MonitoredTask;
@ -175,19 +174,18 @@ public class DefaultMobStoreFlusher extends DefaultStoreFlusher {
// If we know that this KV is going to be included always, then let us
// set its memstoreTS to 0. This will help us save space when writing to
// disk.
KeyValue kv = KeyValueUtil.ensureKeyValue(c);
if (kv.getValueLength() <= mobCellValueSizeThreshold || MobUtils.isMobReferenceCell(kv)
|| kv.getTypeByte() != KeyValue.Type.Put.getCode()) {
writer.append(kv);
if (c.getValueLength() <= mobCellValueSizeThreshold || MobUtils.isMobReferenceCell(c)
|| c.getTypeByte() != KeyValue.Type.Put.getCode()) {
writer.append(c);
} else {
// append the original keyValue in the mob file.
mobFileWriter.append(kv);
mobSize += kv.getValueLength();
mobFileWriter.append(c);
mobSize += c.getValueLength();
mobCount++;
// append the tags to the KeyValue.
// The key is same, the value is the filename of the mob file
KeyValue reference = MobUtils.createMobRefKeyValue(kv, fileName, tableNameTag);
KeyValue reference = MobUtils.createMobRefKeyValue(c, fileName, tableNameTag);
writer.append(reference);
}
}

View File

@ -361,12 +361,10 @@ public class PartitionedMobFileCompactor extends MobFileCompactor {
do {
hasMore = scanner.next(cells, scannerContext);
for (Cell cell : cells) {
// TODO remove this after the new code are introduced.
KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
// write the mob cell to the mob file.
writer.append(kv);
writer.append(cell);
// write the new reference cell to the store file.
KeyValue reference = MobUtils.createMobRefKeyValue(kv, fileName, tableNameTag);
KeyValue reference = MobUtils.createMobRefKeyValue(cell, fileName, tableNameTag);
refFileWriter.append(reference);
mobCells++;
}
@ -468,9 +466,7 @@ public class PartitionedMobFileCompactor extends MobFileCompactor {
do {
hasMore = scanner.next(cells, scannerContext);
for (Cell cell : cells) {
// TODO remove this after the new code are introduced.
KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
writer.append(kv);
writer.append(cell);
}
cells.clear();
} while (hasMore);

View File

@ -34,9 +34,7 @@ import org.apache.hadoop.hbase.KeyValueUtil;
import org.apache.hadoop.hbase.Tag;
import org.apache.hadoop.hbase.TagType;
import org.apache.hadoop.hbase.client.BufferedMutator;
import org.apache.hadoop.hbase.client.HTable;
import org.apache.hadoop.hbase.client.Put;
import org.apache.hadoop.hbase.client.Table;
import org.apache.hadoop.hbase.io.hfile.CacheConfig;
import org.apache.hadoop.hbase.mob.MobConstants;
import org.apache.hadoop.hbase.mob.MobUtils;
@ -140,8 +138,7 @@ public class MemStoreWrapper {
KeyValueScanner scanner = snapshot.getScanner();
Cell cell = null;
while (null != (cell = scanner.next())) {
KeyValue kv = KeyValueUtil.ensureKeyValue(cell);
mobFileWriter.append(kv);
mobFileWriter.append(cell);
}
scanner.close();
// Write out the log sequence number that corresponds to this output

View File

@ -73,8 +73,8 @@ import org.apache.zookeeper.KeeperException;
* This reducer merges the small mob files into bigger ones, and write visited
* names of mob files to a sequence file which is used by the sweep job to delete
* the unused mob files.
* The key of the input is a file name, the value is a collection of KeyValue where
* the KeyValue is the actual cell (its format is valueLength + fileName) in HBase.
* The key of the input is a file name, the value is a collection of KeyValues
* (the value format of KeyValue is valueLength + fileName) in HBase.
* In this reducer, we could know how many cells exist in HBase for a mob file.
* If the existCellSize/mobFileSize < compactionRatio, this mob
* file needs to be merged.