Package org.apache.hadoop.hbase.client

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


    HTable table = new HTable(conf, tableName);
    Map<byte [], Cell> columnMap = new HashMap<byte [], Cell>();
    columnMap.put(TEXT_COLUMN1,
        new Cell(VALUE, HConstants.LATEST_TIMESTAMP));
    RegExpRowFilter filter = new RegExpRowFilter(null, columnMap);
    Scanner scanner = table.getScanner(columns, HConstants.EMPTY_START_ROW, filter);
    int numFound = doScan(scanner, printValues);
    Assert.assertEquals(NUM_ROWS, numFound);
  }
View Full Code Here


      }
    }
    public void scannerClose(int id) throws IOError, IllegalArgument {
      LOG.debug("scannerClose: id=" + id);
      Scanner scanner = getScanner(id);
      if (scanner == null) {
        throw new IllegalArgument("scanner ID is invalid");
      }
      scanner.close();
      removeScanner(id);
    }
View Full Code Here

    }
   
    public ScanEntry scannerGet(int id) throws IllegalArgument, NotFound,
        IOError {
      LOG.debug("scannerGet: id=" + id);
      Scanner scanner = getScanner(id);
      if (scanner == null) {
        throw new IllegalArgument("scanner ID is invalid");
      }
     
      RowResult results = null;
     
      try {
        results = scanner.next();
        if (results == null) {
          throw new NotFound("end of scanner reached");
        }
      } catch (IOException e) {
        throw new IOError(e.getMessage());
View Full Code Here

        HTable table = getTable(tableName);
        byte [][] columnsText = new byte[columns.size()][];
        for (int i = 0; i < columns.size(); ++i) {
          columnsText[i] = getText(columns.get(i));
        }
        Scanner scanner = table.getScanner(columnsText,
            getText(startRow));
        return addScanner(scanner);
      } catch (IOException e) {
        throw new IOError(e.getMessage());
      }
View Full Code Here

        HTable table = getTable(tableName);
        byte [][] columnsText = new byte[columns.size()][];
        for (int i = 0; i < columns.size(); ++i) {
          columnsText[i] = getText(columns.get(i));
        }
        Scanner scanner = table.getScanner(columnsText,
            getText(startRow), getText(stopRow));
        return addScanner(scanner);
      } catch (IOException e) {
        throw new IOError(e.getMessage());
      }
View Full Code Here

        HTable table = getTable(tableName);
        byte [][] columnsText = new byte[columns.size()][];
        for (int i = 0; i < columns.size(); ++i) {
          columnsText[i] = getText(columns.get(i));
        }
        Scanner scanner = table.getScanner(columnsText,
            getText(startRow), timestamp);
        return addScanner(scanner);
      } catch (IOException e) {
        throw new IOError(e.getMessage());
      }
View Full Code Here

        HTable table = getTable(tableName);
        byte [][] columnsText = new byte[columns.size()][];
        for (int i = 0; i < columns.size(); ++i) {
          columnsText[i] = getText(columns.get(i));
        }
        Scanner scanner = table.getScanner(columnsText,
            getText(startRow), getText(stopRow), timestamp);
        return addScanner(scanner);
      } catch (IOException e) {
        throw new IOError(e.getMessage());
      }
View Full Code Here

    byte [] endRow = request.getParameter(END_ROW) == null?
      HConstants.EMPTY_START_ROW:
      Bytes.toBytes(URLDecoder.decode(request.getParameter(END_ROW),
        HConstants.UTF8_ENCODING));

    Scanner scanner = (request.getParameter(END_ROW) == null)?
       table.getScanner(columns, startRow):
       table.getScanner(columns, startRow, endRow);
   
    // Make a scanner id by hashing the object toString value (object name +
    // an id).  Will make identifier less burdensome and more url friendly.
    String scannerid =
      Integer.toHexString(JenkinsHash.hash(scanner.toString().getBytes(), -1));
    ScannerRecord sr = new ScannerRecord(scanner);
   
    // store the scanner for subsequent requests
    this.scanners.put(scannerid, sr);
   
View Full Code Here

      public void run() {
        try {
          // Now try to open a scanner on the meta table. Should stall until
          // meta server comes back up.
          HTable t = new HTable(conf, HConstants.META_TABLE_NAME);
          Scanner s =
            t.getScanner(HConstants.COLUMN_FAMILY_ARRAY,
              HConstants.EMPTY_START_ROW);
          s.close();
         
        } catch (IOException e) {
          LOG.fatal("could not re-open meta table because", e);
          fail();
        }
        Scanner scanner = null;
        try {
          // Verify that the client can find the data after the region has moved
          // to a different server
          scanner =
            table.getScanner(HConstants.COLUMN_FAMILY_ARRAY,
               HConstants.EMPTY_START_ROW);
          LOG.info("Obtained scanner " + scanner);
          for (RowResult r : scanner) {
            assertTrue(Bytes.equals(r.getRow(), row));
            assertEquals(1, r.size());
            byte[] bytes = r.get(HConstants.COLUMN_FAMILY).getValue();
            assertNotNull(bytes);
            assertTrue(tableName.equals(Bytes.toString(bytes)));
          }
          LOG.info("Success!");
        } catch (Exception e) {
          e.printStackTrace();
          fail();
        } finally {
          if (scanner != null) {
            LOG.info("Closing scanner " + scanner);
            scanner.close();
          }
        }
      }
    };
    return new Thread(runnable);
View Full Code Here

      public void run() {
        try {
          // Now try to open a scanner on the meta table. Should stall until
          // meta server comes back up.
          HTable t = new HTable(conf, TABLE_NAME);
          Scanner s = t.getScanner(new byte[][] { COL_A },
              HConstants.EMPTY_START_ROW);
          s.close();

        } catch (IOException e) {
          LOG.fatal("could not re-open meta table because", e);
          fail();
        }
        Scanner scanner = null;
        try {
          verify(numRuns);
          LOG.info("Success!");
        } catch (Exception e) {
          e.printStackTrace();
          fail();
        } finally {
          if (scanner != null) {
            LOG.info("Closing scanner " + scanner);
            scanner.close();
          }
        }
      }
    };
    return new Thread(runnable);
View Full Code Here

TOP

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

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.