org.apache.hadoop.hbase.util.RegionSplitter#SplitAlgorithm ( )源码实例Demo

下面列出了org.apache.hadoop.hbase.util.RegionSplitter#SplitAlgorithm ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: hbase-tools   文件: DecimalStringSplitTest.java
@Test
public void testSplit300_1000() throws Exception {
    int numRegions = 300;
    int cardinality = 1000;

    RegionSplitter.SplitAlgorithm splitAlgorithm = new DecimalStringSplit(cardinality);
    byte[][] splits = splitAlgorithm.split(numRegions);
    assertEquals(numRegions - 1, splits.length);

    int digits = 4;
    assertEquals(String.format("%0" + digits + "d", 3), Bytes.toString(splits[0]));
    assertEquals(String.format("%0" + digits + "d", 6), Bytes.toString(splits[1]));
    assertEquals(String.format("%0" + digits + "d", 10), Bytes.toString(splits[2]));
    assertEquals(String.format("%0" + digits + "d", 996), Bytes.toString(splits[numRegions - 2]));
}
 
源代码2 项目: hbase-tools   文件: DecimalStringSplitTest.java
@Test
public void testSplit3_10() throws Exception {
    int numRegions = 3;
    int cardinality = 10;

    RegionSplitter.SplitAlgorithm splitAlgorithm = new DecimalStringSplit(cardinality);
    byte[][] splits = splitAlgorithm.split(numRegions);
    assertEquals(numRegions - 1, splits.length);

    int digits = 2;
    assertEquals(String.format("%0" + digits + "d", 3), Bytes.toString(splits[0]));
    assertEquals(String.format("%0" + digits + "d", 6), Bytes.toString(splits[numRegions - 2]));
}
 
源代码3 项目: hbase-tools   文件: DecimalStringSplitTest.java
@Test
public void testSplit10_10() throws Exception {
    int numRegions = 10;
    int cardinality = 10;

    RegionSplitter.SplitAlgorithm splitAlgorithm = new DecimalStringSplit(cardinality);
    byte[][] splits = splitAlgorithm.split(numRegions);
    assertEquals(numRegions - 1, splits.length);

    int digits = 2;
    assertEquals(String.format("%0" + digits + "d", 1), Bytes.toString(splits[0]));
    assertEquals(String.format("%0" + digits + "d", 9), Bytes.toString(splits[numRegions - 2]));
}
 
源代码4 项目: hbase-tools   文件: DecimalStringSplitTest.java
@Test
public void testSplit10_10() throws Exception {
    int numRegions = 10;
    int cardinality = 10;

    RegionSplitter.SplitAlgorithm splitAlgorithm = new DecimalStringSplit(cardinality);
    byte[][] splits = splitAlgorithm.split(numRegions);
    assertEquals(numRegions - 1, splits.length);

    int digits = 2;
    assertEquals(String.format("%0" + digits + "d", 1), Bytes.toString(splits[0]));
    assertEquals(String.format("%0" + digits + "d", 9), Bytes.toString(splits[numRegions - 2]));
}
 
源代码5 项目: hbase-tools   文件: DecimalStringSplitTest.java
@Test
public void testSplit10_10() throws Exception {
    int numRegions = 10;
    int cardinality = 10;

    RegionSplitter.SplitAlgorithm splitAlgorithm = new DecimalStringSplit(cardinality);
    byte[][] splits = splitAlgorithm.split(numRegions);
    assertEquals(numRegions - 1, splits.length);

    int digits = 2;
    assertEquals(String.format("%0" + digits + "d", 1), Bytes.toString(splits[0]));
    assertEquals(String.format("%0" + digits + "d", 9), Bytes.toString(splits[numRegions - 2]));
}
 
源代码6 项目: hbase-tools   文件: DecimalStringSplitTest.java
@Test
public void testSplit3_10() throws Exception {
    int numRegions = 3;
    int cardinality = 10;

    RegionSplitter.SplitAlgorithm splitAlgorithm = new DecimalStringSplit(cardinality);
    byte[][] splits = splitAlgorithm.split(numRegions);
    assertEquals(numRegions - 1, splits.length);

    int digits = 2;
    assertEquals(String.format("%0" + digits + "d", 3), Bytes.toString(splits[0]));
    assertEquals(String.format("%0" + digits + "d", 6), Bytes.toString(splits[numRegions - 2]));
}
 
源代码7 项目: hbase   文件: TableSnapshotInputFormatImpl.java
public static RegionSplitter.SplitAlgorithm getSplitAlgo(Configuration conf) throws IOException {
  String splitAlgoClassName = conf.get(SPLIT_ALGO);
  if (splitAlgoClassName == null) {
    return null;
  }
  try {
    return Class.forName(splitAlgoClassName).asSubclass(RegionSplitter.SplitAlgorithm.class)
        .getDeclaredConstructor().newInstance();
  } catch (ClassNotFoundException | InstantiationException | IllegalAccessException |
      NoSuchMethodException | InvocationTargetException e) {
    throw new IOException("SplitAlgo class " + splitAlgoClassName + " is not found", e);
  }
}
 
源代码8 项目: hbase-tools   文件: DecimalStringSplitTest.java
@Test
public void testSplit10_10() throws Exception {
    int numRegions = 10;
    int cardinality = 10;

    RegionSplitter.SplitAlgorithm splitAlgorithm = new DecimalStringSplit(cardinality);
    byte[][] splits = splitAlgorithm.split(numRegions);
    assertEquals(numRegions - 1, splits.length);

    int digits = 2;
    assertEquals(String.format("%0" + digits + "d", 1), Bytes.toString(splits[0]));
    assertEquals(String.format("%0" + digits + "d", 9), Bytes.toString(splits[numRegions - 2]));
}
 
