Skip to content

Commit

Permalink
updated unloader
Browse files Browse the repository at this point in the history
  • Loading branch information
brianmhess committed Aug 3, 2015
1 parent 989726e commit d79db43
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 18 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.0.14
- Updated cassandra-unloader to add support for collections,
consistency level, ssl, etc

## 0.0.13
- Added configFile
- added ssl options (with truststore and keystore)
Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ loading of various types of delimited files, including

### Downloading
This utility has already been built, and is available at
https://github.com/brianmhess/cassandra-loader/releases/download/v0.0.13/cassandra-loader
https://github.com/brianmhess/cassandra-loader/releases/download/v0.0.14/cassandra-loader

Get it with wget:
```
wget https://github.com/brianmhess/cassandra-loader/releases/download/v0.0.13/cassandra-loader
wget https://github.com/brianmhess/cassandra-loader/releases/download/v0.0.14/cassandra-loader
```

### Building
Expand Down Expand Up @@ -255,17 +255,24 @@ cassandra-unloader

Usage statement:
```
version: 0.0.14
Usage: -f <outputStem> -host <ipaddress> -schema <schema> [OPTIONS]
OPTIONS:
-configFile <filename> File with configuration options
-delim <delimiter> Delimiter to use [,]
-dateFormat <dateFormatString> Date format [default for Locale.ENGLISH]
-nullString <nullString> String that signifies NULL [none]
-port <portNumber> CQL Port Number [9042]
-user <username> Cassandra username [none]
-pw <password> Password for user [none]
-ssl-truststore-path <path> Path to SSL truststore [none]
-ssl-truststore-pw <pwd> Password for SSL truststore [none]
-ssl-keystore-path <path> Path to SSL keystore [none]
-ssl-keystore-pw <pwd> Password for SSL keystore [none]
-consistencyLevel <CL> Consistency level [LOCAL_ONE]
-decimalDelim <decimalDelim> Decimal delimiter [.] Other option is ','
-boolStyle <boolStyleString> Style for booleans [TRUE_FALSE]
-numThreads <numThreads> Number of concurrent threads (files) to load [5]
-numThreads <numThreads> Number of concurrent threads to unload [5]
-beginToken <tokenString> Begin token [none]
-endToken <tokenString> End token [none]
```
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apply plugin: 'java'
apply plugin: 'application'

def versionNum = '0.0.13'
def versionNum = '0.0.14'

