Package org.apache.hadoop.hbase.io

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


   * @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


 
  protected void assertCellEquals(final HRegion region, final byte [] row,
    final byte [] column, final long timestamp, final String value)
  throws IOException {
    Map<byte [], Cell> result = region.getFull(row, null, timestamp, 1, null);
    Cell cell_value = result.get(column);
    if(value == null){
      assertEquals(column.toString() + " at timestamp " + timestamp, null, cell_value);
    } else {
      if (cell_value == null) {
        fail(column.toString() + " at timestamp " + timestamp +
          "\" was expected to be \"" + value + " but was null");
      }
      if (cell_value != null) {
        assertEquals(column.toString() + " at timestamp "
            + timestamp, value, new String(cell_value.getValue()));
      }
    }
  }
View Full Code Here

 
  private void verifyGet(final HRegionIncommon r, final String expectedServer)
  throws IOException {
    // This should return a value because there is only one family member
    Cell value = r.get(ROW_KEY, CONTENTS);
    assertNotNull(value);
   
    // This should not return a value because there are multiple family members
    value = r.get(ROW_KEY, HConstants.COLUMN_FAMILY);
    assertNull(value);
View Full Code Here

  private void isExpectedRow(final int rowIndex, TreeMap<byte [], Cell> row) {
    TreeMap<byte [], Cell> converted =
      new TreeMap<byte [], Cell>(Bytes.BYTES_COMPARATOR);
    for (Map.Entry<byte [], Cell> entry : row.entrySet()) {
      converted.put(entry.getKey(),
        new Cell(entry.getValue() == null ? null : entry.getValue().getValue(),
            HConstants.LATEST_TIMESTAMP));
    }
    isExpectedRowWithoutTimestamps(rowIndex, converted);
  }
View Full Code Here

    } catch (IOException e) {
      // This is expected
    }
    // Try to see if it's still inserted
    try {
      Cell cell = table.get("row1", SMALLFAM_STR);
      assertNull(cell);
    } catch (IOException e) {
      e.printStackTrace();
      fail("This is unexpected");
    }
View Full Code Here

      return false;
    if (filterIfColumnMissing) {
      return !columns.containsKey(columnName);
    }
    // Otherwise we must do the filter here
    Cell colCell = columns.get(columnName);
      if (colCell == null) {
        return false;
      }
      return this.filterColumnValue(colCell.getValue());
  }
View Full Code Here

    this.table.commit(b);
    // Now verify that getRow(row, column, latest) works
    RowResult r = table.getRow(ROW);
    assertNotNull(r);
    assertTrue(r.size() != 0);
    Cell c = r.get(COLUMN);
    assertNotNull(c);
    assertTrue(c.getValue().length != 0);
    String value = Bytes.toString(c.getValue());
    assertTrue(value.compareTo(VALUE2) == 0);
    // Now check getRow with multiple versions
    r = table.getRow(ROW, HConstants.ALL_VERSIONS);
    for (Map.Entry<byte[], Cell> e: r.entrySet()) {
      // Column name
//      System.err.print("  " + Bytes.toString(e.getKey()));
      c = e.getValue();
     
      // Need to iterate since there may be multiple versions
      for (Iterator<Map.Entry<Long, byte[]>> it = c.iterator();
            it.hasNext(); ) {
        Map.Entry<Long, byte[]> v = it.next();
        value = Bytes.toString(v.getValue());
//        System.err.println(" = " + value);
        assertTrue(VALUE2.compareTo(Bytes.toString(v.getValue())) == 0);
View Full Code Here

    SortedMap<HStoreKey, byte[]> tailMap = map.tailMap(key);
    long now = System.currentTimeMillis();
    for (Map.Entry<HStoreKey, byte []> es: tailMap.entrySet()) {
      HStoreKey itKey = es.getKey();
      byte [] itCol = itKey.getColumn();
      Cell cell = results.get(itCol);
      if ((cell == null || cell.getNumValues() < numVersions) && key.matchesWithoutColumn(itKey)) {
        if (columns == null || columns.contains(itKey.getColumn())) {
          byte [] val = tailMap.get(itKey);
          if (HLogEdit.isDeleted(val)) {
            if (!deletes.containsKey(itCol)
              || deletes.get(itCol).longValue() < itKey.getTimestamp()) {
              deletes.put(itCol, Long.valueOf(itKey.getTimestamp()));
            }
          } else if (!(deletes.containsKey(itCol)
              && deletes.get(itCol).longValue() >= itKey.getTimestamp())) {
            // Skip expired cells
            if (ttl == HConstants.FOREVER ||
                  now < itKey.getTimestamp() + ttl) {
              if (cell == null) {
                results.put(itCol, new Cell(val, itKey.getTimestamp()));
              } else {
                cell.add(val, itKey.getTimestamp());
              }
            } else {
              addVictim(victims, itKey);
            }
          }
View Full Code Here

      HStoreKey itKey = es.getKey();
      if (itKey.matchesRowCol(key)) {
        if (!isDeleted(es.getValue())) {
          // Filter out expired results
          if (HStore.notExpiredAndNotInDeletes(ttl, itKey, now, deletes)) {
            result.add(new Cell(tailMap.get(itKey), itKey.getTimestamp()));
            if (numVersions > 0 && result.size() >= numVersions) {
              break;
            }
          } else {
            addVictim(victims, itKey);
View Full Code Here

        key.setVersion(this.timestamp);
        getFull(key, isWildcardScanner() ? null : this.columns, 1, 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

TOP

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

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.