源代码9 项目: hbase-tools   文件: Split.java
@Override
public RegionSplitter.SplitAlgorithm createSplitter(int cardinality) {
    return new RegionSplitter.UniformSplit();
}
 
源代码10 项目: hbase-tools   文件: Split.java
@Override
public RegionSplitter.SplitAlgorithm createSplitter(int cardinality) {
    return new RegionSplitter.HexStringSplit();
}
 
源代码11 项目: hbase-tools   文件: Split.java
@Override
public RegionSplitter.SplitAlgorithm createSplitter(int cardinality) {
    return new RegionSplitter.UniformSplit();
}
 
源代码12 项目: hbase-tools   文件: Split.java
public List<byte[]> split(int numRegions, int cardinality) {
    List<byte[]> splitPointList = new ArrayList<>();
    RegionSplitter.SplitAlgorithm splitter = createSplitter(cardinality);
    Collections.addAll(splitPointList, splitter.split(numRegions));
    return splitPointList;
}
 
源代码13 项目: hbase-tools   文件: Split.java
@Override
public RegionSplitter.SplitAlgorithm createSplitter(int cardinality) {
    return new DecimalStringSplit(cardinality);
}
 
源代码14 项目: hbase-tools   文件: Split.java
@Override
public RegionSplitter.SplitAlgorithm createSplitter(int cardinality) {
    return new RegionSplitter.UniformSplit();
}
 
源代码15 项目: hbase-tools   文件: Split.java
@Override
public RegionSplitter.SplitAlgorithm createSplitter(int cardinality) {
    return new RegionSplitter.HexStringSplit();
}
 
源代码16 项目: hbase-tools   文件: Split.java
@Override
public RegionSplitter.SplitAlgorithm createSplitter(int cardinality) {
    return new RegionSplitter.HexStringSplit();
}
 
源代码17 项目: hbase-tools   文件: Split.java
@Override
public RegionSplitter.SplitAlgorithm createSplitter(int cardinality) {
    return new DecimalStringSplit(cardinality);
}
 
源代码18 项目: hbase   文件: TableMapReduceUtil.java
/**
 * Sets up the job for reading from a table snapshot. It bypasses hbase servers
 * and read directly from snapshot files.
 *
 * @param snapshotName The name of the snapshot (of a table) to read from.
 * @param scan  The scan instance with the columns, time range etc.
 * @param mapper  The mapper class to use.
 * @param outputKeyClass  The class of the output key.
 * @param outputValueClass  The class of the output value.
 * @param job  The current job to adjust.  Make sure the passed job is
 * carrying all necessary HBase configuration.
 * @param addDependencyJars upload HBase jars and jars for any of the configured
 *           job classes via the distributed cache (tmpjars).
 *
 * @param tmpRestoreDir a temporary directory to copy the snapshot files into. Current user should
 * have write permissions to this directory, and this should not be a subdirectory of rootdir.
 * After the job is finished, restore directory can be deleted.
 * @param splitAlgo algorithm to split
 * @param numSplitsPerRegion how many input splits to generate per one region
 * @throws IOException When setting up the details fails.
 * @see TableSnapshotInputFormat
 */
public static void initTableSnapshotMapperJob(String snapshotName, Scan scan,
                                              Class<? extends TableMapper> mapper,
                                              Class<?> outputKeyClass,
                                              Class<?> outputValueClass, Job job,
                                              boolean addDependencyJars, Path tmpRestoreDir,
                                              RegionSplitter.SplitAlgorithm splitAlgo,
                                              int numSplitsPerRegion)
        throws IOException {
  TableSnapshotInputFormat.setInput(job, snapshotName, tmpRestoreDir, splitAlgo,
          numSplitsPerRegion);
  initTableMapperJob(snapshotName, scan, mapper, outputKeyClass,
          outputValueClass, job, addDependencyJars, false, TableSnapshotInputFormat.class);
  resetCacheConfig(job.getConfiguration());
}
 
源代码19 项目: hbase   文件: TableSnapshotInputFormat.java
/**
* Configures the job to use TableSnapshotInputFormat to read from a snapshot.
* @param job the job to configure
* @param snapshotName the name of the snapshot to read from
* @param restoreDir a temporary directory to restore the snapshot into. Current user should
* have write permissions to this directory, and this should not be a subdirectory of rootdir.
* After the job is finished, restoreDir can be deleted.
* @param splitAlgo split algorithm to generate splits from region
* @param numSplitsPerRegion how many input splits to generate per one region
* @throws IOException if an error occurs
*/
public static void setInput(Job job, String snapshotName, Path restoreDir,
                            RegionSplitter.SplitAlgorithm splitAlgo, int numSplitsPerRegion) throws IOException {
  TableSnapshotInputFormatImpl.setInput(job.getConfiguration(), snapshotName, restoreDir,
          splitAlgo, numSplitsPerRegion);
}
 
源代码20 项目: hbase   文件: TableSnapshotInputFormat.java
/**
 * Configures the job to use TableSnapshotInputFormat to read from a snapshot.
 * @param job the job to configure
 * @param snapshotName the name of the snapshot to read from
 * @param restoreDir a temporary directory to restore the snapshot into. Current user should
 * have write permissions to this directory, and this should not be a subdirectory of rootdir.
 * After the job is finished, restoreDir can be deleted.
 * @param splitAlgo split algorithm to generate splits from region
 * @param numSplitsPerRegion how many input splits to generate per one region
 * @throws IOException if an error occurs
 */
public static void setInput(JobConf job, String snapshotName, Path restoreDir,
                            RegionSplitter.SplitAlgorithm splitAlgo, int numSplitsPerRegion) throws IOException {
  TableSnapshotInputFormatImpl.setInput(job, snapshotName, restoreDir, splitAlgo, numSplitsPerRegion);
}