Package org.apache.hadoop.hbase.io

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


      byte [] colA = Bytes.toBytes(Bytes.toString(COLUMNS[0]) + "a");
      byte [] colB = Bytes.toBytes(Bytes.toString(COLUMNS[0]) + "b");
      byte [] colC = Bytes.toBytes(Bytes.toString(COLUMNS[1]) + "c");

      BatchUpdate batchUpdate = null;
      batchUpdate = new BatchUpdate(row, t0);
      batchUpdate.put(colA, cellData(0, flush).getBytes());
      batchUpdate.put(colB, cellData(0, flush).getBytes());
      batchUpdate.put(colC, cellData(0, flush).getBytes());     
      region_incommon.commit(batchUpdate);

      batchUpdate = new BatchUpdate(row, t1);
      batchUpdate.put(colA, cellData(1, flush).getBytes());
      batchUpdate.put(colB, cellData(1, flush).getBytes());
      batchUpdate.put(colC, cellData(1, flush).getBytes());     
      region_incommon.commit(batchUpdate);
     
      batchUpdate = new BatchUpdate(row, t2);
      batchUpdate.put(colA, cellData(2, flush).getBytes());
      batchUpdate.put(colB, cellData(2, flush).getBytes());
      batchUpdate.put(colC, cellData(2, flush).getBytes());     
      region_incommon.commit(batchUpdate);

      if (flush) {region_incommon.flushcache();}

      // call delete family at a timestamp, make sure only the most recent stuff
View Full Code Here


        /*
         * Insert data
         */
        for (int j = 0; j < rows[i].length; j++) {
          byte [] row = rows[i][j];
          BatchUpdate b = new BatchUpdate(row);
          b.put(COLUMN_NAME, new ImmutableBytesWritable(row).get());
          regions[i].batchUpdate(b, null);
        }
        HRegion.addRegionToMETA(meta, regions[i]);
      }
      // Close root and meta regions
View Full Code Here

  }
 
  private void addToRow(final HRegion r, final String row, final byte [] column,
      final long ts, final byte [] bytes)
  throws IOException {
    BatchUpdate batchUpdate = new BatchUpdate(row, ts);
    batchUpdate.put(column, bytes);
    r.batchUpdate(batchUpdate, null);
  }