allprojects {
tasks.withType(JavaCompile) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/datastax/loader/CqlDelimLoad.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
import com.codahale.metrics.Timer;

public class CqlDelimLoad {
private String version = "0.0.13";
private String version = "0.0.14";
private String host = null;
private int port = 9042;
private String username = null;
Expand Down Expand Up @@ -152,7 +152,7 @@ private String usage() {
usage.append(" -ssl-truststore-pw <pwd> Password for SSL truststore [none]\n");
usage.append(" -ssl-keystore-path <path> Path to SSL keystore [none]\n");
usage.append(" -ssl-keystore-pw <pwd> Password for SSL keystore [none]\n");
usage.append(" -consistencyLevel <CL> Consistency level [LOCAL_ONE]");
usage.append(" -consistencyLevel <CL> Consistency level [LOCAL_ONE]\n");
usage.append(" -numFutures <numFutures> Number of CQL futures to keep in flight [1000]\n");
usage.append(" -batchSize <batchSize> Number of INSERTs to batch together [1]\n");
usage.append(" -decimalDelim <decimalDelim> Decimal delimiter [.] Other option is ','\n");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/datastax/loader/CqlDelimLoadTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ private void setup() throws IOException, ParseException {

cdp = new CqlDelimParser(cqlSchema, delimiter, nullString,
dateFormatString, boolStyle, locale,
skipCols, session);
skipCols, session, true);
insert = cdp.generateInsert();
statement = session.prepare(insert);
statement.setRetryPolicy(new LoaderRetryPolicy(numRetries));
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/com/datastax/loader/CqlDelimParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ public class CqlDelimParser {
public CqlDelimParser(String inCqlSchema, String inDelimiter,
String inNullString, String inDateFormatString,
BooleanParser.BoolStyle inBoolStyle, Locale inLocale,
String skipList, Session session)
String skipList, Session session, boolean bLoader)
throws ParseException {
// Optionally provide things for the line parser - date format, boolean format, locale
initPmap(inDateFormatString, inBoolStyle, inLocale);
initPmap(inDateFormatString, inBoolStyle, inLocale, bLoader);
processCqlSchema(inCqlSchema, session);
createDelimParser(inDelimiter, inNullString, skipList);
}
Expand All @@ -78,12 +78,12 @@ private class SchemaBits {

// intialize the Parsers and the parser map
private void initPmap(String dateFormatString, BooleanParser.BoolStyle inBoolStyle,
Locale inLocale) {
Locale inLocale, boolean bLoader) {
pmap = new HashMap<DataType.Name, Parser>();
Parser integerParser = new IntegerParser(inLocale);
Parser longParser = new LongParser(inLocale);
Parser floatParser = new FloatParser(inLocale);
Parser doubleParser = new DoubleParser(inLocale);
Parser integerParser = new IntegerParser(inLocale, bLoader);
Parser longParser = new LongParser(inLocale, bLoader);
Parser floatParser = new FloatParser(inLocale, bLoader);
Parser doubleParser = new DoubleParser(inLocale, bLoader);
Parser stringParser = new StringParser();
Parser booleanParser = new BooleanParser(inBoolStyle);
Parser uuidParser = new UUIDParser();
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/com/datastax/loader/CqlDelimUnload.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@


public class CqlDelimUnload {
private String version = "0.0.12";
private String version = "0.0.14";
private String host = null;
private int port = 9042;
private String username = null;
Expand Down Expand Up @@ -116,10 +116,10 @@ private String usage() {
usage.append(" -ssl-truststore-pw <pwd> Password for SSL truststore [none]\n");
usage.append(" -ssl-keystore-path <path> Path to SSL keystore [none]\n");
usage.append(" -ssl-keystore-pw <pwd> Password for SSL keystore [none]\n");
usage.append(" -consistencyLevel <CL> Consistency level [LOCAL_ONE]");
usage.append(" -consistencyLevel <CL> Consistency level [LOCAL_ONE]\n");
usage.append(" -decimalDelim <decimalDelim> Decimal delimiter [.] Other option is ','\n");
usage.append(" -boolStyle <boolStyleString> Style for booleans [TRUE_FALSE]\n");
usage.append(" -numThreads <numThreads> Number of concurrent threads (files) to load [5]\n");
usage.append(" -numThreads <numThreads> Number of concurrent threads to unload [5]\n");
usage.append(" -beginToken <tokenString> Begin token [none]\n");
usage.append(" -endToken <tokenString> End token [none]\n");
return usage.toString();
Expand Down Expand Up @@ -533,7 +533,7 @@ private String getPartitionKey(CqlDelimParser cdp, Session tsession) {
private void setup() throws IOException, ParseException {
cdp = new CqlDelimParser(cqlSchema, delimiter, nullString,
dateFormatString,
boolStyle, locale, null, session);
boolStyle, locale, null, session, false);
String select = cdp.generateSelect();
String partitionKey = getPartitionKey(cdp, session);
if (null != beginToken) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/datastax/loader/parser/DoubleParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public DoubleParser() {
public DoubleParser(Locale inLocale) {
super(inLocale);
}

public DoubleParser(Locale inLocale, Boolean grouping) {
super(inLocale, grouping);
}

public Double parse(String toparse) throws ParseException {
Number val = super.parse(toparse);
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/datastax/loader/parser/FloatParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public FloatParser(Locale inLocale) {
super(inLocale);
}

public FloatParser(Locale inLocale, Boolean grouping) {
super(inLocale, grouping);
}

public Float parse(String toparse) throws ParseException {
Number val = super.parse(toparse);
return (null == val) ? null : val.floatValue();
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/datastax/loader/parser/IntegerParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public IntegerParser(Locale inLocale) {
super(inLocale);
}

public IntegerParser(Locale inLocale, Boolean grouping) {
super(inLocale, grouping);
}

public Integer parse(String toparse) throws ParseException {
Number val = super.parse(toparse);
return (null == val) ? null : val.intValue();
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/datastax/loader/parser/LongParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public LongParser(Locale inLocale) {
super(inLocale);
}

public LongParser(Locale inLocale, Boolean grouping) {
super(inLocale, grouping);
}

public Long parse(String toparse) throws ParseException {
Number val = super.parse(toparse);
return (null == val) ? null : val.longValue();
Expand Down
8 changes: 8 additions & 0 deletions src/main/java/com/datastax/loader/parser/NumberParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.lang.Number;
import java.util.Locale;
import java.text.NumberFormat;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.lang.IndexOutOfBoundsException;
import com.datastax.driver.core.Row;
Expand All @@ -34,9 +35,16 @@ public NumberParser() {
}

public NumberParser(Locale locale) {
this(locale, true);
}

public NumberParser(Locale locale, Boolean grouping) {
if (null == locale)
locale = Locale.ENGLISH;
nf = NumberFormat.getInstance(locale);
if (nf instanceof DecimalFormat) {
((DecimalFormat) nf).setGroupingUsed(grouping);
}
}

// Need this method for the subclasses
Expand Down

0 comments on commit d79db43

Please sign in to comment.