Code for delete row issue in cases of qualifier = null, even after row is
deleted it will return non null value,
@Test
public void testing() throws IOException {
Connection conn = ConnectionFactory.createConnection(conf);
TableName test = TableName.valueOf("Test");
TableDescriptorBuilder tableDescBuilder =
TableDescriptorBuilder.newBuilder(test);
ColumnFamilyDescriptorBuilder columnDescBuilder =
ColumnFamilyDescriptorBuilder
.newBuilder(Bytes.toBytes("test-family"));
columnDescBuilder.setNewVersionBehavior(true);
ColumnFamilyDescriptor columnDescriptor = columnDescBuilder.build();
tableDescBuilder.addColumnFamily(columnDescriptor);
TableDescriptor tableDescriptor = tableDescBuilder.build();
conn.getAdmin().createTable(tableDescriptor);
Table table = conn.getTable(test);
Put put = new Put(Bytes.toBytes("com.example/http"));
put.addColumn(Bytes.toBytes("test-family"), null,
Bytes.toBytes("test-value"));
table.put(put);
Delete del = new Delete(Bytes.toBytes("com.example/http"));
table.delete(del);
Get get = new Get(Bytes.toBytes("com.example/http"));
//get.addColumn(Bytes.toBytes("test-family"), null);
Result result = table.get(get);
byte [] value = result.getValue(Bytes.toBytes("test-family"), null);
if(value == null) {
// Testing purposes
}
}
On Mon, Apr 15, 2019 at 10:51 PM Kevin Ratnasekera <[email protected]>
wrote:
> Hi all,
>
> Here's test code I used for testing purposes and I would like to know the
> behavior,
>
>
> @Test
> public void testing() throws IOException {
>
> Connection conn = ConnectionFactory.createConnection(conf);
>
> TableName test = TableName.valueOf("Test");
> TableDescriptorBuilder tableDescBuilder =
> TableDescriptorBuilder.newBuilder(test);
> ColumnFamilyDescriptorBuilder columnDescBuilder =
> ColumnFamilyDescriptorBuilder
> .newBuilder(Bytes.toBytes("test-family"));
> columnDescBuilder.setNewVersionBehavior(true);
> ColumnFamilyDescriptor columnDescriptor = columnDescBuilder.build();
> tableDescBuilder.addColumnFamily(columnDescriptor);
> TableDescriptor tableDescriptor = tableDescBuilder.build();
>
> conn.getAdmin().createTable(tableDescriptor);
>
> Table table = conn.getTable(test);
> BufferedMutator bm = conn.getBufferedMutator(test);
>
> Delete del = new Delete(Bytes.toBytes("com.example/http"));
> del.addColumn(Bytes.toBytes("test-family"),
> Bytes.toBytes("test-qualifier"));
> bm.mutate(del);
>
> Put put = new Put(Bytes.toBytes("com.example/http"));
> put.addColumn(Bytes.toBytes("test-family"),
> Bytes.toBytes("test-qualifier"), Bytes.toBytes("test-value"));
> bm.mutate(put);
>
> put = new Put(Bytes.toBytes("com.example/http"));
> put.addColumn(Bytes.toBytes("test-family"),
> Bytes.toBytes("test-qualifier"), Bytes.toBytes("test-value-2"));
> bm.mutate(put);
>
> bm.flush();
> bm.close();
>
> Get get = new Get(Bytes.toBytes("com.example/http"));
> get.addColumn(Bytes.toBytes("test-family"),
> Bytes.toBytes("test-qualifier"));
> Result result = table.get(get);
> byte [] val = result.getValue(Bytes.toBytes("test-family"),
> Bytes.toBytes("test-qualifier"));
>
> if(val == null) {
> // Testing purposes
> }
> }
>
> I would like to know the exact behavior of value val variable here, when
> NEW_VERSION_BEHAVIOR
> is true. Above code when it is executed returns null as value for val
> variable. As I can see, delete overshadows the subsequent puts.
>
> Regards
> Kevin
>
> On Mon, Apr 15, 2019 at 2:05 PM Kevin Ratnasekera <[email protected]>
> wrote:
>
>> Update:
>> Found out that above delete row works all columns which have non null
>> qualifier. Delete doesn't work for puts with column qualifier is null.
>>
>> On related note,
>>
>> Delete delete = new Delete(keyRaw);
>>
>> delete.addFamily(hcol.getFamily());
>>
>> Let's say I need to perform delete on all columns created inside a family
>> in a particular row, once I execute above delete operation, I am not be
>> able to do put operation on the same row same column family.
>>
>> Is there something I am missing here?
>>
>> Regards
>>
>> Kevin
>>
>>
>> On Mon, Apr 15, 2019 at 12:20 AM Kevin Ratnasekera <
>> [email protected]> wrote:
>>
>>> Hi all,
>>>
>>> I am from Apache Gora project. I currently in the process of upgrade our
>>> HBase dependencies to 2.0.5. We faced the issue described in [1] and had to
>>> put workarounds to get through it some time back. ( By timestamps ) Now I
>>> started to test NEW_VERSION_BEHAVIOR and I noticed even trivial row deletes
>>> fails when NEW_VERSION_BEHAVIOR is set to true.
>>>
>>> Delete del = new Delete(toBytes(key));
>>>
>>> table = connection.getTable(tableName);
>>>
>>> table.delete(del);
>>> Result result = table.get(new Get(toBytes(key)));
>>>
>>> Here Get returns some cells which are marked for delete. ( Some columns
>>> are deleted and some are not ) These deletes works fine when
>>> NEW_VERSION_BEHAVIOR is set to false. Please note I do this tests using
>>> HBaseTestingUtility
>>> minicluster.
>>>
>>> Are there any known issues with NEW_VERSION_BEHAVIOR with deletes? It
>>> would be really helpful if someone can give some pointers to debug the root
>>> cause of this.
>>>
>>> [1] https://issues.apache.org/jira/browse/HBASE-2256
>>>
>>> Regards
>>> Kevin
>>>
>>