本文整理汇总了Java中org.apache.cassandra.cql3.UntypedResultSet类的典型用法代码示例。如果您正苦于以下问题:Java UntypedResultSet类的具体用法?Java UntypedResultSet怎么用?Java UntypedResultSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UntypedResultSet类属于org.apache.cassandra.cql3包,在下文中一共展示了UntypedResultSet类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: list
import org.apache.cassandra.cql3.UntypedResultSet; //导入依赖的package包/类
public Set<PermissionDetails> list(AuthenticatedUser performer, Set<Permission> permissions, IResource resource, String of)
throws RequestValidationException, RequestExecutionException
{
if (!performer.isSuper() && !performer.getName().equals(of))
throw new UnauthorizedException(String.format("You are not authorized to view %s's permissions",
of == null ? "everyone" : of));
Set<PermissionDetails> details = new HashSet<PermissionDetails>();
for (UntypedResultSet.Row row : process(buildListQuery(resource, of)))
{
if (row.has(PERMISSIONS))
{
for (String p : row.getSet(PERMISSIONS, UTF8Type.instance))
{
Permission permission = Permission.valueOf(p);
if (permissions.contains(permission))
details.add(new PermissionDetails(row.getString(USERNAME),
DataResource.fromName(row.getString(RESOURCE)),
permission));
}
}
}
return details;
}
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:27,代码来源:CassandraAuthorizer.java
示例2: from
import org.apache.cassandra.cql3.UntypedResultSet; //导入依赖的package包/类
public static TabularData from(UntypedResultSet resultSet) throws OpenDataException
{
TabularDataSupport result = new TabularDataSupport(TABULAR_TYPE);
for (UntypedResultSet.Row row : resultSet)
{
UUID id = row.getUUID(ITEM_NAMES[0]);
String ksName = row.getString(ITEM_NAMES[1]);
String cfName = row.getString(ITEM_NAMES[2]);
long compactedAt = row.getLong(ITEM_NAMES[3]);
long bytesIn = row.getLong(ITEM_NAMES[4]);
long bytesOut = row.getLong(ITEM_NAMES[5]);
Map<Integer, Long> rowMerged = row.getMap(ITEM_NAMES[6], Int32Type.instance, LongType.instance);
result.put(new CompositeDataSupport(COMPOSITE_TYPE, ITEM_NAMES,
new Object[]{ id.toString(), ksName, cfName, compactedAt, bytesIn, bytesOut,
"{" + FBUtilities.toString(rowMerged) + "}" }));
}
return result;
}
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:20,代码来源:CompactionHistoryTabularData.java
示例3: migrateIndexInterval
import org.apache.cassandra.cql3.UntypedResultSet; //导入依赖的package包/类
/** Migrates index_interval values to min_index_interval and sets index_interval to null */
private static void migrateIndexInterval()
{
for (UntypedResultSet.Row row : executeOnceInternal(String.format("SELECT * FROM system.%s", SCHEMA_COLUMNFAMILIES_CF)))
{
if (!row.has("index_interval"))
continue;
logger.debug("Migrating index_interval to min_index_interval");
CFMetaData table = CFMetaData.fromSchema(row);
String query = String.format("SELECT writetime(type) FROM system.%s WHERE keyspace_name = ? AND columnfamily_name = ?", SCHEMA_COLUMNFAMILIES_CF);
long timestamp = executeOnceInternal(query, table.ksName, table.cfName).one().getLong("writetime(type)");
try
{
table.toSchema(timestamp).apply();
}
catch (ConfigurationException e)
{
// shouldn't happen
}
}
}
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:24,代码来源:SystemKeyspace.java
示例4: migrateCachingOption
import org.apache.cassandra.cql3.UntypedResultSet; //导入依赖的package包/类
private static void migrateCachingOption()
{
for (UntypedResultSet.Row row : executeOnceInternal(String.format("SELECT * FROM system.%s", SCHEMA_COLUMNFAMILIES_CF)))
{
if (!row.has("caching"))
continue;
if (!CachingOptions.isLegacy(row.getString("caching")))
continue;
try
{
CachingOptions caching = CachingOptions.fromString(row.getString("caching"));
CFMetaData table = CFMetaData.fromSchema(row);
logger.info("Migrating caching option {} to {} for {}.{}", row.getString("caching"), caching.toString(), table.ksName, table.cfName);
String query = String.format("SELECT writetime(type) FROM system.%s WHERE keyspace_name = ? AND columnfamily_name = ?", SCHEMA_COLUMNFAMILIES_CF);
long timestamp = executeOnceInternal(query, table.ksName, table.cfName).one().getLong("writetime(type)");
table.toSchema(timestamp).apply();
}
catch (ConfigurationException e)
{
// shouldn't happen
}
}
}
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:25,代码来源:SystemKeyspace.java
示例5: filterOutRedundantRowsForSparse
import org.apache.cassandra.cql3.UntypedResultSet; //导入依赖的package包/类
private static Iterable<UntypedResultSet.Row> filterOutRedundantRowsForSparse(UntypedResultSet columnRows, boolean isSuper, boolean isCompound)
{
Collection<UntypedResultSet.Row> filteredRows = new ArrayList<>();
for (UntypedResultSet.Row columnRow : columnRows)
{
String kind = columnRow.getString("type");
if ("compact_value".equals(kind))
continue;
if ("clustering_key".equals(kind))
{
int position = columnRow.has("component_index") ? columnRow.getInt("component_index") : 0;
if (isSuper && position != 0)
continue;
if (!isSuper && !isCompound)
continue;
}
filteredRows.add(columnRow);
}
return filteredRows;
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:26,代码来源:LegacySchemaMigrator.java
示例6: loadPaxosState
import org.apache.cassandra.cql3.UntypedResultSet; //导入依赖的package包/类
public static PaxosState loadPaxosState(ByteBuffer key, CFMetaData metadata)
{
String req = "SELECT * FROM system.%s WHERE row_key = ? AND cf_id = ?";
UntypedResultSet results = executeInternal(String.format(req, PAXOS_CF), key, metadata.cfId);
if (results.isEmpty())
return new PaxosState(key, metadata);
UntypedResultSet.Row row = results.one();
Commit promised = row.has("in_progress_ballot")
? new Commit(key, row.getUUID("in_progress_ballot"), ArrayBackedSortedColumns.factory.create(metadata))
: Commit.emptyCommit(key, metadata);
// either we have both a recently accepted ballot and update or we have neither
Commit accepted = row.has("proposal")
? new Commit(key, row.getUUID("proposal_ballot"), ColumnFamily.fromBytes(row.getBytes("proposal")))
: Commit.emptyCommit(key, metadata);
// either most_recent_commit and most_recent_commit_at will both be set, or neither
Commit mostRecent = row.has("most_recent_commit")
? new Commit(key, row.getUUID("most_recent_commit_at"), ColumnFamily.fromBytes(row.getBytes("most_recent_commit")))
: Commit.emptyCommit(key, metadata);
return new PaxosState(promised, accepted, mostRecent);
}
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:21,代码来源:SystemKeyspace.java
示例7: fromSchema
import org.apache.cassandra.cql3.UntypedResultSet; //导入依赖的package包/类
/**
* Deserialize only Keyspace attributes without nested ColumnFamilies
*
* @param row Keyspace attributes in serialized form
*
* @return deserialized keyspace without cf_defs
*/
public static KSMetaData fromSchema(Row row, Iterable<CFMetaData> cfms, UTMetaData userTypes)
{
UntypedResultSet.Row result = QueryProcessor.resultify("SELECT * FROM system.schema_keyspaces", row).one();
try
{
return new KSMetaData(result.getString("keyspace_name"),
AbstractReplicationStrategy.getClass(result.getString("strategy_class")),
fromJsonMap(result.getString("strategy_options")),
result.getBoolean("durable_writes"),
cfms,
userTypes);
}
catch (ConfigurationException e)
{
throw new RuntimeException(e);
}
}
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:25,代码来源:KSMetaData.java
示例8: testInvalidSearch
import org.apache.cassandra.cql3.UntypedResultSet; //导入依赖的package包/类
@Test
public void testInvalidSearch() throws IOException
{
Mutation rm;
rm = new Mutation("PerRowSecondaryIndex", ByteBufferUtil.bytes("k4"));
rm.add("Indexed1", Util.cellname("indexed"), ByteBufferUtil.bytes("foo"), 1);
rm.apply();
// test we can search:
UntypedResultSet result = QueryProcessor.executeInternal("SELECT * FROM \"PerRowSecondaryIndex\".\"Indexed1\" WHERE indexed = 'foo'");
assertEquals(1, result.size());
// test we can't search if the searcher doesn't validate the expression:
try
{
QueryProcessor.executeInternal("SELECT * FROM \"PerRowSecondaryIndex\".\"Indexed1\" WHERE indexed = 'invalid'");
fail("Query should have been invalid!");
}
catch (Exception e)
{
assertTrue(e instanceof InvalidRequestException || (e.getCause() != null && (e.getCause() instanceof InvalidRequestException)));
}
}
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:24,代码来源:PerRowSecondaryIndexTest.java
示例9: shouldImportCqlTable
import org.apache.cassandra.cql3.UntypedResultSet; //导入依赖的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();
}
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:22,代码来源:SSTableImportTest.java
示例10: withElements
import org.apache.cassandra.cql3.UntypedResultSet; //导入依赖的package包/类
private static Matcher<UntypedResultSet.Row> withElements(final int key, final String v1, final int v2) {
return new TypeSafeMatcher<UntypedResultSet.Row>()
{
@Override
public boolean matchesSafely(Row input)
{
if (!input.has("k") || !input.has("v1") || !input.has("v2"))
return false;
return input.getInt("k") == key
&& input.getString("v1").equals(v1)
&& input.getInt("v2") == v2;
}
@Override
public void describeTo(Description description)
{
description.appendText(String.format("a row containing: %s, %s, %s", key, v1, v2));
}
};
}
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:22,代码来源:SSTableImportTest.java
示例11: loadDcRackInfo
import org.apache.cassandra.cql3.UntypedResultSet; //导入依赖的package包/类
/**
* Return a map of IP addresses containing a map of dc and rack info
*/
public static Map<InetAddress, Map<String,String>> loadDcRackInfo()
{
Map<InetAddress, Map<String, String>> result = new HashMap<InetAddress, Map<String, String>>();
for (UntypedResultSet.Row row : processInternal("SELECT peer, data_center, rack from system." + PEERS_CF))
{
InetAddress peer = row.getInetAddress("peer");
if (row.has("data_center") && row.has("rack"))
{
Map<String, String> dcRack = new HashMap<String, String>();
dcRack.put("data_center", row.getString("data_center"));
dcRack.put("rack", row.getString("rack"));
result.put(peer, dcRack);
}
}
return result;
}
开发者ID:pgaref,项目名称:ACaZoo,代码行数:20,代码来源:SystemKeyspace.java
示例12: hasRegularColumns
import org.apache.cassandra.cql3.UntypedResultSet; //导入依赖的package包/类
private static boolean hasRegularColumns(Iterable<UntypedResultSet.Row> columnRows)
{
for (UntypedResultSet.Row row : columnRows)
{
/*
* We need to special case and ignore the empty compact column (pre-3.0, COMPACT STORAGE, primary-key only tables),
* since deserializeKind() will otherwise just return a REGULAR.
* We want the proper EmptyType regular column to be added by addDefinitionForUpgrade(), so we need
* checkNeedsUpgrade() to return true in this case.
* See CASSANDRA-9874.
*/
if (isEmptyCompactValueColumn(row))
return false;
if (deserializeKind(row.getString("type")) == ColumnDefinition.Kind.REGULAR)
return true;
}
return false;
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:21,代码来源:LegacySchemaMigrator.java
示例13: getSSTableReadMeter
import org.apache.cassandra.cql3.UntypedResultSet; //导入依赖的package包/类
/**
* Returns a RestorableMeter tracking the average read rate of a particular SSTable, restoring the last-seen rate
* from values in system.sstable_activity if present.
* @param keyspace the keyspace the sstable belongs to
* @param table the table the sstable belongs to
* @param generation the generation number for the sstable
*/
public static RestorableMeter getSSTableReadMeter(String keyspace, String table, int generation)
{
String cql = "SELECT * FROM %s WHERE keyspace_name='%s' and columnfamily_name='%s' and generation=%d";
UntypedResultSet results = processInternal(String.format(cql,
SSTABLE_ACTIVITY_CF,
keyspace,
table,
generation));
if (results.isEmpty())
return new RestorableMeter();
UntypedResultSet.Row row = results.one();
double m15rate = row.getDouble("rate_15m");
double m120rate = row.getDouble("rate_120m");
return new RestorableMeter(m15rate, m120rate);
}
开发者ID:pgaref,项目名称:ACaZoo,代码行数:25,代码来源:SystemKeyspace.java
示例14: replayAllFailedBatches
import org.apache.cassandra.cql3.UntypedResultSet; //导入依赖的package包/类
private void replayAllFailedBatches() throws ExecutionException, InterruptedException
{
if (!isReplaying.compareAndSet(false, true))
return;
logger.debug("Started replayAllFailedBatches");
try
{
for (UntypedResultSet.Row row : process("SELECT id, written_at FROM %s.%s", Keyspace.SYSTEM_KS, SystemKeyspace.BATCHLOG_CF))
if (System.currentTimeMillis() > row.getLong("written_at") + TIMEOUT)
replayBatch(row.getUUID("id"));
cleanup();
}
finally
{
isReplaying.set(false);
}
logger.debug("Finished replayAllFailedBatches");
}
开发者ID:pgaref,项目名称:ACaZoo,代码行数:22,代码来源:BatchlogManager.java
示例15: readTableMetadata
import org.apache.cassandra.cql3.UntypedResultSet; //导入依赖的package包/类
private static CFMetaData readTableMetadata(String keyspaceName, String tableName)
{
String tableQuery = format("SELECT * FROM %s.%s WHERE keyspace_name = ? AND columnfamily_name = ?",
SystemKeyspace.NAME,
SystemKeyspace.LEGACY_COLUMNFAMILIES);
UntypedResultSet.Row tableRow = query(tableQuery, keyspaceName, tableName).one();
String columnsQuery = format("SELECT * FROM %s.%s WHERE keyspace_name = ? AND columnfamily_name = ?",
SystemKeyspace.NAME,
SystemKeyspace.LEGACY_COLUMNS);
UntypedResultSet columnRows = query(columnsQuery, keyspaceName, tableName);
String triggersQuery = format("SELECT * FROM %s.%s WHERE keyspace_name = ? AND columnfamily_name = ?",
SystemKeyspace.NAME,
SystemKeyspace.LEGACY_TRIGGERS);
UntypedResultSet triggerRows = query(triggersQuery, keyspaceName, tableName);
return decodeTableMetadata(tableRow, columnRows, triggerRows);
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:20,代码来源:LegacySchemaMigrator.java
示例16: migrateLegacyHintsInternal
import org.apache.cassandra.cql3.UntypedResultSet; //导入依赖的package包/类
private void migrateLegacyHintsInternal(UUID hostId, Iterator<UntypedResultSet.Row> iterator, ByteBuffer buffer)
{
HintsDescriptor descriptor = new HintsDescriptor(hostId, System.currentTimeMillis());
try (HintsWriter writer = HintsWriter.create(hintsDirectory, descriptor))
{
try (HintsWriter.Session session = writer.newSession(buffer))
{
while (iterator.hasNext())
{
Hint hint = convertLegacyHint(iterator.next());
if (hint != null)
session.append(hint);
if (session.position() >= maxHintsFileSize)
break;
}
}
}
catch (IOException e)
{
throw new FSWriteError(e, descriptor.fileName());
}
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:25,代码来源:LegacyHintsMigrator.java
示例17: verifyReads
import org.apache.cassandra.cql3.UntypedResultSet; //导入依赖的package包/类
private static void verifyReads(String legacyVersion)
{
for (int compact = 0; compact <= 1; compact++)
{
for (int ck = 0; ck < 50; ck++)
{
String ckValue = Integer.toString(ck) + longString;
for (int pk = 0; pk < 5; pk++)
{
logger.debug("for pk={} ck={}", pk, ck);
String pkValue = Integer.toString(pk);
UntypedResultSet rs;
if (ck == 0)
{
readSimpleTable(legacyVersion, getCompactNameSuffix(compact), pkValue);
readSimpleCounterTable(legacyVersion, getCompactNameSuffix(compact), pkValue);
}
readClusteringTable(legacyVersion, getCompactNameSuffix(compact), ck, ckValue, pkValue);
readClusteringCounterTable(legacyVersion, getCompactNameSuffix(compact), ckValue, pkValue);
}
}
}
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:26,代码来源:LegacySSTableTest.java
示例18: addNewKS
import org.apache.cassandra.cql3.UntypedResultSet; //导入依赖的package包/类
@Test
public void addNewKS() throws ConfigurationException
{
CFMetaData cfm = addTestTable("newkeyspace1", "newstandard1", "A new cf for a new ks");
KeyspaceMetadata newKs = KeyspaceMetadata.create(cfm.ksName, KeyspaceParams.simple(5), Tables.of(cfm));
MigrationManager.announceNewKeyspace(newKs);
assertNotNull(Schema.instance.getKSMetaData(cfm.ksName));
assertEquals(Schema.instance.getKSMetaData(cfm.ksName), newKs);
// test reads and writes.
QueryProcessor.executeInternal("INSERT INTO newkeyspace1.newstandard1 (key, col, val) VALUES (?, ?, ?)",
"key0", "col0", "val0");
ColumnFamilyStore store = Keyspace.open(cfm.ksName).getColumnFamilyStore(cfm.cfName);
assertNotNull(store);
store.forceBlockingFlush();
UntypedResultSet rows = QueryProcessor.executeInternal("SELECT * FROM newkeyspace1.newstandard1");
assertRows(rows, row("key0", "col0", "val0"));
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:21,代码来源:DefsTest.java
示例19: getReleaseVersion
import org.apache.cassandra.cql3.UntypedResultSet; //导入依赖的package包/类
/**
* Get release version for given endpoint.
* If release version is unknown, then this returns null.
*
* @param ep endpoint address to check
* @return Release version or null if version is unknown.
*/
public static CassandraVersion getReleaseVersion(InetAddress ep)
{
try
{
if (FBUtilities.getBroadcastAddress().equals(ep))
{
return new CassandraVersion(FBUtilities.getReleaseVersionString());
}
String req = "SELECT release_version FROM system.%s WHERE peer=?";
UntypedResultSet result = executeInternal(String.format(req, PEERS), ep);
if (result != null && result.one().has("release_version"))
{
return new CassandraVersion(result.one().getString("release_version"));
}
// version is unknown
return null;
}
catch (IllegalArgumentException e)
{
// version string cannot be parsed
return null;
}
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:31,代码来源:SystemKeyspace.java
示例20: loadPaxosState
import org.apache.cassandra.cql3.UntypedResultSet; //导入依赖的package包/类
public static PaxosState loadPaxosState(DecoratedKey key, CFMetaData metadata, int nowInSec)
{
String req = "SELECT * FROM system.%s WHERE row_key = ? AND cf_id = ?";
UntypedResultSet results = QueryProcessor.executeInternalWithNow(nowInSec, String.format(req, PAXOS), key.getKey(), metadata.cfId);
if (results.isEmpty())
return new PaxosState(key, metadata);
UntypedResultSet.Row row = results.one();
Commit promised = row.has("in_progress_ballot")
? new Commit(row.getUUID("in_progress_ballot"), new PartitionUpdate(metadata, key, metadata.partitionColumns(), 1))
: Commit.emptyCommit(key, metadata);
// either we have both a recently accepted ballot and update or we have neither
int proposalVersion = row.has("proposal_version") ? row.getInt("proposal_version") : MessagingService.VERSION_21;
Commit accepted = row.has("proposal")
? new Commit(row.getUUID("proposal_ballot"), PartitionUpdate.fromBytes(row.getBytes("proposal"), proposalVersion, key))
: Commit.emptyCommit(key, metadata);
// either most_recent_commit and most_recent_commit_at will both be set, or neither
int mostRecentVersion = row.has("most_recent_commit_version") ? row.getInt("most_recent_commit_version") : MessagingService.VERSION_21;
Commit mostRecent = row.has("most_recent_commit")
? new Commit(row.getUUID("most_recent_commit_at"), PartitionUpdate.fromBytes(row.getBytes("most_recent_commit"), mostRecentVersion, key))
: Commit.emptyCommit(key, metadata);
return new PaxosState(promised, accepted, mostRecent);
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:23,代码来源:SystemKeyspace.java
注:本文中的org.apache.cassandra.cql3.UntypedResultSet类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论