Package org.apache.hadoop.hbase.io

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


      if (LOG.isDebugEnabled()) {
        LOG.debug(split.getRegionName().toString()
            +" no longer has references to " + parent.toString());
      }
     
      BatchUpdate b = new BatchUpdate(rand.nextLong());
      long lockid = b.startUpdate(parent);
      b.delete(lockid, splitColumn);
      srvr.batchUpdate(metaRegionName, System.currentTimeMillis(), b);
       
      return result;
    }
View Full Code Here


        LOG.info("updating row " + regionInfo.getRegionName() + " in table " +
          metaRegionName + " with startcode " +
          Writables.bytesToLong(this.startCode) + " and server "+
          serverAddress.toString());
        try {
          BatchUpdate b = new BatchUpdate(rand.nextLong());
          long lockid = b.startUpdate(regionInfo.getRegionName());
          b.put(lockid, COL_SERVER,
            Writables.stringToBytes(serverAddress.toString()));
          b.put(lockid, COL_STARTCODE, startCode);
          server.batchUpdate(metaRegionName, System.currentTimeMillis(), b);
          if (isMetaTable) {
            // It's a meta region.
            MetaRegion m = new MetaRegion(this.serverAddress,
              this.regionInfo.getRegionName(), this.regionInfo.getStartKey());
View Full Code Here

    table = new IndexedTable(conf, desc.getName());
  }

  private void writeInitalRows() throws IOException {
    for (int i = 0; i < NUM_ROWS; i++) {
      BatchUpdate update = new BatchUpdate(PerformanceEvaluation.format(i));
      byte[] colA = PerformanceEvaluation.format(random.nextInt(MAX_VAL));
      update.put(COL_A, colA);
      table.commit(update);
      LOG.info("Inserted row [" + Bytes.toString(update.getRow()) + "] val: ["
          + Bytes.toString(colA) + "]");
    }
  }
View Full Code Here

    testTableADesc.addFamily(column);
    testTableADesc.addFamily(column2);
    admin.createTable(testTableADesc);
   
    table = new HTable(conf, tableAname);
    BatchUpdate batchUpdate = new BatchUpdate(row);
    BatchUpdate batchUpdate2 = new BatchUpdate(row);
    BatchUpdate batchUpdate3 = new BatchUpdate(row);
   
    HbaseMapWritable<byte[],byte[]> expectedValues =
      new HbaseMapWritable<byte[],byte[]>();
    HbaseMapWritable<byte[],byte[]> badExpectedValues =
      new HbaseMapWritable<byte[],byte[]>();
   
    for(int i = 0; i < 5; i++) {
      // This batchupdate is our initial batch update,
      // As such we also set our expected values to the same values
      // since we will be comparing the two
      batchUpdate.put(COLUMN_FAMILY_STR+i, Bytes.toBytes(i));
      expectedValues.put(Bytes.toBytes(COLUMN_FAMILY_STR+i), Bytes.toBytes(i));
     
      badExpectedValues.put(Bytes.toBytes(COLUMN_FAMILY_STR+i),
        Bytes.toBytes(500));
     
      // This is our second batchupdate that we will use to update the initial
      // batchupdate
      batchUpdate2.put(COLUMN_FAMILY_STR+i, Bytes.toBytes(i+1));
     
      // This final batch update is to check that our expected values (which
      // are now wrong)
      batchUpdate3.put(COLUMN_FAMILY_STR+i, Bytes.toBytes(i+2));
    }
   
    // Initialize rows
    table.commit(batchUpdate);
   
View Full Code Here

    // Assert the metadata is good.
    HTableDescriptor meta =
      a.getConnection().getHTableDescriptor(tableAdesc.getName());
    assertTrue(meta.equals(tableAdesc));
   
    BatchUpdate batchUpdate = new BatchUpdate(row);
    batchUpdate.put(COLUMN_FAMILY, value);
    a.commit(batchUpdate);
   
    // open a new connection to A and a connection to b
   
    HTable newA = new HTable(conf, tableAname);
    HTable b = new HTable(conf, tableBname);

    // copy data from A to B
   
    Scanner s =
      newA.getScanner(COLUMN_FAMILY_ARRAY, EMPTY_START_ROW);
   
    try {
      for (RowResult r : s) {
        batchUpdate = new BatchUpdate(r.getRow());
        for(Map.Entry<byte [], Cell> e: r.entrySet()) {
          batchUpdate.put(e.getKey(), e.getValue().getValue());
        }
        b.commit(batchUpdate);
      }
    } finally {
      s.close();
View Full Code Here

      testTableADesc.addFamily(column);
      testTableADesc.addFamily(column2);
      admin.createTable(testTableADesc);
     
      table = new HTable(conf, tableAname);
      BatchUpdate batchUpdate = new BatchUpdate(row);
     
      for(int i = 0; i < 5; i++)
        batchUpdate.put(COLUMN_FAMILY_STR+i, Bytes.toBytes(i));
     
      table.commit(batchUpdate);

      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++)
View Full Code Here

    byte[] firstRow = Bytes.toBytes("ro");
    byte[] beforeFirstRow = Bytes.toBytes("rn");
    byte[] beforeSecondRow = Bytes.toBytes("rov");
   
    HTable table = new HTable(conf, tableAname);
    BatchUpdate batchUpdate = new BatchUpdate(firstRow);
    BatchUpdate batchUpdate2 = new BatchUpdate(row);
    byte[] zero = new byte[]{0};
    byte[] one = new byte[]{1};
    byte[] columnFamilyBytes = Bytes.toBytes(COLUMN_FAMILY_STR);
   
    batchUpdate.put(COLUMN_FAMILY_STR,zero);
    batchUpdate2.put(COLUMN_FAMILY_STR,one);
   
    table.commit(batchUpdate);
    table.commit(batchUpdate2);
   
    RowResult result = null;
View Full Code Here

      for (byte b2 = 'a'; b2 < 'z'; b2++) {
        for (byte b3 = 'a'; b3 < 'z'; b3++) {
          k[0] = b1;
          k[1] = b2;
          k[2] = b3;
          BatchUpdate update = new BatchUpdate(k);
          update.put(columnName, k);
          table.commit(update);
        }
      }
    }
View Full Code Here

    long startTime = System.currentTimeMillis();

    // Write out a bunch of values

    for (int k = FIRST_ROW; k <= NUM_VALS; k++) {
      BatchUpdate batchUpdate =
        new BatchUpdate(Bytes.toBytes("row_" + k), System.currentTimeMillis());
      batchUpdate.put(CONTENTS_BASIC,
          (CONTENTSTR + k).getBytes(HConstants.UTF8_ENCODING));
      batchUpdate.put(Bytes.toBytes(ANCHORNUM + k),
          (ANCHORSTR + k).getBytes(HConstants.UTF8_ENCODING));
      region.commit(batchUpdate);
    }
    LOG.info("Write " + NUM_VALS + " rows. Elapsed time: "
        + ((System.currentTimeMillis() - startTime) / 1000.0));
View Full Code Here

  private void badPuts() {
    // Try column name not registered in the table.   
    boolean exceptionThrown = false;
    exceptionThrown = false;
    try {
      BatchUpdate batchUpdate = new BatchUpdate(Bytes.toBytes("Some old key"));
      String unregisteredColName = "FamilyGroup:FamilyLabel";
      batchUpdate.put(Bytes.toBytes(unregisteredColName),
        unregisteredColName.getBytes(HConstants.UTF8_ENCODING));
      region.commit(batchUpdate);
    } catch (IOException e) {
      exceptionThrown = true;
    } finally {
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.