Please include a diff instead, it's hard to compare.

Also I'm not sure there will be a 0.20.7.

-ryan

On Wed, Nov 24, 2010 at 3:45 PM, Ted Yu <yuzhih...@gmail.com> wrote:
> Hi,
> I wanted to automate the manual deletion of dangling row(s) in .META. table.
> Please kindly comment on the following modification to HMaster.createTable()
> which is base on 0.20.6 codebase:
>
>    long scannerid = srvr.openScanner(metaRegionName, scan);
>    try {
>        HashSet<byte[]> regions = new HashSet<byte[]>();
>        boolean cleanTable = false,        // whether the table has a row in
> .META. whose start key is empty
>                exists = false;
>        Result data = srvr.next(scannerid);
>        while (data != null) {
>            if (data != null && data.size() > 0) {
>                HRegionInfo info = Writables.getHRegionInfo(
>                        data.getValue(CATALOG_FAMILY,
> REGIONINFO_QUALIFIER));
>                if (info.getTableDesc().getNameAsString().equals(tableName))
> {
>                    exists = true;
>                    if (info.getStartKey().length == 0) {
>                        cleanTable = true;
>                    } else {
>                        regions.add(info.getRegionName());
>                    }
>                }
>            }
>            data = srvr.next(scannerid);
>        }
>        if (exists) {
>            if (!cleanTable) {
>                HTable meta = new HTable(HConstants.META_TABLE_NAME);
>                for (byte[] region : regions) {
>                    Delete d = new Delete(region);
>                    meta.delete(d);
>                    LOG.info("dangling row " + Bytes.toString(region) + "
> deleted from .META.");
>                }
>            } else {
>                // A region for this table already exists. Ergo table
> exists.
>                throw new TableExistsException(tableName);
>            }
>        }
>    } finally {
>      srvr.close(scannerid);
>    }
>
> Thanks
>

Reply via email to