tabletIters.add(in);
}
MultiIterator multiIter = new MultiIterator(tabletIters, ke);
DeletingIterator delIter = new DeletingIterator(multiIter, false);
VersioningIterator tabletIter = new VersioningIterator(delIter, 1);
tabletIter.seek(new Range(), LocalityGroupUtil.EMPTY_CF_SET, false);
TreeMap<Key,Value> tm = new TreeMap<Key,Value>();
while (tabletIter.hasTop()) {
Key key = tabletIter.getTopKey();
Value val = tabletIter.getTopValue();
// System.out.println("ORIG "+key+" "+val);
try {
if (key.getRow().getLength() > 0 && key.getRow().getBytes()[0] == '~') {
flushRow(out, tm, maxTime);
if (key.getRow().toString().startsWith("~del")) {
if (!key.getRow().toString().startsWith("~del/!METADATA")) {
String path = key.getRow().toString().substring(4);
path = converFileName(path).toString();
String[] tokens = path.split("/");
tokens[1] = tableIds.get(tokens[1]);
path = StringUtil.join(Arrays.asList(tokens), "/");
Key newKey = new Key(new Text("~del" + path));
newKey.setTimestamp(key.getTimestamp());
out.append(newKey, val);
}
} else {
out.append(key, val);
}
} else {
Key newKey = translateKey(key, colQualMap, tableIds);
if (newKey.getColumnFamily().equals(Constants.METADATA_DATAFILE_COLUMN_FAMILY) && !newKey.isDeleted()) {
val = rencodeDatafileValue(val);
} else if (Constants.METADATA_PREV_ROW_COLUMN.equals(newKey.getColumnFamily(), newKey.getColumnQualifier())) {
Text per = KeyExtent.decodePrevEndRow(val);
if (per == null)
val = new Value(val.get(), true);
else if (new KeyExtent(newKey.getRow(), (Text) null).getTableId().toString().equals(Constants.METADATA_TABLE_ID) && per.getBytes()[0] != '~')
val = KeyExtent.encodePrevEndRow(translateRow(per, tableIds));
else
val = new Value(val.get(), true);
} else {
val = new Value(val.get(), true);
}
if (tm.size() > 0 && !tm.lastKey().getRow().equals(newKey.getRow())) {
flushRow(out, tm, maxTime);
}
tm.put(newKey, val);
}
} catch (Exception e) {
System.err.println("Failed to convert !METADATA entry " + key + " " + val);
throw e;
}
tabletIter.next();
}
flushRow(out, tm, maxTime);
}