GET operation for HBase source code analysis converts get to scan1, or you should first look at the constructor publicGet (byte [] row) {this (row, null);} publicGe
For HBase source code analysis, convert GET to scan 1 by using the get operation. Let's take a look at the constructor public Get (byte [] row) {this (row, null);} public Ge
HBase source code analysis-GET operation-to-scan Conversion
1. Let's look at the constructor first.
Public Get (byte [] row ){
This (row, null );
}
Public Get (byte [] row, RowLock rowLock ){
This. row = row;
If (rowLock! = Null ){
This. lockId = rowLock. getLockId ();
}
}
Public Get addFamily (byte [] family ){
FamilyMap. remove (family );
FamilyMap. put (family, null );
Return this;
}
Public Get addColumn (byte [] family, byte [] qualifier ){
NavigableSet Set = familyMap. get (family );
If (set = null ){
Set = new TreeSet (Bytes. BYTES_COMPARATOR );
}
Set. add (qualifier );
FamilyMap. put (family, set );
Return this;
Public Get addColumn (final byte [] column ){
If (column = null) return this;
Byte [] [] split = KeyValue. parseColumn (column );
If (split. length> 1 & split [1]! = Null & split [1]. length> 0 ){
AddColumn (split [0], split [1]);
} Else {
AddFamily (split [0]);
}
Return this;
}
2. The get method in HTable. java actually calls the get method of HregionServer.
Public Result get (final Get) throws IOException {
Return connection. getRegionServerWithRetries (
New ServerCallable (Connection, tableName, get. getRow ()){
Public Result call () throws IOException {
Return server. get (location. getRegionInfo (). getRegionName (), get );
}
}
);
}
3. Let's take a look at HregionServer. java.
/** {@ InheritDoc }*/
Public Result get (byte [] regionName, Get get) throws IOException {
CheckOpen ();
RequestCount. incrementAndGet ();
Try {
HRegion region = getRegion (regionName );
Return region. get (get, getLockFromId (get. getLockId ()));
} Catch (Throwable t ){
Throw convertThrowableToIOE (cleanup (t ));
}
}
Let's take a look at the get method of Hregion:
1) First, check the family to ensure that the family in the Table is consistent with that in get.
Public Result get (final Get, final Integer lockid) throws IOException {
// Verify families are all valid
If (get. hasFamilies ()){
For (byte [] family: get. familySet ()){
CheckFamily (family );
}
} Else {// Adding all families to your
For (byte [] family: regionInfo. getTableDesc (). getFamiliesKeys ()){
Get. addFamily (family );
}
}
List Result = get (get );
Return new Result (result );
}
The final GET is actually converted to scan.
/*
* Do a get based on the get parameter.
*/
Private List Get (final Get) throws IOException {
Scan scan = new Scan (get );
List Results = new ArrayList ();
Internal1_timeout = null;
Try {
Rows = getrows (scan );
Response. next (results );
} Finally {
If (response! = Null)
Response. close ();
}
Return results;
}