Skip to content

Commit 5297b63

Browse files
committed
Migration to HDP v3.1 (78)
1 parent 06d9b6a commit 5297b63

20 files changed

+96
-429
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
/output/
44
/out/
55
/target/
6-
.DS_Store
6+
.DS_Store
7+
*.txt
8+
*.rdb

README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,8 @@
33
## Introduction
44
An ultra-light-weight HBase ORM library that enables
55

6-
1. reading from and/or writing to HBase tables in Hadoop MapReduce jobs
7-
2. object-oriented access of HBase rows ([Data Access Object](https://en.wikipedia.org/wiki/Data_access_object))
8-
3. writing high-quality test cases for classes that interact with HBase
6+
1. object-oriented access of HBase rows (Data Access Object) with minimal code and good testability
7+
2. reading from and/or writing to HBase tables in Hadoop MapReduce jobs
98

109

1110
## Usage
@@ -262,7 +261,7 @@ Add below entry within the `dependencies` section of your `pom.xml`:
262261
<version>1.11</version>
263262
</dependency>
264263
```
265-
See artifact details: [com.flipkart:hbase-object-mapper on **Maven Central**](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.flipkart%22%20AND%20a%3A%22hbase-object-mapper%22) or
264+
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
266265
[com.flipkart:hbase-object-mapper on **MVN Repository**](https://mvnrepository.com/artifact/com.flipkart/hbase-object-mapper).
267266
## How to build?
268267
To build this project, follow below simple steps:

pom.xml

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55
<name>HBase ORM</name>
66
<description>
77
An ultra-light-weight HBase ORM library that enables
8-
[1] object-oriented access of HBase rows (Data Access Object)
8+
[1] object-oriented access of HBase rows (Data Access Object) with minimal code and good testability
99
[2] reading from and/or writing to HBase tables in Hadoop MapReduce jobs
10-
[3] writing high-quality test cases for classes that interact with HBase
1110
</description>
1211
<modelVersion>4.0.0</modelVersion>
1312
<groupId>com.flipkart</groupId>
1413
<artifactId>hbase-object-mapper</artifactId>
15-
<version>1.11</version>
14+
<version>1.11-hdp31-78</version>
1615
<url>https://flipkart-incubator.github.io/hbase-orm/</url>
1716
<scm>
1817
<url>https://github.com/flipkart-incubator/hbase-orm/</url>
@@ -45,8 +44,9 @@
4544
</repositories>
4645
<properties>
4746
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
48-
<version.hadoop>2.7.1.2.4.0.0-169</version.hadoop>
49-
<version.hbase>1.1.2.2.4.0.0-169</version.hbase>
47+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
48+
<version.hadoop>3.1.1.3.1.0.0-78</version.hadoop>
49+
<version.hbase>2.0.2.3.1.0.0-78</version.hbase>
5050
</properties>
5151
<distributionManagement>
5252
<repository>
@@ -66,11 +66,16 @@
6666
<artifactId>jackson-databind</artifactId>
6767
<version>2.8.11.3</version>
6868
</dependency>
69+
<dependency>
70+
<groupId>com.google.guava</groupId>
71+
<artifactId>guava</artifactId>
72+
<version>19.0</version>
73+
</dependency>
6974
<!-- test dependencies -->
7075
<dependency>
7176
<groupId>org.projectlombok</groupId>
7277
<artifactId>lombok</artifactId>
73-
<version>1.16.16</version>
78+
<version>1.18.4</version>
7479
<scope>test</scope>
7580
</dependency>
7681
<dependency>
@@ -90,24 +95,23 @@
9095
<artifactId>hbase-testing-util</artifactId>
9196
<version>${version.hbase}</version>
9297
<scope>test</scope>
98+
<exclusions>
99+
<exclusion>
100+
<groupId>junit</groupId>
101+
<artifactId>junit</artifactId>
102+
</exclusion>
103+
</exclusions>
93104
</dependency>
94105
<dependency>
95-
<groupId>org.apache.mrunit</groupId>
96-
<artifactId>mrunit</artifactId>
97-
<version>1.1.0</version>
98-
<classifier>hadoop2</classifier>
99-
<scope>test</scope>
100-
</dependency>
101-
<dependency>
102-
<groupId>junit</groupId>
103-
<artifactId>junit</artifactId>
104-
<version>4.12</version>
106+
<groupId>org.junit.jupiter</groupId>
107+
<artifactId>junit-jupiter-engine</artifactId>
108+
<version>5.3.2</version>
105109
<scope>test</scope>
106110
</dependency>
107111
<dependency>
108-
<groupId>org.javatuples</groupId>
109-
<artifactId>javatuples</artifactId>
110-
<version>1.2</version>
112+
<groupId>org.mockito</groupId>
113+
<artifactId>mockito-core</artifactId>
114+
<version>2.23.4</version>
111115
<scope>test</scope>
112116
</dependency>
113117
</dependencies>
@@ -116,10 +120,10 @@
116120
<plugin>
117121
<groupId>org.apache.maven.plugins</groupId>
118122
<artifactId>maven-compiler-plugin</artifactId>
119-
<version>3.6.1</version>
123+
<version>3.8.0</version>
120124
<configuration>
121-
<source>1.7</source>
122-
<target>1.7</target>
125+
<source>1.8</source>
126+
<target>1.8</target>
123127
<compilerArgument>-Xlint:all</compilerArgument>
124128
</configuration>
125129
</plugin>

src/main/java/com/flipkart/hbaseobjectmapper/AbstractHBDAO.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ protected AbstractHBDAO(Configuration configuration) throws IOException {
147147
* @throws IOException When HBase call fails
148148
*/
149149
public T get(R rowKey, int numVersionsToFetch) throws IOException {
150-
Result result = this.table.get(new Get(toBytes(rowKey)).setMaxVersions(numVersionsToFetch));
150+
Result result = this.table.get(new Get(toBytes(rowKey)).readVersions(numVersionsToFetch));
151151
return hbObjectMapper.readValue(rowKey, result, hbRecordClass);
152152
}
153153

@@ -214,7 +214,7 @@ public List<T> getOnGets(List<Get> gets) throws IOException {
214214
public T[] get(R[] rowKeys, int numVersionsToFetch) throws IOException {
215215
List<Get> gets = new ArrayList<>(rowKeys.length);
216216
for (R rowKey : rowKeys) {
217-
gets.add(new Get(toBytes(rowKey)).setMaxVersions(numVersionsToFetch));
217+
gets.add(new Get(toBytes(rowKey)).readVersions(numVersionsToFetch));
218218
}
219219
Result[] results = this.table.get(gets);
220220
@SuppressWarnings("unchecked") T[] records = (T[]) Array.newInstance(hbRecordClass, rowKeys.length);
@@ -246,7 +246,7 @@ public T[] get(R[] rowKeys) throws IOException {
246246
public List<T> get(List<R> rowKeys, int numVersionsToFetch) throws IOException {
247247
List<Get> gets = new ArrayList<>(rowKeys.size());
248248
for (R rowKey : rowKeys) {
249-
gets.add(new Get(toBytes(rowKey)).setMaxVersions(numVersionsToFetch));
249+
gets.add(new Get(toBytes(rowKey)).readVersions(numVersionsToFetch));
250250
}
251251
Result[] results = this.table.get(gets);
252252
List<T> records = new ArrayList<>(rowKeys.size());
@@ -277,7 +277,7 @@ public List<T> get(List<R> rowKeys) throws IOException {
277277
* @throws IOException When HBase call fails
278278
*/
279279
public List<T> get(R startRowKey, R endRowKey, int numVersionsToFetch) throws IOException {
280-
Scan scan = new Scan(toBytes(startRowKey), toBytes(endRowKey)).setMaxVersions(numVersionsToFetch);
280+
Scan scan = new Scan().withStartRow(toBytes(startRowKey)).withStopRow(toBytes(endRowKey)).readVersions(numVersionsToFetch);
281281
ResultScanner scanner = table.getScanner(scan);
282282
List<T> records = new ArrayList<>();
283283
for (Result result : scanner) {
@@ -312,7 +312,7 @@ public long increment(R rowKey, String fieldName, long amount) throws IOExceptio
312312
* Increments field by specified amount
313313
*
314314
* @param rowKey Row key of the record whose column needs to be incremented
315-
* @param fieldName Field that needs to be incremented (this must be of {@link Long} type)
315+
* @param fieldName Field that needs to be incremented (this must be of {@link Long} type)
316316
* @param amount Amount by which the HBase column needs to be incremented
317317
* @param durability The persistence guarantee for this increment (see {@link Durability})
318318
* @return The new value, post increment
@@ -337,9 +337,9 @@ public Increment getIncrement(R rowKey) {
337337
* Performs HBase {@link Table#increment} on the given {@link Increment} object <br>
338338
* <br>
339339
* <b>Note</b>: <ul>
340-
* <li>You may construct {@link Increment} object using the {@link #getIncrement(Serializable) getIncrement} method</li>
341-
* <li>Unlike the {@link #increment(Serializable, String, long)} methods, this method skips some validations (hence, be cautious)</li>
342-
* </ul>
340+
* <li>You may construct {@link Increment} object using the {@link #getIncrement(Serializable) getIncrement} method</li>
341+
* <li>Unlike the {@link #increment(Serializable, String, long)} methods, this method skips some validations (hence, be cautious)</li>
342+
* </ul>
343343
*
344344
* @param increment HBase Increment object
345345
* @return <b>Partial object</b> containing (only) values that were incremented
@@ -570,9 +570,9 @@ private Map<R, Object> toSingleVersioned(Map<R, NavigableMap<Long, Object>> mult
570570
public NavigableMap<R, NavigableMap<Long, Object>> fetchFieldValues(R startRowKey, R endRowKey, String fieldName, int numVersionsToFetch) throws IOException {
571571
Field field = getField(fieldName);
572572
WrappedHBColumn hbColumn = new WrappedHBColumn(field, true);
573-
Scan scan = new Scan(toBytes(startRowKey), toBytes(endRowKey));
573+
Scan scan = new Scan().withStartRow(toBytes(startRowKey)).withStopRow(toBytes(endRowKey));
574574
scan.addColumn(hbColumn.familyBytes(), hbColumn.columnBytes());
575-
scan.setMaxVersions(numVersionsToFetch);
575+
scan.readVersions(numVersionsToFetch);
576576
ResultScanner scanner = table.getScanner(scan);
577577
NavigableMap<R, NavigableMap<Long, Object>> map = new TreeMap<>();
578578
for (Result result : scanner) {
@@ -609,7 +609,7 @@ public Map<R, NavigableMap<Long, Object>> fetchFieldValues(R[] rowKeys, String f
609609
List<Get> gets = new ArrayList<>(rowKeys.length);
610610
for (R rowKey : rowKeys) {
611611
Get get = new Get(toBytes(rowKey));
612-
get.setMaxVersions(numVersionsToFetch);
612+
get.readVersions(numVersionsToFetch);
613613
get.addColumn(hbColumn.familyBytes(), hbColumn.columnBytes());
614614
gets.add(get);
615615
}

src/main/java/com/flipkart/hbaseobjectmapper/HBObjectMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
import com.flipkart.hbaseobjectmapper.codec.Codec;
55
import com.flipkart.hbaseobjectmapper.codec.exceptions.DeserializationException;
66
import com.flipkart.hbaseobjectmapper.codec.exceptions.SerializationException;
7-
import com.flipkart.hbaseobjectmapper.exceptions.*;
87
import com.flipkart.hbaseobjectmapper.exceptions.InternalError;
8+
import com.flipkart.hbaseobjectmapper.exceptions.*;
99
import org.apache.hadoop.hbase.Cell;
1010
import org.apache.hadoop.hbase.CellUtil;
1111
import org.apache.hadoop.hbase.HConstants;

0 commit comments

Comments
 (0)