在此代码的帮助下,我已经使用 key_validation_class=LexicalUUIDType 为新行完成了批量加载程序,但我更改了我的key_validation_class=AsciiType或key_validation_class=UTF8Type以便将字符串作为行键
create column family Users1
with key_validation_class=AsciiType
and comparator=AsciiType
AND column_metadata = [
{column_name: timestamp1, validation_class: AsciiType}
{column_name: symbol, validation_class: AsciiType}
{column_name: Bid_Price, validation_class:AsciiType}
{column_name: Ask_Price, validation_class:AsciiType}
];
我已尝试对代码进行所有可能的更改,以便将行键设为字符串类型,但出现错误,甚至没有usersWriter.newRow无法写入 sstable
while ((line = reader.readLine()) != null)
{
if (entry.parse(line, lineNumber))
{
//usersWriter.newRow(uuid);
usersWriter.newRow(String.valueOf(lineNumber));
usersWriter.addColumn(bytes("symbol"), bytes(entry.symbol), timestamp);
usersWriter.addColumn(bytes("timestamp1"), bytes(entry.timestamp1), timestamp);
usersWriter.addColumn(bytes("Bid_Price"), bytes(entry.Bid_Price), timestamp);
usersWriter.addColumn(bytes("Ask_Price"), bytes(entry.Ask_Price), timestamp);
}
lineNumber++;
}
正如预期的那样得到一个错误它只需要ByteBuffer
usersWriter.newRow(String.valueOf(lineNumber));
^
required: ByteBuffer
found: String
reason: actual argument String cannot be converted to ByteBuffer by method invocation conversion
任何帮助将字符串作为上述列族定义的 sstable 中的行键。谢谢。