Refine search
/** * For row/column specified by rowIdx/colIdx, delete the cell * corresponding to the specified version. */ private void deleteOneVersion(Table ht, byte[] cf, int rowIdx, int colIdx, long version) throws IOException { byte row[] = Bytes.toBytes("row:" + rowIdx); byte column[] = Bytes.toBytes("column:" + colIdx); Delete del = new Delete(row); del.addColumn(cf, column, version); ht.delete(del); }
/** * For row/column specified by rowIdx/colIdx, delete the cell * corresponding to the specified version. */ private void deleteOneVersion(Table ht, byte[] cf, int rowIdx, int colIdx, long version) throws IOException { byte row[] = Bytes.toBytes("row:" + rowIdx); byte column[] = Bytes.toBytes("column:" + colIdx); Delete del = new Delete(row); del.addColumn(cf, column, version); ht.delete(del); }
@Override public void deleteCells(String tableName, List<DeleteRequest> deletes) throws IOException { List<Delete> deleteRequests = new ArrayList<>(); for (int index = 0; index < deletes.size(); index++) { DeleteRequest req = deletes.get(index); Delete delete = new Delete(req.getRowId()) .addColumn(req.getColumnFamily(), req.getColumnQualifier()); if (!StringUtils.isEmpty(req.getVisibilityLabel())) { delete.setCellVisibility(new CellVisibility(req.getVisibilityLabel())); } deleteRequests.add(delete); } batchDelete(tableName, deleteRequests); }
@Test public void testMinorCompactionWithDeleteColumn2() throws Exception { Delete dc = new Delete(secondRowBytes); dc.addColumn(fam2, col2); /* compactionThreshold is 3. The table has 4 versions: 0, 1, 2, and 3. * we only delete the latest version. One might expect to see only * versions 1 and 2. HBase differs, and gives us 0, 1 and 2. * This is okay as well. Since there was no compaction done before the * delete, version 0 seems to stay on. */ testMinorCompactionWithDelete(dc, 3); }
@Test public void testMinorCompactionWithDeleteVersion2() throws Exception { Delete deleteVersion = new Delete(secondRowBytes); deleteVersion.addColumn(fam2, col2, 1); /* * the table has 4 versions: 0, 1, 2, and 3. * We delete 1. * Should have 3 remaining. */ testMinorCompactionWithDelete(deleteVersion, 3); }
private RowMutations makeRowMutationsWithColumnCDeleted() throws IOException { RowMutations rm = new RowMutations(ROWKEY, 2); Put put = new Put(ROWKEY); put.addColumn(FAMILY, Bytes.toBytes("A"), Bytes.toBytes("a")); put.addColumn(FAMILY, Bytes.toBytes("B"), Bytes.toBytes("b")); rm.add(put); Delete del = new Delete(ROWKEY); del.addColumn(FAMILY, Bytes.toBytes("C")); rm.add(del); return rm; }
private void deleteColumns(Table ht, String value, String keyPrefix) throws IOException { ResultScanner scanner = buildScanner(keyPrefix, value, ht); Iterator<Result> it = scanner.iterator(); int count = 0; while (it.hasNext()) { Result result = it.next(); Delete delete = new Delete(result.getRow()); delete.addColumn(Bytes.toBytes("trans-tags"), Bytes.toBytes("qual2")); ht.delete(delete); count++; } assertEquals("Did not perform correct number of deletes", 3, count); }
@Override public Void run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf); Table table = connection.getTable(tableName)) { Delete d = new Delete(row1); d.addColumn(fam, qual, 125L); table.delete(d); } catch (Throwable t) { throw new IOException(t); } return null; } };
/** * Reset the split parent region info in meta table */ private void resetSplitParent(HbckInfo hi) throws IOException { RowMutations mutations = new RowMutations(hi.metaEntry.getRegionName()); Delete d = new Delete(hi.metaEntry.getRegionName()); d.addColumn(HConstants.CATALOG_FAMILY, HConstants.SPLITA_QUALIFIER); d.addColumn(HConstants.CATALOG_FAMILY, HConstants.SPLITB_QUALIFIER); mutations.add(d); RegionInfo hri = RegionInfoBuilder.newBuilder(hi.metaEntry) .setOffline(false) .setSplit(false) .build(); Put p = MetaTableAccessor.makePutFromRegionInfo(hri, EnvironmentEdgeManager.currentTime()); mutations.add(p); meta.mutateRow(mutations); LOG.info("Reset split parent " + hi.metaEntry.getRegionNameAsString() + " in META" ); }
@Override public Void run() throws Exception { try (Connection connection = ConnectionFactory.createConnection(conf)) { try (Table t = connection.getTable(TEST_TABLE.getTableName())) { Delete d = new Delete(TEST_ROW1); d.addColumn(TEST_FAMILY1, TEST_Q1, 123); d.addColumn(TEST_FAMILY1, TEST_Q2); d.addFamilyVersion(TEST_FAMILY2, 125); t.delete(d); } } return null; } });
@Test public void testMultiPut() throws Exception { List<Put> puts = IntStream.range(0, 10) .mapToObj(i -> new Put(ROW).addColumn(FAMILY, Bytes.toBytes(i), VALUE)) .collect(Collectors.toList()); table.put(puts); assertResult(table.get(new Get(ROW)), VALUE); assertObserverHasExecuted(); List<Delete> deletes = IntStream.range(0, 10) .mapToObj(i -> new Delete(ROW).addColumn(FAMILY, Bytes.toBytes(i))) .collect(Collectors.toList()); table.delete(deletes); assertTrue(table.get(new Get(ROW)).isEmpty()); assertObserverHasExecuted(); }
@Test public void testTimeStamp() { long ts = 2014L; Delete delete = new Delete(ROW); delete.setTimestamp(ts); delete.addColumn(FAMILY, QUALIFIER); NavigableMap<byte[], List<Cell>> familyCellmap = delete.getFamilyCellMap(); for (Entry<byte[], List<Cell>> entry : familyCellmap.entrySet()) { for (Cell cell : entry.getValue()) { Assert.assertEquals(ts, cell.getTimestamp()); } } } }
@Test public void testDeleteIteration() throws IOException { Delete d = new Delete(ROW); for (int i = 0; i < COUNT; i++) { byte [] bytes = Bytes.toBytes(i); d.addColumn(bytes, bytes, TIMESTAMP); } int index = 0; for (CellScanner cellScanner = d.cellScanner(); cellScanner.advance();) { Cell cell = cellScanner.current(); byte [] bytes = Bytes.toBytes(index++); cell.equals(new KeyValue(ROW, bytes, bytes, TIMESTAMP, KeyValue.Type.DeleteColumn)); } assertEquals(COUNT, index); }
@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; } };