Package org.apache.hadoop.hbase.io

Examples of org.apache.hadoop.hbase.io.HbaseMapWritable


      Text metaRegionName = m.getRegionName();
      HRegionInterface server = connection.getHRegionConnection(m.getServer());
      long scannerid = server.openScanner(metaRegionName, COL_REGIONINFO_ARRAY,
          tableName, HConstants.LATEST_TIMESTAMP, null);
      try {
        HbaseMapWritable data = server.next(scannerid);
           
        // Test data and that the row for the data is for our table. If table
        // does not exist, scanner will return row after where our table would
        // be inserted if it exists so look for exact match on table name.
           
        if (data != null && data.size() > 0) {
          for (Writable k: data.keySet()) {
            if (HRegionInfo.getTableNameFromRegionName(
                ((HStoreKey) k).getRow()).equals(tableName)) {
         
              // Then a region for this table already exists. Ergo table exists.
                 
View Full Code Here


          COLUMN_FAMILY_ARRAY, tableName, LATEST_TIMESTAMP,
          null);
       
        // iterate through the scanner, accumulating unique table names
        SCANNER_LOOP: while (true) {
          HbaseMapWritable values = server.next(scannerId);
          if (values == null || values.size() == 0) {
            break;
          }
          for (Map.Entry<Writable, Writable> e: values.entrySet()) {
            HStoreKey key = (HStoreKey) e.getKey();
            if (key.getColumn().equals(COL_REGIONINFO)) {
              HRegionInfo info = new HRegionInfo();
              info = (HRegionInfo) Writables.getWritable(
                  ((ImmutableBytesWritable) e.getValue()).get(), info);
View Full Code Here

   * @throws IOException
   */
  public SortedMap<Text, byte[]> getRow(final Text row, final long ts)
  throws IOException {
    checkClosed();
    HbaseMapWritable value = null;
        
    value = getRegionServerWithRetries(new ServerCallable<HbaseMapWritable>(row) {
      public HbaseMapWritable call() throws IOException {
        return server.getRow(location.getRegionInfo().getRegionName(), row, ts);
      }
    });
   
    SortedMap<Text, byte[]> results = new TreeMap<Text, byte[]>();
    if (value != null && value.size() != 0) {
      for (Map.Entry<Writable, Writable> e: value.entrySet()) {
        HStoreKey key = (HStoreKey) e.getKey();
        results.put(key.getColumn(),
            ((ImmutableBytesWritable) e.getValue()).get());
      }
    }
View Full Code Here

    throws IOException {
      checkClosed();
      if (this.closed) {
        return false;
      }
      HbaseMapWritable values = null;
      // Clear the results so we don't inherit any values from any previous
      // calls to next.
      results.clear();
      do {
        values = server.next(scannerId);
      } while ((values == null || values.size() == 0) && nextScanner());

      if (values != null && values.size() != 0) {
        for (Map.Entry<Writable, Writable> e: values.entrySet()) {
          HStoreKey k = (HStoreKey) e.getKey();
          key.setRow(k.getRow());
          key.setVersion(k.getTimestamp());
          key.setColumn(EMPTY_COLUMN);
          results.put(k.getColumn(),
              ((ImmutableBytesWritable) e.getValue()).get());
        }
      }
      return values == null ? false : values.size() != 0;
    }
View Full Code Here

    // Do initial RPC setup.
    this.hbaseMaster = (HMasterRegionInterface)HbaseRPC.waitForProxy(
      HMasterRegionInterface.class, HMasterRegionInterface.versionID,
      new HServerAddress(conf.get(MASTER_ADDRESS)).getInetSocketAddress(),
      this.conf);
    HbaseMapWritable result = null;
    long lastMsg = 0;
    while(!stopRequested.get()) {
      try {
        this.requestCount.set(0);
        this.serverInfo.setLoad(new HServerLoad(0, onlineRegions.size()));
View Full Code Here

    checkOpen();
    requestCount.incrementAndGet();
    try {
      HRegion region = getRegion(regionName);
      HbaseMapWritable result = new HbaseMapWritable();
      Map<Text, byte[]> map = region.getFull(row, ts);
      for (Map.Entry<Text, byte []> es: map.entrySet()) {
        result.put(new HStoreKey(row, es.getKey()),
            new ImmutableBytesWritable(es.getValue()));
      }
      return result;
     
    } catch (IOException e) {
View Full Code Here

    checkOpen();
    requestCount.incrementAndGet();
    try {
      // locate the region we're operating on
      HRegion region = getRegion(regionName);
      HbaseMapWritable result = new HbaseMapWritable();
      // ask the region for all the data
      Map<Text, byte[]> map = region.getClosestRowBefore(row);
      // convert to a MapWritable
      if (map == null) {
        return null;
      }
      for (Map.Entry<Text, byte []> es: map.entrySet()) {
        result.put(new HStoreKey(row, es.getKey()),
            new ImmutableBytesWritable(es.getValue()));
      }
      return result;
     
    } catch (IOException e) {
View Full Code Here

        throw new UnknownScannerException("Name: " + scannerName);
      }
      this.leases.renewLease(scannerId, scannerId);

      // Collect values to be returned here
      HbaseMapWritable values = new HbaseMapWritable();
      HStoreKey key = new HStoreKey();
      TreeMap<Text, byte []> results = new TreeMap<Text, byte []>();
      while (s.next(key, results)) {
        for(Map.Entry<Text, byte []> e: results.entrySet()) {
          values.put(new HStoreKey(key.getRow(), e.getKey(), key.getTimestamp()),
            new ImmutableBytesWritable(e.getValue()));
        }

        if(values.size() > 0) {
          // Row has something in it. Return the value.
          break;
        }

        // No data for this row, go get another.
        results.clear();
      }
      return values.size() == 0 ? null : values;
     
    } catch (IOException e) {
      checkFileSystem();
      throw e;
    }
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.io.HbaseMapWritable

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.