List of usage examples for org.apache.cassandra.io.sstable KeyIterator close
public void close()
From source file:com.cloudian.support.SSTableKeyWriter.java
License:Apache License
private void iterateKeys(int limit) throws IOException { KeyIterator itr = new KeyIterator(this.descriptor); int count = 0; while (itr.hasNext() && count < limit) { DecoratedKey key = itr.next();/*from w ww . java2 s. c o m*/ System.out.println(ByteBufferUtil.string(key.key)); count++; } itr.close(); }
From source file:net.imagini.cassandra.DumpSSTables.SSTableExport.java
License:Apache License
/** * Enumerate row keys from an SSTableReader and write the result to a * PrintStream./*from ww w . j a v a 2 s . c om*/ * * @param desc * the descriptor of the file to export the rows from * @param outs * PrintStream to write the output to * @throws IOException * on failure to read/write input/output */ public static void enumeratekeys(Descriptor desc, PrintStream outs) throws IOException { KeyIterator iter = new KeyIterator(desc); DecoratedKey lastKey = null; while (iter.hasNext()) { DecoratedKey key = iter.next(); // validate order of the keys in the sstable if (lastKey != null && lastKey.compareTo(key) > 0) throw new IOException("Key out of order! " + lastKey + " > " + key); lastKey = key; outs.println(ByteBufferUtil.string(key.key)); } iter.close(); outs.flush(); }