Java 类org.apache.hadoop.hbase.filter.ColumnCountGetFilter 实例源码

项目:cloud-bigtable-client    文件:TestColumnCountGetFilterAdapter.java   
@Test
public void testSimpleColumnCount() throws IOException {
  RowFilter adaptedFilter =
      adapter.adapt(
          new FilterAdapterContext(new Scan()),
          new ColumnCountGetFilter(2));
  Assert.assertEquals(
      RowFilter.newBuilder()
          .setChain(Chain.newBuilder()
              .addFilters(
                  RowFilter.newBuilder()
                      .setCellsPerColumnLimitFilter(1))
              .addFilters(
                  RowFilter.newBuilder()
                      .setCellsPerRowLimitFilter(2)))
      .build(),
      adaptedFilter);
}
项目:themis    文件:TestThemisCpUtil.java   
@Test
public void testToConcreteFilters() throws IOException {
  FiltersCounter counter = new FiltersCounter();
  ThemisCpUtil.processFilters(null, counter);
  Assert.assertEquals(0, counter.concreteFilterCount);
  counter = new FiltersCounter();
  ThemisCpUtil.processFilters(new ColumnRangeFilter(), counter);
  Assert.assertEquals(1, counter.concreteFilterCount);
  counter = new FiltersCounter();
  FilterList filterList = new FilterList();
  filterList.addFilter(new ColumnRangeFilter());
  filterList.addFilter(new ColumnCountGetFilter());
  ThemisCpUtil.processFilters(filterList, counter);
  Assert.assertEquals(2, counter.concreteFilterCount);
  // test process filterlist operator
  counter = new ConcreteFiltersCounter();
  ThemisCpUtil.processFilters(new ColumnRangeFilter(), counter);
  Assert.assertEquals(1, counter.concreteFilterCount);
  counter = new ConcreteFiltersCounter();
  ThemisCpUtil.processFilters(filterList, counter);
  Assert.assertEquals(0, counter.concreteFilterCount);
}
项目:cloud-bigtable-client    文件:ColumnCountGetFilterAdapter.java   
@Override
public RowFilter adapt(FilterAdapterContext context, ColumnCountGetFilter filter)
    throws IOException {
  // This is fairly broken for all scans, but I'm simply going for bug-for-bug
  // compatible with string reader expressions.
  return RowFilter.newBuilder()
      .setChain(Chain.newBuilder()
          .addFilters(
              RowFilter.newBuilder()
                  .setCellsPerColumnLimitFilter(1))
          .addFilters(
              RowFilter.newBuilder()
                  .setCellsPerRowLimitFilter(filter.getLimit())))
      .build();
}
项目:cloud-bigtable-client    文件:TestFilters.java   
/**
 * Requirement 9.1 - ColumnCountGetFilter - return first N columns on rows only
 */
