diff options
author | Antonios Chalkiopoulos <Antwnis@gmail.com> | 2014-05-22 22:04:44 +0100 |
---|---|---|
committer | Antonios Chalkiopoulos <Antwnis@gmail.com> | 2014-05-22 22:04:44 +0100 |
commit | 08e00dfce43244ec1edb0e2363a977fea985b454 (patch) | |
tree | 3ef8c08587edd2826c272c1277389bb7427aad66 /src/main/java/parallelai/spyglass/hbase/HBaseSalter.java | |
parent | ba87c17eed4e6f2d1e1b1d4644193485aae0bb4e (diff) | |
download | SpyGlass-08e00dfce43244ec1edb0e2363a977fea985b454.tar.gz SpyGlass-08e00dfce43244ec1edb0e2363a977fea985b454.zip |
Releasing 4.3 Spyglass for Scalding (0.9.1) and Scala (2.10)
Diffstat (limited to 'src/main/java/parallelai/spyglass/hbase/HBaseSalter.java')
-rw-r--r-- | src/main/java/parallelai/spyglass/hbase/HBaseSalter.java | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/main/java/parallelai/spyglass/hbase/HBaseSalter.java b/src/main/java/parallelai/spyglass/hbase/HBaseSalter.java index 5bdf8cd..b20fd89 100644 --- a/src/main/java/parallelai/spyglass/hbase/HBaseSalter.java +++ b/src/main/java/parallelai/spyglass/hbase/HBaseSalter.java @@ -1,7 +1,6 @@ package parallelai.spyglass.hbase; import java.io.IOException; -import java.util.ArrayList; import java.util.Arrays; import java.util.SortedSet; import java.util.TreeSet; @@ -13,6 +12,21 @@ import org.apache.hadoop.hbase.io.ImmutableBytesWritable; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Pair; +/** + * Use this Salter if you want maximum efficiency and speed when writing new data into HBase + * + * The 'Region Hot Spot' problem occurs when we are writing in an HBase table data, + * where the key is in sequential order. + * + * http://www.appfirst.com/blog/best-practices-for-managing-hbase-in-a-high-write-environment/ + * + * By using this salter we can prefix the keys with a character followed by an _ + * i.e. + * + * SCALDING -> G_SCALDING + * + * and thus distribute better the write load in the HBase cluster + */ public class HBaseSalter { private static final Log LOG = LogFactory.getLog(HBaseSalter.class); @@ -151,12 +165,10 @@ public class HBaseSalter { char[] prefixArray = prefixList.toCharArray(); return getAllKeysWithStartStop(originalKey, prefixList, (byte)prefixArray[0], stopKey); -// return getAllKeysWithStartStop(originalKey, prefixList, (byte)prefixArray[0], (byte)(stopKey - 1)); } public static byte[][] getAllKeysInRange(byte[] originalKey, String prefixList, byte startPrefix, byte stopPrefix) { return getAllKeysWithStartStop(originalKey, prefixList, startPrefix, stopPrefix); -// return getAllKeysWithStartStop(originalKey, prefixList, startPrefix, (byte)(stopPrefix - 1)); } private static byte[][] getAllKeysWithStartStop(byte[] originalKey, String prefixList, byte startPrefix, byte stopPrefix) { |