Java Code Examples for org.apache.hadoop.hbase.regionserver.BloomType#NONE

The following examples show how to use org.apache.hadoop.hbase.regionserver.BloomType#NONE . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestMobFile.java    From hbase with Apache License 2.0 6 votes vote down vote up
@Test
public void testGetScanner() throws Exception {
  Path testDir = TEST_UTIL.getDataTestDir();
  FileSystem fs = testDir.getFileSystem(conf);
  HFileContext meta = new HFileContextBuilder().withBlockSize(8*1024).build();
  StoreFileWriter writer = new StoreFileWriter.Builder(conf, cacheConf, fs)
          .withOutputDir(testDir)
          .withFileContext(meta)
          .build();
  MobTestUtil.writeStoreFile(writer, testName.getMethodName());

  MobFile mobFile =
      new MobFile(new HStoreFile(fs, writer.getPath(), conf, cacheConf, BloomType.NONE, true));
  assertNotNull(mobFile.getScanner());
  assertTrue(mobFile.getScanner() instanceof StoreFileScanner);
}
 
Example 2
Source File: TestMobStoreCompaction.java    From hbase with Apache License 2.0 6 votes vote down vote up
private long countMobCellsInMetadata() throws IOException {
  long mobCellsCount = 0;
  Path mobDirPath = MobUtils.getMobFamilyPath(conf, tableDescriptor.getTableName(),
    familyDescriptor.getNameAsString());
  Configuration copyOfConf = new Configuration(conf);
  copyOfConf.setFloat(HConstants.HFILE_BLOCK_CACHE_SIZE_KEY, 0f);
  CacheConfig cacheConfig = new CacheConfig(copyOfConf);
  if (fs.exists(mobDirPath)) {
    FileStatus[] files = UTIL.getTestFileSystem().listStatus(mobDirPath);
    for (FileStatus file : files) {
      HStoreFile sf = new HStoreFile(fs, file.getPath(), conf, cacheConfig, BloomType.NONE, true);
      sf.initReader();
      Map<byte[], byte[]> fileInfo = sf.getReader().loadFileInfo();
      byte[] count = fileInfo.get(MOB_CELLS_COUNT);
      assertTrue(count != null);
      mobCellsCount += Bytes.toLong(count);
    }
  }
  return mobCellsCount;
}
 
Example 3
Source File: ThriftUtilities.java    From hbase with Apache License 2.0 5 votes vote down vote up
public static BloomType bloomFilterFromThrift(TBloomFilterType in) {
  switch (in.getValue()) {
    case 0: return BloomType.NONE;
    case 1: return BloomType.ROW;
    case 2: return BloomType.ROWCOL;
    case 3: return BloomType.ROWPREFIX_FIXED_LENGTH;
    default: return BloomType.ROW;
  }
}
 
Example 4
Source File: CachedMobFile.java    From hbase with Apache License 2.0 5 votes vote down vote up
public static CachedMobFile create(FileSystem fs, Path path, Configuration conf,
    CacheConfig cacheConf) throws IOException {
  // XXX: primaryReplica is only used for constructing the key of block cache so it is not a
  // critical problem if we pass the wrong value, so here we always pass true. Need to fix later.
  HStoreFile sf = new HStoreFile(fs, path, conf, cacheConf, BloomType.NONE, true);
  return new CachedMobFile(sf);
}
 
Example 5
Source File: BloomFilterFactory.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new general (Row or RowCol) Bloom filter at the time of
 * {@link org.apache.hadoop.hbase.regionserver.HStoreFile} writing.
 *
 * @param conf
 * @param cacheConf
 * @param bloomType
 * @param maxKeys an estimate of the number of keys we expect to insert.
 *        Irrelevant if compound Bloom filters are enabled.
 * @param writer the HFile writer
 * @return the new Bloom filter, or null in case Bloom filters are disabled
 *         or when failed to create one.
 */
public static BloomFilterWriter createGeneralBloomAtWrite(Configuration conf,
    CacheConfig cacheConf, BloomType bloomType, int maxKeys,
    HFile.Writer writer) {
  if (!isGeneralBloomEnabled(conf)) {
    LOG.trace("Bloom filters are disabled by configuration for "
        + writer.getPath()
        + (conf == null ? " (configuration is null)" : ""));
    return null;
  } else if (bloomType == BloomType.NONE) {
    LOG.trace("Bloom filter is turned off for the column family");
    return null;
  }

  float err = getErrorRate(conf);

  // In case of row/column Bloom filter lookups, each lookup is an OR if two
  // separate lookups. Therefore, if each lookup's false positive rate is p,
  // the resulting false positive rate is err = 1 - (1 - p)^2, and
  // p = 1 - sqrt(1 - err).
  if (bloomType == BloomType.ROWCOL) {
    err = (float) (1 - Math.sqrt(1 - err));
  }

  int maxFold = conf.getInt(IO_STOREFILE_BLOOM_MAX_FOLD,
      MAX_ALLOWED_FOLD_FACTOR);

  // Do we support compound bloom filters?
  // In case of compound Bloom filters we ignore the maxKeys hint.
  CompoundBloomFilterWriter bloomWriter = new CompoundBloomFilterWriter(getBloomBlockSize(conf),
      err, Hash.getHashType(conf), maxFold, cacheConf.shouldCacheBloomsOnWrite(),
      bloomType == BloomType.ROWCOL ? CellComparatorImpl.COMPARATOR : null, bloomType);
  writer.addInlineBlockWriter(bloomWriter);
  return bloomWriter;
}
 
Example 6
Source File: MobFile.java    From hbase with Apache License 2.0 3 votes vote down vote up
/**
 * Creates an instance of the MobFile.
 * @param fs The file system.
 * @param path The path of the underlying StoreFile.
 * @param conf The configuration.
 * @param cacheConf The CacheConfig.
 * @return An instance of the MobFile.
 * @throws IOException
 */
public static MobFile create(FileSystem fs, Path path, Configuration conf, CacheConfig cacheConf)
    throws IOException {
  // XXX: primaryReplica is only used for constructing the key of block cache so it is not a
  // critical problem if we pass the wrong value, so here we always pass true. Need to fix later.
  HStoreFile sf = new HStoreFile(fs, path, conf, cacheConf, BloomType.NONE, true);
  return new MobFile(sf);
}