Java Code Examples for org.apache.hadoop.hbase.KeyValue.Type#DeleteFamily
The following examples show how to use
org.apache.hadoop.hbase.KeyValue.Type#DeleteFamily .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ColumnBasedIndexerTest.java From hbase-indexer with Apache License 2.0 | 6 votes |
@Test public void testCalculateIndexUpdates_DeleteFamily() throws IOException { final String ROW_FIELD = "_row_field_"; final String FAMILY_FIELD = "_family_field_"; doReturn(ROW_FIELD).when(indexerConf).getRowField(); doReturn(FAMILY_FIELD).when(indexerConf).getColumnFamilyField(); KeyValue toDelete = new KeyValue(Bytes.toBytes("_row_"), Bytes.toBytes("_cf_"), Bytes.toBytes("_qual_"), 0L, Type.DeleteFamily); RowData rowData = createEventRowData("_row_", toDelete); indexer.calculateIndexUpdates(Lists.newArrayList(rowData), updateCollector); assertEquals(ImmutableList.of("(" + ROW_FIELD + ":_row_)AND(" + FAMILY_FIELD + ":_cf_)"), updateCollector.getDeleteQueries()); assertTrue(updateCollector.getIdsToDelete().isEmpty()); assertTrue(updateCollector.getDocumentsToAdd().isEmpty()); }
Example 2
Source File: TestIndexMemStore.java From phoenix with Apache License 2.0 | 5 votes |
/** * We don't expect custom KeyValue creation, so we can't get into weird situations, where a * {@link Type#DeleteFamily} has a column qualifier specified. * @throws Exception */ @Test public void testExpectedOrdering() throws Exception { IndexMemStore store = new IndexMemStore(); KeyValue kv = new KeyValue(row, family, qual, 12, Type.Put, val); store.add(kv, true); KeyValue kv2 = new KeyValue(row, family, qual, 10, Type.Put, val2); store.add(kv2, true); KeyValue df = new KeyValue(row, family, null, 11, Type.DeleteFamily, null); store.add(df, true); KeyValue dc = new KeyValue(row, family, qual, 11, Type.DeleteColumn, null); store.add(dc, true); KeyValue d = new KeyValue(row, family, qual, 12, Type.Delete, null); store.add(d, true); // null qualifiers should always sort before the non-null cases KeyValueScanner scanner = store.getScanner(); KeyValue first = KeyValue.createFirstOnRow(row); assertTrue("Didn't have any data in the scanner", scanner.seek(first)); assertTrue("Didn't get delete family first (no qualifier == sort first)", df == scanner.next()); assertTrue("Didn't get point delete before corresponding put", d == scanner.next()); assertTrue("Didn't get larger ts Put", kv == scanner.next()); assertTrue("Didn't get delete column before corresponding put(delete sorts first)", dc == scanner.next()); assertTrue("Didn't get smaller ts Put", kv2 == scanner.next()); assertNull("Have more data in the scanner", scanner.next()); }
Example 3
Source File: TestIndexMemStore.java From phoenix with Apache License 2.0 | 5 votes |
/** * We don't expect custom KeyValue creation, so we can't get into weird situations, where a * {@link Type#DeleteFamily} has a column qualifier specified. * @throws Exception */ @Test public void testExpectedOrdering() throws Exception { IndexMemStore store = new IndexMemStore(); KeyValue kv = new KeyValue(row, family, qual, 12, Type.Put, val); store.add(kv, true); KeyValue kv2 = new KeyValue(row, family, qual, 10, Type.Put, val2); store.add(kv2, true); KeyValue df = new KeyValue(row, family, null, 11, Type.DeleteFamily, null); store.add(df, true); KeyValue dc = new KeyValue(row, family, qual, 11, Type.DeleteColumn, null); store.add(dc, true); KeyValue d = new KeyValue(row, family, qual, 12, Type.Delete, null); store.add(d, true); // null qualifiers should always sort before the non-null cases ReseekableScanner scanner = store.getScanner(); KeyValue first = KeyValueUtil.createFirstOnRow(row); assertTrue("Didn't have any data in the scanner", scanner.seek(first)); assertTrue("Didn't get delete family first (no qualifier == sort first)", df == scanner.next()); assertTrue("Didn't get point delete before corresponding put", d == scanner.next()); assertTrue("Didn't get larger ts Put", kv == scanner.next()); assertTrue("Didn't get delete column before corresponding put(delete sorts first)", dc == scanner.next()); assertTrue("Didn't get smaller ts Put", kv2 == scanner.next()); assertNull("Have more data in the scanner", scanner.next()); }
Example 4
Source File: TestIndexMemStore.java From phoenix with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * We don't expect custom KeyValue creation, so we can't get into weird situations, where a * {@link Type#DeleteFamily} has a column qualifier specified. * @throws Exception */ @Test public void testExpectedOrdering() throws Exception { IndexMemStore store = new IndexMemStore(); KeyValue kv = new KeyValue(row, family, qual, 12, Type.Put, val); store.add(kv, true); KeyValue kv2 = new KeyValue(row, family, qual, 10, Type.Put, val2); store.add(kv2, true); KeyValue df = new KeyValue(row, family, null, 11, Type.DeleteFamily, null); store.add(df, true); KeyValue dc = new KeyValue(row, family, qual, 11, Type.DeleteColumn, null); store.add(dc, true); KeyValue d = new KeyValue(row, family, qual, 12, Type.Delete, null); store.add(d, true); // null qualifiers should always sort before the non-null cases KeyValueScanner scanner = store.getScanner(); KeyValue first = KeyValue.createFirstOnRow(row); assertTrue("Didn't have any data in the scanner", scanner.seek(first)); assertTrue("Didn't get delete family first (no qualifier == sort first)", df == scanner.next()); assertTrue("Didn't get point delete before corresponding put", d == scanner.next()); assertTrue("Didn't get larger ts Put", kv == scanner.next()); assertTrue("Didn't get delete column before corresponding put(delete sorts first)", dc == scanner.next()); assertTrue("Didn't get smaller ts Put", kv2 == scanner.next()); assertNull("Have more data in the scanner", scanner.next()); }
Example 5
Source File: TestClientKeyValueLocal.java From phoenix with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Test public void testReadWrite() throws IOException { byte[] row = Bytes.toBytes("row"); byte[] family = Bytes.toBytes("family"); byte[] qualifier = Bytes.toBytes("qualifier"); byte[] value = Bytes.toBytes("value"); long ts = 10; Type type = KeyValue.Type.Put; ClientKeyValue kv = new ClientKeyValue(wrap(row), wrap(family), wrap(qualifier), ts, type, wrap(value)); validate(kv, row, family, qualifier, ts, type, value); type = Type.Delete; kv = new ClientKeyValue(wrap(row), wrap(family), wrap(qualifier), ts, type, wrap(value)); validate(kv, row, family, qualifier, ts, type, value); type = Type.DeleteColumn; kv = new ClientKeyValue(wrap(row), wrap(family), wrap(qualifier), ts, type, wrap(value)); validate(kv, row, family, qualifier, ts, type, value); type = Type.DeleteFamily; kv = new ClientKeyValue(wrap(row), wrap(family), wrap(qualifier), ts, type, wrap(value)); validate(kv, row, family, qualifier, ts, type, value); type = Type.Maximum; kv = new ClientKeyValue(wrap(row), wrap(family), wrap(qualifier), ts, type, wrap(value)); validate(kv, row, family, qualifier, ts, type, value); // test a couple different variables, to make sure we aren't faking it row = Bytes.toBytes("row-never-seen-before1234"); family = Bytes.toBytes("family-to-test-more"); qualifier = Bytes.toBytes("untested-qualifier"); value = Bytes.toBytes("value-that-we-haven't_tested"); ts = System.currentTimeMillis(); kv = new ClientKeyValue(wrap(row), wrap(family), wrap(qualifier), ts, type, wrap(value)); validate(kv, row, family, qualifier, ts, type, value); }
Example 6
Source File: ColumnBasedIndexerTest.java From hbase-indexer with Apache License 2.0 | 5 votes |
@Test public void testCalculateIndexUpdates_DeleteFamily_NoFamilyFieldDefinedForIndexer() throws IOException { KeyValue toDelete = new KeyValue(Bytes.toBytes("_row_"), Bytes.toBytes("_cf_"), Bytes.toBytes("_qual_"), 0L, Type.DeleteFamily); RowData eventRowData = createEventRowData("_row_", toDelete); indexer.calculateIndexUpdates(ImmutableList.of(eventRowData), updateCollector); assertTrue(updateCollector.getDeleteQueries().isEmpty()); assertTrue(updateCollector.getIdsToDelete().isEmpty()); assertTrue(updateCollector.getDocumentsToAdd().isEmpty()); }
Example 7
Source File: TestCompactorScanner.java From phoenix-omid with Apache License 2.0 | 4 votes |
@Test(dataProvider = "cell-retain-options", timeOut = 60_000) public void testShouldRetainNonTransactionallyDeletedCellMethod(int optionIdx, boolean retainOption) throws Exception { // Create required mocks @SuppressWarnings("unchecked") ObserverContext<RegionCoprocessorEnvironment> ctx = mock(ObserverContext.class); InternalScanner internalScanner = mock(InternalScanner.class); CommitTable.Client ctClient = mock(CommitTable.Client.class); RegionCoprocessorEnvironment rce = mock(RegionCoprocessorEnvironment.class); HRegion hRegion = mock(HRegion.class); HRegionInfo hRegionInfo = mock(HRegionInfo.class); SettableFuture<Long> f = SettableFuture.create(); // Wire required mock internals f.set(TEST_TS); when(ctClient.readLowWatermark()).thenReturn(f); when(ctx.getEnvironment()).thenReturn(rce); when(rce.getRegion()).thenReturn(hRegion); when(hRegion.getRegionInfo()).thenReturn(hRegionInfo); LOG.info("Testing when retain is {}", retainOption); try (CompactorScanner scanner = spy(new CompactorScanner(ctx, internalScanner, ctClient, false, retainOption))) { // Different cell types to test KeyValue regularKV = new KeyValue(Bytes.toBytes("test-row"), TEST_TS, Type.Put); KeyValue deleteKV = new KeyValue(Bytes.toBytes("test-row"), TEST_TS, Type.Delete); KeyValue deleteColumnKV = new KeyValue(Bytes.toBytes("test-row"), TEST_TS, Type.DeleteColumn); KeyValue deleteFamilyKV = new KeyValue(Bytes.toBytes("test-row"), TEST_TS, Type.DeleteFamily); KeyValue deleteFamilyVersionKV = new KeyValue(Bytes.toBytes("test-row"), TEST_TS, Type.DeleteFamilyVersion); assertFalse(scanner.shouldRetainNonTransactionallyDeletedCell(regularKV)); assertEquals(scanner.shouldRetainNonTransactionallyDeletedCell(deleteKV), retainOption); assertEquals(scanner.shouldRetainNonTransactionallyDeletedCell(deleteColumnKV), retainOption); assertEquals(scanner.shouldRetainNonTransactionallyDeletedCell(deleteFamilyKV), retainOption); assertEquals(scanner.shouldRetainNonTransactionallyDeletedCell(deleteFamilyVersionKV), retainOption); } }
Example 8
Source File: ClientKeyValueBuilder.java From phoenix with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public KeyValue buildDeleteFamily(ImmutableBytesWritable row, ImmutableBytesWritable family, ImmutableBytesWritable qualifier, long ts) { return new ClientKeyValue(row, family, qualifier, ts, Type.DeleteFamily, null); }