View Full Code Here

   * Test file of multiple deletes and with deletes as final key.
   * @see <a href="https://issues.apache.org/jira/browse/HBASE-751">HBASE-751</a>
   */
  public void testGetClosestRowBefore3() throws IOException{
    HRegion region = null;
    BatchUpdate batchUpdate = null;
    try {
      HTableDescriptor htd = createTableDescriptor(getName());
      region = createNewHRegion(htd, null, null);
     
      batchUpdate = new BatchUpdate(T00);
      batchUpdate.put(COLUMNS[0], T00.getBytes());
      region.batchUpdate(batchUpdate, null);
     
      batchUpdate = new BatchUpdate(T10);
      batchUpdate.put(COLUMNS[0], T10.getBytes());
      region.batchUpdate(batchUpdate, null);
     
      batchUpdate = new BatchUpdate(T20);
      batchUpdate.put(COLUMNS[0], T20.getBytes());
      region.batchUpdate(batchUpdate, null);
     
      Map<byte [], Cell> results =
        region.getClosestRowBefore(Bytes.toBytes(T20), COLUMNS[0]);
      assertEquals(T20, new String(results.get(COLUMNS[0]).getValue()));
     
      batchUpdate = new BatchUpdate(T20);
      batchUpdate.delete(COLUMNS[0]);
      region.batchUpdate(batchUpdate, null);
     
      results = region.getClosestRowBefore(Bytes.toBytes(T20), COLUMNS[0]);
      assertEquals(T10, new String(results.get(COLUMNS[0]).getValue()));
     
      batchUpdate = new BatchUpdate(T30);
      batchUpdate.put(COLUMNS[0], T30.getBytes());
      region.batchUpdate(batchUpdate, null);
     
      results = region.getClosestRowBefore(Bytes.toBytes(T30), COLUMNS[0]);
      assertEquals(T30, new String(results.get(COLUMNS[0]).getValue()));
     
      batchUpdate = new BatchUpdate(T30);
      batchUpdate.delete(COLUMNS[0]);
      region.batchUpdate(batchUpdate, null);

      results = region.getClosestRowBefore(Bytes.toBytes(T30), COLUMNS[0]);
      assertEquals(T10, new String(results.get(COLUMNS[0]).getValue()));
      results = region.getClosestRowBefore(Bytes.toBytes(T31), COLUMNS[0]);
      assertEquals(T10, new String(results.get(COLUMNS[0]).getValue()));

      region.flushcache();

      // try finding "010" after flush
      results = region.getClosestRowBefore(Bytes.toBytes(T30), COLUMNS[0]);
      assertEquals(T10, new String(results.get(COLUMNS[0]).getValue()));
      results = region.getClosestRowBefore(Bytes.toBytes(T31), COLUMNS[0]);
      assertEquals(T10, new String(results.get(COLUMNS[0]).getValue()));
     
      // Put into a different column family.  Should make it so I still get t10
      batchUpdate = new BatchUpdate(T20);
      batchUpdate.put(COLUMNS[1], T20.getBytes());
      region.batchUpdate(batchUpdate, null);
     
      results = region.getClosestRowBefore(Bytes.toBytes(T30), COLUMNS[0]);
      assertEquals(T10, new String(results.get(COLUMNS[0]).getValue()));
      results = region.getClosestRowBefore(Bytes.toBytes(T31), COLUMNS[0]);
      assertEquals(T10, new String(results.get(COLUMNS[0]).getValue()));
      region.flushcache();
      results = region.getClosestRowBefore(Bytes.toBytes(T30), COLUMNS[0]);
      assertEquals(T10, new String(results.get(COLUMNS[0]).getValue()));
      results = region.getClosestRowBefore(Bytes.toBytes(T31), COLUMNS[0]);
      assertEquals(T10, new String(results.get(COLUMNS[0]).getValue()));
     
      // Now try combo of memcache and mapfiles.  Delete the t20 COLUMS[1]
      // in memory; make sure we get back t10 again.
      batchUpdate = new BatchUpdate(T20);
      batchUpdate.delete(COLUMNS[1]);
      region.batchUpdate(batchUpdate, null);
      results = region.getClosestRowBefore(Bytes.toBytes(T30), COLUMNS[0]);
      assertEquals(T10, new String(results.get(COLUMNS[0]).getValue()));
     
      // Ask for a value off the end of the file.  Should return t10.
      results = region.getClosestRowBefore(Bytes.toBytes(T31), COLUMNS[0]);
      assertEquals(T10, new String(results.get(COLUMNS[0]).getValue()));
      region.flushcache();
      results = region.getClosestRowBefore(Bytes.toBytes(T31), COLUMNS[0]);
      assertEquals(T10, new String(results.get(COLUMNS[0]).getValue()));
     
      // Ok.  Let the candidate come out of mapfiles but have delete of
      // the candidate be in memory.
      batchUpdate = new BatchUpdate(T11);
      batchUpdate.put(COLUMNS[0], T11.getBytes());
      region.batchUpdate(batchUpdate, null);
      batchUpdate = new BatchUpdate(T10);
      batchUpdate.delete(COLUMNS[0]);
      region.batchUpdate(batchUpdate, null);
      results = region.getClosestRowBefore(Bytes.toBytes(T12), COLUMNS[0]);
      assertEquals(T11, new String(results.get(COLUMNS[0]).getValue()));
    } finally {
      if (region != null) {
View Full Code Here

     
      long right_now = System.currentTimeMillis();
      long one_second_ago = right_now - 1000;
     
      String t = "test_row";
      BatchUpdate batchUpdate = new BatchUpdate(t, one_second_ago);
      batchUpdate.put(COLUMNS[0], "old text".getBytes());
      region_incommon.commit(batchUpdate);
      batchUpdate = new BatchUpdate(t, right_now);
      batchUpdate.put(COLUMNS[0], "new text".getBytes());
      region_incommon.commit(batchUpdate);

      assertCellEquals(region, Bytes.toBytes(t), COLUMNS[0],
        right_now, "new text");
      assertCellEquals(region, Bytes.toBytes(t), COLUMNS[0],
View Full Code Here

   */
  public void testGetClosestRowBefore() throws IOException{

    HRegion region = null;
    HRegionIncommon region_incommon = null;
    BatchUpdate batchUpdate = null;
   
    try {
      HTableDescriptor htd = createTableDescriptor(getName());
      region = createNewHRegion(htd, null, null);
      region_incommon = new HRegionIncommon(region);
    
      // set up some test data
      String t10 = "010";
      String t20 = "020";
      String t30 = "030";
      String t35 = "035";
      String t40 = "040";
     
      batchUpdate = new BatchUpdate(t10);
      batchUpdate.put(COLUMNS[0], "t10 bytes".getBytes());
      region.batchUpdate(batchUpdate, null);
     
      batchUpdate = new BatchUpdate(t20);
      batchUpdate.put(COLUMNS[0], "t20 bytes".getBytes());
      region.batchUpdate(batchUpdate, null);
     
      batchUpdate = new BatchUpdate(t30);
      batchUpdate.put(COLUMNS[0], "t30 bytes".getBytes());
      region.batchUpdate(batchUpdate, null);
     
      batchUpdate = new BatchUpdate(t35);
      batchUpdate.put(COLUMNS[0], "t35 bytes".getBytes());
      region.batchUpdate(batchUpdate, null);
     
      batchUpdate = new BatchUpdate(t35);
      batchUpdate.delete(COLUMNS[0]);
      region.batchUpdate(batchUpdate, null);
     
      batchUpdate = new BatchUpdate(t40);
      batchUpdate.put(COLUMNS[0], "t40 bytes".getBytes());
      region.batchUpdate(batchUpdate, null);
     
      // try finding "015"
      String t15 = "015";
      Map<byte [], Cell> results =
View Full Code Here

       
        if (LOG.isDebugEnabled()) {
          LOG.debug("updating columns in row: " + i.getRegionName());
        }

        BatchUpdate b = new BatchUpdate(rand.nextLong());
        lockid = b.startUpdate(i.getRegionName());
        updateRegionInfo(b, i);
        b.delete(lockid, COL_SERVER);
        b.delete(lockid, COL_STARTCODE);
        server.batchUpdate(m.getRegionName(), System.currentTimeMillis(), b);
        if (LOG.isDebugEnabled()) {
          LOG.debug("updated columns in row: " + i.getRegionName());
        }
View Full Code Here

    }

    protected void updateRegionInfo(HRegionInterface server, Text regionName,
        HRegionInfo i) throws IOException {

      BatchUpdate b = new BatchUpdate(rand.nextLong());
      long lockid = b.startUpdate(i.getRegionName());
      b.put(lockid, COL_REGIONINFO, Writables.getBytes(i));
      server.batchUpdate(regionName, System.currentTimeMillis(), b);
      if (LOG.isDebugEnabled()) {
        LOG.debug("updated columns in row: " + i.getRegionName());
      }
    }
View Full Code Here

   * @throws IOException
   */
  static void offlineRegionInMETA(final HRegionInterface srvr,
      final Text metaRegionName, final HRegionInfo info)
  throws IOException {
    BatchUpdate b = new BatchUpdate(rand.nextLong());
    long lockid = b.startUpdate(info.getRegionName());
    info.setOffline(true);
    b.put(lockid, COL_REGIONINFO, Writables.getBytes(info));
    b.delete(lockid, COL_SERVER);
    b.delete(lockid, COL_STARTCODE);
    // If carrying splits, they'll be in place when we show up on new
    // server.
    srvr.batchUpdate(metaRegionName, System.currentTimeMillis(), b);
  }
View Full Code Here

      // 3. Insert into meta
         
      HRegionInfo info = region.getRegionInfo();
      Text regionName = region.getRegionName();
      BatchUpdate b = new BatchUpdate(rand.nextLong());
      long lockid = b.startUpdate(regionName);
      b.put(lockid, COL_REGIONINFO, Writables.getBytes(info));
      server.batchUpdate(metaRegionName, System.currentTimeMillis(), b);

      // 4. Close the new region to flush it to disk.  Close its log file too.
     
      region.close();
View Full Code Here

TOP

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

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.