Package org.apache.hadoop.hbase.io

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


   * @return Null or found HRegionInfo.
   * @throws IOException
   */
  HRegionInfo getHRegionInfo(final byte [] row, final Map<byte [], Cell> map)
  throws IOException {
    Cell regioninfo = map.get(COL_REGIONINFO);
    if (regioninfo == null) {
      StringBuilder sb =  new StringBuilder();
      for (byte [] e: map.keySet()) {
        if (sb.length() > 0) {
          sb.append(", ");
        }
        sb.append(Bytes.toString(e));
      }
      LOG.warn(Bytes.toString(COL_REGIONINFO) + " is empty for row: " +
         Bytes.toString(row) + "; has keys: " + sb.toString());
      return null;
    }
    return Writables.getHRegionInfo(regioninfo.getValue());
  }
View Full Code Here


          } else if (!(deletes.containsKey(itCol)
              && deletes.get(itCol).longValue() >= itKey.getTimestamp())) {
            // Skip expired cells
            if (ttl == HConstants.FOREVER ||
                  now < itKey.getTimestamp() + ttl) {
              results.put(itCol, new Cell(val, itKey.getTimestamp()));
            } else {
              victims.add(itKey);
              if (LOG.isDebugEnabled()) {
                LOG.debug("internalGetFull: " + itKey + ": expired, skipped");
              }
View Full Code Here

      if (itKey.matchesRowCol(key)) {
        if (!HLogEdit.isDeleted(es.getValue())) {
          // Filter out expired results
          if (ttl == HConstants.FOREVER ||
                now < itKey.getTimestamp() + ttl) {
            result.add(new Cell(tailMap.get(itKey), itKey.getTimestamp()));
            if (numVersions > 0 && result.size() >= numVersions) {
              break;
            }
          } else {
            victims.add(itKey);
View Full Code Here

        key.setVersion(this.timestamp);
        getFull(key, isWildcardScanner() ? null : this.columns, deletes,
            rowResults);
        for (Map.Entry<byte [], Long> e: deletes.entrySet()) {
          rowResults.put(e.getKey(),
            new Cell(HLogEdit.deleteBytes.get(), e.getValue().longValue()));
        }
        for (Map.Entry<byte [], Cell> e: rowResults.entrySet()) {
          byte [] column = e.getKey();
          Cell c = e.getValue();
          if (isWildcardScanner()) {
            // Check the results match.  We only check columns, not timestamps.
            // We presume that timestamps have been handled properly when we
            // called getFull.
            if (!columnMatch(column)) {
              continue;
            }
          }
          // We should never return HConstants.LATEST_TIMESTAMP as the time for
          // the row. As a compromise, we return the largest timestamp for the
          // entries that we find that match.
          if (c.getTimestamp() != HConstants.LATEST_TIMESTAMP &&
              c.getTimestamp() > latestTimestamp) {
            latestTimestamp = c.getTimestamp();
          }
          results.put(column, c);
        }
        this.currentRow = getNextRow(this.currentRow);
View Full Code Here

        getRegionServerWithRetries(s);
        currentRegion = s.getHRegionInfo();
        try {
          RowResult r = null;
          while (result && (r = getRegionServerWithRetries(s)) != null) {
            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) {
                  if (Bytes.equals(info.getTableDesc().getName(), tableName)) {
                    rowsScanned += 1;
View Full Code Here

          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.");
View Full Code Here

   * @throws Exception
   */
  public void testRowResult() throws Exception {
    HbaseMapWritable<byte [], Cell> m = new HbaseMapWritable<byte [], Cell>();
    byte [] b = Bytes.toBytes(getName());
    m.put(b, new Cell(b, System.currentTimeMillis()));
    RowResult rr = new RowResult(b, m);
    byte [] mb = Writables.getBytes(rr);
    RowResult deserializedRr =
      (RowResult)Writables.getWritable(mb, new RowResult());
    assertTrue(Bytes.equals(rr.getRow(), deserializedRr.getRow()));
View Full Code Here

   */
  public static void changeOnlineStatus (final HBaseConfiguration c,
      final byte [] row, final boolean onlineOffline)
  throws IOException {
    HTable t = new HTable(c, HConstants.META_TABLE_NAME);
    Cell cell = t.get(row, HConstants.COL_REGIONINFO);
    if (cell == null) {
      throw new IOException("no information for row " + row);
    }
    // Throws exception if null.
    HRegionInfo info = (HRegionInfo)Writables.
      getWritable(cell.getValue(), new HRegionInfo());
    BatchUpdate b = new BatchUpdate(row);
    info.setOffline(onlineOffline);
    b.put(HConstants.COL_REGIONINFO, Writables.getBytes(info));
    b.delete(HConstants.COL_SERVER);
    b.delete(HConstants.COL_STARTCODE);
View Full Code Here

  // Read from ROW1,COL_A and put it in ROW2_COLA and ROW3_COLA
  private TransactionState makeTransaction1() throws IOException {
    TransactionState transactionState = transactionManager.beginTransaction();

    Cell row1_A = table.get(transactionState, ROW1, COL_A);

    BatchUpdate write1 = new BatchUpdate(ROW2);
    write1.put(COL_A, row1_A.getValue());
    table.commit(transactionState, write1);

    BatchUpdate write2 = new BatchUpdate(ROW3);
    write2.put(COL_A, row1_A.getValue());
    table.commit(transactionState, write2);

    return transactionState;
  }
View Full Code Here

  // Read ROW1,COL_A, increment its (integer) value, write back
  private TransactionState makeTransaction2() throws IOException {
    TransactionState transactionState = transactionManager.beginTransaction();

    Cell row1_A = table.get(transactionState, ROW1, COL_A);

    int value = Bytes.toInt(row1_A.getValue());

    BatchUpdate write = new BatchUpdate(ROW1);
    write.put(COL_A, Bytes.toBytes(value + 1));
    table.commit(transactionState, write);
View Full Code Here

TOP

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

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.