Examples of RowResult


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

   */
  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()));
    byte [] one = rr.get(b).getValue();
    byte [] two = deserializedRr.get(b).getValue();
    assertTrue(Bytes.equals(one, two));
    Writables.copyWritable(rr, deserializedRr);
    one = rr.get(b).getValue();
    two = deserializedRr.get(b).getValue();
    assertTrue(Bytes.equals(one, two));
   
  }
View Full Code Here

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

      this.scanner = scanner;
    }
   
    public boolean next(HStoreKey key, SortedMap<byte [], Cell> values)
    throws IOException {
      RowResult results = scanner.next();
      if (results == null) {
        return false;
      }
      key.setRow(results.getRow());
      values.clear();
      for (Map.Entry<byte [], Cell> entry : results.entrySet()) {
        values.put(entry.getKey(), entry.getValue());
      }
      return true;
    }
View Full Code Here

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

    // 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));
  }
View Full Code Here

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

      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

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

    batchUpdate2.put(COLUMN_FAMILY_STR,one);
   
    table.commit(batchUpdate);
    table.commit(batchUpdate2);
   
    RowResult result = null;
   
    // Test before first that null is returned
    result = table.getClosestRowBefore(beforeFirstRow, columnFamilyBytes);
    assertTrue(result == null);
   
    // Test at first that first is returned
    result = table.getClosestRowBefore(firstRow, columnFamilyBytes);
    assertTrue(result.containsKey(COLUMN_FAMILY_STR));
    assertTrue(Bytes.equals(result.get(COLUMN_FAMILY_STR).getValue(), zero));
   
    // Test inbetween first and second that first is returned
    result = table.getClosestRowBefore(beforeSecondRow, columnFamilyBytes);
    assertTrue(result.containsKey(COLUMN_FAMILY_STR));
    assertTrue(Bytes.equals(result.get(COLUMN_FAMILY_STR).getValue(), zero));
   
    // Test at second make sure second is returned
    result = table.getClosestRowBefore(row, columnFamilyBytes);
    assertTrue(result.containsKey(COLUMN_FAMILY_STR));
    assertTrue(Bytes.equals(result.get(COLUMN_FAMILY_STR).getValue(), one));
   
    // Test after second, make sure second is returned
    result = table.getClosestRowBefore(Bytes.add(row,one), columnFamilyBytes);
    assertTrue(result.containsKey(COLUMN_FAMILY_STR));
    assertTrue(Bytes.equals(result.get(COLUMN_FAMILY_STR).getValue(), one));
  }
View Full Code Here

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

    // Overwrite previous value
    b = new BatchUpdate(ROW, TIMESTAMP);
    b.put(COLUMN, Bytes.toBytes(VALUE2));
    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
View Full Code Here

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

      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

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

    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

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

          = 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

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

      TransactionalRegion region = getTransactionalRegion(regionName);
      Map<byte[], Cell> map = region.getFull(transactionId, row, columnSet, ts);
      HbaseMapWritable<byte[], Cell> result = new HbaseMapWritable<byte[], Cell>();
      result.putAll(map);
      return new RowResult(row, result);
    } catch (IOException e) {
      checkFileSystem();
      throw e;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.