当前位置: 首页>>代码示例>>Java>>正文


Java KeyValueTestUtil.create方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.KeyValueTestUtil.create方法的典型用法代码示例。如果您正苦于以下问题:Java KeyValueTestUtil.create方法的具体用法?Java KeyValueTestUtil.create怎么用?Java KeyValueTestUtil.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.KeyValueTestUtil的用法示例。


在下文中一共展示了KeyValueTestUtil.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testScanSameTimestamp

import org.apache.hadoop.hbase.KeyValueTestUtil; //导入方法依赖的package包/类
public void testScanSameTimestamp() throws IOException {
  // returns only 1 of these 2 even though same timestamp
  KeyValue [] kvs = new KeyValue[] {
      KeyValueTestUtil.create("R1", "cf", "a", 1, KeyValue.Type.Put, "dont-care"),
      KeyValueTestUtil.create("R1", "cf", "a", 1, KeyValue.Type.Put, "dont-care"),
  };
  List<KeyValueScanner> scanners = Arrays.asList(
      new KeyValueScanner[] {
          new KeyValueScanFixture(KeyValue.COMPARATOR, kvs)
      });

  Scan scanSpec = new Scan(Bytes.toBytes("R1"));
  // this only uses maxVersions (default=1) and TimeRange (default=all)
  StoreScanner scan = new StoreScanner(scanSpec, scanInfo, scanType,
      getCols("a"), scanners);

  List<Cell> results = new ArrayList<Cell>();
  assertEquals(true, scan.next(results));
  assertEquals(1, results.size());
  assertEquals(kvs[0], results.get(0));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:22,代码来源:TestStoreScanner.java

示例2: testDeletedRowThenGoodRow

import org.apache.hadoop.hbase.KeyValueTestUtil; //导入方法依赖的package包/类
public void testDeletedRowThenGoodRow() throws IOException {
  KeyValue [] kvs = new KeyValue [] {
      KeyValueTestUtil.create("R1", "cf", "a", 1, KeyValue.Type.Put, "dont-care"),
      KeyValueTestUtil.create("R1", "cf", "a", 1, KeyValue.Type.Delete, "dont-care"),
      KeyValueTestUtil.create("R2", "cf", "a", 20, KeyValue.Type.Put, "dont-care")
  };
  List<KeyValueScanner> scanners = scanFixture(kvs);
  Scan scanSpec = new Scan(Bytes.toBytes("R1"));
  StoreScanner scan = new StoreScanner(scanSpec, scanInfo, scanType,
      getCols("a"), scanners);

  List<Cell> results = new ArrayList<Cell>();
  assertEquals(true, scan.next(results));
  assertEquals(0, results.size());

  assertEquals(true, scan.next(results));
  assertEquals(1, results.size());
  assertEquals(kvs[2], results.get(0));

  assertEquals(false, scan.next(results));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:22,代码来源:TestStoreScanner.java

示例3: testDeleteVersionMaskingMultiplePuts

import org.apache.hadoop.hbase.KeyValueTestUtil; //导入方法依赖的package包/类
public void testDeleteVersionMaskingMultiplePuts() throws IOException {
  long now = System.currentTimeMillis();
  KeyValue [] kvs1 = new KeyValue[] {
      KeyValueTestUtil.create("R1", "cf", "a", now, KeyValue.Type.Put, "dont-care"),
      KeyValueTestUtil.create("R1", "cf", "a", now, KeyValue.Type.Delete, "dont-care")
  };
  KeyValue [] kvs2 = new KeyValue[] {
      KeyValueTestUtil.create("R1", "cf", "a", now-500, KeyValue.Type.Put, "dont-care"),
      KeyValueTestUtil.create("R1", "cf", "a", now-100, KeyValue.Type.Put, "dont-care"),
      KeyValueTestUtil.create("R1", "cf", "a", now, KeyValue.Type.Put, "dont-care")
  };
  List<KeyValueScanner> scanners = scanFixture(kvs1, kvs2);

  StoreScanner scan = new StoreScanner(new Scan(Bytes.toBytes("R1")),
      scanInfo, scanType, getCols("a"), scanners);
  List<Cell> results = new ArrayList<Cell>();
  // the two put at ts=now will be masked by the 1 delete, and
  // since the scan default returns 1 version we'll return the newest
  // key, which is kvs[2], now-100.
  assertEquals(true, scan.next(results));
  assertEquals(1, results.size());
  assertEquals(kvs2[1], results.get(0));
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:24,代码来源:TestStoreScanner.java

示例4: testUpsertMemstoreSize

import org.apache.hadoop.hbase.KeyValueTestUtil; //导入方法依赖的package包/类
/**
 * Add keyvalues with a fixed memstoreTs, and checks that memstore size is decreased
 * as older keyvalues are deleted from the memstore.
 * @throws Exception
 */
public void testUpsertMemstoreSize() throws Exception {
  Configuration conf = HBaseConfiguration.create();
  memstore = new MemStore(conf, KeyValue.COMPARATOR);
  long oldSize = memstore.size.get();

  List<Cell> l = new ArrayList<Cell>();
  KeyValue kv1 = KeyValueTestUtil.create("r", "f", "q", 100, "v");
  KeyValue kv2 = KeyValueTestUtil.create("r", "f", "q", 101, "v");
  KeyValue kv3 = KeyValueTestUtil.create("r", "f", "q", 102, "v");

  kv1.setMvccVersion(1); kv2.setMvccVersion(1);kv3.setMvccVersion(1);
  l.add(kv1); l.add(kv2); l.add(kv3);

  this.memstore.upsert(l, 2);// readpoint is 2
  long newSize = this.memstore.size.get();
  assert(newSize > oldSize);

  KeyValue kv4 = KeyValueTestUtil.create("r", "f", "q", 104, "v");
  kv4.setMvccVersion(1);
  l.clear(); l.add(kv4);
  this.memstore.upsert(l, 3);
  assertEquals(newSize, this.memstore.size.get());
  //this.memstore = null;
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:30,代码来源:TestMemStore.java

示例5: testDeleteVersionsMixedAndMultipleVersionReturn

import org.apache.hadoop.hbase.KeyValueTestUtil; //导入方法依赖的package包/类
public void testDeleteVersionsMixedAndMultipleVersionReturn() throws IOException {
  long now = System.currentTimeMillis();
  KeyValue [] kvs1 = new KeyValue[] {
      KeyValueTestUtil.create("R1", "cf", "a", now, KeyValue.Type.Put, "dont-care"),
      KeyValueTestUtil.create("R1", "cf", "a", now, KeyValue.Type.Delete, "dont-care")
  };
  KeyValue [] kvs2 = new KeyValue[] {
      KeyValueTestUtil.create("R1", "cf", "a", now-500, KeyValue.Type.Put, "dont-care"),
      KeyValueTestUtil.create("R1", "cf", "a", now+500, KeyValue.Type.Put, "dont-care"),
      KeyValueTestUtil.create("R1", "cf", "a", now, KeyValue.Type.Put, "dont-care"),
      KeyValueTestUtil.create("R2", "cf", "z", now, KeyValue.Type.Put, "dont-care")
  };
  List<KeyValueScanner> scanners = scanFixture(kvs1, kvs2);

  Scan scanSpec = new Scan(Bytes.toBytes("R1")).setMaxVersions(2);
  StoreScanner scan = new StoreScanner(scanSpec, scanInfo, scanType,
      getCols("a"), scanners);
  List<Cell> results = new ArrayList<Cell>();
  assertEquals(true, scan.next(results));
  assertEquals(2, results.size());
  assertEquals(kvs2[1], results.get(0));
  assertEquals(kvs2[0], results.get(1));
}
 
开发者ID:tenggyut,项目名称:HIndex,代码行数:24,代码来源:TestStoreScanner.java

示例6: testDeleteVersionsMixedAndMultipleVersionReturn

import org.apache.hadoop.hbase.KeyValueTestUtil; //导入方法依赖的package包/类
public void testDeleteVersionsMixedAndMultipleVersionReturn() throws IOException {
  long now = System.currentTimeMillis();
  KeyValue [] kvs1 = new KeyValue[] {
      KeyValueTestUtil.create("R1", "cf", "a", now, KeyValue.Type.Put, "dont-care"),
      KeyValueTestUtil.create("R1", "cf", "a", now, KeyValue.Type.Delete, "dont-care")
  };
  KeyValue [] kvs2 = new KeyValue[] {
      KeyValueTestUtil.create("R1", "cf", "a", now-500, KeyValue.Type.Put, "dont-care"),
      KeyValueTestUtil.create("R1", "cf", "a", now+500, KeyValue.Type.Put, "dont-care"),
      KeyValueTestUtil.create("R1", "cf", "a", now, KeyValue.Type.Put, "dont-care"),
      KeyValueTestUtil.create("R2", "cf", "z", now, KeyValue.Type.Put, "dont-care")
  };
  List<KeyValueScanner> scanners = scanFixture(kvs1, kvs2);

  Scan scanSpec = new Scan(Bytes.toBytes("R1")).setMaxVersions(2);
  StoreScanner scan = new StoreScanner(scanSpec, scanInfo, scanType,
      getCols("a"), scanners);
  List<KeyValue> results = new ArrayList<KeyValue>();
  assertEquals(true, scan.next(results));
  assertEquals(2, results.size());
  assertEquals(kvs2[1], results.get(0));
  assertEquals(kvs2[0], results.get(1));
}
 
开发者ID:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:24,代码来源:TestStoreScanner.java

示例7: testDeleteVersionMaskingMultiplePuts

import org.apache.hadoop.hbase.KeyValueTestUtil; //导入方法依赖的package包/类
public void testDeleteVersionMaskingMultiplePuts() throws IOException {
  long now = System.currentTimeMillis();
  KeyValue [] kvs1 = new KeyValue[] {
      KeyValueTestUtil.create("R1", "cf", "a", now, KeyValue.Type.Put, "dont-care"),
      KeyValueTestUtil.create("R1", "cf", "a", now, KeyValue.Type.Delete, "dont-care")
  };
  KeyValue [] kvs2 = new KeyValue[] {
      KeyValueTestUtil.create("R1", "cf", "a", now-500, KeyValue.Type.Put, "dont-care"),
      KeyValueTestUtil.create("R1", "cf", "a", now-100, KeyValue.Type.Put, "dont-care"),
      KeyValueTestUtil.create("R1", "cf", "a", now, KeyValue.Type.Put, "dont-care")
  };
  List<KeyValueScanner> scanners = scanFixture(kvs1, kvs2);

  StoreScanner scan = new StoreScanner(new Scan(Bytes.toBytes("R1")),
      scanInfo, scanType, getCols("a"), scanners);
  List<KeyValue> results = new ArrayList<KeyValue>();
  // the two put at ts=now will be masked by the 1 delete, and
  // since the scan default returns 1 version we'll return the newest
  // key, which is kvs[2], now-100.
  assertEquals(true, scan.next(results));
  assertEquals(1, results.size());
  assertEquals(kvs2[1], results.get(0));
}
 
开发者ID:algarecu,项目名称:hbase-0.94.8-qod,代码行数:24,代码来源:TestStoreScanner.java

示例8: testScanSameTimestamp

import org.apache.hadoop.hbase.KeyValueTestUtil; //导入方法依赖的package包/类
public void testScanSameTimestamp() throws IOException {
  // returns only 1 of these 2 even though same timestamp
  KeyValue [] kvs = new KeyValue[] {
      KeyValueTestUtil.create("R1", "cf", "a", 1, KeyValue.Type.Put, "dont-care"),
      KeyValueTestUtil.create("R1", "cf", "a", 1, KeyValue.Type.Put, "dont-care"),
  };
  List<KeyValueScanner> scanners = Arrays.asList(
      new KeyValueScanner[] {
          new KeyValueScanFixture(KeyValue.COMPARATOR, kvs)
      });

  Scan scanSpec = new Scan(Bytes.toBytes("R1"));
  // this only uses maxVersions (default=1) and TimeRange (default=all)
  StoreScanner scan = new StoreScanner(scanSpec, scanInfo, scanType,
      getCols("a"), scanners);

  List<KeyValue> results = new ArrayList<KeyValue>();
  assertEquals(true, scan.next(results));
  assertEquals(1, results.size());
  assertEquals(kvs[0], results.get(0));
}
 
开发者ID:algarecu,项目名称:hbase-0.94.8-qod,代码行数:22,代码来源:TestStoreScanner.java

示例9: testRetainsDeleteVersion

import org.apache.hadoop.hbase.KeyValueTestUtil; //导入方法依赖的package包/类
public void testRetainsDeleteVersion() throws IOException {
  // add a put to memstore
  memstore.add(KeyValueTestUtil.create("row1", "fam", "a", 100, "dont-care"));

  // now process a specific delete:
  KeyValue delete = KeyValueTestUtil.create(
      "row1", "fam", "a", 100, KeyValue.Type.Delete, "dont-care");
  memstore.delete(delete);

  assertEquals(2, memstore.cellSet.size());
  assertEquals(delete, memstore.cellSet.first());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:13,代码来源:TestDefaultMemStore.java

示例10: testRetainsDeleteColumn

import org.apache.hadoop.hbase.KeyValueTestUtil; //导入方法依赖的package包/类
public void testRetainsDeleteColumn() throws IOException {
  // add a put to memstore
  memstore.add(KeyValueTestUtil.create("row1", "fam", "a", 100, "dont-care"));

  // now process a specific delete:
  KeyValue delete = KeyValueTestUtil.create("row1", "fam", "a", 100,
      KeyValue.Type.DeleteColumn, "dont-care");
  memstore.delete(delete);

  assertEquals(2, memstore.cellSet.size());
  assertEquals(delete, memstore.cellSet.first());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:13,代码来源:TestDefaultMemStore.java

示例11: testRetainsDeleteFamily

import org.apache.hadoop.hbase.KeyValueTestUtil; //导入方法依赖的package包/类
public void testRetainsDeleteFamily() throws IOException {
  // add a put to memstore
  memstore.add(KeyValueTestUtil.create("row1", "fam", "a", 100, "dont-care"));

  // now process a specific delete:
  KeyValue delete = KeyValueTestUtil.create("row1", "fam", "a", 100,
      KeyValue.Type.DeleteFamily, "dont-care");
  memstore.delete(delete);

  assertEquals(2, memstore.cellSet.size());
  assertEquals(delete, memstore.cellSet.first());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:13,代码来源:TestDefaultMemStore.java

示例12: testUpsertMemstoreSize

import org.apache.hadoop.hbase.KeyValueTestUtil; //导入方法依赖的package包/类
/**
 * Add keyvalues with a fixed memstoreTs, and checks that memstore size is decreased
 * as older keyvalues are deleted from the memstore.
 * @throws Exception
 */
public void testUpsertMemstoreSize() throws Exception {
  Configuration conf = HBaseConfiguration.create();
  memstore = new DefaultMemStore(conf, KeyValue.COMPARATOR);
  long oldSize = memstore.size.get();

  List<Cell> l = new ArrayList<Cell>();
  KeyValue kv1 = KeyValueTestUtil.create("r", "f", "q", 100, "v");
  KeyValue kv2 = KeyValueTestUtil.create("r", "f", "q", 101, "v");
  KeyValue kv3 = KeyValueTestUtil.create("r", "f", "q", 102, "v");

  kv1.setSequenceId(1); kv2.setSequenceId(1);kv3.setSequenceId(1);
  l.add(kv1); l.add(kv2); l.add(kv3);

  this.memstore.upsert(l, 2);// readpoint is 2
  long newSize = this.memstore.size.get();
  assert(newSize > oldSize);
  //The kv1 should be removed.
  assert(memstore.cellSet.size() == 2);
  
  KeyValue kv4 = KeyValueTestUtil.create("r", "f", "q", 104, "v");
  kv4.setSequenceId(1);
  l.clear(); l.add(kv4);
  this.memstore.upsert(l, 3);
  assertEquals(newSize, this.memstore.size.get());
  //The kv2 should be removed.
  assert(memstore.cellSet.size() == 2);
  //this.memstore = null;
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:34,代码来源:TestDefaultMemStore.java

示例13: testUpdateToTimeOfOldestEdit

import org.apache.hadoop.hbase.KeyValueTestUtil; //导入方法依赖的package包/类
/**
 * Tests that the timeOfOldestEdit is updated correctly for the 
 * various edit operations in memstore.
 * @throws Exception
 */
public void testUpdateToTimeOfOldestEdit() throws Exception {
  try {
    EnvironmentEdgeForMemstoreTest edge = new EnvironmentEdgeForMemstoreTest();
    EnvironmentEdgeManager.injectEdge(edge);
    DefaultMemStore memstore = new DefaultMemStore();
    long t = memstore.timeOfOldestEdit();
    assertEquals(t, Long.MAX_VALUE);

    // test the case that the timeOfOldestEdit is updated after a KV add
    memstore.add(KeyValueTestUtil.create("r", "f", "q", 100, "v"));
    t = memstore.timeOfOldestEdit();
    assertTrue(t == 1234);
    // snapshot() will reset timeOfOldestEdit. The method will also assert the 
    // value is reset to Long.MAX_VALUE
    t = runSnapshot(memstore);

    // test the case that the timeOfOldestEdit is updated after a KV delete
    memstore.delete(KeyValueTestUtil.create("r", "f", "q", 100, "v"));
    t = memstore.timeOfOldestEdit();
    assertTrue(t == 1234);
    t = runSnapshot(memstore);

    // test the case that the timeOfOldestEdit is updated after a KV upsert
    List<Cell> l = new ArrayList<Cell>();
    KeyValue kv1 = KeyValueTestUtil.create("r", "f", "q", 100, "v");
    kv1.setSequenceId(100);
    l.add(kv1);
    memstore.upsert(l, 1000);
    t = memstore.timeOfOldestEdit();
    assertTrue(t == 1234);
  } finally {
    EnvironmentEdgeManager.reset();
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:40,代码来源:TestDefaultMemStore.java

示例14: testKeyValueScanFixture

import org.apache.hadoop.hbase.KeyValueTestUtil; //导入方法依赖的package包/类
public void testKeyValueScanFixture() throws IOException {
  KeyValue kvs[] = new KeyValue[]{
      KeyValueTestUtil.create("RowA", "family", "qf1",
          1, KeyValue.Type.Put, "value-1"),
      KeyValueTestUtil.create("RowA", "family", "qf2",
          1, KeyValue.Type.Put, "value-2"),
      KeyValueTestUtil.create("RowB", "family", "qf1",
          10, KeyValue.Type.Put, "value-10")
  };
  KeyValueScanner scan = new KeyValueScanFixture(
      KeyValue.COMPARATOR, kvs);

  KeyValue kv = KeyValueUtil.createFirstOnRow(Bytes.toBytes("RowA"));
  // should seek to this:
  assertTrue(scan.seek(kv));
  Cell res = scan.peek();
  assertEquals(kvs[0], res);

  kv = KeyValueUtil.createFirstOnRow(Bytes.toBytes("RowB"));
  assertTrue(scan.seek(kv));
  res = scan.peek();
  assertEquals(kvs[2], res);

  // ensure we pull things out properly:
  kv = KeyValueUtil.createFirstOnRow(Bytes.toBytes("RowA"));
  assertTrue(scan.seek(kv));
  assertEquals(kvs[0], scan.peek());
  assertEquals(kvs[0], scan.next());
  assertEquals(kvs[1], scan.peek());
  assertEquals(kvs[1], scan.next());
  assertEquals(kvs[2], scan.peek());
  assertEquals(kvs[2], scan.next());
  assertEquals(null, scan.peek());
  assertEquals(null, scan.next());
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:36,代码来源:TestKeyValueScanFixture.java

示例15: testWontNextToNext

import org.apache.hadoop.hbase.KeyValueTestUtil; //导入方法依赖的package包/类
public void testWontNextToNext() throws IOException {
  // build the scan file:
  KeyValue [] kvs = new KeyValue[] {
      KeyValueTestUtil.create("R1", "cf", "a", 2, KeyValue.Type.Put, "dont-care"),
      KeyValueTestUtil.create("R1", "cf", "a", 1, KeyValue.Type.Put, "dont-care"),
      KeyValueTestUtil.create("R2", "cf", "a", 1, KeyValue.Type.Put, "dont-care")
  };
  List<KeyValueScanner> scanners = scanFixture(kvs);

  Scan scanSpec = new Scan(Bytes.toBytes("R1"));
  // this only uses maxVersions (default=1) and TimeRange (default=all)
  StoreScanner scan = new StoreScanner(scanSpec, scanInfo, scanType,
      getCols("a"), scanners);

  List<Cell> results = new ArrayList<Cell>();
  scan.next(results);
  assertEquals(1, results.size());
  assertEquals(kvs[0], results.get(0));
  // should be ok...
  // now scan _next_ again.
  results.clear();
  scan.next(results);
  assertEquals(1, results.size());
  assertEquals(kvs[2], results.get(0));

  results.clear();
  scan.next(results);
  assertEquals(0, results.size());

}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:31,代码来源:TestStoreScanner.java


注:本文中的org.apache.hadoop.hbase.KeyValueTestUtil.create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。