You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* First-class support for namespaces
* Upgraded dependent libraries and plugins
* Added jackson datatype support for JDK 8 types
* Fixed multi custom codec issue
* Error handling, javadoc and README improvements
HBase ORM is a light-weight, thread-safe and performant library that enables:
11
11
12
-
1. object-oriented access of HBase rows (Data Access Object) with minimal code and good testability
13
-
2. reading from and/or writing to HBase tables in Hadoop MapReduce jobs
12
+
1. object-oriented access of HBase rows (Data Access Object) with minimal code and good testability.
13
+
2. reading from and/or writing to HBase tables in Hadoop MapReduce jobs.
14
+
15
+
This can also be used as an ORM for Bigtable. Scroll down till the relevant section to know how.
14
16
15
17
## Usage
16
18
Let's say you've an HBase table `citizens` with row-key format of `country_code#UID`. Now, let's say this table is created with three column families `main`, `optional` and `tracked`, which may have columns (qualifiers) `uid`, `name`, `salary` etc.
17
19
18
20
This library enables to you represent your HBase table as a *bean-like class*, as below:
19
21
20
22
```java
21
-
@HBTable(name="citizens",
23
+
@HBTable(namepsace="govt", name="citizens",
22
24
families= {
23
25
@Family(name="main"),
24
26
@Family(name="optional", versions=3),
@@ -37,8 +39,11 @@ public class Citizen implements HBRecord<String> {
@@ -74,18 +79,17 @@ public class Citizen implements HBRecord<String> {
74
79
```
75
80
That is,
76
81
77
-
* The above class `Citizen` represents the HBase table `citizens`, using the `@HBTable` annotation.
82
+
* The above class `Citizen` represents the HBase table `citizens` in namespace `govt`, using the `@HBTable` annotation.
78
83
* Logics for conversion of HBase row key to member variables of `Citizen` objects and vice-versa are implemented using `parseRowKey` and `composeRowKey` methods respectively.
79
84
* The data type representing row key is the type parameter to `HBRecord` generic interface (in above case, `String`).
80
-
* Note that `String` is both `Comparable` and `Serializable`.
85
+
* Note that `String` is both '`Comparable` with itself' and `Serializable`.
81
86
* Names of columns and their column families are specified using `@HBColumn` or `@HBColumnMultiVersion` annotations.
82
87
* The class may contain fields of simple data types (e.g. `String`, `Integer`), generic data types (e.g. `Map`, `List`), custom class (e.g. `Dependents`) or even generics of custom class (e.g. `List<Dependent>`)
83
88
* The `@HBColumnMultiVersion` annotation allows you to map multiple versions of column in a `NavigableMap<Long, ?>`. In above example, field `phoneNumber` is mapped to column `phone_number` within the column family `tracked` (which is configured for multiple versions)
So, it is recommended that you create `Connection` instance once and use it for the entire life cycle of your program across all the DAO classes that you create (such as above).
158
+
159
+
Now, you can access, manipulate and persist records of `citizens` table as shown in below examples:
152
160
153
161
Create new record:
154
162
@@ -290,7 +298,7 @@ citizenDao.getHBaseTable() // returns HTable instance (in case you want to direc
290
298
291
299
(see [TestsAbstractHBDAO.java](./src/test/java/com/flipkart/hbaseobjectmapper/testcases/TestsAbstractHBDAO.java) for more detailed examples)
292
300
293
-
**Please note:** Since we're dealing with HBase (and not an OLTP data store), fitting a classical (Hibernate-like) ORM paradigm may not make sense. So this library doesn't intend to evolve as a full-fledged ORM. However, if that's your intent, I suggest you use [Apache Phoenix](https://phoenix.apache.org/).
301
+
**Please note:** Since we're dealing with HBase (and not a classical RDBMS), fitting a Hibernate-like ORM may not make sense. So, this library does **not** intend to evolve as a full-fledged ORM. However, if that's your intent, I suggest you use [Apache Phoenix](https://phoenix.apache.org/).
294
302
295
303
296
304
## Using this library for DDL operations
@@ -418,30 +426,32 @@ Being an *object mapper*, this library works for pre-defined columns only. For e
418
426
* columns matching a pattern or a regular expression
419
427
* unmapped columns of a column family
420
428
421
-
## Maven
422
-
Add below entry within the `dependencies` section of your `pom.xml`:
429
+
## Adding to your build
430
+
If you are using Maven, add below entry within the `dependencies` section of your `pom.xml`:
423
431
424
432
```xml
425
433
<dependency>
426
434
<groupId>com.flipkart</groupId>
427
435
<artifactId>hbase-object-mapper</artifactId>
428
-
<version>1.16</version>
436
+
<version>1.18</version>
429
437
</dependency>
430
438
```
431
439
432
-
See artifact details: [com.flipkart:hbase-object-mapper on **Maven Central**](https://search.maven.org/search?q=g:com.flipkart%20AND%20a:hbase-object-mapper&core=gav) or
433
-
[com.flipkart:hbase-object-mapper on **MVN Repository**](https://mvnrepository.com/artifact/com.flipkart/hbase-object-mapper).
440
+
See artifact details: [com.flipkart:hbase-object-mapper on **Maven Central**](https://search.maven.org/search?q=g:com.flipkart%20AND%20a:hbase-object-mapper&core=gav).
441
+
442
+
If you're using Gradle or Ivy or SBT, see how to include this library in your build:
2. Checkout latest stable version `git checkout v1.16`
449
+
2. Checkout latest stable version `git checkout v1.18`
440
450
3. Execute `mvn clean install` from shell
441
451
442
452
### Please note:
443
453
444
-
* Currently, projects that use this library are running on [Hortonworks Data Platform v3.1](https://docs.cloudera.com/HDPDocuments/HDP3/HDP-3.1.0/index.html) (corresponds to Hadoop 3.1 and HBase 2.0). However, if you are using a different version of Hadoop/HBase, you may change the versions in [pom.xml](./pom.xml) to desired ones and build the project.
454
+
* Currently, systems that use this library are running on Hadoop 3.1 and HBase 2.0. However, if you are using a different version of Hadoop/HBase, you may change the versions in [pom.xml](./pom.xml) to desired ones and build the project.
445
455
* Test cases are **very comprehensive**. So, `mvn` build times can sometimes be longer, depending on your machine configuration.
446
456
* By default, test cases spin an [in-memory HBase test cluster](https://github.com/apache/hbase/blob/master/hbase-server/src/test/java/org/apache/hadoop/hbase/HBaseTestingUtility.java) to run data access related test cases (near-realworld scenario).
447
457
* If test cases are failing with time out errors, you may increase the timeout by setting environment variable `INMEMORY_CLUSTER_START_TIMEOUT` (seconds). For example, on Linux you may run the command `export INMEMORY_CLUSTER_START_TIMEOUT=8` on terminal, before running the aforementioned `mvn` command.
@@ -457,6 +467,22 @@ The change log can be found in the [releases](//github.com/flipkart-incubator/hb
457
467
458
468
If you intend to request a feature or report a bug, you may use [Github Issues for hbase-orm](//github.com/flipkart-incubator/hbase-orm/issues).
459
469
470
+
## Bigtable ORM
471
+
Google's [Cloud Bigtable](https://cloud.google.com/bigtable) provides first-class support for [accessing Bigtable using HBase client](https://cloud.google.com/bigtable/docs/reference/libraries#client-libraries-usage-hbase-java).
472
+
473
+
This library can be used as a **Bigtable ORM**, 3 simple steps:
474
+
1. Add following to your dependencies:
475
+
*[bigtable-hbase-2.x](https://mvnrepository.com/artifact/com.google.cloud.bigtable/bigtable-hbase-2.x) or [bigtable-hbase-2.x-shaded](https://mvnrepository.com/artifact/com.google.cloud.bigtable/bigtable-hbase-2.x-shaded)
if (!field.getType().isAssignableFrom(value.getClass())) {
564
559
thrownewIllegalArgumentException(String.format("An attempt was made to append a value of type '%s' to field '%s', which is of type '%s' (incompatible)", value.getClass(), fieldName, field.getType()));
0 commit comments