Search in sources :

Example 1 with HMobStore

use of org.apache.hadoop.hbase.regionserver.HMobStore in project hbase by apache.

the class TestMobFileCache method createMobStoreFile.

/**
   * Create the mob store file
   */
private Path createMobStoreFile(HColumnDescriptor hcd) throws IOException {
    // Setting up a Store
    TableName tn = TableName.valueOf(TABLE);
    HTableDescriptor htd = new HTableDescriptor(tn);
    htd.addFamily(hcd);
    HMobStore mobStore = (HMobStore) region.getStore(hcd.getName());
    KeyValue key1 = new KeyValue(ROW, hcd.getName(), QF1, 1, VALUE);
    KeyValue key2 = new KeyValue(ROW, hcd.getName(), QF2, 1, VALUE);
    KeyValue key3 = new KeyValue(ROW2, hcd.getName(), QF3, 1, VALUE2);
    KeyValue[] keys = new KeyValue[] { key1, key2, key3 };
    int maxKeyCount = keys.length;
    HRegionInfo regionInfo = new HRegionInfo(tn);
    StoreFileWriter mobWriter = mobStore.createWriterInTmp(currentDate, maxKeyCount, hcd.getCompactionCompression(), regionInfo.getStartKey(), false);
    Path mobFilePath = mobWriter.getPath();
    String fileName = mobFilePath.getName();
    mobWriter.append(key1);
    mobWriter.append(key2);
    mobWriter.append(key3);
    mobWriter.close();
    String targetPathName = MobUtils.formatDate(currentDate);
    Path targetPath = new Path(mobStore.getPath(), targetPathName);
    mobStore.commitFile(mobFilePath, targetPath);
    return new Path(targetPath, fileName);
}
Also used : HRegionInfo(org.apache.hadoop.hbase.HRegionInfo) Path(org.apache.hadoop.fs.Path) TableName(org.apache.hadoop.hbase.TableName) StoreFileWriter(org.apache.hadoop.hbase.regionserver.StoreFileWriter) KeyValue(org.apache.hadoop.hbase.KeyValue) HMobStore(org.apache.hadoop.hbase.regionserver.HMobStore) HTableDescriptor(org.apache.hadoop.hbase.HTableDescriptor)

Aggregations

Path (org.apache.hadoop.fs.Path)1 HRegionInfo (org.apache.hadoop.hbase.HRegionInfo)1 HTableDescriptor (org.apache.hadoop.hbase.HTableDescriptor)1 KeyValue (org.apache.hadoop.hbase.KeyValue)1 TableName (org.apache.hadoop.hbase.TableName)1 HMobStore (org.apache.hadoop.hbase.regionserver.HMobStore)1 StoreFileWriter (org.apache.hadoop.hbase.regionserver.StoreFileWriter)1