Package org.apache.hadoop.hbase.client

Examples of org.apache.hadoop.hbase.client.Scan


    try {
      this.r = createNewHRegion(REGION_INFO.getTableDesc(), null, null);
      addContent(this.r, HConstants.CATALOG_FAMILY);
      List<KeyValue> results = new ArrayList<KeyValue>();
      // Do simple test of getting one row only first.
      Scan scan = new Scan(Bytes.toBytes("abc"), Bytes.toBytes("abd"));
      scan.addFamily(HConstants.CATALOG_FAMILY);

      InternalScanner s = r.getScanner(scan);
      int count = 0;
      while (s.next(results)) {
        count++;
      }
      s.close();
      assertEquals(0, count);
      assertEquals(1, results.size());
      // Now do something a bit more imvolved.
      scan = new Scan(startrow, stoprow);
      scan.addFamily(HConstants.CATALOG_FAMILY);

      s = r.getScanner(scan);
      count = 0;
      KeyValue kv = null;
      results = new ArrayList<KeyValue>();
View Full Code Here


    try {
      this.r = createNewHRegion(REGION_INFO.getTableDesc(), null, null);
      addContent(this.r, HConstants.CATALOG_FAMILY);
      byte [] prefix = Bytes.toBytes("ab");
      Filter newFilter = new PrefixFilter(prefix);
      Scan scan = new Scan();
      scan.setFilter(newFilter);
      rowPrefixFilter(scan);
      RowFilterInterface oldFilter = new PrefixRowFilter(Bytes.toBytes("ab"));
      scan = new Scan();
      scan.setOldFilter(oldFilter);
      rowPrefixFilter(scan);
     
      byte[] stopRow = Bytes.toBytes("bbc");
      newFilter = new WhileMatchFilter(new InclusiveStopFilter(stopRow));
      scan = new Scan();
      scan.setFilter(newFilter);
      rowInclusiveStopFilter(scan, stopRow);
     
      oldFilter = new WhileMatchRowFilter(
          new InclusiveStopRowFilter(stopRow));
      scan = new Scan();
      scan.setOldFilter(oldFilter);
      rowInclusiveStopFilter(scan, stopRow);
     
    } finally {
      this.r.close();
      this.r.getLog().closeAndDelete();
View Full Code Here

 
  /** Use a scanner to get the region info and then validate the results */
  private void scan(boolean validateStartcode, String serverName)
  throws IOException
    InternalScanner scanner = null;
    Scan scan = null;
    List<KeyValue> results = new ArrayList<KeyValue>();
    byte [][][] scanColumns = {
        COLS,
        EXPLICIT_COLS
    };
   
    for(int i = 0; i < scanColumns.length; i++) {
      try {
        scan = new Scan(FIRST_ROW);
        for (int ii = 0; ii < EXPLICIT_COLS.length; ii++) {
          scan.addColumn(COLS[0],  EXPLICIT_COLS[ii]);
        }
        scanner = r.getScanner(scan);
        while (scanner.next(results)) {
          assertTrue(hasColumn(results, HConstants.CATALOG_FAMILY,
              HConstants.REGIONINFO_QUALIFIER));
View Full Code Here

    put2.add(HConstants.CATALOG_FAMILY, qual2, val2);
    r.put(put2);
    /**
     * Scan for the second row.
     */
    Scan scan = new Scan();
    scan.setFilter(new SingleColumnValueFilter(HConstants.CATALOG_FAMILY,
      qual2, CompareFilter.CompareOp.EQUAL, val2));

    InternalScanner scanner1 = r.getScanner(scan);
    List<KeyValue> res = new ArrayList<KeyValue>();
    assertFalse(scanner1.next(res));
View Full Code Here

      region.initialize(null, null);
      if (majorCompact) {
        region.compactStores(true);
      } else {
        // Default behavior
        Scan scan = new Scan();
        // scan.addFamily(HConstants.CATALOG_FAMILY);
        InternalScanner scanner = region.getScanner(scan);
        try {
          List<KeyValue> kvs = new ArrayList<KeyValue>();
          boolean done = false;
View Full Code Here

    SingleColumnValueFilter filter =
      new SingleColumnValueFilter(Bytes.toBytes("trans-tags"),
        Bytes.toBytes("qual2"), CompareOp.EQUAL, Bytes.toBytes(value));
    filter.setFilterIfMissing(true);
    allFilters.addFilter(filter);
    Scan scan = new Scan();
    scan.addFamily(Bytes.toBytes("trans-blob"));
    scan.addFamily(Bytes.toBytes("trans-type"));
    scan.addFamily(Bytes.toBytes("trans-date"));
    scan.addFamily(Bytes.toBytes("trans-tags"));
    scan.addFamily(Bytes.toBytes("trans-group"));
    scan.setFilter(allFilters);
    return r.getScanner(scan);
  }
View Full Code Here

    put = new Put(rowB);
    put.add(fam1, null, value);
    put.add(fam2, null, value);
    region.put(put);

    Scan scan = new Scan();
    scan.addFamily(fam1).addFamily(fam2);
    InternalScanner s = region.getScanner(scan);
    List<KeyValue> results = new ArrayList<KeyValue>();
    s.next(results);
    assertTrue(Bytes.equals(rowA, results.get(0).getRow()));
View Full Code Here

    Result r = region.get(get, null);
    assertEquals(1, r.size());
    assertByteEquals(value2, r.getValue(fam1, qual1));

    // next:
    Scan scan = new Scan(row);
    scan.addColumn(fam1, qual1);
    InternalScanner s = region.getScanner(scan);

    List<KeyValue> results = new ArrayList<KeyValue>();
    assertEquals(false, s.next(results));
    assertEquals(1, results.size());
View Full Code Here

          Bytes.compareTo(
              expected[i].getQualifier(), res.raw()[i].getQualifier()));
    }
   
    //Scan
    Scan scan = new Scan();
    scan.addFamily(HConstants.CATALOG_FAMILY);
    InternalScanner s = region.getScanner(scan);
    List<KeyValue> result = new ArrayList<KeyValue>();
    s.next(result);
   
    assertEquals(expected.length, result.size());
View Full Code Here

   
    //Setting up region
    String method = this.getName();
    initHRegion(tableName, method, families);
   
    Scan scan = new Scan();
    scan.addFamily(fam1);
    scan.addFamily(fam2);
    try {
      region.getScanner(scan);
    } catch (Exception e) {
      assertTrue("Families could not be found in Region", false);
    }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.client.Scan

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.