Package org.apache.hadoop.hbase.io

Examples of org.apache.hadoop.hbase.io.RowResult$Entry


          }
         
          // if we get to here, then hasNext() has given us an item to return.
          // we want to return the item and then null out the next pointer, so
          // we use a temporary variable.
          RowResult temp = next;
          next = null;
          return temp;
        }

        public void remove() {
View Full Code Here


    try {
      regionServer = master.connection.getHRegionConnection(region.getServer());
      scannerId = regionServer.openScanner(region.getRegionName(),
        COLUMN_FAMILY_ARRAY, EMPTY_START_ROW, HConstants.LATEST_TIMESTAMP, null);
      while (true) {
        RowResult values = regionServer.next(scannerId);
        if (values == null || values.size() == 0) {
          break;
        }
        HRegionInfo info = master.getHRegionInfo(values.getRow(), values);
        if (info == null) {
          emptyRows.add(values.getRow());
          continue;
        }
        String serverName = Writables.cellToString(values.get(COL_SERVER));
        long startCode = Writables.cellToLong(values.get(COL_STARTCODE));

        // Note Region has been assigned.
        checkAssigned(info, serverName, startCode);
        if (isSplitParent(info)) {
          splitParents.put(info, values);
View Full Code Here

      HbaseMapWritable<byte [], Cell> result =
        region.getFull(row, columnSet,
          ts, numVersions, getLockFromId(lockId));
      if (result == null || result.isEmpty())
        return null;
      return new RowResult(row, result);
    } catch (Throwable t) {
      throw convertThrowableToIOE(cleanup(t));
    }
  }
View Full Code Here

    requestCount.incrementAndGet();
    try {
      // locate the region we're operating on
      HRegion region = getRegion(regionName);
      // ask the region for all the data
      RowResult rr = region.getClosestRowBefore(row, columnFamily);
      return rr;
    } catch (Throwable t) {
      throw convertThrowableToIOE(cleanup(t));
    }
  }
View Full Code Here

          = new HbaseMapWritable<byte [], Cell>();
        HStoreKey key = new HStoreKey();
        while (s.next(key, values)) {
          if (values.size() > 0) {
            // Row has something in it. Return the value.
            resultSets.add(new RowResult(key.getRow(), values));
            break;
          }
        }
      }
      return resultSets.toArray(new RowResult[resultSets.size()]);
View Full Code Here

      // Now that we've found our key, get the values
      HbaseMapWritable<byte [], Cell> cells =
        new HbaseMapWritable<byte [], Cell>();
      // This will get all results for this store.
      store.getFull(key, null, 1, cells);
      return new RowResult(key.getRow(), cells);
    } finally {
      splitsAndClosesLock.readLock().unlock();
    }
  }
