Environment:
hadoop:hadoop-2.2.0
hbase:hbase-0.96.0
1.org.apache.hadoop.hbase.client.put
<1> canceling the parameterless construction method
<2>put class no longer inherits writable class
0.94.6 the public class put extends Mutation implements HeapSize, writable, comparable<row>
0.96.0 when public class put extends Mutation implements HeapSize, comparable<row>
Workaround:
By the public class Monthuserlogintimeindexreducer extends Reducer<byteswritable,monthuserlogintimeindexwritable, Immutablebyteswritable, writable> {
Change public class Monthuserlogintimeindexreducer extends Reducer<byteswritable,monthuserlogintimeindexwritable, Immutablebyteswritable, put> {
2.org.apache.hadoop.hbase.client.mutation.familymap
ORG.APACHE.HADOOP.HBASE.CLIENT.MUTATION.FAMILYMAP Type change:
/**
* 0.94.6
* Protected map<byte[],list<keyvalue>> Familymap
*
* 0.96.*
* Protected navigablemap<byte[],list<cell>> Familymap
* Org.apache.hadoop.hbase.Cell hbase-0.94.* is not in the
*/
Changes in Org.apache.hadoop.hbase.KeyValue:
/**
* 0.94.*
* Public class KeyValue extends Object implements writable, HeapSize
*
* 0.96.0
* Public class KeyValue extends Object implements Cell, HeapSize, cloneable
*/
Workaround: Change the list<keyvalue> in the code to list<cell>
3. Org.apache.hadoop.hbase.KeyValue
0.96.0 method getfamily has been discarded (deprecated) and converted to Method Getfamilyarray ()
4.org.apache.hadoop.hbase.htabledescriptor
The constructor for class Org.apache.hadoop.hbase.HTableDescriptor public htabledescriptor (String name) has been deprecated (deprecated)
Workaround: Use public htabledescriptor (tablename name)
Old: Htabledescriptor Tabledesc = new Htabledescriptor (tablename);
Htabledescriptor Tabledesc = new Htabledescriptor (tablename.valueof (tablename));
5.org.apache.hadoop.hbase.client.htablepool
Class Org.apache.hadoop.hbase.client.HTablePool entire deprecated (deprecated)
Workaround: Use Hconnection.gettable (String) instead, Hconnection is an interface, and class coprocessorhconnection is its only implementation class:
Hregionserver hregionserver = new Hregionserver (conf);
Hconnection connection = hconnectionmanager.createconnection (conf);
Hconnection = new Coprocessorhconnection (connection,hregionserver);
6.org.apache.hadoop.hbase.client.result
Method public keyvalue[] Raw () is deprecated (deprecated), it is recommended to use public cell[] Rawcells ()
Method GetRow is deprecated (deprecated)
Method getfamily is deprecated (deprecated)
Method Getqualifier is deprecated (deprecated)
Method GetValue is deprecated (deprecated)
Method public list<keyvalue> GetColumn (byte[] family,byte[] qualifier) deprecated (deprecated)
Method public KeyValue Getcolumnlatest (byte[] family,byte[] qualifier) deprecated (deprecated)
Cell: Change to the following method
Getrowarray ()
Getfamilyarray ()
Getqualifierarray ()
Getvaluearray ()
Result: Add the following method
Public list<keyvalue> getcolumncells (byte[] family,byte[] qualifier)
Public KeyValue Getcolumnlatestcell (byte[] family,byte[] qualifier)
Changes: All Ipeijian_data and "new users active users lost users" are related to the following changes:
Old code: if (Value.raw (). length = = 1
New code: if (Value.rawcells (). length = = 1
Set Tableinputformat.scan in 7.job
The method is removed in 0.96.0: public void Write (DataOutput out) throws IOException
Previous versions use Conf.set (Tableinputformat.scan, statutils.convertscantostring (SCAN));
The specific implementation of statutils.convertscantostring is:
public static String convertscantostring (Scan Scan) throws IOException {
Bytearrayoutputstream out = new Bytearrayoutputstream ();
DataOutputStream dos = new DataOutputStream (out);
Scan.write (Dos);
Return Base64.encodebytes (Out.tobytearray ());
}
The implementation of this method is the same as tablemapreduceutil.convertscantostring (Scan Scan).
But when HBase upgrades to 0.96.* is for class scan discard (not just deprecated, but deleted) method write, so above
Implementation becomes incorrect
This method is implemented in hbase0.96.*:
public static String convertscantostring (Scan Scan) throws IOException {
Clientprotos.scan proto = Protobufutil.toscan (Scan);
Return Base64.encodebytes (Proto.tobytearray ());
}
So make the following changes:
The implementation of method convertscantostring in the Statutils class is changed to fit the hbase0.96.*
8.cn.m15.ipj.db.hbase.myput
Custom put class, more than the traditional put class one length, the original and the new version of the Code comparison:
Original: (red font for the API into the new times the wrong place)
public class Myput extends put {
Public Myput (byte[] row, int length) {
The reason is that put's parameterless construction method has disappeared in the new book.
if (row = null | | | length > Hconstants.max_row_length) {
throw new IllegalArgumentException ("Row key is invalid");
}
This.row = arrays.copyof (row, length);
This.ts = Hconstants.latest_timestamp;
}
Public myput Add (byte[] family, byte[] qualifier, long ts, byte[] value,int length) {
list<keyvalue> list = getkeyvaluelist (family);
KeyValue kv = createputkeyvalue (family, qualifier, TS, value, length);
List.add (KV);
Familymap.put (kv.getfamily (), list);
The type of familymap has changed
return this;
}
Private list<keyvalue> getkeyvaluelist (byte[] family) {
list<keyvalue> list = Familymap.get (family);
The type of familymap has changed
if (list = = null) {
List = new arraylist<keyvalue> (0);
}
return list;
}
Private KeyValue Createputkeyvalue (byte[] family, byte[] Qualifier,long ts, byte[] value, int length) {
return new KeyValue (This.row, 0, This.row.length, family, 0,
Family.length, qualifier, 0, qualifier.length, TS,
KeyValue.Type.Put, value, 0, length);
}
}
After the change:
Public Myput (byte[] row, int length) {
Super (Row,length);
New additions
if (row = null | | | length > Hconstants.max_row_length) {
throw new IllegalArgumentException ("Row key is invalid");
}
This.row = arrays.copyof (row, length);
This.ts = Hconstants.latest_timestamp;
}
Public myput Add (byte[] family, byte[] qualifier, long ts, byte[] value,int length) {
list<cell> list = getcellslist (family);
KeyValue kv = createputkeyvalue (family, qualifier, TS, value, length);
List.add (KV);
Familymap.put (cellutil.clonefamily (KV), list);
return this;
}
Private list<cell> getcellslist (byte[] family) {
list<cell> list = Familymap.get (family);
if (list = = null) {
List = new arraylist<cell> (0);
}
return list;
}
Private KeyValue Createputkeyvalue (byte[] family, byte[] Qualifier,long ts, byte[] value, int length) {
return new KeyValue (This.row, 0, This.row.length, family, 0,family.length, qualifier, 0, qualifier.length, TS,
KeyValue.Type.Put, value, 0, length);
}
}