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:
Zhihong Yu 2011-11-02 18:35:52 +00:00
parent 0e32567cdd
commit 5721a5ac53
1 changed files with 9 additions and 14 deletions

View File

@ -2781,33 +2781,27 @@ public class HRegion implements HeapSize { // , Writable{
}
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>
*/
public static COLUMN_FAMILY_TYPES getColumnFamilyType(
private static boolean hasMultipleColumnFamilies(
List<Pair<byte[], String>> familyPaths) {
if (familyPaths == null) return COLUMN_FAMILY_TYPES.NONE;
COLUMN_FAMILY_TYPES familyType = COLUMN_FAMILY_TYPES.SINGLE;
boolean multipleFamilies = false;
byte[] family = null;
for (Pair<byte[], String> pair : familyPaths) {
byte[] fam = pair.getFirst();
if (family == null) {
family = fam;
} else if (!Bytes.equals(family, fam)) {
familyType = COLUMN_FAMILY_TYPES.MULTIPLE;
multipleFamilies = true;
break;
}
}
return familyType;
return multipleFamilies;
}
/**
@ -2818,8 +2812,9 @@ public class HRegion implements HeapSize { // , Writable{
*/
public void bulkLoadHFiles(List<Pair<byte[], String>> familyPaths)
throws IOException {
Preconditions.checkNotNull(familyPaths);
// we need writeLock for multi-family bulk load
startBulkRegionOperation(getColumnFamilyType(familyPaths) == COLUMN_FAMILY_TYPES.MULTIPLE);
startBulkRegionOperation(hasMultipleColumnFamilies(familyPaths));
this.writeRequestsCount.increment();
List<IOException> ioes = new ArrayList<IOException>();
List<Pair<byte[], String>> failures = new ArrayList<Pair<byte[], String>>();