本文整理汇总了Java中org.apache.cassandra.io.sstable.SSTableReader.open方法的典型用法代码示例。如果您正苦于以下问题:Java SSTableReader.open方法的具体用法?Java SSTableReader.open怎么用?Java SSTableReader.open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.io.sstable.SSTableReader
的用法示例。
在下文中一共展示了SSTableReader.open方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldImportCqlTable
import org.apache.cassandra.io.sstable.SSTableReader; //导入方法依赖的package包/类
@Test
/*
* The schema is
* CREATE TABLE cql_keyspace.table1 (k int PRIMARY KEY, v1 text, v2 int)
* */
public void shouldImportCqlTable() throws IOException, URISyntaxException
{
String cql_keyspace = "cql_keyspace";
String cql_table = "table1";
String jsonUrl = resourcePath("CQLTable.json");
File tempSS = tempSSTableFile(cql_keyspace, cql_table);
new SSTableImport(true).importJson(jsonUrl, cql_keyspace, cql_table, tempSS.getPath());
SSTableReader reader = SSTableReader.open(Descriptor.fromFilename(tempSS.getPath()));
Keyspace.open(cql_keyspace).getColumnFamilyStore(cql_table).addSSTable(reader);
UntypedResultSet result = QueryProcessor.executeOnceInternal(String.format("SELECT * FROM %s.%s", cql_keyspace, cql_table));
assertThat(result.size(), is(2));
assertThat(result, hasItem(withElements(1, "NY", 1980)));
assertThat(result, hasItem(withElements(2, "CA", 2014)));
reader.selfRef().release();
}
示例2: main
import org.apache.cassandra.io.sstable.SSTableReader; //导入方法依赖的package包/类
/**
* @param args a list of sstables whose metadata we are changing
*/
public static void main(String[] args) throws IOException
{
PrintStream out = System.out;
if (args.length < 2)
{
out.println("This command should be run with Cassandra stopped!");
out.println("Usage: sstableofflinerelevel [--dry-run] <keyspace> <columnfamily>");
System.exit(1);
}
boolean dryRun = args[0].equals("--dry-run");
String keyspace = args[args.length - 2];
String columnfamily = args[args.length - 1];
DatabaseDescriptor.loadSchemas(false);
if (Schema.instance.getCFMetaData(keyspace, columnfamily) == null)
throw new IllegalArgumentException(String.format("Unknown keyspace/columnFamily %s.%s",
keyspace,
columnfamily));
Keyspace ks = Keyspace.openWithoutSSTables(keyspace);
ColumnFamilyStore cfs = ks.getColumnFamilyStore(columnfamily);
Directories.SSTableLister lister = cfs.directories.sstableLister().skipTemporary(true);
Set<SSTableReader> sstables = new HashSet<>();
for (Map.Entry<Descriptor, Set<Component>> sstable : lister.list().entrySet())
{
if (sstable.getKey() != null)
{
try
{
SSTableReader reader = SSTableReader.open(sstable.getKey());
sstables.add(reader);
}
catch (Throwable t)
{
out.println("Couldn't open sstable: "+sstable.getKey().filenameFor(Component.DATA));
Throwables.propagate(t);
}
}
}
if (sstables.isEmpty())
{
out.println("No sstables to relevel for "+keyspace+"."+columnfamily);
System.exit(1);
}
Relevel rl = new Relevel(sstables);
rl.relevel(dryRun);
System.exit(0);
}