Skip to content

Commit

Permalink
Add sstabledump tool
Browse files Browse the repository at this point in the history
patch by Chris Lohfink; reviewed by yukim for CASSANDRA-7464
  • Loading branch information
Chris Lohfink authored and yukim committed Feb 24, 2016
1 parent a623977 commit 71b1c4a
Show file tree
Hide file tree
Showing 15 changed files with 933 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
3.0.4
* Add sstabledump tool (CASSANDRA-7464)
* Introduce backpressure for hints (CASSANDRA-10972)
* Fix ClusteringPrefix not being able to read tombstone range boundaries (CASSANDRA-11158)
* Prevent logging in sandboxed state (CASSANDRA-11033)
Expand Down
14 changes: 14 additions & 0 deletions NEWS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,20 @@ restore snapshots created with the previous major version using the
'sstableloader' tool. You can upgrade the file format of your snapshots
using the provided 'sstableupgrade' tool.

3.0.4
=====

New features
------------
- sstabledump tool is added to be 3.0 version of former sstable2json. The tool only
supports v3.0+ SSTables. See tool's help for more detail.

Upgrading
---------
- Nothing specific to this release, but please see previous versions upgrading section,
especially if you are upgrading from 2.2.


3.0.3
=====

Expand Down
8 changes: 4 additions & 4 deletions src/java/org/apache/cassandra/config/CFMetaData.java
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ public static class Builder
private final boolean isSuper;
private final boolean isCounter;
private final boolean isView;
private IPartitioner partitioner;
private Optional<IPartitioner> partitioner;

private UUID tableId;

Expand All @@ -1150,7 +1150,7 @@ private Builder(String keyspace, String table, boolean isDense, boolean isCompou
this.isSuper = isSuper;
this.isCounter = isCounter;
this.isView = isView;
this.partitioner = DatabaseDescriptor.getPartitioner();
this.partitioner = Optional.empty();
}

public static Builder create(String keyspace, String table)
Expand Down Expand Up @@ -1185,7 +1185,7 @@ public static Builder createSuper(String keyspace, String table, boolean isCount

public Builder withPartitioner(IPartitioner partitioner)
{
this.partitioner = partitioner;
this.partitioner = Optional.ofNullable(partitioner);
return this;
}

Expand Down Expand Up @@ -1296,7 +1296,7 @@ public CFMetaData build()
partitions,
clusterings,
builder.build(),
partitioner);
partitioner.orElseGet(DatabaseDescriptor::getPartitioner));
}
}

Expand Down
25 changes: 25 additions & 0 deletions src/java/org/apache/cassandra/db/SerializationHeader.java
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,31 @@ public String toString()
return String.format("SerializationHeader.Component[key=%s, cks=%s, statics=%s, regulars=%s, stats=%s]",
keyType, clusteringTypes, staticColumns, regularColumns, stats);
}

public AbstractType<?> getKetType()
{
return keyType;
}

public List<AbstractType<?>> getClusteringTypes()
{
return clusteringTypes;
}

public Map<ByteBuffer, AbstractType<?>> getStaticColumns()
{
return staticColumns;
}

public Map<ByteBuffer, AbstractType<?>> getRegularColumns()
{
return regularColumns;
}

public EncodingStats getEncodingStats()
{
return stats;
}
}

public static class Serializer implements IMetadataComponentSerializer<Component>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,8 @@ public String toString(CFMetaData metadata, boolean fullDetails)
{
return toString(metadata);
}
public String toString(CFMetaData metadata, boolean includeClusteringKeys, boolean fullDetails)
{
return toString(metadata);
}
}
12 changes: 11 additions & 1 deletion src/java/org/apache/cassandra/db/rows/AbstractRow.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ public String toString(CFMetaData metadata)
}

public String toString(CFMetaData metadata, boolean fullDetails)
{
return toString(metadata, true, fullDetails);
}

public String toString(CFMetaData metadata, boolean includeClusterKeys, boolean fullDetails)
{
StringBuilder sb = new StringBuilder();
sb.append("Row");
Expand All @@ -101,7 +106,12 @@ public String toString(CFMetaData metadata, boolean fullDetails)
sb.append(" del=").append(deletion());
sb.append(" ]");
}
sb.append(": ").append(clustering().toString(metadata)).append(" | ");
sb.append(": ");
if(includeClusterKeys)
sb.append(clustering().toString(metadata));
else
sb.append(clustering().toCQLString(metadata));
sb.append(" | ");
boolean isFirst = true;
for (ColumnData cd : this)
{
Expand Down
1 change: 1 addition & 0 deletions src/java/org/apache/cassandra/db/rows/Unfiltered.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public enum Kind { ROW, RANGE_TOMBSTONE_MARKER };

public String toString(CFMetaData metadata);
public String toString(CFMetaData metadata, boolean fullDetails);
public String toString(CFMetaData metadata, boolean includeClusterKeys, boolean fullDetails);

default boolean isRow()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1760,6 +1760,14 @@ public ISSTableScanner getScanner(Range<Token> range, RateLimiter limiter)
*/
public abstract ISSTableScanner getScanner(Collection<Range<Token>> ranges, RateLimiter limiter);

/**
* Direct I/O SSTableScanner over an iterator of bounds.
*
* @param bounds the keys to cover
* @return A Scanner for seeking over the rows of the SSTable.
*/
public abstract ISSTableScanner getScanner(Iterator<AbstractBounds<PartitionPosition>> rangeIterator);

/**
* @param columns the columns to return.
* @param dataRange filter to use when reading the columns
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import org.apache.cassandra.db.filter.ColumnFilter;
import org.apache.cassandra.db.columniterator.SSTableIterator;
import org.apache.cassandra.db.columniterator.SSTableReversedIterator;
import org.apache.cassandra.dht.IPartitioner;
import org.apache.cassandra.dht.AbstractBounds;
import org.apache.cassandra.dht.Range;
import org.apache.cassandra.dht.Token;
import org.apache.cassandra.io.sstable.Component;
Expand Down Expand Up @@ -81,6 +81,17 @@ public ISSTableScanner getScanner(ColumnFilter columns, DataRange dataRange, Rat
return BigTableScanner.getScanner(this, columns, dataRange, limiter, isForThrift);
}

/**
* Direct I/O SSTableScanner over an iterator of bounds.
*
* @param boundsIterator the keys to cover
* @return A Scanner for seeking over the rows of the SSTable.
*/
public ISSTableScanner getScanner(Iterator<AbstractBounds<PartitionPosition>> boundsIterator)
{
return BigTableScanner.getScanner(this, boundsIterator);
}

/**
* Direct I/O SSTableScanner over the full sstable.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ public static ISSTableScanner getScanner(SSTableReader sstable, Collection<Range
return new BigTableScanner(sstable, ColumnFilter.all(sstable.metadata), null, limiter, false, makeBounds(sstable, tokenRanges).iterator());
}

public static ISSTableScanner getScanner(SSTableReader sstable, Iterator<AbstractBounds<PartitionPosition>> rangeIterator)
{
return new BigTableScanner(sstable, ColumnFilter.all(sstable.metadata), null, null, false, rangeIterator);
}

private BigTableScanner(SSTableReader sstable, ColumnFilter columns, DataRange dataRange, RateLimiter limiter, boolean isForThrift, Iterator<AbstractBounds<PartitionPosition>> rangeIterator)
{
assert sstable != null;
Expand Down
Loading

0 comments on commit 71b1c4a

Please sign in to comment.