當前位置: 首頁>>代碼示例>>Java>>正文


Java HBaseTestingUtility.getFromStoreFile方法代碼示例

本文整理匯總了Java中org.apache.hadoop.hbase.HBaseTestingUtility.getFromStoreFile方法的典型用法代碼示例。如果您正苦於以下問題:Java HBaseTestingUtility.getFromStoreFile方法的具體用法?Java HBaseTestingUtility.getFromStoreFile怎麽用?Java HBaseTestingUtility.getFromStoreFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.hadoop.hbase.HBaseTestingUtility的用法示例。


在下文中一共展示了HBaseTestingUtility.getFromStoreFile方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testGet_FromMemStoreOnly

import org.apache.hadoop.hbase.HBaseTestingUtility; //導入方法依賴的package包/類
/**
 * Getting data from memstore only
 * @throws IOException
 */
@Test
public void testGet_FromMemStoreOnly() throws IOException {
  init(this.name.getMethodName());

  //Put data in memstore
  this.store.add(new KeyValue(row, family, qf1, 1, (byte[])null));
  this.store.add(new KeyValue(row, family, qf2, 1, (byte[])null));
  this.store.add(new KeyValue(row, family, qf3, 1, (byte[])null));
  this.store.add(new KeyValue(row, family, qf4, 1, (byte[])null));
  this.store.add(new KeyValue(row, family, qf5, 1, (byte[])null));
  this.store.add(new KeyValue(row, family, qf6, 1, (byte[])null));

  //Get
  result = HBaseTestingUtility.getFromStoreFile(store,
      get.getRow(), qualifiers);

  //Compare
  assertCheck();
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:24,代碼來源:TestStore.java

示例2: testEmptyStoreFile

import org.apache.hadoop.hbase.HBaseTestingUtility; //導入方法依賴的package包/類
/**
 * Test for hbase-1686.
 * @throws IOException
 */
@Test
public void testEmptyStoreFile() throws IOException {
  init(this.name.getMethodName());
  // Write a store file.
  this.store.add(new KeyValue(row, family, qf1, 1, (byte[])null));
  this.store.add(new KeyValue(row, family, qf2, 1, (byte[])null));
  flush(1);
  // Now put in place an empty store file.  Its a little tricky.  Have to
  // do manually with hacked in sequence id.
  StoreFile f = this.store.getStorefiles().iterator().next();
  Path storedir = f.getPath().getParent();
  long seqid = f.getMaxSequenceId();
  Configuration c = HBaseConfiguration.create();
  FileSystem fs = FileSystem.get(c);
  HFileContext meta = new HFileContextBuilder().withBlockSize(BLOCKSIZE_SMALL).build();
  StoreFile.Writer w = new StoreFile.WriterBuilder(c, new CacheConfig(c),
      fs)
          .withOutputDir(storedir)
          .withFileContext(meta)
          .build();
  w.appendMetadata(seqid + 1, false);
  w.close();
  this.store.close();
  // Reopen it... should pick up two files
  this.store = new HStore(this.store.getHRegion(), this.store.getFamily(), c);
  Assert.assertEquals(2, this.store.getStorefilesCount());

  result = HBaseTestingUtility.getFromStoreFile(store,
      get.getRow(),
      qualifiers);
  Assert.assertEquals(1, result.size());
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:37,代碼來源:TestStore.java

示例3: testGet_FromFilesOnly

import org.apache.hadoop.hbase.HBaseTestingUtility; //導入方法依賴的package包/類
/**
 * Getting data from files only
 * @throws IOException
 */
@Test
public void testGet_FromFilesOnly() throws IOException {
  init(this.name.getMethodName());

  //Put data in memstore
  this.store.add(new KeyValue(row, family, qf1, 1, (byte[])null));
  this.store.add(new KeyValue(row, family, qf2, 1, (byte[])null));
  //flush
  flush(1);

  //Add more data
  this.store.add(new KeyValue(row, family, qf3, 1, (byte[])null));
  this.store.add(new KeyValue(row, family, qf4, 1, (byte[])null));
  //flush
  flush(2);

  //Add more data
  this.store.add(new KeyValue(row, family, qf5, 1, (byte[])null));
  this.store.add(new KeyValue(row, family, qf6, 1, (byte[])null));
  //flush
  flush(3);

  //Get
  result = HBaseTestingUtility.getFromStoreFile(store,
      get.getRow(),
      qualifiers);
  //this.store.get(get, qualifiers, result);

  //Need to sort the result since multiple files
  Collections.sort(result, KeyValue.COMPARATOR);

  //Compare
  assertCheck();
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:39,代碼來源:TestStore.java

示例4: testGet_FromMemStoreAndFiles

import org.apache.hadoop.hbase.HBaseTestingUtility; //導入方法依賴的package包/類
/**
 * Getting data from memstore and files
 * @throws IOException
 */
@Test
public void testGet_FromMemStoreAndFiles() throws IOException {
  init(this.name.getMethodName());

  //Put data in memstore
  this.store.add(new KeyValue(row, family, qf1, 1, (byte[])null));
  this.store.add(new KeyValue(row, family, qf2, 1, (byte[])null));
  //flush
  flush(1);

  //Add more data
  this.store.add(new KeyValue(row, family, qf3, 1, (byte[])null));
  this.store.add(new KeyValue(row, family, qf4, 1, (byte[])null));
  //flush
  flush(2);

  //Add more data
  this.store.add(new KeyValue(row, family, qf5, 1, (byte[])null));
  this.store.add(new KeyValue(row, family, qf6, 1, (byte[])null));

  //Get
  result = HBaseTestingUtility.getFromStoreFile(store,
      get.getRow(), qualifiers);

  //Need to sort the result since multiple files
  Collections.sort(result, KeyValue.COMPARATOR);

  //Compare
  assertCheck();
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:35,代碼來源:TestStore.java

示例5: testIncrementColumnValue_ICVDuringFlush

import org.apache.hadoop.hbase.HBaseTestingUtility; //導入方法依賴的package包/類
@Test
public void testIncrementColumnValue_ICVDuringFlush()
    throws IOException, InterruptedException {
  init(this.name.getMethodName());

  long oldValue = 1L;
  long newValue = 3L;
  this.store.add(new KeyValue(row, family, qf1,
      System.currentTimeMillis(),
      Bytes.toBytes(oldValue)));

  // snapshot the store.
  this.store.snapshot();

  // add other things:
  this.store.add(new KeyValue(row, family, qf2,
      System.currentTimeMillis(),
      Bytes.toBytes(oldValue)));

  // update during the snapshot.
  long ret = this.store.updateColumnValue(row, family, qf1, newValue);

  // memstore should have grown by some amount.
  Assert.assertTrue(ret > 0);

  // then flush.
  flushStore(store, id++);
  Assert.assertEquals(1, this.store.getStorefiles().size());
  // from the one we inserted up there, and a new one
  Assert.assertEquals(2, ((DefaultMemStore)this.store.memstore).cellSet.size());

  // how many key/values for this row are there?
  Get get = new Get(row);
  get.addColumn(family, qf1);
  get.setMaxVersions(); // all versions.
  List<Cell> results = new ArrayList<Cell>();

  results = HBaseTestingUtility.getFromStoreFile(store, get);
  Assert.assertEquals(2, results.size());

  long ts1 = results.get(0).getTimestamp();
  long ts2 = results.get(1).getTimestamp();

  Assert.assertTrue(ts1 > ts2);

  Assert.assertEquals(newValue, Bytes.toLong(CellUtil.cloneValue(results.get(0))));
  Assert.assertEquals(oldValue, Bytes.toLong(CellUtil.cloneValue(results.get(1))));
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:49,代碼來源:TestStore.java

示例6: testIncrementColumnValue_SnapshotFlushCombo

import org.apache.hadoop.hbase.HBaseTestingUtility; //導入方法依賴的package包/類
@Test
public void testIncrementColumnValue_SnapshotFlushCombo() throws Exception {
  ManualEnvironmentEdge mee = new ManualEnvironmentEdge();
  EnvironmentEdgeManagerTestHelper.injectEdge(mee);
  init(this.name.getMethodName());

  long oldValue = 1L;
  long newValue = 3L;
  this.store.add(new KeyValue(row, family, qf1,
      EnvironmentEdgeManager.currentTime(),
      Bytes.toBytes(oldValue)));

  // snapshot the store.
  this.store.snapshot();

  // update during the snapshot, the exact same TS as the Put (lololol)
  long ret = this.store.updateColumnValue(row, family, qf1, newValue);

  // memstore should have grown by some amount.
  Assert.assertTrue(ret > 0);

  // then flush.
  flushStore(store, id++);
  Assert.assertEquals(1, this.store.getStorefiles().size());
  Assert.assertEquals(1, ((DefaultMemStore)this.store.memstore).cellSet.size());

  // now increment again:
  newValue += 1;
  this.store.updateColumnValue(row, family, qf1, newValue);

  // at this point we have a TS=1 in snapshot, and a TS=2 in kvset, so increment again:
  newValue += 1;
  this.store.updateColumnValue(row, family, qf1, newValue);

  // the second TS should be TS=2 or higher., even though 'time=1' right now.


  // how many key/values for this row are there?
  Get get = new Get(row);
  get.addColumn(family, qf1);
  get.setMaxVersions(); // all versions.
  List<Cell> results = new ArrayList<Cell>();

  results = HBaseTestingUtility.getFromStoreFile(store, get);
  Assert.assertEquals(2, results.size());

  long ts1 = results.get(0).getTimestamp();
  long ts2 = results.get(1).getTimestamp();

  Assert.assertTrue(ts1 > ts2);
  Assert.assertEquals(newValue, Bytes.toLong(CellUtil.cloneValue(results.get(0))));
  Assert.assertEquals(oldValue, Bytes.toLong(CellUtil.cloneValue(results.get(1))));

  mee.setValue(2); // time goes up slightly
  newValue += 1;
  this.store.updateColumnValue(row, family, qf1, newValue);

  results = HBaseTestingUtility.getFromStoreFile(store, get);
  Assert.assertEquals(2, results.size());

  ts1 = results.get(0).getTimestamp();
  ts2 = results.get(1).getTimestamp();

  Assert.assertTrue(ts1 > ts2);
  Assert.assertEquals(newValue, Bytes.toLong(CellUtil.cloneValue(results.get(0))));
  Assert.assertEquals(oldValue, Bytes.toLong(CellUtil.cloneValue(results.get(1))));
}
 
開發者ID:fengchen8086,項目名稱:ditb,代碼行數:68,代碼來源:TestStore.java


注:本文中的org.apache.hadoop.hbase.HBaseTestingUtility.getFromStoreFile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。