View Full Code Here

          HRegionInfo oldRegion = currentRegion;
          if (oldRegion != null) {
            startKey = oldRegion.getEndKey();
          }
          currentRegion = s.getHRegionInfo();
          RowResult r = null;
          RowResult[] rrs = null;
          while ((rrs = getRegionServerWithRetries(s)) != null) {
            r = rrs[0];
            Cell c = r.get(HConstants.COL_REGIONINFO);
            if (c != null) {
              byte[] value = c.getValue();
              if (value != null) {
                HRegionInfo info = Writables.getHRegionInfoOrNull(value);
                if (info != null) {
View Full Code Here

          HRegionLocation metaLocation = locateRegion(parentTable, metaKey);
          HRegionInterface server =
            getHRegionConnection(metaLocation.getServerAddress());

          // Query the root region for the location of the meta region
          RowResult regionInfoRow = server.getClosestRowBefore(
            metaLocation.getRegionInfo().getRegionName(), metaKey,
            HConstants.COLUMN_FAMILY);
          if (regionInfoRow == null) {
            throw new TableNotFoundException(Bytes.toString(tableName));
          }

          Cell value = regionInfoRow.get(COL_REGIONINFO);
          if (value == null || value.getValue().length == 0) {
            throw new IOException("HRegionInfo was null or empty in " +
              Bytes.toString(parentTable));
          }
          // convert the row result into the HRegionLocation we need!
          HRegionInfo regionInfo = (HRegionInfo) Writables.getWritable(
              value.getValue(), new HRegionInfo());
          // possible we got a region of a different table...
          if (!Bytes.equals(regionInfo.getTableDesc().getName(), tableName)) {
            throw new TableNotFoundException(
              "Table '" + Bytes.toString(tableName) + "' was not found.");
          }
          if (regionInfo.isOffline()) {
            throw new RegionOfflineException("region offline: " +
              regionInfo.getRegionNameAsString());
          }
         
          String serverAddress =
            Writables.cellToString(regionInfoRow.get(COL_SERVER));
          if (serverAddress.equals("")) {
            throw new NoServerForRegionException("No server address listed " +
              "in " + Bytes.toString(parentTable) + " for region " +
              regionInfo.getRegionNameAsString());
          }
View Full Code Here

    // make sure first expected values are correct
    assertTrue(table.checkAndSave(batchUpdate2, expectedValues,null));
       
    // make sure check and save truly saves the data after checking the expected
    // values
    RowResult r = table.getRow(row);
    byte[][] columns = batchUpdate2.getColumns();
    for(int i = 0;i < columns.length;i++) {
      assertTrue(Bytes.equals(r.get(columns[i]).getValue(),batchUpdate2.get(columns[i])));
    }
   
    // make sure that the old expected values fail
    assertFalse(table.checkAndSave(batchUpdate3, expectedValues,null));

    // row doesn't exist, so doesn't matter the expected
    // values (unless they are empty)
    assertFalse(table.checkAndSave(batchUpdate4, badExpectedValues, null));

    assertTrue(table.checkAndSave(batchUpdate4, expectedNoValues, null));
    // make sure check and save saves the data when expected values were empty and the row
    // didn't exist
    r = table.getRow(row1);
    columns = batchUpdate4.getColumns();
    for(int i = 0; i < columns.length;i++) {
      assertTrue(Bytes.equals(r.get(columns[i]).getValue(),batchUpdate4.get(columns[i])));
   

    // since the row isn't empty anymore, those expected (empty) values
    // are not valid anymore, so check and save method doesn't save.
    assertFalse(table.checkAndSave(batchUpdate4, expectedNoValues, null));
   
    // the row exists, but the columns don't. since the expected values are
    // for columns without value, checkAndSave must be successful.
    assertTrue(table.checkAndSave(batchUpdate5, expectedNoValues1, null));
    // make sure checkAndSave saved values for batchUpdate5.
    r = table.getRow(row);
    columns = batchUpdate5.getColumns();
    for(int i = 0; i < columns.length;i++) {
      assertTrue(Bytes.equals(r.get(columns[i]).getValue(),batchUpdate5.get(columns[i])));
   

    // since the condition wasn't changed, the following checkAndSave
    // must also be successful.
    assertTrue(table.checkAndSave(batchUpdate, expectedNoValues1, null));
    // make sure checkAndSave saved values for batchUpdate1
    r = table.getRow(row);
    columns = batchUpdate.getColumns();
    for(int i = 0; i < columns.length;i++) {
      assertTrue(Bytes.equals(r.get(columns[i]).getValue(),batchUpdate.get(columns[i])));
    }

    // one failing condition must make the following checkAndSave fail
    // the failing condition is a column to be empty, however, it has a value.
    HbaseMapWritable<byte[],byte[]> expectedValues1 =
      new HbaseMapWritable<byte[],byte[]>();
    expectedValues1.put(Bytes.toBytes(COLUMN_FAMILY_STR+0), new byte[] {});
    expectedValues1.put(Bytes.toBytes(COLUMN_FAMILY_STR+"EMPTY+ROW"), new byte[] {});
    assertFalse(table.checkAndSave(batchUpdate5, expectedValues1, null));

    // assure the values on the row remain the same
    r = table.getRow(row);
    columns = batchUpdate.getColumns();
    for(int i = 0; i < columns.length;i++) {
      assertTrue(Bytes.equals(r.get(columns[i]).getValue(),batchUpdate.get(columns[i])));
    }   
  }
View Full Code Here

      assertTrue(table.exists(row));
      for(int i = 0; i < 5; i++)
        assertTrue(table.exists(row, Bytes.toBytes(COLUMN_FAMILY_STR+i)));

      RowResult result = null;
      result = table.getRow(row,  new byte[][] {COLUMN_FAMILY});
      for(int i = 0; i < 5; i++)
        assertTrue(result.containsKey(Bytes.toBytes(COLUMN_FAMILY_STR+i)));
     
      result = table.getRow(row);
      for(int i = 0; i < 5; i++)
        assertTrue(result.containsKey(Bytes.toBytes(COLUMN_FAMILY_STR+i)));

      batchUpdate = new BatchUpdate(row);
      batchUpdate.put("info2:a", Bytes.toBytes("a"));
      table.commit(batchUpdate);
     
      result = table.getRow(row, new byte[][] { COLUMN_FAMILY,
          Bytes.toBytes("info2:a") });
      for(int i = 0; i < 5; i++)
        assertTrue(result.containsKey(Bytes.toBytes(COLUMN_FAMILY_STR+i)));
      assertTrue(result.containsKey(Bytes.toBytes("info2:a")));
  
    } catch (IOException e) {
      e.printStackTrace();
      fail("Should not have any exception " +
        e.getClass());
View Full Code Here

TOP

Related Classes of org.apache.hadoop.hbase.io.RowResult$Entry

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.