Differences between revisions 5 and 6
Revision 5 as of 2009-09-20 23:55:06
Size: 6948
Editor: localhost
Comment: converted to 1.6 markup
Revision 6 as of 2015-10-23 07:24:31
Size: 192
Editor: Misty
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
= Changes to HBaseAdmin and HTable between HBase 0.1.3 and 0.2 =

== General Changes ==

The APIs for both `HBaseAdmin` and `HTable` have significantly changed between versions 0.1.3 and 0.2.x. 0.2.x is NOT backward-compatible. The following document summarizes the key differences that are most important for developers wishing to use these classes. For more information, see the full API documentations for [[http://hadoop.apache.org/hbase/docs/current/api/index.html|0.1.3]] and [0.2].

A general difference in both `HBaseAdmin` and `HTable` is a transition away from using Hadoop's `Text` class (package `org.apache.hadoop.io`) and toward using `byte[]` as a replacement. All methods from 0.1.3 that returned either `Text` or `Text[]` now return either `byte[]` or `byte[][]` or the fatter `RowResult`. HBase 0.2 has not completely abandoned the use of `Text`. All methods that once accepted parameters of type `Text` are now overloaded to support `Text`, `String`, or `byte[]` as parameters. The following API changes from `HBaseAdmin` demonstrate this overloading:

''0.1.3:''
<<BR>> {{{public void addColumn(Text, HColumnDescriptor);}}}
<<BR>> {{{public void deleteColumn(Text, Text);}}}

''0.2:''
<<BR>> {{{public void addColumn(Text, HColumnDescriptor);}}}
<<BR>> {{{public void addColumn(String, HColumnDescriptor);}}}
<<BR>> {{{public void addColumn(byte[], HColumnDescriptor);}}}
<<BR>> {{{public void deleteColumn(Text, Text);}}}
<<BR>> {{{public void deleteColumn(String, String);}}}
<<BR>> {{{public void deleteColumn(byte[], byte[]);}}}

== HBaseAdmin ==

Aside from the method overloading described above, `HBaseAdmin` has not significantly changed. HBase 0.2 adds the following new methods to `HBaseAdmin`:

''0.2:''
<<BR>> {{{public boolean isTableEnabled(Text);}}}
<<BR>> {{{public boolean isTableEnabled(String);}}}
<<BR>> {{{public boolean isTableEnabled(byte[]);}}}
<<BR>> {{{public void modifyTableMeta(byte[] HTableDescriptor);}}}

The only method in `HBaseAdmin` from 0.1.3 that no longer exists in HBase 0.2 is `checkReservedTableName(Text)`. These changes aside, the API and functional capability of `HBaseAdmin` has not drastically changed between versions 0.1.3 and 0.2.

== HTable ==

`HTable` has experienced far more significant changes to its API and functional capability. The biggest change is the way in which row updates are performed. In HBase 0.1.3, `HTable` had its own support for atomic row insertions and changes. The following methods existed in `HTable` and aided the row updating process:

''0.1.3:''
<<BR>> {{{public synchronized long startUpdate(Text);}}}
<<BR>> {{{public void put(long, Text, byte[]);}}}
<<BR>> {{{public void put(long, Text, Writable);}}}
<<BR>> {{{public void delete(long, Text);}}}
<<BR>> {{{public synchronized void checkUpdateInProgress();}}}
<<BR>> {{{public synchronized void abort(long);}}}
<<BR>> {{{public synchronized void commit(long, long);}}}
<<BR>> {{{public void commit(long);}}}

`startUpdate(Text)` was used to start an atomic row update on the passed row name, and a "lock id" (`long`) was returned to identify the update. `put(...)` and `delete(...)` could be called using the lock id, and any changes made with that lock id could be aborted or committed.

HBase 0.2 has completely changed the way in which atomic row updates take place. To update a row, the user first creates a `BatchUpdate` object. `put(...)` and `delete(...)` operations are applied to the `BatchUpdate`, not the `HTable`. Once finished, the user commits the `BatchUpdate` with one of the following new `HTable` methods:

''0.2:''
<<BR>> {{{public synchronized void commit(BatchUpdate);}}}
<<BR>> {{{public synchronized void commit(List<BatchUpdate>);}}}

Aside from the transition from Text toward `byte[]` and the addition of the `BatchUpdate` structure, `HTable` has experienced a number of other API changes:

 * In 0.1.3, package-private `getRegionLocation(...)` took parameters of either `(Text)` or `(Text, boolean)`. In 0.2, `getRegionLocation(...)` has become public and only accepts parameters of either `(Text)`, `(String)`, or `(byte[])`; the boolean "reload" option no longer exists.
 * In 0.1.3, the `HTable` constructor took parameters of either `(HBaseConfiguration, Text)`. In 0.2, the `HBaseConfiguration` parameter has become optional and as such there are now 6 different constructors (with or without the `HBaseConfiguration` parameter, and with the `Text` parameter varying as either `Text`, `String`, or `byte[]`).
 * `public HTableDescriptor getMetadata()` has been replaced in 0.2 by `public HTableDescriptor getTableDescriptor()`; `getMetadata()` still exists in 0.2, although it is marked as deprecated. Additionally, both `getTableDescriptor()` and `getMetadata()` now return `UnmodifyableHTableDescriptor` (new to 0.2, package `org.apache.hadoop.hbase.client`, a subclass of `HTableDescriptor`), although the return type of both methods is still `HTableDescriptor`.
 * In 0.1.3, all `get(...)` methods had a return type of `byte[]`. In 0.2, these methods now return a `Cell` (new to 0.2, package `org.apache.hadoop.hbase.io`).
 * In 0.1.3, all `getRow(...)` methods had a return type of `SortedMap<Text, byte[]>`. In 0.2, these methods now return a `RowResult` (new to 0.2, package `org.apache.hadoop.hbase.io`).
 * The methods `obtainScanner(...)` from 0.1.3 have been renamed `getScanner(...)` in 0.2. Moreover, `getScanner(...)` has a return type of `Scanner` (new to 0.2, package `org.apache.hadoop.hbase.client`), whereas `obtainScanner(...)` had a return type of `HScannerInterface` (a class that no longer exists in 0.2).
 * In 0.1.3, `deteleFamily(...)` took parameters of either `(Text, Text, long)` or `(Text, Text)`. In 0.2, `deleteFamily(...)` only accepts parameters of either `(Text, Text, long)`, `(String, String, long)`, or `(byte[], byte[], long)`; the long "timestamp" must be included as a parameter.
 * The `HTable` subclass `ServerCallable<T>` from 0.1.3 has been moved to its own separate class in 0.2, located in package `org.apache.hadoop.hbase.client`.
 * The method `getRegionServerWithRetries(ServerCallable<T>)` from 0.1.3 has been moved to the `HConnection` interface in 0.2.

Finally, the following methods have been added to `HTable` in HBase 0.2:

''0.2:''
<<BR>> {{{public static boolean isTableEnabled(Text);}}}
<<BR>> {{{public static boolean isTableEnabled(String);}}}
<<BR>> {{{public static boolean isTableEnabled(byte[]);}}}
<<BR>> {{{public static boolean isTableEnabled(HBaseConfiguration, Text);}}}
<<BR>> {{{public static boolean isTableEnabled(HBaseConfiguration, String);}}}
<<BR>> {{{public static boolean isTableEnabled(HBaseConfiguration, byte[]);}}}

Once again, for greater detail on API changes to `HBaseAdmin`, `HTable`, and all classes new to HBase 0.2, please refer to the [HBase 0.2 API].
The HBase Wiki is in the process of being decommissioned. The info that used to be on this page has moved to http://hbase.apache.org/book.html#hbase.versioning. Please update your bookmarks.

The HBase Wiki is in the process of being decommissioned. The info that used to be on this page has moved to http://hbase.apache.org/book.html#hbase.versioning. Please update your bookmarks.

Hbase/Plan-0.2/APIChanges (last edited 2015-10-23 07:24:31 by Misty)