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
Copy file name to clipboardExpand all lines: README.md
+80-79Lines changed: 80 additions & 79 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -99,85 +99,6 @@ public class Citizen implements HBRecord<CitizenKey> {
99
99
* The default codec class `BestSuitCodec` takes a flag `BestSuitCodec.SERIALIZE_AS_STRING`, whose value is "serializeAsString" (as in the above `Citizen` class example). When this flag is set to `true` on a field, the default codec serializes that field (even numerical fields) as strings.
100
100
* Your custom codec may take other such flags to customize serialization/deserialization behavior at a **class field level**.
101
101
102
-
## Using this library in MapReduce jobs
103
-
104
-
### Mapper
105
-
If your MapReduce job is reading from an HBase table, in your `map()` method, HBase's `Result` object can be converted to object of your bean-like class using below method:
106
-
107
-
```java
108
-
T readValue(ImmutableBytesWritable rowKey, Result result, Class<T> clazz)
109
-
```
110
-
111
-
For example:
112
-
113
-
```java
114
-
Citizen e = hbObjectMapper.readValue(key, value, Citizen.class);
115
-
```
116
-
117
-
### Reducer
118
-
If your MapReduce job is writing to an HBase table, in your `reduce()` method, object of your bean-like class can be converted to HBase's `Put` (for row contents) and `ImmutableBytesWritable` (for row key) using below methods:
119
-
120
-
```java
121
-
ImmutableBytesWritable getRowKey(HBRecord<R> obj)
122
-
```
123
-
```java
124
-
Put writeValueAsPut(HBRecord<R> obj)
125
-
```
126
-
For example, below code in Reducer writes your object as one HBase row with appropriate column families and columns:
This library provides an abstract class to define your own [data access object](https://en.wikipedia.org/wiki/Data_access_object). For example, you can create one for `Citizen` class in the above example as follows:
183
104
@@ -292,6 +213,86 @@ citizenDao.getHBaseTable() // returns HTable instance (in case you want to direc
292
213
293
214
**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/).
294
215
216
+
## Using this library in MapReduce jobs
217
+
218
+
### Mapper
219
+
If your MapReduce job is reading from an HBase table, in your `map()` method, HBase's `Result` object can be converted to object of your bean-like class using below method:
220
+
221
+
```java
222
+
T readValue(ImmutableBytesWritable rowKey, Result result, Class<T> clazz)
223
+
```
224
+
225
+
For example:
226
+
227
+
```java
228
+
Citizen e = hbObjectMapper.readValue(key, value, Citizen.class);
229
+
```
230
+
231
+
### Reducer
232
+
If your MapReduce job is writing to an HBase table, in your `reduce()` method, object of your bean-like class can be converted to HBase's `Put` (for row contents) and `ImmutableBytesWritable` (for row key) using below methods:
233
+
234
+
```java
235
+
ImmutableBytesWritable getRowKey(HBRecord<R> obj)
236
+
```
237
+
```java
238
+
Put writeValueAsPut(HBRecord<R> obj)
239
+
```
240
+
For example, below code in Reducer writes your object as one HBase row with appropriate column families and columns:
* Your application code will be clean and minimal.
297
298
* Your code need not worry about HBase methods or serialization/deserialization at all, thereby helping you maintain clear [separation of concerns](https://en.wikipedia.org/wiki/Separation_of_concerns).
0 commit comments