Database Reference
In-Depth Information
The preceding code snippet shows that the program takes the file
name as an input argument. If it isn't provided, then the default file
(
CSVInput.csv
) is used. It will also create a data folder in the root
folder (see
Figure 10-2
)
.
Figure 10-2
.
The created data folder with .db files
5.
Next, we need to instantiate
SSTableSimpleUnsortedWriter
:
SSTableSimpleUnsortedWriter usersWriter = new
SSTableSimpleUnsortedWriter(directory, new
Murmur3Partitioner(),
keyspace, "Users", AsciiType.instance, null,
64, new CompressionParameters(
org.apache.cassandra.io.compress.SnappyCompressor.create(Collections.<String,
String> emptyMap())));
6.
Now, we need to parse each entry in the
CSVInput.csv
file:
static class CsvEntry
{
UUID key;
String firstname;
String lastname;
String password;
int age;
String email;
boolean parse(String line, int