Database Reference
In-Depth Information
The preceding code snippet parses and sets each cell value
( firstname , lastname , and so forth) and reads each line from
the .csv file like this:
CsvEntry entry = new CsvEntry();
while ((line = reader.readLine()) != null)
{
if (entry.parse(line, lineNumber))
{
...
}
}
7.
After parsing, let's prepare a composite type for each column value.
Since we have uuid, int, and text as data types defined for the primary
key, first name, last name, and age, we need to define them as fol-
lows:
ByteBuffer uuid =
UUIDType.instance.decompose(entry.key);
usersWriter.newRow(uuid);
List types = newArrayList();
types.add(UTF8Type.instance);
CompositeType compositeType =
CompositeType.getInstance(types);
List numericTypes = newArrayList();
numericTypes.add(IntegerType.instance);
CompositeType numericType =
CompositeType.getInstance(numericTypes);
8.
Next, let's assign values:
long timestamp = System.currentTimeMillis() *
1000;
Search WWH ::




Custom Search