当前位置: 首页>>代码示例>>Java>>正文


Java Delete.addColumn方法代码示例

本文整理汇总了Java中org.apache.hadoop.hbase.client.Delete.addColumn方法的典型用法代码示例。如果您正苦于以下问题:Java Delete.addColumn方法的具体用法?Java Delete.addColumn怎么用?Java Delete.addColumn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.hadoop.hbase.client.Delete的用法示例。


在下文中一共展示了Delete.addColumn方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkAndDeleteName

import org.apache.hadoop.hbase.client.Delete; //导入方法依赖的package包/类
@Override
public boolean checkAndDeleteName(final byte[] bNewUid, final byte[] name) {
    if (LOGGER.isTraceEnabled()) {
        final String rowKeyStr = ByteArrayUtils.byteArrayToHex(bNewUid);

        final String valueStr = Bytes.toString(name);

        LOGGER.trace("checkAndDeleteName - Key: [" + rowKeyStr + "], Value: [" + valueStr + "]");
    }

    final Delete delete = new Delete(bNewUid);
    delete.addColumn(NAME_FAMILY, NAME_COL_QUALIFIER);

    boolean result;

    // only delete the naem if the current value matches what we think it is
    result = doCheckAndDelete(bNewUid, NAME_FAMILY, NAME_COL_QUALIFIER, name, delete);

    return result;
}
 
开发者ID:gchq,项目名称:stroom-stats,代码行数:21,代码来源:HBaseUniqueIdReverseMapTable.java

示例2: testRow

import org.apache.hadoop.hbase.client.Delete; //导入方法依赖的package包/类
@Override
void testRow(final int i) throws IOException {
  byte [] bytes = format(i);
  // Put a known value so when we go to check it, it is there.
  Put put = new Put(bytes);
  put.addColumn(FAMILY_NAME, getQualifier(), bytes);
  this.table.put(put);
  Delete delete = new Delete(put.getRow());
  delete.addColumn(FAMILY_NAME, getQualifier());
  this.table.checkAndDelete(bytes, FAMILY_NAME, getQualifier(), CompareOp.EQUAL, bytes, delete);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:12,代码来源:PerformanceEvaluation.java

示例3: testVisibilityLabelsWithDeleteColumnExactVersion

import org.apache.hadoop.hbase.client.Delete; //导入方法依赖的package包/类
@Test
public void testVisibilityLabelsWithDeleteColumnExactVersion() throws Exception {
  setAuths();
  final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
  long[] ts = new long[] { 123l, 125l };
  try (Table table = createTableAndWriteDataWithLabels(tableName, ts,
      CONFIDENTIAL + "|" + TOPSECRET, SECRET);) {
    PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
      @Override
      public Void run() throws Exception {
        try (Connection connection = ConnectionFactory.createConnection(conf);
             Table table = connection.getTable(tableName)) {
          Delete d = new Delete(row1);
          d.setCellVisibility(new CellVisibility(TOPSECRET + "|" + CONFIDENTIAL));
          d.addColumn(fam, qual, 123l);
          table.delete(d);
        } catch (Throwable t) {
          throw new IOException(t);
        }
        return null;
      }
    };
    SUPERUSER.runAs(actiona);

    TEST_UTIL.getHBaseAdmin().flush(tableName);
    Scan s = new Scan();
    s.setAuthorizations(new Authorizations(SECRET, PRIVATE, CONFIDENTIAL));
    ResultScanner scanner = table.getScanner(s);
    Result[] next = scanner.next(3);
    assertTrue(next.length == 1);
    CellScanner cellScanner = next[0].cellScanner();
    cellScanner.advance();
    Cell current = cellScanner.current();
    assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
        current.getRowLength(), row2, 0, row2.length));
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:38,代码来源:TestVisibilityLabelsWithDeletes.java

示例4: fillTable

