Java Code Examples for org.apache.hadoop.hbase.client.HTable#getConfiguration()

The following examples show how to use org.apache.hadoop.hbase.client.HTable#getConfiguration() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HalyardTableUtils.java    From Halyard with Apache License 2.0 6 votes vote down vote up
/**
 * Truncates HTable while preserving the region pre-splits
 * @param table HTable to truncate
 * @return new instance of the truncated HTable
 * @throws IOException throws IOException in case of any HBase IO problems
 */
public static HTable truncateTable(HTable table) throws IOException {
    Configuration conf = table.getConfiguration();
    byte[][] presplits = table.getRegionLocator().getStartKeys();
    if (presplits.length > 0 && presplits[0].length == 0) {
        presplits = Arrays.copyOfRange(presplits, 1, presplits.length);
    }
    HTableDescriptor desc = table.getTableDescriptor();
    table.close();
    try (Connection con = ConnectionFactory.createConnection(conf)) {
        try (Admin admin = con.getAdmin()) {
            admin.disableTable(desc.getTableName());
            admin.deleteTable(desc.getTableName());
            admin.createTable(desc, presplits);
        }
    }
    return HalyardTableUtils.getTable(conf, desc.getTableName().getNameAsString(), false, 0);
}
 
Example 2
Source File: RegionSizeCalculator.java    From tajo with Apache License 2.0 5 votes vote down vote up
/**
 * Computes size of each region for table and given column families.
 *
 * @deprecated Use {@link #RegionSizeCalculator(RegionLocator, Admin)} instead.
 */
@Deprecated
public RegionSizeCalculator(HTable table) throws IOException {
  HBaseAdmin admin = new HBaseAdmin(table.getConfiguration());
  try {
    init(table, admin);
  } finally {
    admin.close();
  }
}
 
Example 3
Source File: HBaseRecordReaderBase.java    From SpyGlass with Apache License 2.0 5 votes vote down vote up
/**
 * @param htable
 *          the {@link org.apache.hadoop.hbase.client.HTable} to scan.
 */
public void setHTable(HTable htable) {
    Configuration conf = htable.getConfiguration();
    logScannerActivity = conf.getBoolean(ScannerCallable.LOG_SCANNER_ACTIVITY,
            false);
    logPerRowCount = conf.getInt(LOG_PER_ROW_COUNT, 100);
    this.htable = htable;
}
 
Example 4
Source File: HBaseRegionSizeCalculator.java    From Kylin with Apache License 2.0 4 votes vote down vote up
/**
 * Computes size of each region for table and given column families.
 * */
public HBaseRegionSizeCalculator(HTable table) throws IOException {
    this(table, new HBaseAdmin(table.getConfiguration()));
}