hbase-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zhang_xzhi <zhang_x...@163.com>
Subject Re:Re: a short introduction of simplehbase(hbase ORM)
Date Tue, 07 Jan 2014 16:44:51 GMT

Yes, I know there are some framework such as Phoenix.
Phoenix is good work.

But I have some other ideas.
To me, each data store is different, especially non-traditional relation database.
Because they bring us some new ideas to design,store,handle datum.
If we still encapsulate it to a SQL skin, Is there some chance to handle impedance mismatch
we compromise some sparking thing.

So I want to write a simple framework on and only on Hbase.
And invent a simple dynamic query language for hbase query (I know it is simple so far).
It focus on Hbase, modeled after hbase's design and concept. such as model RowKey as an interface
not a @Id tagged field in DO, because I think the rowkey design is important, so row key deserves
a first level class in a framework.

Besides Phoenix way, is there another way to build a framework to simplify hbase app dev.
That is what I am working on.

Cheers!

xinzhi.zhang




At 2014-01-06 00:40:47,"Ted Yu-3 [via Apache HBase]" <ml-node+s679495n4054490h58@n3.nabble.com>
wrote:
There seems to be some overlap between your project and the following:

HBASE-8089 Add type support
Phoenix which becomes Apache incubator project

Cheers


On Sun, Jan 5, 2014 at 7:58 AM, zhang_xzhi <[hidden email]> wrote:


> https://github.com/zhang-xzhi/simplehbase
> https://github.com/zhang-xzhi/simplehbase/wiki
>
> I am writing a light weight hbase ORM now, search for some suggestion.
> thanks.
>
>
> # 3 mins on simplehbase
>
> ## Introduction to simplehbase
> Simplehbase is a lightweight ORM framework between java app and hbase.
> The main feature of it are following:
> * data type mapping: mapping java type to hbase's bytes back and forth.
> * hbase operation wrapping: warpping hbase's put get scan operation to
> simple java interface.
> * hbase query language: using hbase filter, simplehbase can use sql-like
> style to operate on hbase.
> * dynamic query: like myibatis, simplehbase can use xml config file to
> define dynamic query to operate on hbase.
> * insert update support: provide insert, update on top of checkAndPut.
> * multiple version support: provide interface to operation on hbase's
> multiple version.
> * hbase native interface support.
>
> ## Simplehbase sample
>
> ### Init simplehbase
>     private static SimpleHbaseClient getSimpleHbaseClient() {
>         HBaseDataSource hbaseDataSource = new HBaseDataSource();
>         List<String> hbaseConfigFilePaths = new ArrayList<String>();
>         //hbase config file.
>         hbaseConfigFilePaths.add("sample\\hbase_site");
>         //zk config file.
>         hbaseConfigFilePaths.add("sample\\zk_conf");
>         hbaseDataSource.setHbaseConfigFilePaths(hbaseConfigFilePaths);
>         hbaseDataSource.init();
>
>         HBaseTableConfig hbaseTableConfig = new HBaseTableConfig();
>         //simplehbase config file.
>         hbaseTableConfig.setConfigFilePath("sample\\myRecord.xml");
>         hbaseTableConfig.init();
>
>         SimpleHbaseClient tClient = new SimpleHbaseClientImpl();
>         tClient.setHBaseDataSource(hbaseDataSource);
>         tClient.setHbaseTableConfig(hbaseTableConfig);
>
>         return tClient;
>     }
> ### Simplehbase config xml
> including htable's config and one dynamic query config.
> <SimpleHbase>
>
>         <HBaseTableSchema tableName="MyRecord"
> defaultFamily="MyRecordFamily">
>                 <HBaseColumnSchema qualifier="id" typeName="int" />
>                 <HBaseColumnSchema qualifier="name" typeName="string" />
>                 <HBaseColumnSchema qualifier="date" typeName="date" />
>                 <HBaseColumnSchema qualifier="gender"
> typeName="allen.sample.Gender" />
>                 <HBaseColumnSchema qualifier="age" typeName="int" />
>         </HBaseTableSchema>
>
>         <statements>
>                 <statement id="queryByNameAndAge">
>                         select where id greater #id#
>                         <isPropertyAvailable prepend="and" property="name">
>                                 name equal #name#
>                         </isPropertyAvailable>
>                         <isPropertyAvailable prepend="and" property="age">
>                                 age greater #age#
>                         </isPropertyAvailable>
>                 </statement>
>         </statements>
> </SimpleHbase>
>
> ### Define Data Object
>     @HBaseTable(defaultFamily = "MyRecordFamily")
>     public class Person {
>         @HBaseColumn(qualifier = "id")
>         private int    id;
>         @HBaseColumn(qualifier = "name")
>         private String name;
>         @HBaseColumn(qualifier = "date")
>         private Date   date;
>         @HBaseColumn(qualifier = "gender")
>         private Gender gender;
>         @HBaseColumn(qualifier = "age")
>         private int    age;
>     }
>
> ### Define RowKey of Data Object
>         public class PersonRowKey implements RowKey {
>
>                 private int row;
>
>                 public PersonRowKey(int row) {
>                         this.row = row;
>                 }
>
>                 @Override
>                 public byte[] toBytes() {
>                         return Bytes.toBytes(row);
>                 }
>         }
> ### Using SimpleHbaseClient to operate hbase
>     public static void main(String[] args) throws Exception {
>
>         SimpleHbaseClient simpleHbaseClient = getSimpleHbaseClient();
>
>         //insert one record.
>         Person one = new Person();
>         one.setId(1);
>         one.setName("allen");
>         one.setAge(30);
>         one.setGender(Gender.MALE);
>         simpleHbaseClient.putObject(new PersonRowKey(1), one);
>
>         //insert another record.
>         Person two = new Person();
>         two.setId(2);
>         two.setName("dan");
>         two.setAge(31);
>         two.setGender(Gender.FEMALE);
>         simpleHbaseClient.putObject(new PersonRowKey(2), two);
>
>         //search by rowkey.
>         Person result = simpleHbaseClient.findObject(new PersonRowKey(1),
>                 Person.class);
>         log.info(result);
>
>         //search by range.
>         List<Person> resultList = simpleHbaseClient.findObjectList(
>                 new PersonRowKey(1), new PersonRowKey(3), Person.class);
>         log.info(resultList);
>
>         //search by dynamic query.
>         Map<String, Object> para = new HashMap<String, Object>();
>         para.put("id", 0);
>         resultList = simpleHbaseClient.findObjectList(new PersonRowKey(1),
>                 new PersonRowKey(3), Person.class, "queryByNameAndAge",
> para);
>         log.info(resultList);
>
>         //search by dynamic query.
>         para.put("name", "allen");
>         para.put("age", 0);
>         resultList = simpleHbaseClient.findObjectList(new PersonRowKey(1),
>                 new PersonRowKey(3), Person.class, "queryByNameAndAge",
> para);
>         log.info(resultList);
>
>         //batch delete.
>         simpleHbaseClient.deleteObjectList(new PersonRowKey(0),
>                 new PersonRowKey(100));
>
>     }
>
>
>
>
>
>
>
>
> --
> View this message in context:
> http://apache-hbase.679495.n3.nabble.com/a-short-introduction-of-simplehbase-hbase-ORM-tp4054488.html
> Sent from the HBase User mailing list archive at Nabble.com.
>




If you reply to this email, your message will be added to the discussion below:
http://apache-hbase.679495.n3.nabble.com/a-short-introduction-of-simplehbase-hbase-ORM-tp4054488p4054490.html
To unsubscribe from a short introduction of simplehbase(hbase ORM), click here.
NAML



--
View this message in context: http://apache-hbase.679495.n3.nabble.com/a-short-introduction-of-simplehbase-hbase-ORM-tp4054488p4054556.html
Sent from the HBase User mailing list archive at Nabble.com.
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message