import org.apache.hadoop.hbase.client.Delete; //导入方法依赖的package包/类
private void fillTable() throws IOException, InterruptedException {
  Table table = TEST_UTIL.createTable(TABLE_NAME, FAMILIES, 3,
      Bytes.toBytes("row0"), Bytes.toBytes("row99"), NUM_RS);
  Random rand = new Random(19387129L);
  for (int iStoreFile = 0; iStoreFile < 4; ++iStoreFile) {
    for (int iRow = 0; iRow < 100; ++iRow) {
      final byte[] row = Bytes.toBytes("row" + iRow);
      Put put = new Put(row);
      Delete del = new Delete(row);
      for (int iCol = 0; iCol < 10; ++iCol) {
        final byte[] cf = rand.nextBoolean() ? CF1 : CF2;
        final long ts = Math.abs(rand.nextInt());
        final byte[] qual = Bytes.toBytes("col" + iCol);
        if (rand.nextBoolean()) {
          final byte[] value = Bytes.toBytes("value_for_row_" + iRow +
              "_cf_" + Bytes.toStringBinary(cf) + "_col_" + iCol + "_ts_" +
              ts + "_random_" + rand.nextLong());
          put.add(cf, qual, ts, value);
        } else if (rand.nextDouble() < 0.8) {
          del.addColumn(cf, qual, ts);
        } else {
          del.addColumn(cf, qual, ts);
        }
      }
      table.put(put);
      table.delete(del);
    }
  }
  TEST_UTIL.waitUntilAllRegionsAssigned(TABLE_NAME);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:31,代码来源:TestWALFiltering.java

示例5: testDeleteColumnWithSpecificTimeStampUsingMultipleVersionsUnMatchingVisExpression

import org.apache.hadoop.hbase.client.Delete; //导入方法依赖的package包/类
@Test
public void testDeleteColumnWithSpecificTimeStampUsingMultipleVersionsUnMatchingVisExpression()
    throws Exception {
  setAuths();
  final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
  try (Table table = doPuts(tableName)) {
    TEST_UTIL.getHBaseAdmin().flush(tableName);
    PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
      @Override
      public Void run() throws Exception {
        try (Connection connection = ConnectionFactory.createConnection(conf);
             Table table = connection.getTable(tableName)) {
          Delete d = new Delete(row1);
          d.setCellVisibility(new CellVisibility("(" + PRIVATE + "&" + CONFIDENTIAL + ")|(" +
              SECRET + "&" + TOPSECRET+")"));
          d.addColumn(fam, qual, 125l);
          table.delete(d);
        } catch (Throwable t) {
          throw new IOException(t);
        }
        return null;
      }
    };
    SUPERUSER.runAs(actiona);

    TEST_UTIL.getHBaseAdmin().flush(tableName);
    Scan s = new Scan();
    s.setMaxVersions(5);
    s.setAuthorizations(new Authorizations(SECRET, PRIVATE, CONFIDENTIAL, TOPSECRET));
    ResultScanner scanner = table.getScanner(s);
    Result[] next = scanner.next(3);
    assertTrue(next.length == 2);
    CellScanner cellScanner = next[0].cellScanner();
    cellScanner.advance();
    Cell current = cellScanner.current();
    assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
        current.getRowLength(), row1, 0, row1.length));
    assertEquals(current.getTimestamp(), 127l);
    cellScanner.advance();
    current = cellScanner.current();
    assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
        current.getRowLength(), row1, 0, row1.length));
    assertEquals(current.getTimestamp(), 126l);
    cellScanner.advance();
    current = cellScanner.current();
    assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
        current.getRowLength(), row1, 0, row1.length));
    assertEquals(current.getTimestamp(), 125l);
    cellScanner.advance();
    current = cellScanner.current();
    assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
        current.getRowLength(), row1, 0, row1.length));
    assertEquals(current.getTimestamp(), 124l);
    cellScanner.advance();
    current = cellScanner.current();
    assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
        current.getRowLength(), row1, 0, row1.length));
    assertEquals(current.getTimestamp(), 123l);
    cellScanner = next[1].cellScanner();
    cellScanner.advance();
    current = cellScanner.current();
    assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
        current.getRowLength(), row2, 0, row2.length));
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:66,代码来源:TestVisibilityLabelsWithDeletes.java

示例6: testDeleteColumnWithLatestTimeStampUsingMultipleVersions

