use of org.apache.cassandra.cql3.UntypedResultSet in project cassandra by apache.
the class LegacySSTableTest method readSimpleTable.
private static void readSimpleTable(String legacyVersion, String pkValue) {
logger.debug("Read simple: legacy_{}_simple", legacyVersion);
UntypedResultSet rs;
rs = QueryProcessor.executeInternal(String.format("SELECT val FROM legacy_tables.legacy_%s_simple WHERE pk=?", legacyVersion), pkValue);
Assert.assertNotNull(rs);
Assert.assertEquals(1, rs.size());
Assert.assertEquals("foo bar baz", rs.one().getString("val"));
}
use of org.apache.cassandra.cql3.UntypedResultSet in project cassandra by apache.
the class TriggersTest method assertUpdateNotExecuted.
private void assertUpdateNotExecuted(String cf, int key) {
UntypedResultSet rs = QueryProcessor.executeInternal(String.format("SELECT * FROM %s.%s WHERE k=%s", ksName, cf, key));
assertTrue(rs.isEmpty());
}
use of org.apache.cassandra.cql3.UntypedResultSet in project cassandra by apache.
the class LocalSessionTest method loadCorruptRow.
/**
* If there are problems with the rows we're reading out of the repair table, we should
* do the best we can to repair them, but not refuse to startup.
*/
@Test
public void loadCorruptRow() throws Exception {
LocalSessions sessions = new LocalSessions();
LocalSession session = createSession();
sessions.save(session);
sessions = new LocalSessions();
sessions.start();
Assert.assertNotNull(sessions.getSession(session.sessionID));
QueryProcessor.instance.executeInternal("DELETE participants, participants_wp FROM system.repairs WHERE parent_id=?", session.sessionID);
sessions = new LocalSessions();
sessions.start();
Assert.assertNull(sessions.getSession(session.sessionID));
UntypedResultSet res = QueryProcessor.executeInternal("SELECT * FROM system.repairs WHERE parent_id=?", session.sessionID);
assertTrue(res.isEmpty());
}
use of org.apache.cassandra.cql3.UntypedResultSet in project cassandra by apache.
the class SSTableTasksTableTest method testSelectAll.
@Test
public void testSelectAll() throws Throwable {
createTable("CREATE TABLE %s (pk int, ck int, PRIMARY KEY (pk, ck))");
ColumnFamilyStore cfs = getCurrentColumnFamilyStore();
long bytesCompacted = 123;
long bytesTotal = 123456;
UUID compactionId = UUID.randomUUID();
List<SSTableReader> sstables = IntStream.range(0, 10).mapToObj(i -> MockSchema.sstable(i, i * 10L, i * 10L + 9, cfs)).collect(Collectors.toList());
CompactionInfo.Holder compactionHolder = new CompactionInfo.Holder() {
public CompactionInfo getCompactionInfo() {
return new CompactionInfo(cfs.metadata(), OperationType.COMPACTION, bytesCompacted, bytesTotal, compactionId, sstables);
}
public boolean isGlobal() {
return false;
}
};
CompactionManager.instance.active.beginCompaction(compactionHolder);
UntypedResultSet result = execute("SELECT * FROM vts.sstable_tasks");
assertRows(result, row(CQLTester.KEYSPACE, currentTable(), compactionId, 1.0 * bytesCompacted / bytesTotal, OperationType.COMPACTION.toString().toLowerCase(), bytesCompacted, sstables.size(), bytesTotal, CompactionInfo.Unit.BYTES.toString()));
CompactionManager.instance.active.finishCompaction(compactionHolder);
result = execute("SELECT * FROM vts.sstable_tasks");
assertEmpty(result);
}
use of org.apache.cassandra.cql3.UntypedResultSet in project cassandra by apache.
the class MigrationManagerTest method addNewTable.
@Test
public void addNewTable() throws ConfigurationException {
final String ksName = KEYSPACE1;
final String tableName = "anewtable";
KeyspaceMetadata original = Schema.instance.getKeyspaceMetadata(ksName);
TableMetadata cfm = addTestTable(original.name, tableName, "A New Table");
assertFalse(Schema.instance.getKeyspaceMetadata(ksName).tables.get(cfm.name).isPresent());
MigrationManager.announceNewTable(cfm);
assertTrue(Schema.instance.getKeyspaceMetadata(ksName).tables.get(cfm.name).isPresent());
assertEquals(cfm, Schema.instance.getKeyspaceMetadata(ksName).tables.get(cfm.name).get());
// now read and write to it.
QueryProcessor.executeInternal(String.format("INSERT INTO %s.%s (key, col, val) VALUES (?, ?, ?)", ksName, tableName), "key0", "col0", "val0");
// flush to exercise more than just hitting the memtable
ColumnFamilyStore cfs = Keyspace.open(ksName).getColumnFamilyStore(tableName);
assertNotNull(cfs);
cfs.forceBlockingFlush();
// and make sure we get out what we put in
UntypedResultSet rows = QueryProcessor.executeInternal(String.format("SELECT * FROM %s.%s", ksName, tableName));
assertRows(rows, row("key0", "col0", "val0"));
}
Aggregations