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 Sun, 05 Jan 2014 16:46:01 GMT
I just read some short introduction of Phoenix these days.
If I am wrong, pls let me know, thx.
It seems to me Phoenix will provide a JDBC-driver against hbase.
But simplehbase will provide some hbase close related features.

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-tp4054488p4054491.html
Sent from the HBase User mailing list archive at Nabble.com.
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message