Java Code Examples for org.apache.hadoop.hbase.HBaseTestingUtility#getFromStoreFile()

The following examples show how to use org.apache.hadoop.hbase.HBaseTestingUtility#getFromStoreFile() . 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: TestHStore.java    From hbase with Apache License 2.0 6 votes vote down vote up
/**
 * 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), null);
  this.store.add(new KeyValue(row, family, qf2, 1, (byte[])null), null);
  this.store.add(new KeyValue(row, family, qf3, 1, (byte[])null), null);
  this.store.add(new KeyValue(row, family, qf4, 1, (byte[])null), null);
  this.store.add(new KeyValue(row, family, qf5, 1, (byte[])null), null);
  this.store.add(new KeyValue(row, family, qf6, 1, (byte[])null), null);

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

  //Compare
  assertCheck();
}
 
Example 2
Source File: TestHStore.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * 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), null);
  this.store.add(new KeyValue(row, family, qf2, 1, (byte[])null), null);
  flush(1);
  // Now put in place an empty store file.  Its a little tricky.  Have to
  // do manually with hacked in sequence id.
  HStoreFile 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();
  StoreFileWriter w = new StoreFileWriter.Builder(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.getColumnFamilyDescriptor(), c, false);
  assertEquals(2, this.store.getStorefilesCount());

  result = HBaseTestingUtility.getFromStoreFile(store,
      get.getRow(),
      qualifiers);
  assertEquals(1, result.size());
}
 
Example 3
Source File: TestHStore.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * 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), null);
  this.store.add(new KeyValue(row, family, qf2, 1, (byte[])null), null);
  //flush
  flush(1);

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

  //Add more data
  this.store.add(new KeyValue(row, family, qf5, 1, (byte[])null), null);
  this.store.add(new KeyValue(row, family, qf6, 1, (byte[])null), 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, CellComparatorImpl.COMPARATOR);

  //Compare
  assertCheck();
}
 
Example 4
Source File: TestHStore.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * 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), null);
  this.store.add(new KeyValue(row, family, qf2, 1, (byte[])null), null);
  //flush
  flush(1);

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

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

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

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

  //Compare
  assertCheck();
}