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


Java KeyValueTestUtil类代码示例

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


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

示例1: checkShouldFlush

import org.apache.hadoop.hbase.KeyValueTestUtil; //导入依赖的package包/类
private void checkShouldFlush(Configuration conf, boolean expected) throws Exception {
  try {
    EnvironmentEdgeForMemstoreTest edge = new EnvironmentEdgeForMemstoreTest();
    EnvironmentEdgeManager.injectEdge(edge);
    HBaseTestingUtility hbaseUtility = HBaseTestingUtility.createLocalHTU(conf);
    HRegion region = hbaseUtility.createTestRegion("foobar", new HColumnDescriptor("foo"));

    List<Store> stores = region.getStores();
    assertTrue(stores.size() == 1);

    Store s = stores.iterator().next();
    edge.setCurrentTimeMillis(1234);
    s.add(KeyValueTestUtil.create("r", "f", "q", 100, "v"));
    edge.setCurrentTimeMillis(1234 + 100);
    StringBuffer sb = new StringBuffer();
    assertTrue(region.shouldFlush(sb) == false);
    edge.setCurrentTimeMillis(1234 + 10000);
    assertTrue(region.shouldFlush(sb) == expected);
  } finally {
    EnvironmentEdgeManager.reset();
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:23,代码来源:TestDefaultMemStore.java

示例2: 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

示例3: 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

示例4: 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

示例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:fengchen8086,项目名称:ditb,代码行数:24,代码来源:TestStoreScanner.java

示例6: 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:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:22,代码来源:TestStoreScanner.java

示例7: 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<KeyValue> results = new ArrayList<KeyValue>();
  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,项目名称:LCIndex-HBase-0.94.16,代码行数:22,代码来源:TestStoreScanner.java

示例8: 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:fengchen8086,项目名称:LCIndex-HBase-0.94.16,代码行数:24,代码来源:TestStoreScanner.java

示例9: 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

示例10: 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);

  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());
  //this.memstore = null;
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:30,代码来源:TestDefaultMemStore.java

示例11: checkShouldFlush

import org.apache.hadoop.hbase.KeyValueTestUtil; //导入依赖的package包/类
private void checkShouldFlush(Configuration conf, boolean expected) throws Exception {
  try {
    EnvironmentEdgeForMemstoreTest edge = new EnvironmentEdgeForMemstoreTest();
    EnvironmentEdgeManager.injectEdge(edge);
    HBaseTestingUtility hbaseUtility = HBaseTestingUtility.createLocalHTU(conf);
    HRegion region = hbaseUtility.createTestRegion("foobar", new HColumnDescriptor("foo"));

    Map<byte[], Store> stores = region.getStores();
    assertTrue(stores.size() == 1);

    Store s = stores.entrySet().iterator().next().getValue();
    edge.setCurrentTimeMillis(1234);
    s.add(KeyValueTestUtil.create("r", "f", "q", 100, "v"));
    edge.setCurrentTimeMillis(1234 + 100);
    assertTrue(region.shouldFlush() == false);
    edge.setCurrentTimeMillis(1234 + 10000);
    assertTrue(region.shouldFlush() == expected);
  } finally {
    EnvironmentEdgeManager.reset();
  }
}
 
开发者ID:grokcoder,项目名称:pbase,代码行数:22,代码来源: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 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

示例13: checkShouldFlush

import org.apache.hadoop.hbase.KeyValueTestUtil; //导入依赖的package包/类
protected void checkShouldFlush(Configuration conf, boolean expected) throws Exception {
  try {
    EnvironmentEdgeForMemstoreTest edge = new EnvironmentEdgeForMemstoreTest();
    EnvironmentEdgeManager.injectEdge(edge);
    HBaseTestingUtility hbaseUtility = HBaseTestingUtility.createLocalHTU(conf);
    String cf = "foo";
    HRegion region =
        hbaseUtility.createTestRegion("foobar", ColumnFamilyDescriptorBuilder.of(cf));

    edge.setCurrentTimeMillis(1234);
    Put p = new Put(Bytes.toBytes("r"));
    p.add(KeyValueTestUtil.create("r", cf, "q", 100, "v"));
    region.put(p);
    edge.setCurrentTimeMillis(1234 + 100);
    StringBuilder sb = new StringBuilder();
    assertTrue(!region.shouldFlush(sb));
    edge.setCurrentTimeMillis(1234 + 10000);
    assertTrue(region.shouldFlush(sb) == expected);
  } finally {
    EnvironmentEdgeManager.reset();
  }
}
 
开发者ID:apache,项目名称:hbase,代码行数:23,代码来源:TestDefaultMemStore.java

示例14: 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.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:shenli-uiuc,项目名称:PyroDB,代码行数:30,代码来源:TestDefaultMemStore.java


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