Search in sources :

Example 1 with MobFileName

use of org.apache.hadoop.hbase.mob.MobFileName in project hbase by apache.

the class TestPartitionedMobCompactor method createMobDelFile.

/**
   * Create mulitple partition delete files
   */
private void createMobDelFile(Path basePath, int startKey) throws IOException {
    HFileContext meta = new HFileContextBuilder().withBlockSize(8 * 1024).build();
    MobFileName mobFileName = null;
    Date today = new Date();
    byte[] startRow = Bytes.toBytes(startKey);
    mobFileName = MobFileName.create(startRow, MobUtils.formatDate(today), delSuffix);
    StoreFileWriter mobFileWriter = new StoreFileWriter.Builder(conf, cacheConf, fs).withFileContext(meta).withFilePath(new Path(basePath, mobFileName.getFileName())).build();
    long now = System.currentTimeMillis();
    try {
        byte[] key = Bytes.add(Bytes.toBytes(KEYS[startKey]), Bytes.toBytes(0));
        byte[] dummyData = new byte[5000];
        new Random().nextBytes(dummyData);
        mobFileWriter.append(new KeyValue(key, Bytes.toBytes(family), Bytes.toBytes(qf), now, Type.Delete, dummyData));
        key = Bytes.add(Bytes.toBytes(KEYS[startKey]), Bytes.toBytes(2));
        mobFileWriter.append(new KeyValue(key, Bytes.toBytes(family), Bytes.toBytes(qf), now, Type.Delete, dummyData));
        key = Bytes.add(Bytes.toBytes(KEYS[startKey]), Bytes.toBytes(4));
        mobFileWriter.append(new KeyValue(key, Bytes.toBytes(family), Bytes.toBytes(qf), now, Type.Delete, dummyData));
    } finally {
        mobFileWriter.close();
    }
}
Also used : Path(org.apache.hadoop.fs.Path) MobFileName(org.apache.hadoop.hbase.mob.MobFileName) HFileContextBuilder(org.apache.hadoop.hbase.io.hfile.HFileContextBuilder) HFileContext(org.apache.hadoop.hbase.io.hfile.HFileContext)

Example 2 with MobFileName

use of org.apache.hadoop.hbase.mob.MobFileName in project hbase by apache.

the class HMobStore method createDelFileWriterInTmp.

/**
   * Creates the writer for the del file in temp directory.
   * The del file keeps tracking the delete markers. Its name has a suffix _del,
   * the format is [0-9a-f]+(_del)?.
   * @param date The latest date of written cells.
   * @param maxKeyCount The key count.
   * @param compression The compression algorithm.
   * @param startKey The start key.
   * @return The writer for the del file.
   * @throws IOException
   */
public StoreFileWriter createDelFileWriterInTmp(Date date, long maxKeyCount, Compression.Algorithm compression, byte[] startKey) throws IOException {
    if (startKey == null) {
        startKey = HConstants.EMPTY_START_ROW;
    }
    Path path = getTempDir();
    String suffix = UUID.randomUUID().toString().replaceAll("-", "") + "_del";
    MobFileName mobFileName = MobFileName.create(startKey, MobUtils.formatDate(date), suffix);
    return createWriterInTmp(mobFileName, path, maxKeyCount, compression, true);
}
Also used : Path(org.apache.hadoop.fs.Path) MobFileName(org.apache.hadoop.hbase.mob.MobFileName)

Example 3 with MobFileName

use of org.apache.hadoop.hbase.mob.MobFileName in project hbase by apache.

the class BaseTestHBaseFsck method createMobFileName.

/**
 * Creates a new mob file name by the old one.
 * @param oldFileName The old mob file name.
 * @return The new mob file name.
 */
String createMobFileName(String oldFileName) {
    MobFileName mobFileName = MobFileName.create(oldFileName);
    String startKey = mobFileName.getStartKey();
    String date = mobFileName.getDate();
    return MobFileName.create(startKey, date, TEST_UTIL.getRandomUUID().toString().replaceAll("-", ""), "abcdef").getFileName();
}
Also used : MobFileName(org.apache.hadoop.hbase.mob.MobFileName)

