List of usage examples for org.apache.cassandra.io.util RandomAccessReader readInt
@Override public int readInt() throws IOException
From source file:com.cloudian.support.RowFinder.java
License:Apache License
private void find() throws IOException { // get ColumnFamilyStore instance System.out.println("Opening keyspace " + ksName + " ..."); Keyspace keyspace = Keyspace.open(ksName); System.out.println("Opened keyspace " + ksName); System.out.println("Getting column family " + cfName + " ..."); ColumnFamilyStore cfStore = keyspace.getColumnFamilyStore(cfName); Collection<SSTableReader> ssTables = cfStore.getSSTables(); System.out.println("Got column family " + cfName); ByteBuffer buff = ByteBufferUtil.bytes(this.rowKey); IPartitioner<?> partitioner = cfStore.partitioner; System.out.println(this.rowKey + " is included in the following files"); System.out.println("=============================================================================="); System.out.println("FINE_NAME, COLUMN_INFO, CONTIGUOUS_TOMBSTONED_COLUMNS(over " + threshold + ")"); System.out.println("=============================================================================="); for (SSTableReader reader : ssTables) { if (reader.getBloomFilter().isPresent(buff)) { // seek to row key RandomAccessReader dfile = reader.openDataReader(); RowIndexEntry entry = reader.getPosition(partitioner.decorateKey(buff), SSTableReader.Operator.EQ); if (entry == null) continue; dfile.seek(entry.position);/* ww w. ja v a 2s . com*/ // read some ByteBufferUtil.readWithShortLength(dfile); if (reader.descriptor.version.hasRowSizeAndColumnCount) dfile.readLong(); DeletionInfo deletionInfo = new DeletionInfo(DeletionTime.serializer.deserialize(dfile)); int columnCount = reader.descriptor.version.hasRowSizeAndColumnCount ? dfile.readInt() : Integer.MAX_VALUE; // get iterator Iterator<OnDiskAtom> atomIterator = reader.metadata.getOnDiskIterator(dfile, columnCount, reader.descriptor.version); // iterate System.out.print(new File(reader.getFilename()).getName()); boolean isContiguous = false; int contiguousTombstonedColumns = 0; String contiguousTombstonedColumnsStart = null; int live = 0; int deleted = 0; int rangeTombstone = 0; StringBuffer sb = new StringBuffer(); while (atomIterator.hasNext()) { OnDiskAtom atom = atomIterator.next(); if (atom instanceof Column) { if (atom instanceof DeletedColumn) { deleted++; if (!isContiguous) { isContiguous = true; contiguousTombstonedColumnsStart = ByteBufferUtil.string(atom.name()); } contiguousTombstonedColumns++; } else { live++; if (isContiguous) { // print if (contiguousTombstonedColumns >= this.threshold) { sb.append(", [" + contiguousTombstonedColumnsStart + "|" + contiguousTombstonedColumns + "]"); } // reset contiguousTombstonedColumns = 0; contiguousTombstonedColumnsStart = null; isContiguous = false; } } } else if (atom instanceof RangeTombstone) { rangeTombstone++; int localDeletionTime = atom.getLocalDeletionTime(); ByteBuffer min = ((RangeTombstone) atom).min; ByteBuffer max = ((RangeTombstone) atom).max; String minString = ByteBufferUtil.string(min); String maxString = ByteBufferUtil.string(max); sb.append(", [" + minString + ", " + maxString + "(" + localDeletionTime + ")]"); } // if it ends with finished columns if (contiguousTombstonedColumns >= this.threshold) { sb.append( ", [" + contiguousTombstonedColumnsStart + "|" + contiguousTombstonedColumns + "]"); } } System.out.print(", (live, deleted, range tombstone)=(" + live + ", " + deleted + ", " + rangeTombstone + ")"); System.out.println(sb.toString()); } } }