From 5721a5ac53bfc205e746b89ada32d6ac441cd4f4 Mon Sep 17 00:00:00 2001 From: Zhihong Yu Date: Wed, 2 Nov 2011 18:35:52 +0000 Subject: [PATCH] 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 --- .../hadoop/hbase/regionserver/HRegion.java | 23 ++++++++----------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java b/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java index 95698fbb03f..acbf06a16b2 100644 --- a/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java +++ b/src/main/java/org/apache/hadoop/hbase/regionserver/HRegion.java @@ -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 */ - public static COLUMN_FAMILY_TYPES getColumnFamilyType( + private static boolean hasMultipleColumnFamilies( List> 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 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> 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 ioes = new ArrayList(); List> failures = new ArrayList>();