import org.apache.hadoop.hbase.client.Delete; //导入方法依赖的package包/类
@Test
public void testDeleteColumnWithLatestTimeStampUsingMultipleVersions() throws Exception {
  setAuths();
  final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
  try (Table table = doPuts(tableName)) {
    TEST_UTIL.getHBaseAdmin().flush(tableName);
    PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
      @Override
      public Void run() throws Exception {
        try (Connection connection = ConnectionFactory.createConnection(conf);
             Table table = connection.getTable(tableName)) {
          Delete d = new Delete(row1);
          d.setCellVisibility(new CellVisibility(SECRET + "&" + TOPSECRET));
          d.addColumn(fam, qual);
          table.delete(d);
        } catch (Throwable t) {
          throw new IOException(t);
        }
        return null;
      }
    };
    SUPERUSER.runAs(actiona);

    TEST_UTIL.getHBaseAdmin().flush(tableName);
    Scan s = new Scan();
    s.setMaxVersions(5);
    s.setAuthorizations(new Authorizations(SECRET, PRIVATE, CONFIDENTIAL, TOPSECRET));
    ResultScanner scanner = table.getScanner(s);
    Result[] next = scanner.next(3);
    assertTrue(next.length == 2);
    CellScanner cellScanner = next[0].cellScanner();
    cellScanner.advance();
    Cell current = cellScanner.current();
    assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
        current.getRowLength(), row1, 0, row1.length));
    assertEquals(current.getTimestamp(), 127l);
    cellScanner.advance();
    current = cellScanner.current();
    assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
        current.getRowLength(), row1, 0, row1.length));
    assertEquals(current.getTimestamp(), 126l);
    cellScanner.advance();
    current = cellScanner.current();
    assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
        current.getRowLength(), row1, 0, row1.length));
    assertEquals(current.getTimestamp(), 124l);
    cellScanner.advance();
    current = cellScanner.current();
    assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
        current.getRowLength(), row1, 0, row1.length));
    assertEquals(current.getTimestamp(), 123l);
    cellScanner = next[1].cellScanner();
    cellScanner.advance();
    current = cellScanner.current();
    assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
        current.getRowLength(), row2, 0, row2.length));
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:59,代码来源:TestVisibilityLabelsWithDeletes.java

示例7: testDeleteColumnWithLatestTimeStampUsingMultipleVersionsAfterCompaction

import org.apache.hadoop.hbase.client.Delete; //导入方法依赖的package包/类
@Test
public void testDeleteColumnWithLatestTimeStampUsingMultipleVersionsAfterCompaction()
    throws Exception {
  setAuths();
  final TableName tableName = TableName.valueOf(TEST_NAME.getMethodName());
  try (Table table = doPuts(tableName)) {
    TEST_UTIL.getHBaseAdmin().flush(tableName);
    PrivilegedExceptionAction<Void> actiona = new PrivilegedExceptionAction<Void>() {
      @Override
      public Void run() throws Exception {
        try (Connection connection = ConnectionFactory.createConnection(conf);
             Table table = connection.getTable(tableName)) {
          Delete d = new Delete(row1);
          d.setCellVisibility(new CellVisibility(SECRET + "&" + TOPSECRET));
          d.addColumn(fam, qual);
          table.delete(d);
        } catch (Throwable t) {
          throw new IOException(t);
        }
        return null;
      }
    };
    SUPERUSER.runAs(actiona);
    TEST_UTIL.getHBaseAdmin().flush(tableName);
    Put put = new Put(Bytes.toBytes("row3"));
    put.add(fam, qual, 127l, value);
    put.setCellVisibility(new CellVisibility(CONFIDENTIAL + "&" + PRIVATE));
    table.put(put);
    TEST_UTIL.getHBaseAdmin().flush(tableName);
    TEST_UTIL.getHBaseAdmin().majorCompact(tableName);
    // Sleep to ensure compaction happens. Need to do it in a better way
    Thread.sleep(5000);
    Scan s = new Scan();
    s.setMaxVersions(5);
    s.setAuthorizations(new Authorizations(SECRET, PRIVATE, CONFIDENTIAL, TOPSECRET));
    ResultScanner scanner = table.getScanner(s);
    Result[] next = scanner.next(3);
    assertTrue(next.length == 3);
    CellScanner cellScanner = next[0].cellScanner();
    cellScanner.advance();
    Cell current = cellScanner.current();
    assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
        current.getRowLength(), row1, 0, row1.length));
    assertEquals(current.getTimestamp(), 127l);
    cellScanner.advance();
    current = cellScanner.current();
    assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
        current.getRowLength(), row1, 0, row1.length));
    assertEquals(current.getTimestamp(), 126l);
    cellScanner.advance();
    current = cellScanner.current();
    assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
        current.getRowLength(), row1, 0, row1.length));
    assertEquals(current.getTimestamp(), 124l);
    cellScanner.advance();
    current = cellScanner.current();
    assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
        current.getRowLength(), row1, 0, row1.length));
    assertEquals(current.getTimestamp(), 123l);
    cellScanner = next[1].cellScanner();
    cellScanner.advance();
    current = cellScanner.current();
    assertTrue(Bytes.equals(current.getRowArray(), current.getRowOffset(),
        current.getRowLength(), row2, 0, row2.length));
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:67,代码来源:TestVisibilityLabelsWithDeletes.java

