metadata.setBatchSize(1000 * 1000);
metadata.setRange(Constants.METADATA_KEYSPACE);
metadata.fetchColumnFamily(Constants.METADATA_DATAFILE_COLUMN_FAMILY);
int count = 0;
int missing = 0;
Writer writer = MetadataTable.getMetadataTable(SecurityConstants.getSystemCredentials());
for (Entry<Key,Value> entry : metadata) {
count++;
Key key = entry.getKey();
String table = new String(KeyExtent.tableOfMetadataRow(entry.getKey().getRow()));
Path map = new Path(ServerConstants.getTablesDir() + "/" + table + key.getColumnQualifier().toString());
if (!fs.exists(map)) {
missing++;
log.info("File " + map + " is missing");
Mutation m = new Mutation(key.getRow());
m.putDelete(key.getColumnFamily(), key.getColumnQualifier());
if (args.length > 4) {
writer.update(m);
log.info("entry removed from metadata table: " + m);
}
}
}
log.info(String.format("%d files of %d missing", missing, count));