Package org.apache.hadoop.hbase.io

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


          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) {
                  if (Bytes.equals(info.getTableDesc().getName(), tableName)) {
                    rowsScanned += 1;
View Full Code Here


            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.");
          }
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

    byte[] colcstring = "colc:astring".getBytes();
     
    // Data
    HbaseMapWritable<byte[], Cell> cells =
      new HbaseMapWritable<byte[], Cell>();
    cells.put(colabyte,    new Cell("123".getBytes(), 0));
    cells.put(colbshort,   new Cell("456".getBytes(), 0));
    cells.put(colcint,     new Cell("789".getBytes(), 0));
    cells.put(colalong,    new Cell("1000".getBytes(), 0));
    cells.put(colbdouble,  new Cell("5.3".getBytes(), 0));
    cells.put(colcstring,  new Cell("hive and hadoop".getBytes(), 0));
    RowResult rr = new RowResult("test-row1".getBytes(), cells);
    BatchUpdate bu = new BatchUpdate("test-row1".getBytes());
    bu.put(colabyte,    "123".getBytes());
    bu.put(colbshort,   "456".getBytes());
    bu.put(colcint,     "789".getBytes());
View Full Code Here

       
    LazyHBaseCellMap b = new LazyHBaseCellMap((LazyMapObjectInspector) oi);
       
    // Intialize a row result
    HbaseMapWritable<byte[], Cell> cells = new HbaseMapWritable<byte[], Cell>();
    cells.put("cfa:col1".getBytes(), new Cell("cfacol1".getBytes(), 0));
    cells.put("cfa:col2".getBytes(), new Cell("cfacol2".getBytes(), 0));
    cells.put("cfb:2".getBytes(),    new Cell("def".getBytes(), 0));
    cells.put("cfb:-1".getBytes(),   new Cell("".getBytes(), 0));
    cells.put("cfb:0".getBytes(),    new Cell("0".getBytes(), 0));
    cells.put("cfb:8".getBytes(),    new Cell("abc".getBytes(), 0));
    cells.put("cfc:col3".getBytes(), new Cell("cfccol3".getBytes(), 0));
       
    RowResult rr = new RowResult("test-row".getBytes(), cells);
       
    b.init(rr, "cfb:");
       
View Full Code Here

    LazyHBaseCellMap b = new LazyHBaseCellMap((LazyMapObjectInspector) oi);
       
    // Intialize a row result
    HbaseMapWritable<byte[], Cell> cells =
      new HbaseMapWritable<byte[], Cell>();
    cells.put("cfa:col1".getBytes(), new Cell("cfacol1".getBytes(), 0));
    cells.put("cfa:col2".getBytes(), new Cell("cfacol2".getBytes(), 0));
    cells.put("cfb:2".getBytes(),    new Cell("d\tf".getBytes(), 0));
    cells.put("cfb:-1".getBytes(),   new Cell("".getBytes(), 0));
    cells.put("cfb:0".getBytes(),    new Cell("0".getBytes(), 0));
    cells.put("cfb:8".getBytes(),    new Cell("abc".getBytes(), 0));
    cells.put("cfc:col3".getBytes(), new Cell("cfccol3".getBytes(), 0));
       
    RowResult rr = new RowResult("test-row".getBytes(), cells);
       
    b.init(rr, "cfb:");
       
View Full Code Here

    LazyHBaseRow o = new LazyHBaseRow((LazySimpleStructObjectInspector) oi);

    HbaseMapWritable<byte[], Cell> cells =
      new HbaseMapWritable<byte[], Cell>();
       
    cells.put("cfa:a".getBytes(), new Cell("123".getBytes(), 0));
    cells.put("cfa:b".getBytes(), new Cell("a:b:c".getBytes(), 0));
    cells.put("cfb:c".getBytes(), new Cell("d=e:f=g".getBytes(), 0));
    cells.put("cfb:d".getBytes(), new Cell("hi".getBytes(), 0));
    RowResult rr = new RowResult("test-row".getBytes(), cells);
    o.init(rr, hbaseColumnNames);
    assertEquals(
      ("{'key':'test-row','a':123,'b':['a','b','c'],"
        + "'c':{'d':'e','f':'g'},'d':'hi'}").replace("'", "\""),
      SerDeUtils.getJSONString(o, oi));

    cells.clear();
    cells.put("cfa:a".getBytes(), new Cell("123".getBytes(), 0));
    cells.put("cfb:c".getBytes(), new Cell("d=e:f=g".getBytes(), 0));
    rr = new RowResult("test-row".getBytes(), cells);
    o.init(rr, hbaseColumnNames);
    assertEquals(
      ("{'key':'test-row','a':123,'b':null,"
        + "'c':{'d':'e','f':'g'},'d':null}").replace("'", "\""),
      SerDeUtils.getJSONString(o, oi));

    cells.clear();
    cells.put("cfa:b".getBytes(), new Cell("a".getBytes(), 0));
    cells.put("cfb:c".getBytes(), new Cell("d=\\N:f=g:h".getBytes(), 0));
    cells.put("cfb:d".getBytes(), new Cell("no".getBytes(), 0));
    rr = new RowResult("test-row".getBytes(), cells);
    o.init(rr, hbaseColumnNames);
    assertEquals(
      ("{'key':'test-row','a':null,'b':['a'],"
        + "'c':{'d':null,'f':'g','h':null},'d':'no'}").replace("'", "\""),
      SerDeUtils.getJSONString(o, oi));

    cells.clear();
    cells.put("cfa:b".getBytes(), new Cell(":a::".getBytes(), 0));
    cells.put("cfb:d".getBytes(), new Cell("no".getBytes(), 0));
    rr = new RowResult("test-row".getBytes(), cells);
    o.init(rr, hbaseColumnNames);
    assertEquals(
      ("{'key':'test-row','a':null,'b':['','a','',''],"
        + "'c':null,'d':'no'}").replace("'", "\""),
      SerDeUtils.getJSONString(o, oi));

    cells.clear();
    cells.put("cfa:a".getBytes(), new Cell("123".getBytes(), 0));
    cells.put("cfa:b".getBytes(), new Cell("".getBytes(), 0));
    cells.put("cfb:c".getBytes(), new Cell("".getBytes(), 0));
    cells.put("cfb:d".getBytes(), new Cell("".getBytes(), 0));
    rr = new RowResult("test-row".getBytes(), cells);
    o.init(rr, hbaseColumnNames);
    assertEquals(
      "{'key':'test-row','a':123,'b':[],'c':{},'d':''}".replace("'", "\""),
      SerDeUtils.getJSONString(o, oi));
View Full Code Here

    LazyHBaseRow o = new LazyHBaseRow((LazySimpleStructObjectInspector) oi);

    HbaseMapWritable<byte[], Cell> cells =
      new HbaseMapWritable<byte[], Cell>();
       
    cells.put("cfa:a".getBytes(), new Cell("123".getBytes(), 0));
    cells.put("cfa:b".getBytes(), new Cell("a:b:c".getBytes(), 0));
    cells.put("cfb:d".getBytes(), new Cell("e".getBytes(), 0));
    cells.put("cfb:f".getBytes(), new Cell("g".getBytes(), 0));
    cells.put("cfc:d".getBytes(), new Cell("hi".getBytes(), 0));
    RowResult rr = new RowResult("test-row".getBytes(), cells);
    o.init(rr, hbaseColumnNames);
    assertEquals(
      ("{'key':'test-row','a':123,'b':['a','b','c'],"
        + "'c':{'d':'e','f':'g'},'d':'hi'}").replace("'", "\""),
      SerDeUtils.getJSONString(o, oi));

    cells.clear();
    cells.put("cfa:a".getBytes(), new Cell("123".getBytes(), 0));
    cells.put("cfb:d".getBytes(), new Cell("e".getBytes(), 0));
    cells.put("cfb:f".getBytes(), new Cell("g".getBytes(), 0));
    rr = new RowResult("test-row".getBytes(), cells);
    o.init(rr, hbaseColumnNames);
    assertEquals(
      ("{'key':'test-row','a':123,'b':null,"
        + "'c':{'d':'e','f':'g'},'d':null}").replace("'", "\""),
      SerDeUtils.getJSONString(o, oi));

    cells.clear();
    cells.put("cfa:b".getBytes(), new Cell("a".getBytes(), 0));
    cells.put("cfb:f".getBytes(), new Cell("g".getBytes(), 0));
    cells.put("cfc:d".getBytes(), new Cell("no".getBytes(), 0));
    rr = new RowResult("test-row".getBytes(), cells);
    o.init(rr, hbaseColumnNames);
    assertEquals(
      ("{'key':'test-row','a':null,'b':['a'],"
        + "'c':{'f':'g'},'d':'no'}").replace("'", "\""),
      SerDeUtils.getJSONString(o, oi));

    cells.clear();
    cells.put("cfa:b".getBytes(), new Cell(":a::".getBytes(), 0));
    cells.put("cfc:d".getBytes(), new Cell("no".getBytes(), 0));
    rr = new RowResult("test-row".getBytes(), cells);
    o.init(rr, hbaseColumnNames);
    assertEquals(
      ("{'key':'test-row','a':null,'b':['','a','',''],"
        + "'c':{},'d':'no'}").replace("'", "\""),
      SerDeUtils.getJSONString(o, oi));

    cells.clear();
    cells.put("cfa:a".getBytes(), new Cell("123".getBytes(), 0));
    cells.put("cfa:b".getBytes(), new Cell("".getBytes(), 0));
    cells.put("cfc:d".getBytes(), new Cell("".getBytes(), 0));
    rr = new RowResult("test-row".getBytes(), cells);
    o.init(rr, hbaseColumnNames);
    assertEquals(
      "{'key':'test-row','a':123,'b':[],'c':{},'d':''}".replace("'", "\""),
      SerDeUtils.getJSONString(o, oi));
View Full Code Here

    OutputCollector<ImmutableBytesWritable, RowResult> output,
    @SuppressWarnings("unused") Reporter reporter)
  throws IOException {
    boolean content = false;
    for (Map.Entry<byte [], Cell> e: value.entrySet()) {
      Cell cell = e.getValue();
      if (cell != null && cell.getValue().length > 0) {
        content = true;
        break;
      }
    }
    if (!content) {
View Full Code Here

    } catch (InterruptedException e) {
      // ignore
    }
   
    for(int i = 0; i < testKeys.length; i++) {
      Cell value = table.get(testKeys[i], CONTENTS);
      if(value != null && value.getValue().length != 0) {
        LOG.error("non existant key: " + testKeys[i] + " returned value: " +
            new String(value.getValue(), HConstants.UTF8_ENCODING));
        fail();
      }
    }
   
    for (int i = 0; i < rows.length; i++) {
      Cell value = table.get(rows[i], CONTENTS);
      if (value == null || value.getValue().length == 0) {
        LOG.error("No value returned for row " + Bytes.toString(rows[i]));
        fail();
      }
    }
    } catch (Exception e) {
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.