@Test
public void testColumnCountGetFilter() throws Exception {
  // Initialize data
  int numColumns = 20;
  int numColumnsToFilter = 10;
  Table table = getConnection().getTable(TABLE_NAME);
  byte[] rowKey = dataHelper.randomData("testrow-");
  byte[][] quals = new byte[numColumns][];
  byte[][][] values = new byte[2][][];
  values[0] = dataHelper.randomData("testvalue-", numColumns);
  values[1] = dataHelper.randomData("testvalue-", numColumns);
  Put put = new Put(rowKey);
  for (int i = 0; i < numColumns; ++i) {
    quals[i] = Bytes.toBytes(i);
    // Add two timestamps to test that filter only grabs the latest version
    put.addColumn(COLUMN_FAMILY, quals[i], 1L, values[0][i]);
    put.addColumn(COLUMN_FAMILY, quals[i], 2L, values[1][i]);
  }
  table.put(put);

  // Filter and test
  Filter filter = new ColumnCountGetFilter(numColumnsToFilter);
  Get get = new Get(rowKey).setFilter(filter).setMaxVersions(10);
  Result result = table.get(get);
  Assert.assertEquals("Should have filtered to N columns", numColumnsToFilter, result.size());
  for (int i = 0 ; i < numColumnsToFilter; ++i) {
    Assert.assertTrue("Should contain qual " + Bytes.toInt(quals[i]),
      result.containsColumn(COLUMN_FAMILY, quals[i]));
    List<Cell> cells = result.getColumnCells(COLUMN_FAMILY, quals[i]);
    Assert.assertEquals("Should have only the latest version", 1, cells.size());
    Assert.assertArrayEquals("Value v2 should be first and match", values[1][i],
      CellUtil.cloneValue(cells.get(0)));
  }

  table.close();
}
项目:ditb    文件:TestHRegion.java   
@Test
public void testGet_Basic() throws IOException {
  byte[] row1 = Bytes.toBytes("row1");
  byte[] fam1 = Bytes.toBytes("fam1");
  byte[] col1 = Bytes.toBytes("col1");
  byte[] col2 = Bytes.toBytes("col2");
  byte[] col3 = Bytes.toBytes("col3");
  byte[] col4 = Bytes.toBytes("col4");
  byte[] col5 = Bytes.toBytes("col5");

  // Setting up region
  String method = this.getName();
  this.region = initHRegion(tableName, method, CONF, fam1);
  try {
    // Add to memstore
    Put put = new Put(row1);
    put.add(fam1, col1, null);
    put.add(fam1, col2, null);
    put.add(fam1, col3, null);
    put.add(fam1, col4, null);
    put.add(fam1, col5, null);
    region.put(put);

    Get get = new Get(row1);
    get.addColumn(fam1, col2);
    get.addColumn(fam1, col4);
    // Expected result
    KeyValue kv1 = new KeyValue(row1, fam1, col2);
    KeyValue kv2 = new KeyValue(row1, fam1, col4);
    KeyValue[] expected = { kv1, kv2 };

    // Test
    Result res = region.get(get);
    assertEquals(expected.length, res.size());
    for (int i = 0; i < res.size(); i++) {
      assertTrue(CellUtil.matchingRow(expected[i], res.rawCells()[i]));
      assertTrue(CellUtil.matchingFamily(expected[i], res.rawCells()[i]));
      assertTrue(CellUtil.matchingQualifier(expected[i], res.rawCells()[i]));
    }

    // Test using a filter on a Get
    Get g = new Get(row1);
    final int count = 2;
    g.setFilter(new ColumnCountGetFilter(count));
    res = region.get(g);
    assertEquals(count, res.size());
  } finally {
    HRegion.closeHRegion(this.region);
    this.region = null;
  }
}
项目:LCIndex-HBase-0.94.16    文件:TestHRegion.java   
public void testGet_Basic() throws IOException {
  byte [] tableName = Bytes.toBytes("testtable");
  byte [] row1 = Bytes.toBytes("row1");
  byte [] fam1 = Bytes.toBytes("fam1");
  byte [] col1 = Bytes.toBytes("col1");
  byte [] col2 = Bytes.toBytes("col2");
  byte [] col3 = Bytes.toBytes("col3");
  byte [] col4 = Bytes.toBytes("col4");
  byte [] col5 = Bytes.toBytes("col5");

  //Setting up region
  String method = this.getName();
  this.region = initHRegion(tableName, method, conf, fam1);
  try {
    //Add to memstore
    Put put = new Put(row1);
    put.add(fam1, col1, null);
    put.add(fam1, col2, null);
    put.add(fam1, col3, null);
    put.add(fam1, col4, null);
    put.add(fam1, col5, null);
    region.put(put);

    Get get = new Get(row1);
    get.addColumn(fam1, col2);
    get.addColumn(fam1, col4);
    //Expected result
    KeyValue kv1 = new KeyValue(row1, fam1, col2);
    KeyValue kv2 = new KeyValue(row1, fam1, col4);
    KeyValue [] expected = {kv1, kv2};

    //Test
    Result res = region.get(get, null);
    assertEquals(expected.length, res.size());
    for(int i=0; i<res.size(); i++){
      assertEquals(0,
          Bytes.compareTo(expected[i].getRow(), res.raw()[i].getRow()));
      assertEquals(0,
          Bytes.compareTo(expected[i].getFamily(), res.raw()[i].getFamily()));
      assertEquals(0,
          Bytes.compareTo(
              expected[i].getQualifier(), res.raw()[i].getQualifier()));
    }

    // Test using a filter on a Get
    Get g = new Get(row1);
    final int count = 2;
    g.setFilter(new ColumnCountGetFilter(count));
    res = region.get(g, null);
    assertEquals(count, res.size());
  } finally {
    HRegion.closeHRegion(this.region);
    this.region = null;
  }
}
项目:cloud-bigtable-client    文件:ColumnCountGetFilterAdapter.java   
@Override
public FilterSupportStatus isFilterSupported(FilterAdapterContext context,
    ColumnCountGetFilter filter) {
  return FilterSupportStatus.SUPPORTED;
}
项目:cloud-bigtable-client    文件:FilterAdapter.java   
/**
 * Create a new FilterAdapter
 */
