Reputation: 1932
Say, I have such entity that I want to persist into HBase
public class Message {
private final String id;
private final String chatId;
private final String from;
private final String to;
private final long when;
}
Should I remove id
field and simply generate rowName
that will serve as an id
or rowName
is something more than id
?
Upvotes: 0
Views: 423
Reputation: 20860
I think, you are referring to row key
as a row name
.
Row Key design is a crucial part of HBase Table design.
Row key is used to index the HBase tables. Rows in HBase are sorted lexicographically by row key. This design optimizes for scans, allowing you to store related rows in the same region, or rows that will be read together, near each other.
HBase figures out which region a record will go to as it goes.
While the ID
as a part of your example is part of the record type Message
. It can be stored in a column family as a column. But it won't contribute in deciding which region the record should be written to.
Also if you have multiple column families with the same Message type but with different IDs, you can store all in one row(with one row key). Each row has a timestamp associated to it with respect to the column family and column qualifer.
<Row1, CF1<ID:1,Chat:abc,To:A1,From:B1>>,timestamp
<Row1, CF2<ID:1,Chat:abc,To:A1,From:B1>>,timestamp
You can read more about it : http://hbase.apache.org/0.94/book/rowkey.design.html
Upvotes: 1