Package org.apache.hadoop.hbase.client

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


  throws IOException {
    HTable meta = new HTable(TEST_UTIL.getConfiguration(),
      HConstants.META_TABLE_NAME);
    while (true) {
      int rows = 0;
      Scan scan = new Scan();
      scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER);
      ResultScanner s = meta.getScanner(scan);
      for (Result r = null; (r = s.next()) != null;) {
        byte [] b =
          r.getValue(HConstants.CATALOG_FAMILY, HConstants.SERVER_QUALIFIER);
        if (b == null || b.length <= 0) {
View Full Code Here


  private static int addToEachStartKey(final int expected) throws IOException {
    HTable t = new HTable(TEST_UTIL.getConfiguration(), TABLENAME);
    HTable meta = new HTable(TEST_UTIL.getConfiguration(),
        HConstants.META_TABLE_NAME);
    int rows = 0;
    Scan scan = new Scan();
    scan.addColumn(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
    ResultScanner s = meta.getScanner(scan);
    for (Result r = null; (r = s.next()) != null;) {
      byte [] b =
        r.getValue(HConstants.CATALOG_FAMILY, HConstants.REGIONINFO_QUALIFIER);
      if (b == null || b.length <= 0) {
View Full Code Here

  public ResultScanner getScanner(Scan scan) throws IOException {
    return new Scanner(scan);
  }

  public ResultScanner getScanner(byte[] family) throws IOException {
    Scan scan = new Scan();
    scan.addFamily(family);
    return new Scanner(scan);
  }
View Full Code Here

    return new Scanner(scan);
  }

  public ResultScanner getScanner(byte[] family, byte[] qualifier)
      throws IOException {
    Scan scan = new Scan();
    scan.addColumn(family, qualifier);
    return new Scanner(scan);
  }
View Full Code Here

  private void checkScanWithOneRow(byte[] family, boolean memStoreEmpty)
    throws IOException {
    /**
     * Scan without the index
     */
    Scan scan = new Scan();
    scan.addFamily(family);
    InternalScanner scanner = region.getScanner(scan);
    List<KeyValue> res = new ArrayList<KeyValue>();

    while (scanner.next(res)) ;
    assertEquals(1, res.size());
View Full Code Here

  private void checkScanWithOneIndexAndOneColumn(byte[] family,
    boolean memStoreEmpty, int numRows, int numColumns) throws IOException {
    /**
     * Scan without the index for everything
     */
    Scan scan = new Scan();
    scan.addFamily(family);
    InternalScanner scanner = region.getScanner(scan);
    List<KeyValue> res = new ArrayList<KeyValue>();

    while (scanner.next(res)) ;
    assertEquals(numRows * numColumns, res.size());
    res.clear();

    /**
     * Scan without the index for one
     */
    scan = new Scan();
    scan.addFamily(family);
    scan.setFilter(new SingleColumnValueFilter(family, qualLong,
      CompareFilter.CompareOp.EQUAL, new BinaryComparator(Bytes.toBytes(42L))));
    scanner = region.getScanner(scan);
    res.clear();

    while (scanner.next(res)) ;
View Full Code Here

      new ObjectArrayList<KeyValue>(this.keys.size());

    StopWatch stopWatch = new StopWatch();
    stopWatch.start();

    InternalScanner scanner = region.getScanner(new Scan());
    boolean moreRows;
    int id = 0;
    do {
      List<KeyValue> nextRow = new ArrayList<KeyValue>();
      moreRows = scanner.next(nextRow);
View Full Code Here

    doFsCommand(shell, new String [] {"-lsr", "/"});
    TEST_UTIL.startMiniHBaseCluster(1, 1);

    for(String table: tables) {
      int count = 0;
      for(Result res: new HTable(TEST_UTIL.getConfiguration(), table).getScanner(new Scan())) {
        assertEquals(currentKeys[count++], Bytes.toString(res.getRow()));
      }
      Assert.assertEquals(currentKeys.length, count);
    }
    assertEquals(2, TEST_UTIL.getHBaseAdmin().listNamespaceDescriptors().length);

    //verify ACL table is migrated
    HTable secureTable = new HTable(conf, AccessControlLists.ACL_TABLE_NAME);
    ResultScanner scanner = secureTable.getScanner(new Scan());
    int count = 0;
    for(Result r : scanner) {
      count++;
    }
    assertEquals(3, count);
View Full Code Here

        TEST_UTIL.getHBaseAdmin().cloneSnapshot(table+"_snapshot"+i, table+"_clone"+i);
        FSUtils.logFileSystemState(FileSystem.get(TEST_UTIL.getConfiguration()),
            FSUtils.getRootDir(TEST_UTIL.getConfiguration()),
            LOG);
        int count = 0;
        for(Result res: new HTable(TEST_UTIL.getConfiguration(), table+"_clone"+i).getScanner(new
            Scan())) {
          assertEquals(snapshots[i-1][count++], Bytes.toString(res.getRow()));
        }
        Assert.assertEquals(table+"_snapshot"+i, snapshots[i-1].length, count);
      }
View Full Code Here

  public void testRenameUsingSnapshots() throws Exception {
    String newNS = "newNS";
    TEST_UTIL.getHBaseAdmin().createNamespace(NamespaceDescriptor.create(newNS).build());
    for(String table: tables) {
      int count = 0;
      for(Result res: new HTable(TEST_UTIL.getConfiguration(), table).getScanner(new
          Scan())) {
        assertEquals(currentKeys[count++], Bytes.toString(res.getRow()));
      }
      TEST_UTIL.getHBaseAdmin().snapshot(table + "_snapshot3", table);
      final String newTableName = newNS + TableName.NAMESPACE_DELIM + table + "_clone3";
      TEST_UTIL.getHBaseAdmin().cloneSnapshot(table + "_snapshot3", newTableName);
      Thread.sleep(1000);
      count = 0;
      for(Result res: new HTable(TEST_UTIL.getConfiguration(), newTableName).getScanner(new
          Scan())) {
        assertEquals(currentKeys[count++], Bytes.toString(res.getRow()));
      }
      FSUtils.logFileSystemState(TEST_UTIL.getTestFileSystem(), TEST_UTIL.getDefaultRootDirPath()
          , LOG);
      Assert.assertEquals(newTableName, currentKeys.length, count);
      TEST_UTIL.getHBaseAdmin().flush(newTableName);
      TEST_UTIL.getHBaseAdmin().majorCompact(newTableName);
      TEST_UTIL.waitFor(30000, new Waiter.Predicate<IOException>() {
        @Override
        public boolean evaluate() throws IOException {
          try {
            return TEST_UTIL.getHBaseAdmin().getCompactionState(newTableName) ==
                AdminProtos.GetRegionInfoResponse.CompactionState.NONE;
          } catch (InterruptedException e) {
            throw new IOException(e);
          }
        }
      });
    }

    String nextNS = "nextNS";
    TEST_UTIL.getHBaseAdmin().createNamespace(NamespaceDescriptor.create(nextNS).build());
    for(String table: tables) {
      String srcTable = newNS + TableName.NAMESPACE_DELIM + table + "_clone3";
      TEST_UTIL.getHBaseAdmin().snapshot(table + "_snapshot4", srcTable);
      String newTableName = nextNS + TableName.NAMESPACE_DELIM + table + "_clone4";
      TEST_UTIL.getHBaseAdmin().cloneSnapshot(table+"_snapshot4", newTableName);
      FSUtils.logFileSystemState(TEST_UTIL.getTestFileSystem(), TEST_UTIL.getDefaultRootDirPath(),
        LOG);
      int count = 0;
      for(Result res: new HTable(TEST_UTIL.getConfiguration(), newTableName).getScanner(new
          Scan())) {
        assertEquals(currentKeys[count++], Bytes.toString(res.getRow()));
      }
      Assert.assertEquals(newTableName, currentKeys.length, count);
    }
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.