Skip to content

Commit

Permalink
Update README with new usage and short keys example.
Browse files Browse the repository at this point in the history
  • Loading branch information
tolbertam committed Dec 17, 2015
1 parent d462619 commit ce28dbf
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 12 deletions.
40 changes: 35 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ should be much more pleasant to follow.
```
java -jar sstable-tools.jar toJson
usage: toJson <sstable> -c <arg> [-e] [-k <arg>] [-x <arg>]
usage: toJson <sstable> [-c <arg>] [-e] [-k <arg>] [-x <arg>]
Converts SSTable into a JSON formatted document.
-c <arg> file containing "CREATE TABLE..." for the sstable's schema
-e Enumerate keys only
-k <arg> Partition key to be included
-x <arg> Partition key to be excluded
-c <arg> Optional file containing "CREATE TABLE..." for the sstable's schema. Used to determine the partition and
clustering key names. Must not include "keyspace." in create statement. If not included will not print key names.
-e Only print out the keys for the sstable. If enabled other options are ignored.
-k <arg> Partition key to be included. May be used multiple times. If not set will default to all keys.
-x <arg> Partition key to be excluded. May be used multiple times.
```

### Examples
Expand Down Expand Up @@ -123,6 +125,34 @@ series of rows with columns:
]
```

An example demonstrating what output will look like if you do not provide a CQL
schema via `-c`. Partition and Clustering key column names are simply omitted
and only their values are provided:


```json
[
{
"partition" : {
"key" : [ "ZLC", "2003" ]
},
"rows" : [
{
"type" : "row",
"clustering" : [ "12", "31" ],
"cells" : [
{ "name" : "close", "value" : "53.2", "tstamp" : 1449469421557041 },
{ "name" : "high", "value" : "53.48", "tstamp" : 1449469421557041 },
{ "name" : "low", "value" : "52.56", "tstamp" : 1449469421557041 },
{ "name" : "open", "value" : "53.35", "tstamp" : 1449469421557041 },
{ "name" : "volume", "value" : "93600", "tstamp" : 1449469421557041 }
]
}
]
}
]
```


An example showing an SSTable with tombstones at all levels:

Expand Down
14 changes: 7 additions & 7 deletions src/main/java/com/csforge/sstable/SSTable2Json.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ public class SSTable2Json {
if (DatabaseDescriptor.getPartitioner() == null)
DatabaseDescriptor.setPartitionerUnsafe(Murmur3Partitioner.instance);

Option partitionKey = new Option(PARTITION_KEY_OPTION, true, "Partition key to be included. May be used multiple times. If not set will default to all keys");
Option partitionKey = new Option(PARTITION_KEY_OPTION, true, "Partition key to be included. May be used multiple times. If not set will default to all keys.");
partitionKey.setArgs(Option.UNLIMITED_VALUES);

Option excludeKey = new Option(EXCLUDE_KEY_OPTION, true, "Partition key to be excluded. May be used multiple times");
Option excludeKey = new Option(EXCLUDE_KEY_OPTION, true, "Partition key to be excluded. May be used multiple times.");
excludeKey.setArgs(Option.UNLIMITED_VALUES);

Option enumerateKeys = new Option(ENUMERATE_KEYS_OPTION, false, "Only print out the keys for the sstable. If enabled other options are ignored");
Option shortKeys = new Option(SHORT_KEYS_OPTION, false,
"Only display key values, not names. Required (and defaulted) to true if -c is not provided.");
Option enumerateKeys = new Option(ENUMERATE_KEYS_OPTION, false, "Only print out the keys for the sstable. If enabled other options are ignored.");

Option cqlCreate = new Option(CREATE_OPTION, true, "file containing \"CREATE TABLE...\" for the sstable's chema. Used to determine the partition and clustering key names. Must not include \"keyspace.\" in create statement");
Option cqlCreate = new Option(CREATE_OPTION, true, "Optional file containing \"CREATE TABLE...\" for the sstable's schema. " +
"Used to determine the partition and clustering key names. Must not include \"keyspace.\" in create statement. " +
"If not included will not print key names.");

options.addOption(partitionKey);
options.addOption(excludeKey);
Expand All @@ -75,7 +75,7 @@ public static void main(String args[]) {
try (PrintWriter errWriter = new PrintWriter(System.err, true)) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp(errWriter, 120, "toJson <sstable>",
"Converts SSTable into a JSON formatted document.",
System.getProperty("line.separator") + "Converts SSTable into a JSON formatted document.",
options, 2, 1, "", true);
} finally {
System.exit(-1);
Expand Down

0 comments on commit ce28dbf

Please sign in to comment.