示例8: testReadPointAndPartialResults

import org.apache.hadoop.hbase.client.Delete; //导入方法依赖的package包/类
@Test
public void testReadPointAndPartialResults() throws Exception {
  TableName testName = TableName.valueOf("testReadPointAndPartialResults");
  int numRows = 5;
  int numFamilies = 5;
  int numQualifiers = 5;
  byte[][] rows = HTestConst.makeNAscii(Bytes.toBytes("testRow"), numRows);
  byte[][] families = HTestConst.makeNAscii(Bytes.toBytes("testFamily"), numFamilies);
  byte[][] qualifiers = HTestConst.makeNAscii(Bytes.toBytes("testQualifier"), numQualifiers);
  byte[] value = Bytes.createMaxByteArray(100);

  Table tmpTable = createTestTable(testName, rows, families, qualifiers, value);

  Scan scan = new Scan();
  scan.setMaxResultSize(1);
  scan.setAllowPartialResults(true);

  // Open scanner before deletes
  ResultScanner scanner = tmpTable.getScanner(scan);

  Delete delete1 = new Delete(rows[0]);
  delete1.addColumn(families[0], qualifiers[0], 0);
  tmpTable.delete(delete1);

  Delete delete2 = new Delete(rows[1]);
  delete2.addColumn(families[1], qualifiers[1], 1);
  tmpTable.delete(delete2);

  // Should see all cells because scanner was opened prior to deletes
  int scannerCount = countCellsFromScanner(scanner);
  int expectedCount = numRows * numFamilies * numQualifiers;
  assertTrue("scannerCount: " + scannerCount + " expectedCount: " + expectedCount,
      scannerCount == expectedCount);

  // Minus 2 for the two cells that were deleted
  scanner = tmpTable.getScanner(scan);
  scannerCount = countCellsFromScanner(scanner);
  expectedCount = numRows * numFamilies * numQualifiers - 2;
  assertTrue("scannerCount: " + scannerCount + " expectedCount: " + expectedCount,
      scannerCount == expectedCount);

  scanner = tmpTable.getScanner(scan);
  // Put in 2 new rows. The timestamps differ from the deleted rows
  Put put1 = new Put(rows[0]);
  put1.add(new KeyValue(rows[0], families[0], qualifiers[0], 1, value));
  tmpTable.put(put1);

  Put put2 = new Put(rows[1]);
  put2.add(new KeyValue(rows[1], families[1], qualifiers[1], 2, value));
  tmpTable.put(put2);

  // Scanner opened prior to puts. Cell count shouldn't have changed
  scannerCount = countCellsFromScanner(scanner);
  expectedCount = numRows * numFamilies * numQualifiers - 2;
  assertTrue("scannerCount: " + scannerCount + " expectedCount: " + expectedCount,
      scannerCount == expectedCount);

  // Now the scanner should see the cells that were added by puts
  scanner = tmpTable.getScanner(scan);
  scannerCount = countCellsFromScanner(scanner);
  expectedCount = numRows * numFamilies * numQualifiers;
  assertTrue("scannerCount: " + scannerCount + " expectedCount: " + expectedCount,
      scannerCount == expectedCount);

  TEST_UTIL.deleteTable(testName);
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:67,代码来源:TestPartialResultsFromClientSide.java


注:本文中的org.apache.hadoop.hbase.client.Delete.addColumn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。