@Override
public void restoreKeyValuesFromBackup(final String tableName, KeyValueBackup keyValueBackup)
throws IOException {
LOG.debug(String.format("Restoring '%s' key-value(s) from backup for table '%s'.",
keyValueBackup.getKeyValues().size(), tableName));
for (KeyValueBackupEntry kvRecord : keyValueBackup.getKeyValues()) {
final byte[] key = Bytes.toBytes(kvRecord.getKey());
final ByteBuffer valueBuffer = kvRecord.getValue();
byte[] value = new byte[valueBuffer.remaining()];
valueBuffer.get(value);
final long timestamp = kvRecord.getTimestamp();
LOG.debug(String.format("For the table '%s' we are writing to family '%s', qualifier '%s'"
+ ", timestamp '%s', and value '%s' to the" + " meta table named '%s'.", tableName,
Bytes.toString(mFamilyBytes), Bytes.toString(key), "" + timestamp, Bytes.toString(value),
Bytes.toString(mTable.getTableName())));
final Put put = new Put(Bytes.toBytes(tableName)).add(mFamilyBytes, key, timestamp, value);
mTable.put(put);
}
LOG.debug("Flushing commits to restore key-values from backup.");
mTable.flushCommits();
}
}