* @throws IOException on failure to read/write input/output
*/
public static void export(Descriptor desc, PrintStream outs, Collection<String> toExport, String[] excludes) throws IOException
{
SSTableReader reader = SSTableReader.open(desc);
SSTableScanner scanner = reader.getDirectScanner(null);
IPartitioner<?> partitioner = reader.partitioner;
if (excludes != null)
toExport.removeAll(Arrays.asList(excludes));
outs.println("[");
int i = 0;
// last key to compare order
DecoratedKey lastKey = null;
for (String key : toExport)
{
DecoratedKey decoratedKey = partitioner.decorateKey(hexToBytes(key));
if (lastKey != null && lastKey.compareTo(decoratedKey) > 0)
throw new IOException("Key out of order! " + lastKey + " > " + decoratedKey);
lastKey = decoratedKey;
scanner.seekTo(decoratedKey);
if (!scanner.hasNext())
continue;
SSTableIdentityIterator row = (SSTableIdentityIterator) scanner.next();
if (!row.getKey().equals(decoratedKey))
continue;
serializeRow(row, decoratedKey, outs);
if (i != 0)
outs.println(",");
i++;
}
outs.println("\n]");
outs.flush();
scanner.close();
}