FAQ
Hi,
I have a HBASE table with script:
create 'STATE_STORE', {NAME => 'CREATIVE_GROUP'}, {NAME => 'CREATIVE'},
{NAME =>'AD_CODE'}.
I put integer value '1000' in column family 'CREATIVE_GROUP' with column
name 'STATE'.
When I tried to get value from the same table with column family 'CREATIVE'
and column name 'STATE' i'm getting '1000' instead of 'NULL'.

What can be the issue ?

My code for get and put is as follows,

PUT:

void putToHbase() {
Configuration conf = new Configuration();
conf.set("hbase.zookeeper.quorum", "demo-hadoop1");
conf.set("hbase.zookeeper.property.clientPort", "2181");
byte[] byteValue = Bytes.toBytes(1000);
String colFamily = "CREATIVE_GROUP";
HTableInterface hbaseStateStore=null;
try {
hbaseStateStore = new HTable(conf, "STATE_STORE");
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
Put put = new Put(Bytes.toBytes("" + 3001));
put.add(Bytes.toBytes(colFamily), Bytes.toBytes("STATE"),
byteValue);
try {
hbaseStateStore.put(put);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}


GET:

static void print() {
Configuration conf = new Configuration();
conf.set("hbase.zookeeper.quorum", "192.168.150.203");
conf.set("hbase.zookeeper.property.clientPort", "2181");
HTableInterface htable = null;
byte[] key = Bytes.toBytes("3001");
Get g = new Get(key);
Advertiser ad = null;
MsisdnAlgoDetails[] algos = null;
try {
htable = new HTable(conf, "STATE_STORE");
Result res = htable.get(g);
byte[] value = res.getValue(Bytes.toBytes("CREATIVE"),
Bytes.toBytes("STATE"));
System.out.println(Bytes.toInt(value));
} catch (Exception e) {

}
}


Result for GET:-
1000

Waiting for your reply, Thanks in Advance.

Search Discussions

  • Mikael Sitruk at Feb 27, 2012 at 4:37 pm
    Can you get all the row and print all the columns?

    Maybe silly q. but did you check that the row was empty before your
    execution?

    Mikael.S
    On Mon, Feb 27, 2012 at 5:32 PM, krishnaprasad wrote:

    Hi,
    I have a HBASE table with script:
    create 'STATE_STORE', {NAME => 'CREATIVE_GROUP'}, {NAME => 'CREATIVE'},
    {NAME =>'AD_CODE'}.
    I put integer value '1000' in column family 'CREATIVE_GROUP' with column
    name 'STATE'.
    When I tried to get value from the same table with column family 'CREATIVE'
    and column name 'STATE' i'm getting '1000' instead of 'NULL'.

    What can be the issue ?

    My code for get and put is as follows,

    PUT:

    void putToHbase() {
    Configuration conf = new Configuration();
    conf.set("hbase.zookeeper.quorum", "demo-hadoop1");
    conf.set("hbase.zookeeper.property.clientPort", "2181");
    byte[] byteValue = Bytes.toBytes(1000);
    String colFamily = "CREATIVE_GROUP";
    HTableInterface hbaseStateStore=null;
    try {
    hbaseStateStore = new HTable(conf, "STATE_STORE");
    } catch (IOException e1) {
    // TODO Auto-generated catch block
    e1.printStackTrace();
    }
    Put put = new Put(Bytes.toBytes("" + 3001));
    put.add(Bytes.toBytes(colFamily), Bytes.toBytes("STATE"),
    byteValue);
    try {
    hbaseStateStore.put(put);
    } catch (IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    }


    GET:

    static void print() {
    Configuration conf = new Configuration();
    conf.set("hbase.zookeeper.quorum", "192.168.150.203");
    conf.set("hbase.zookeeper.property.clientPort", "2181");
    HTableInterface htable = null;
    byte[] key = Bytes.toBytes("3001");
    Get g = new Get(key);
    Advertiser ad = null;
    MsisdnAlgoDetails[] algos = null;
    try {
    htable = new HTable(conf, "STATE_STORE");
    Result res = htable.get(g);
    byte[] value = res.getValue(Bytes.toBytes("CREATIVE"),
    Bytes.toBytes("STATE"));
    System.out.println(Bytes.toInt(value));
    } catch (Exception e) {

    }
    }


    Result for GET:-
    1000

    Waiting for your reply, Thanks in Advance.

    --
    View this message in context:
    http://apache-hbase.679495.n3.nabble.com/While-putting-value-in-one-column-family-results-getting-the-same-value-from-every-column-family-of--tp3781052p3781052.html
    Sent from the HBase - Developer mailing list archive at Nabble.com.


    --
    Mikael.S
  • Krishnaprasad at Feb 28, 2012 at 4:45 pm
    Hi Mikael,
    I checked that the row is empty or not and it is obviously not empty,
    because I have put value into column family 'CREATIVE_GROUP' just before
    'get'.
    The HBase shell responds correctly,
    --------------------------------------------
    Shell output:-

    hbase(main):002:0> get 'STATE_STORE','3000','CREATIVE_GROUP'
    COLUMN CELL
    CREATIVE_GROUP:STATE
    timestamp=1330353883796, value=\xFF
    1 row(s) in 0.0220 seconds

    hbase(main):003:0> get 'STATE_STORE','3000','CREATIVE'
    COLUMN CELL
    0 row(s) in 0.0130 seconds

    --------------------------------------------

    I also checked for the existence of column 'STATE' in column-family
    'CREATIVE' but it returns true.
    ----------
    boolean b = res.containsColumn(Bytes.toBytes("CREATIVE"),
    Bytes.toBytes("STATE"));
    result is 'true'.
    ----------
    I created the column, 'STATE', only for column family 'CREATIVE_GROUP', then
    why the above code returns true ?
    I think it refers to the same column 'STATE' of the family 'CREATIVE_GROUP'.
    How can I fix this issue with out changing the column name ?

    Regards,
    Krishnaprasad
  • Mikael Sitruk at Feb 28, 2012 at 5:00 pm
    Hi Krishnaprasad
    1. I meant "did you checked the table was empty, before the execution of
    the put, not the get"
    2. Just by curiosity: in your code you have once: "demo-hadoop1" and
    "192.168.150.203"
    3. The key you use in your program is 3001 and the one you use in the shell
    is 3000, so are you sure you check the same stuff??

    Mikael.S
    On Tue, Feb 28, 2012 at 9:01 AM, krishnaprasad wrote:

    Hi Mikael,
    I checked that the row is empty or not and it is obviously not empty,
    because I have put value into column family 'CREATIVE_GROUP' just before
    'get'.
    The HBase shell responds correctly,
    --------------------------------------------
    Shell output:-

    hbase(main):002:0> get 'STATE_STORE','3000','CREATIVE_GROUP'
    COLUMN CELL
    CREATIVE_GROUP:STATE
    timestamp=1330353883796, value=\xFF
    1 row(s) in 0.0220 seconds

    hbase(main):003:0> get 'STATE_STORE','3000','CREATIVE'
    COLUMN CELL
    0 row(s) in 0.0130 seconds

    --------------------------------------------

    I also checked for the existence of column 'STATE' in column-family
    'CREATIVE' but it returns true.
    ----------
    boolean b = res.containsColumn(Bytes.toBytes("CREATIVE"),
    Bytes.toBytes("STATE"));
    result is 'true'.
    ----------
    I created the column, 'STATE', only for column family 'CREATIVE_GROUP',
    then
    why the above code returns true ?
    I think it refers to the same column 'STATE' of the family
    'CREATIVE_GROUP'.
    How can I fix this issue with out changing the column name ?

    Regards,
    Krishnaprasad


    --
    View this message in context:
    http://apache-hbase.679495.n3.nabble.com/While-putting-value-in-one-column-family-results-getting-the-same-value-from-every-column-family-of--tp3781052p3783187.html
    Sent from the HBase - Developer mailing list archive at Nabble.com.


    --
    Mikael.S
  • Krishnaprasad at Feb 29, 2012 at 4:00 pm
    Hi Mikael,
    First of all sorry for making the confusions in my sample code.
    Please note that
    "192.168.150.203" is same as "demo-hadoop1",
    and also the shell output is same for the key '3001'.
    I'm sure that the row was empty(you mentioned as table, which we can't
    check) before 'put'.

    Regards,
    Krishnaprasad
  • Daniel Gómez Ferro at Feb 29, 2012 at 4:18 pm
    Hi,

    I think you are hitting HBASE-5271. I don't know what release has this fix integrated.

    Regards,
    Daniel
    On Feb 29, 2012, at 10:15 , krishnaprasad wrote:

    Hi Mikael,
    First of all sorry for making the confusions in my sample code.
    Please note that
    "192.168.150.203" is same as "demo-hadoop1",
    and also the shell output is same for the key '3001'.
    I'm sure that the row was empty(you mentioned as table, which we can't
    check) before 'put'.

    Regards,
    Krishnaprasad

    --
    View this message in context: http://apache-hbase.679495.n3.nabble.com/While-putting-value-in-one-column-family-results-getting-the-same-value-from-every-column-family-of--tp3781052p3786708.html
    Sent from the HBase - Developer mailing list archive at Nabble.com.
  • Krishnaprasad at Mar 1, 2012 at 4:00 pm
    Thank you guys,
    I think this is the same issue(HBASE-5271),

    Fix Version/s: 0.90.7, 0.92.1, 0.94.0

    https://issues.apache.org/jira/browse/HBASE-5271.

    Regards,
    Krishnaprasad

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupdev @
categorieshbase, hadoop
postedFeb 27, '12 at 4:20p
activeMar 1, '12 at 4:00p
posts7
users3
websitehbase.apache.org

People

Translate

site design / logo © 2022 Grokbase