@Override public void run() { long startTime, endTime; HTableDescriptor desc = new HTableDescriptor(TABLE_NAME); desc.addFamily(new HColumnDescriptor(COLUMN_NAME)); SplitAlgorithm algo = new RegionSplitter.HexStringSplit(); byte[][] splits = algo.split(REGION_COUNT); LOG.info(String.format("Creating table %s with %d splits.", TABLE_NAME, REGION_COUNT)); startTime = System.currentTimeMillis(); try { admin.createTable(desc, splits); endTime = System.currentTimeMillis(); success = true; LOG.info( String.format("Pre-split table created successfully in %dms.", (endTime - startTime))); } catch (IOException e) { LOG.error("Failed to create table", e); } finally { doneSignal.countDown(); } }
private boolean splitFailsPrecondition(SplitAlgorithm algo, int numRegions) { try { byte[][] s = algo.split(numRegions); LOG.debug("split algo = " + algo); if (s != null) { StringBuilder sb = new StringBuilder(); for (byte[] b : s) { sb.append(Bytes.toStringBinary(b) + " "); } LOG.debug(sb.toString()); } return false; } catch (IllegalArgumentException e) { return true; } catch (IllegalStateException e) { return true; } catch (IndexOutOfBoundsException e) { return true; } }
private boolean splitFailsPrecondition( SplitAlgorithm algo, String firstRow, String lastRow, int numRegions) { algo.setFirstRow(firstRow); algo.setLastRow(lastRow); return splitFailsPrecondition(algo, numRegions); }