hbase-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aleksandr B (JIRA)" <j...@apache.org>
Subject [jira] [Created] (HBASE-9115) HTableInterface.append operation fails (overwrites) the value added to the 1st colum out of several
Date Fri, 02 Aug 2013 11:17:48 GMT
Aleksandr B created HBASE-9115:

             Summary: HTableInterface.append operation fails (overwrites) the value added
to the 1st colum out of several
                 Key: HBASE-9115
                 URL: https://issues.apache.org/jira/browse/HBASE-9115
             Project: HBase
          Issue Type: Bug
    Affects Versions: 0.94.10
         Environment: MAC OS X 10.8.4, Hbase in the pseudo-distributed mode, hadoop v1.2.0,
Hbase Java API based client.


            Reporter: Aleksandr B
            Priority: Critical

I use Hbase Java API and I try to append values Bytes.toBytes("one two") and Bytes.toBytes("
three") in 3 columns.
Only for 2 out of these 3 columns the result is "one two three".

*Output from the hbase shell:*
hbase(main):008:0* scan "mytesttable"
ROW                                    COLUMN+CELL                                       
 mytestRowKey                          column=TestA:dlbytes, timestamp=1375436156140, value=one
two three                                             
 mytestRowKey                          column=TestA:tbytes, timestamp=1375436156140, value=one
two three                                              
 mytestRowKey                          column=TestA:ulbytes, timestamp=1375436156140, value=
1 row(s) in 0.0280 seconds

*My test code:*
import static org.junit.Assert.*;

import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.HColumnDescriptor;
import org.apache.hadoop.hbase.HTableDescriptor;
import org.apache.hadoop.hbase.client.HBaseAdmin;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.apache.hadoop.hbase.client.HTablePool;
import org.apache.hadoop.hbase.client.Append;
import org.apache.hadoop.hbase.client.Result;
import org.apache.hadoop.hbase.util.Bytes;
import org.junit.Test;


    public void testAppend() throws IOException {
        byte [] rowKey = Bytes.toBytes("mytestRowKey");
        byte [] column1 = Bytes.toBytes("ulbytes");
        byte [] column2 = Bytes.toBytes("dlbytes");
        byte [] column3 = Bytes.toBytes("tbytes");
        String part11 = "one two";
        String part12 = " three";
        String cFamily = "TestA";
        String TABLE = "mytesttable";
        Configuration conf = HBaseConfiguration.create();

        HTablePool pool = new HTablePool(conf, 10);
        HBaseAdmin admin = new HBaseAdmin(conf);
        HTableDescriptor tableDescriptor = new HTableDescriptor(TABLE);
        HColumnDescriptor hcd = new HColumnDescriptor(cFamily);

        HTableInterface table = pool.getTable(TABLE);
        Append a = new Append(rowKey);
        a.add(Bytes.toBytes(cFamily), column1, Bytes.toBytes(part11));
        a.add(Bytes.toBytes(cFamily), column2, Bytes.toBytes(part11));
        a.add(Bytes.toBytes(cFamily), column3, Bytes.toBytes(part11));
        HTableInterface table2 = pool.getTable(TABLE);
        a = new Append(rowKey);
        a.add(Bytes.toBytes(cFamily), column1, Bytes.toBytes(part12));
        a.add(Bytes.toBytes(cFamily), column2, Bytes.toBytes(part12));
        a.add(Bytes.toBytes(cFamily), column3, Bytes.toBytes(part12));
        Result result = table2.append(a);

        byte [] resultForColumn1 = result.getValue(Bytes.toBytes(cFamily), column1);
        byte [] resultForColumn2 = result.getValue(Bytes.toBytes(cFamily), column2);
        byte [] resultForColumn3 = result.getValue(Bytes.toBytes(cFamily), column3);
        if (resultForColumn1 == null || resultForColumn2 == null || resultForColumn3 == null)
            System.out.println("The DB table contains these values but they are never given
back, strange...");
        else {
            assertEquals(0, Bytes.compareTo(Bytes.toBytes(part11 + part12),
            assertEquals(0, Bytes.compareTo(Bytes.toBytes(part11 + part12),
            assertEquals(0, Bytes.compareTo(Bytes.toBytes(part11 + part12),

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

View raw message