public static FilterAdapter buildAdapter() {
  FilterAdapter adapter = new FilterAdapter();
  adapter.addFilterAdapter(
      ColumnPrefixFilter.class, new ColumnPrefixFilterAdapter());
  adapter.addFilterAdapter(
      ColumnRangeFilter.class, new ColumnRangeFilterAdapter());
  adapter.addFilterAdapter(
      KeyOnlyFilter.class, new KeyOnlyFilterAdapter());
  adapter.addFilterAdapter(
      MultipleColumnPrefixFilter.class, new MultipleColumnPrefixFilterAdapter());
  adapter.addFilterAdapter(
      TimestampsFilter.class, new TimestampsFilterAdapter());
  ValueFilterAdapter valueFilterAdapter = new ValueFilterAdapter();
  adapter.addFilterAdapter(
      ValueFilter.class, valueFilterAdapter);
  SingleColumnValueFilterAdapter scvfa =
      new SingleColumnValueFilterAdapter(valueFilterAdapter);
  adapter.addFilterAdapter(
      SingleColumnValueFilter.class, scvfa);
  adapter.addFilterAdapter(
      SingleColumnValueExcludeFilter.class,
      new SingleColumnValueExcludeFilterAdapter(scvfa));
  adapter.addFilterAdapter(
      ColumnPaginationFilter.class, new ColumnPaginationFilterAdapter());
  adapter.addFilterAdapter(
      FirstKeyOnlyFilter.class, new FirstKeyOnlyFilterAdapter());
  adapter.addFilterAdapter(
      ColumnCountGetFilter.class, new ColumnCountGetFilterAdapter());
  adapter.addFilterAdapter(
      RandomRowFilter.class, new RandomRowFilterAdapter());
  adapter.addFilterAdapter(
      PrefixFilter.class, new PrefixFilterAdapter());
  adapter.addFilterAdapter(
      QualifierFilter.class, new QualifierFilterAdapter());

  // Passing the FilterAdapter in to the FilterListAdapter is a bit
  // unfortunate, but makes adapting the FilterList's subfilters simpler.
  FilterListAdapter filterListAdapter = new FilterListAdapter(adapter);
  // FilterList implements UnsupportedStatusCollector so it should
  // be used when possible (third parameter to addFilterAdapter()).
  adapter.addFilterAdapter(
      FilterList.class, filterListAdapter, filterListAdapter);

  return adapter;
}
项目:pbase    文件:TestHRegion.java   
@Test
public void testGet_Basic() throws IOException {
  byte[] row1 = Bytes.toBytes("row1");
  byte[] fam1 = Bytes.toBytes("fam1");
  byte[] col1 = Bytes.toBytes("col1");
  byte[] col2 = Bytes.toBytes("col2");
  byte[] col3 = Bytes.toBytes("col3");
  byte[] col4 = Bytes.toBytes("col4");
  byte[] col5 = Bytes.toBytes("col5");

  // Setting up region
  String method = this.getName();
  this.region = initHRegion(tableName, method, CONF, fam1);
  try {
    // Add to memstore
    Put put = new Put(row1);
    put.add(fam1, col1, null);
    put.add(fam1, col2, null);
    put.add(fam1, col3, null);
    put.add(fam1, col4, null);
    put.add(fam1, col5, null);
    region.put(put);

    Get get = new Get(row1);
    get.addColumn(fam1, col2);
    get.addColumn(fam1, col4);
    // Expected result
    KeyValue kv1 = new KeyValue(row1, fam1, col2);
    KeyValue kv2 = new KeyValue(row1, fam1, col4);
    KeyValue[] expected = { kv1, kv2 };

    // Test
    Result res = region.get(get);
    assertEquals(expected.length, res.size());
    for (int i = 0; i < res.size(); i++) {
      assertTrue(CellUtil.matchingRow(expected[i], res.rawCells()[i]));
      assertTrue(CellUtil.matchingFamily(expected[i], res.rawCells()[i]));
      assertTrue(CellUtil.matchingQualifier(expected[i], res.rawCells()[i]));
    }

    // Test using a filter on a Get
    Get g = new Get(row1);
    final int count = 2;
    g.setFilter(new ColumnCountGetFilter(count));
    res = region.get(g);
    assertEquals(count, res.size());
  } finally {
    HRegion.closeHRegion(this.region);
    this.region = null;
  }
}
项目:HIndex    文件:TestHRegion.java   
@Test
public void testGet_Basic() throws IOException {
  byte[] row1 = Bytes.toBytes("row1");
  byte[] fam1 = Bytes.toBytes("fam1");
  byte[] col1 = Bytes.toBytes("col1");
  byte[] col2 = Bytes.toBytes("col2");
  byte[] col3 = Bytes.toBytes("col3");
  byte[] col4 = Bytes.toBytes("col4");
  byte[] col5 = Bytes.toBytes("col5");

  // Setting up region
  String method = this.getName();
  this.region = initHRegion(tableName, method, CONF, fam1);
  try {
    // Add to memstore
    Put put = new Put(row1);
    put.add(fam1, col1, null);
    put.add(fam1, col2, null);
    put.add(fam1, col3, null);
    put.add(fam1, col4, null);
    put.add(fam1, col5, null);
    region.put(put);

    Get get = new Get(row1);
    get.addColumn(fam1, col2);
    get.addColumn(fam1, col4);
    // Expected result
    KeyValue kv1 = new KeyValue(row1, fam1, col2);
    KeyValue kv2 = new KeyValue(row1, fam1, col4);
    KeyValue[] expected = { kv1, kv2 };

    // Test
    Result res = region.get(get);
    assertEquals(expected.length, res.size());
    for (int i = 0; i < res.size(); i++) {
      assertTrue(CellUtil.matchingRow(expected[i], res.rawCells()[i]));
      assertTrue(CellUtil.matchingFamily(expected[i], res.rawCells()[i]));
      assertTrue(CellUtil.matchingQualifier(expected[i], res.rawCells()[i]));
    }

    // Test using a filter on a Get
    Get g = new Get(row1);
    final int count = 2;
    g.setFilter(new ColumnCountGetFilter(count));
    res = region.get(g);
    assertEquals(count, res.size());
  } finally {
    HRegion.closeHRegion(this.region);
    this.region = null;
  }
}
项目:IRIndex    文件:TestHRegion.java   
public void testGet_Basic() throws IOException {
  byte [] tableName = Bytes.toBytes("testtable");
  byte [] row1 = Bytes.toBytes("row1");
  byte [] fam1 = Bytes.toBytes("fam1");
  byte [] col1 = Bytes.toBytes("col1");
  byte [] col2 = Bytes.toBytes("col2");
  byte [] col3 = Bytes.toBytes("col3");
  byte [] col4 = Bytes.toBytes("col4");
  byte [] col5 = Bytes.toBytes("col5");

  //Setting up region
  String method = this.getName();
  this.region = initHRegion(tableName, method, conf, fam1);
  try {
    //Add to memstore
    Put put = new Put(row1);
    put.add(fam1, col1, null);
    put.add(fam1, col2, null);
    put.add(fam1, col3, null);
    put.add(fam1, col4, null);
    put.add(fam1, col5, null);
    region.put(put);

    Get get = new Get(row1);
    get.addColumn(fam1, col2);
    get.addColumn(fam1, col4);
    //Expected result
    KeyValue kv1 = new KeyValue(row1, fam1, col2);
    KeyValue kv2 = new KeyValue(row1, fam1, col4);
    KeyValue [] expected = {kv1, kv2};

    //Test
    Result res = region.get(get, null);
    assertEquals(expected.length, res.size());
    for(int i=0; i<res.size(); i++){
      assertEquals(0,
          Bytes.compareTo(expected[i].getRow(), res.raw()[i].getRow()));
      assertEquals(0,
          Bytes.compareTo(expected[i].getFamily(), res.raw()[i].getFamily()));
      assertEquals(0,
          Bytes.compareTo(
              expected[i].getQualifier(), res.raw()[i].getQualifier()));
    }

    // Test using a filter on a Get
    Get g = new Get(row1);
    final int count = 2;
    g.setFilter(new ColumnCountGetFilter(count));
    res = region.get(g, null);
    assertEquals(count, res.size());
  } finally {
    HRegion.closeHRegion(this.region);
    this.region = null;
  }
}
项目:hbase    文件:TestHRegion.java   
@Test
public void testGet_Basic() throws IOException {
  byte[] row1 = Bytes.toBytes("row1");
  byte[] fam1 = Bytes.toBytes("fam1");
  byte[] col1 = Bytes.toBytes("col1");
  byte[] col2 = Bytes.toBytes("col2");
  byte[] col3 = Bytes.toBytes("col3");
  byte[] col4 = Bytes.toBytes("col4");
  byte[] col5 = Bytes.toBytes("col5");

  // Setting up region
  this.region = initHRegion(tableName, method, CONF, fam1);
  try {
    // Add to memstore
    Put put = new Put(row1);
    put.addColumn(fam1, col1, null);
    put.addColumn(fam1, col2, null);
    put.addColumn(fam1, col3, null);
    put.addColumn(fam1, col4, null);
    put.addColumn(fam1, col5, null);
    region.put(put);

    Get get = new Get(row1);
    get.addColumn(fam1, col2);
    get.addColumn(fam1, col4);
    // Expected result
    KeyValue kv1 = new KeyValue(row1, fam1, col2);
    KeyValue kv2 = new KeyValue(row1, fam1, col4);
    KeyValue[] expected = { kv1, kv2 };

    // Test
    Result res = region.get(get);
    assertEquals(expected.length, res.size());
    for (int i = 0; i < res.size(); i++) {
      assertTrue(CellUtil.matchingRows(expected[i], res.rawCells()[i]));
      assertTrue(CellUtil.matchingFamily(expected[i], res.rawCells()[i]));
      assertTrue(CellUtil.matchingQualifier(expected[i], res.rawCells()[i]));
    }

    // Test using a filter on a Get
    Get g = new Get(row1);
    final int count = 2;
    g.setFilter(new ColumnCountGetFilter(count));
    res = region.get(g);
    assertEquals(count, res.size());
  } finally {
    HBaseTestingUtility.closeRegionAndWAL(this.region);
    this.region = null;
  }
}
项目:PyroDB    文件:TestHRegion.java   
@Test
public void testGet_Basic() throws IOException {
  byte[] row1 = Bytes.toBytes("row1");
  byte[] fam1 = Bytes.toBytes("fam1");
  byte[] col1 = Bytes.toBytes("col1");
  byte[] col2 = Bytes.toBytes("col2");
  byte[] col3 = Bytes.toBytes("col3");
  byte[] col4 = Bytes.toBytes("col4");
  byte[] col5 = Bytes.toBytes("col5");

  // Setting up region
  String method = this.getName();
  this.region = initHRegion(tableName, method, CONF, fam1);
  try {
    // Add to memstore
    Put put = new Put(row1);
    put.add(fam1, col1, null);
    put.add(fam1, col2, null);
    put.add(fam1, col3, null);
    put.add(fam1, col4, null);
    put.add(fam1, col5, null);
    region.put(put);

    Get get = new Get(row1);
    get.addColumn(fam1, col2);
    get.addColumn(fam1, col4);
    // Expected result
    KeyValue kv1 = new KeyValue(row1, fam1, col2);
    KeyValue kv2 = new KeyValue(row1, fam1, col4);
    KeyValue[] expected = { kv1, kv2 };

    // Test
    Result res = region.get(get);
    assertEquals(expected.length, res.size());
    for (int i = 0; i < res.size(); i++) {
      assertTrue(CellUtil.matchingRow(expected[i], res.rawCells()[i]));
      assertTrue(CellUtil.matchingFamily(expected[i], res.rawCells()[i]));
      assertTrue(CellUtil.matchingQualifier(expected[i], res.rawCells()[i]));
    }

    // Test using a filter on a Get
    Get g = new Get(row1);
    final int count = 2;
    g.setFilter(new ColumnCountGetFilter(count));
    res = region.get(g);
    assertEquals(count, res.size());
  } finally {
    HRegion.closeHRegion(this.region);
    this.region = null;
  }
}
项目:c5    文件:TestHRegion.java   
@Test
public void testGet_Basic() throws IOException {
  byte[] row1 = Bytes.toBytes("row1");
  byte[] fam1 = Bytes.toBytes("fam1");
  byte[] col1 = Bytes.toBytes("col1");
  byte[] col2 = Bytes.toBytes("col2");
  byte[] col3 = Bytes.toBytes("col3");
  byte[] col4 = Bytes.toBytes("col4");
  byte[] col5 = Bytes.toBytes("col5");

  // Setting up region
  String method = this.getName();
  this.region = initHRegion(tableName, method, conf, fam1);
  try {
    // Add to memstore
    Put put = new Put(row1);
    put.add(fam1, col1, null);
    put.add(fam1, col2, null);
    put.add(fam1, col3, null);
    put.add(fam1, col4, null);
    put.add(fam1, col5, null);
    region.put(put);

    Get get = new Get(row1);
    get.addColumn(fam1, col2);
    get.addColumn(fam1, col4);
    // Expected result
    KeyValue kv1 = new KeyValue(row1, fam1, col2);
    KeyValue kv2 = new KeyValue(row1, fam1, col4);
    KeyValue[] expected = { kv1, kv2 };

    // Test
    Result res = region.get(get);
    assertEquals(expected.length, res.size());
    for (int i = 0; i < res.size(); i++) {
      assertTrue(CellUtil.matchingRow(expected[i], res.rawCells()[i]));
      assertTrue(CellUtil.matchingFamily(expected[i], res.rawCells()[i]));
      assertTrue(CellUtil.matchingQualifier(expected[i], res.rawCells()[i]));
    }

    // Test using a filter on a Get
    Get g = new Get(row1);
    final int count = 2;
    g.setFilter(new ColumnCountGetFilter(count));
    res = region.get(g);
    assertEquals(count, res.size());
  } finally {
    HRegion.closeHRegion(this.region);
    this.region = null;
  }
}
项目:HBase-Research    文件:TestHRegion.java   
public void testGet_Basic() throws IOException {
  byte [] tableName = Bytes.toBytes("testtable");
  byte [] row1 = Bytes.toBytes("row1");
  byte [] fam1 = Bytes.toBytes("fam1");
  byte [] col1 = Bytes.toBytes("col1");
  byte [] col2 = Bytes.toBytes("col2");
  byte [] col3 = Bytes.toBytes("col3");
  byte [] col4 = Bytes.toBytes("col4");
  byte [] col5 = Bytes.toBytes("col5");

  //Setting up region
  String method = this.getName();
  this.region = initHRegion(tableName, method, conf, fam1);
  try {
    //Add to memstore
    Put put = new Put(row1);
    put.add(fam1, col1, null);
    put.add(fam1, col2, null);
    put.add(fam1, col3, null);
    put.add(fam1, col4, null);
    put.add(fam1, col5, null);
    region.put(put);

    Get get = new Get(row1);
    get.addColumn(fam1, col2);
    get.addColumn(fam1, col4);
    //Expected result
    KeyValue kv1 = new KeyValue(row1, fam1, col2);
    KeyValue kv2 = new KeyValue(row1, fam1, col4);
    KeyValue [] expected = {kv1, kv2};

    //Test
    Result res = region.get(get, null);
    assertEquals(expected.length, res.size());
    for(int i=0; i<res.size(); i++){
      assertEquals(0,
          Bytes.compareTo(expected[i].getRow(), res.raw()[i].getRow()));
      assertEquals(0,
          Bytes.compareTo(expected[i].getFamily(), res.raw()[i].getFamily()));
      assertEquals(0,
          Bytes.compareTo(
              expected[i].getQualifier(), res.raw()[i].getQualifier()));
    }

    // Test using a filter on a Get
    Get g = new Get(row1);
    final int count = 2;
    g.setFilter(new ColumnCountGetFilter(count));
    res = region.get(g, null);
    assertEquals(count, res.size());
  } finally {
    HRegion.closeHRegion(this.region);
    this.region = null;
  }
}
项目:hbase-0.94.8-qod    文件:TestHRegion.java   
public void testGet_Basic() throws IOException {
  byte [] tableName = Bytes.toBytes("testtable");
  byte [] row1 = Bytes.toBytes("row1");
  byte [] fam1 = Bytes.toBytes("fam1");
  byte [] col1 = Bytes.toBytes("col1");
  byte [] col2 = Bytes.toBytes("col2");
  byte [] col3 = Bytes.toBytes("col3");
  byte [] col4 = Bytes.toBytes("col4");
  byte [] col5 = Bytes.toBytes("col5");

  //Setting up region
  String method = this.getName();
  this.region = initHRegion(tableName, method, conf, fam1);
  try {
    //Add to memstore
    Put put = new Put(row1);
    put.add(fam1, col1, null);
    put.add(fam1, col2, null);
    put.add(fam1, col3, null);
    put.add(fam1, col4, null);
    put.add(fam1, col5, null);
    region.put(put);

    Get get = new Get(row1);
    get.addColumn(fam1, col2);
    get.addColumn(fam1, col4);
    //Expected result
    KeyValue kv1 = new KeyValue(row1, fam1, col2);
    KeyValue kv2 = new KeyValue(row1, fam1, col4);
    KeyValue [] expected = {kv1, kv2};

    //Test
    Result res = region.get(get, null);
    assertEquals(expected.length, res.size());
    for(int i=0; i<res.size(); i++){
      assertEquals(0,
          Bytes.compareTo(expected[i].getRow(), res.raw()[i].getRow()));
      assertEquals(0,
          Bytes.compareTo(expected[i].getFamily(), res.raw()[i].getFamily()));
      assertEquals(0,
          Bytes.compareTo(
              expected[i].getQualifier(), res.raw()[i].getQualifier()));
    }

    // Test using a filter on a Get
    Get g = new Get(row1);
    final int count = 2;
    g.setFilter(new ColumnCountGetFilter(count));
    res = region.get(g, null);
    assertEquals(count, res.size());
  } finally {
    HRegion.closeHRegion(this.region);
    this.region = null;
  }
}
项目:hbase-0.94.8-qod    文件:TestHRegion.java   
public void testGet_Basic() throws IOException {
  byte [] tableName = Bytes.toBytes("testtable");
  byte [] row1 = Bytes.toBytes("row1");
  byte [] fam1 = Bytes.toBytes("fam1");
  byte [] col1 = Bytes.toBytes("col1");
  byte [] col2 = Bytes.toBytes("col2");
  byte [] col3 = Bytes.toBytes("col3");
  byte [] col4 = Bytes.toBytes("col4");
  byte [] col5 = Bytes.toBytes("col5");

  //Setting up region
  String method = this.getName();
  this.region = initHRegion(tableName, method, conf, fam1);
  try {
    //Add to memstore
    Put put = new Put(row1);
    put.add(fam1, col1, null);
    put.add(fam1, col2, null);
    put.add(fam1, col3, null);
    put.add(fam1, col4, null);
    put.add(fam1, col5, null);
    region.put(put);

    Get get = new Get(row1);
    get.addColumn(fam1, col2);
    get.addColumn(fam1, col4);
    //Expected result
    KeyValue kv1 = new KeyValue(row1, fam1, col2);
    KeyValue kv2 = new KeyValue(row1, fam1, col4);
    KeyValue [] expected = {kv1, kv2};

    //Test
    Result res = region.get(get, null);
    assertEquals(expected.length, res.size());
    for(int i=0; i<res.size(); i++){
      assertEquals(0,
          Bytes.compareTo(expected[i].getRow(), res.raw()[i].getRow()));
      assertEquals(0,
          Bytes.compareTo(expected[i].getFamily(), res.raw()[i].getFamily()));
      assertEquals(0,
          Bytes.compareTo(
              expected[i].getQualifier(), res.raw()[i].getQualifier()));
    }

    // Test using a filter on a Get
    Get g = new Get(row1);
    final int count = 2;
    g.setFilter(new ColumnCountGetFilter(count));
    res = region.get(g, null);
    assertEquals(count, res.size());
  } finally {
    HRegion.closeHRegion(this.region);
    this.region = null;
  }
}
项目:DominoHBase    文件:TestHRegion.java   
public void testGet_Basic() throws IOException {
  byte [] tableName = Bytes.toBytes("testtable");
  byte [] row1 = Bytes.toBytes("row1");
  byte [] fam1 = Bytes.toBytes("fam1");
  byte [] col1 = Bytes.toBytes("col1");
  byte [] col2 = Bytes.toBytes("col2");
  byte [] col3 = Bytes.toBytes("col3");
  byte [] col4 = Bytes.toBytes("col4");
  byte [] col5 = Bytes.toBytes("col5");

  //Setting up region
  String method = this.getName();
  this.region = initHRegion(tableName, method, conf, fam1);
  try {
    //Add to memstore
    Put put = new Put(row1);
    put.add(fam1, col1, null);
    put.add(fam1, col2, null);
    put.add(fam1, col3, null);
    put.add(fam1, col4, null);
    put.add(fam1, col5, null);
    region.put(put);

    Get get = new Get(row1);
    get.addColumn(fam1, col2);
    get.addColumn(fam1, col4);
    //Expected result
    KeyValue kv1 = new KeyValue(row1, fam1, col2);
    KeyValue kv2 = new KeyValue(row1, fam1, col4);
    KeyValue [] expected = {kv1, kv2};

    //Test
    Result res = region.get(get, null);
    assertEquals(expected.length, res.size());
    for(int i=0; i<res.size(); i++){
      assertEquals(0,
          Bytes.compareTo(expected[i].getRow(), res.raw()[i].getRow()));
      assertEquals(0,
          Bytes.compareTo(expected[i].getFamily(), res.raw()[i].getFamily()));
      assertEquals(0,
          Bytes.compareTo(
              expected[i].getQualifier(), res.raw()[i].getQualifier()));
    }

    // Test using a filter on a Get
    Get g = new Get(row1);
    final int count = 2;
    g.setFilter(new ColumnCountGetFilter(count));
    res = region.get(g, null);
    assertEquals(count, res.size());
  } finally {
    HRegion.closeHRegion(this.region);
    this.region = null;
  }
}
项目:hindex    文件:TestHRegion.java   
public void testGet_Basic() throws IOException {
  byte [] tableName = Bytes.toBytes("testtable");
  byte [] row1 = Bytes.toBytes("row1");
  byte [] fam1 = Bytes.toBytes("fam1");
  byte [] col1 = Bytes.toBytes("col1");
  byte [] col2 = Bytes.toBytes("col2");
  byte [] col3 = Bytes.toBytes("col3");
  byte [] col4 = Bytes.toBytes("col4");
  byte [] col5 = Bytes.toBytes("col5");

  //Setting up region
  String method = this.getName();
  this.region = initHRegion(tableName, method, conf, fam1);
  try {
    //Add to memstore
    Put put = new Put(row1);
    put.add(fam1, col1, null);
    put.add(fam1, col2, null);
    put.add(fam1, col3, null);
    put.add(fam1, col4, null);
    put.add(fam1, col5, null);
    region.put(put);

    Get get = new Get(row1);
    get.addColumn(fam1, col2);
    get.addColumn(fam1, col4);
    //Expected result
    KeyValue kv1 = new KeyValue(row1, fam1, col2);
    KeyValue kv2 = new KeyValue(row1, fam1, col4);
    KeyValue [] expected = {kv1, kv2};

    //Test
    Result res = region.get(get, null);
    assertEquals(expected.length, res.size());
    for(int i=0; i<res.size(); i++){
      assertEquals(0,
          Bytes.compareTo(expected[i].getRow(), res.raw()[i].getRow()));
      assertEquals(0,
          Bytes.compareTo(expected[i].getFamily(), res.raw()[i].getFamily()));
      assertEquals(0,
          Bytes.compareTo(
              expected[i].getQualifier(), res.raw()[i].getQualifier()));
    }

    // Test using a filter on a Get
    Get g = new Get(row1);
    final int count = 2;
    g.setFilter(new ColumnCountGetFilter(count));
    res = region.get(g, null);
    assertEquals(count, res.size());
  } finally {
    HRegion.closeHRegion(this.region);
    this.region = null;
  }
}