Example 4 with MobFileName

use of org.apache.hadoop.hbase.mob.MobFileName in project hbase by apache.

the class TestPartitionedMobCompactor method createMobFile.

/**
   * Create mulitple partition files
   */
private void createMobFile(Path basePath) throws IOException {
    HFileContext meta = new HFileContextBuilder().withBlockSize(8 * 1024).build();
    MobFileName mobFileName = null;
    int ii = 0;
    Date today = new Date();
    for (byte k0 : KEYS) {
        byte[] startRow = Bytes.toBytes(ii++);
        mobFileName = MobFileName.create(startRow, MobUtils.formatDate(today), mobSuffix);
        StoreFileWriter mobFileWriter = new StoreFileWriter.Builder(conf, cacheConf, fs).withFileContext(meta).withFilePath(new Path(basePath, mobFileName.getFileName())).build();
        long now = System.currentTimeMillis();
        try {
            for (int i = 0; i < 10; i++) {
                byte[] key = Bytes.add(Bytes.toBytes(k0), Bytes.toBytes(i));
                byte[] dummyData = new byte[5000];
                new Random().nextBytes(dummyData);
                mobFileWriter.append(new KeyValue(key, Bytes.toBytes(family), Bytes.toBytes(qf), now, Type.Put, dummyData));
            }
        } finally {
            mobFileWriter.close();
        }
    }
}
Also used : Path(org.apache.hadoop.fs.Path) HFileContextBuilder(org.apache.hadoop.hbase.io.hfile.HFileContextBuilder) HFileContext(org.apache.hadoop.hbase.io.hfile.HFileContext) MobFileName(org.apache.hadoop.hbase.mob.MobFileName)

Example 5 with MobFileName

use of org.apache.hadoop.hbase.mob.MobFileName in project hbase by apache.

the class TestPartitionedMobCompactor method createStoreFiles.

private void createStoreFiles(Path basePath, String family, String qualifier, int count, Type type, boolean sameStartKey, final Date date) throws IOException {
    HFileContext meta = new HFileContextBuilder().withBlockSize(8 * 1024).build();
    String startKey = "row_";
    MobFileName mobFileName = null;
    for (int i = 0; i < count; i++) {
        byte[] startRow;
        if (sameStartKey) {
            // When creating multiple files under one partition, suffix needs to be different.
            startRow = Bytes.toBytes(startKey);
            mobSuffix = UUID.randomUUID().toString().replaceAll("-", "");
            delSuffix = UUID.randomUUID().toString().replaceAll("-", "") + "_del";
        } else {
            startRow = Bytes.toBytes(startKey + i);
        }
        if (type.equals(Type.Delete)) {
            mobFileName = MobFileName.create(startRow, MobUtils.formatDate(date), delSuffix);
        }
        if (type.equals(Type.Put)) {
            mobFileName = MobFileName.create(startRow, MobUtils.formatDate(date), mobSuffix);
        }
        StoreFileWriter mobFileWriter = new StoreFileWriter.Builder(conf, cacheConf, fs).withFileContext(meta).withFilePath(new Path(basePath, mobFileName.getFileName())).build();
        writeStoreFile(mobFileWriter, startRow, Bytes.toBytes(family), Bytes.toBytes(qualifier), type, (i + 1) * 1000);
    }
}
Also used : Path(org.apache.hadoop.fs.Path) MobFileName(org.apache.hadoop.hbase.mob.MobFileName) HFileContextBuilder(org.apache.hadoop.hbase.io.hfile.HFileContextBuilder) HFileContext(org.apache.hadoop.hbase.io.hfile.HFileContext)

Aggregations

MobFileName (org.apache.hadoop.hbase.mob.MobFileName)5 Path (org.apache.hadoop.fs.Path)4 HFileContext (org.apache.hadoop.hbase.io.hfile.HFileContext)3 HFileContextBuilder (org.apache.hadoop.hbase.io.hfile.HFileContextBuilder)3