HBASE-4716 Addendum Use Preconditions and remove enum
git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1196749 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
0e32567cdd
commit
5721a5ac53
|
@ -2782,32 +2782,26 @@ public class HRegion implements HeapSize { // , Writable{
|
||||||
return lid;
|
return lid;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum COLUMN_FAMILY_TYPES {
|
|
||||||
NONE, // there is no column family
|
|
||||||
SINGLE,
|
|
||||||
MULTIPLE // there are more than one column family
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Determines the type of column family based on list of family/hfilePath pairs
|
* Determines whether multiple column families are present
|
||||||
|
* Precondition: familyPaths is not null
|
||||||
*
|
*
|
||||||
* @param familyPaths List of Pair<byte[] column family, String hfilePath>
|
* @param familyPaths List of Pair<byte[] column family, String hfilePath>
|
||||||
*/
|
*/
|
||||||
public static COLUMN_FAMILY_TYPES getColumnFamilyType(
|
private static boolean hasMultipleColumnFamilies(
|
||||||
List<Pair<byte[], String>> familyPaths) {
|
List<Pair<byte[], String>> familyPaths) {
|
||||||
if (familyPaths == null) return COLUMN_FAMILY_TYPES.NONE;
|
boolean multipleFamilies = false;
|
||||||
COLUMN_FAMILY_TYPES familyType = COLUMN_FAMILY_TYPES.SINGLE;
|
|
||||||
byte[] family = null;
|
byte[] family = null;
|
||||||
for (Pair<byte[], String> pair : familyPaths) {
|
for (Pair<byte[], String> pair : familyPaths) {
|
||||||
byte[] fam = pair.getFirst();
|
byte[] fam = pair.getFirst();
|
||||||
if (family == null) {
|
if (family == null) {
|
||||||
family = fam;
|
family = fam;
|
||||||
} else if (!Bytes.equals(family, fam)) {
|
} else if (!Bytes.equals(family, fam)) {
|
||||||
familyType = COLUMN_FAMILY_TYPES.MULTIPLE;
|
multipleFamilies = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return familyType;
|
return multipleFamilies;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2818,8 +2812,9 @@ public class HRegion implements HeapSize { // , Writable{
|
||||||
*/
|
*/
|
||||||
public void bulkLoadHFiles(List<Pair<byte[], String>> familyPaths)
|
public void bulkLoadHFiles(List<Pair<byte[], String>> familyPaths)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
|
Preconditions.checkNotNull(familyPaths);
|
||||||
// we need writeLock for multi-family bulk load
|
// we need writeLock for multi-family bulk load
|
||||||
startBulkRegionOperation(getColumnFamilyType(familyPaths) == COLUMN_FAMILY_TYPES.MULTIPLE);
|
startBulkRegionOperation(hasMultipleColumnFamilies(familyPaths));
|
||||||
this.writeRequestsCount.increment();
|
this.writeRequestsCount.increment();
|
||||||
List<IOException> ioes = new ArrayList<IOException>();
|
List<IOException> ioes = new ArrayList<IOException>();
|
||||||
List<Pair<byte[], String>> failures = new ArrayList<Pair<byte[], String>>();
|
List<Pair<byte[], String>> failures = new ArrayList<Pair<byte[], String>>();
|
||||||
|
|
Loading…
Reference in New Issue