本文整理汇总了Java中org.apache.cassandra.cql3.statements.SelectStatement类的典型用法代码示例。如果您正苦于以下问题:Java SelectStatement类的具体用法?Java SelectStatement怎么用?Java SelectStatement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SelectStatement类属于org.apache.cassandra.cql3.statements包,在下文中一共展示了SelectStatement类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getQuery
import org.apache.cassandra.cql3.statements.SelectStatement; //导入依赖的package包/类
public Query getQuery(String command) throws Exception {
SelectStatement.RawStatement statement = (SelectStatement.RawStatement) QueryProcessor.parseStatement(command);
if (statement.columnFamily().matches("sstables?")) {
if (sstables.isEmpty()) {
return null;
}
metadata = CassandraUtils.tableFromBestSource(sstables.iterator().next());
return new Query(command, sstables, metadata);
} else {
File path = new File(statement.columnFamily());
if (!path.exists()) {
throw new FileNotFoundException(path.getAbsolutePath());
}
metadata = CassandraUtils.tableFromBestSource(path);
return new Query(command, Collections.singleton(path), metadata);
}
}
开发者ID:tolbertam,项目名称:sstable-tools,代码行数:18,代码来源:Cqlsh.java
示例2: executeCQL
import org.apache.cassandra.cql3.statements.SelectStatement; //导入依赖的package包/类
private Set<String> executeCQL(String rawStatement) throws Exception
{
SelectStatement statement = (SelectStatement) QueryProcessor.parseStatement(rawStatement).prepare().statement;
ResultMessage.Rows cqlRows = statement.executeInternal(QueryState.forInternalCalls(), new QueryOptions(ConsistencyLevel.LOCAL_ONE, Collections.<ByteBuffer>emptyList()));
Set<String> results = new TreeSet<>();
for (CqlRow row : cqlRows.toThriftResult().getRows())
{
for (org.apache.cassandra.thrift.Column col : row.columns)
{
String columnName = UTF8Type.instance.getString(col.bufferForName());
if (columnName.equals("key"))
results.add(AsciiType.instance.getString(col.bufferForValue()));
}
}
return results;
}
开发者ID:xedin,项目名称:sasi,代码行数:19,代码来源:SSTableAttachedSecondaryIndexTest.java
示例3: authenticate
import org.apache.cassandra.cql3.statements.SelectStatement; //导入依赖的package包/类
private AuthenticatedUser authenticate(String username, String password) throws AuthenticationException
{
try
{
// If the legacy users table exists try to verify credentials there. This is to handle the case
// where the cluster is being upgraded and so is running with mixed versions of the authn tables
SelectStatement authenticationStatement = Schema.instance.getCFMetaData(AuthKeyspace.NAME, LEGACY_CREDENTIALS_TABLE) == null
? authenticateStatement
: legacyAuthenticateStatement;
return doAuthenticate(username, password, authenticationStatement);
}
catch (RequestExecutionException e)
{
logger.trace("Error performing internal authentication", e);
throw new AuthenticationException(e.toString());
}
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:18,代码来源:PasswordAuthenticator.java
示例4: addPermissionsForRole
import org.apache.cassandra.cql3.statements.SelectStatement; //导入依赖的package包/类
private void addPermissionsForRole(Set<Permission> permissions, IResource resource, RoleResource role)
throws RequestExecutionException, RequestValidationException
{
QueryOptions options = QueryOptions.forInternalCalls(ConsistencyLevel.LOCAL_ONE,
Lists.newArrayList(ByteBufferUtil.bytes(role.getRoleName()),
ByteBufferUtil.bytes(resource.getName())));
// If it exists, read from the legacy user permissions table to handle the case where the cluster
// is being upgraded and so is running with mixed versions of the authz schema
SelectStatement statement = Schema.instance.getCFMetaData(AuthKeyspace.NAME, USER_PERMISSIONS) == null
? authorizeRoleStatement
: legacyAuthorizeRoleStatement;
ResultMessage.Rows rows = statement.execute(QueryState.forInternalCalls(), options) ;
UntypedResultSet result = UntypedResultSet.create(rows.result);
if (!result.isEmpty() && result.one().has(PERMISSIONS))
{
for (String perm : result.one().getSet(PERMISSIONS, UTF8Type.instance))
{
permissions.add(Permission.valueOf(perm));
}
}
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:24,代码来源:CassandraAuthorizer.java
示例5: renameColumn
import org.apache.cassandra.cql3.statements.SelectStatement; //导入依赖的package包/类
/**
* Replace the column {@param from} with {@param to} in this materialized view definition's partition,
* clustering, or included columns.
*/
public void renameColumn(ColumnIdentifier from, ColumnIdentifier to)
{
metadata.renameColumn(from, to);
// convert whereClause to Relations, rename ids in Relations, then convert back to whereClause
List<Relation> relations = whereClauseToRelations(whereClause);
ColumnIdentifier.Raw fromRaw = new ColumnIdentifier.Literal(from.toString(), true);
ColumnIdentifier.Raw toRaw = new ColumnIdentifier.Literal(to.toString(), true);
List<Relation> newRelations = relations.stream()
.map(r -> r.renameIdentifier(fromRaw, toRaw))
.collect(Collectors.toList());
this.whereClause = View.relationsToWhereClause(newRelations);
String rawSelect = View.buildSelectStatement(baseTableName, metadata.allColumns(), whereClause);
this.select = (SelectStatement.RawStatement) QueryProcessor.parseStatement(rawSelect);
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:21,代码来源:ViewDefinition.java
示例6: FromPager
import org.apache.cassandra.cql3.statements.SelectStatement; //导入依赖的package包/类
private FromPager(SelectStatement select, QueryPager pager, int pageSize)
{
this.select = select;
this.pager = pager;
this.pageSize = pageSize;
this.metadata = select.getResultMetadata().names;
}
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:8,代码来源:UntypedResultSet.java
示例7: setup
import org.apache.cassandra.cql3.statements.SelectStatement; //导入依赖的package包/类
/**
* Sets up Authenticator and Authorizer.
*/
public static void setup()
{
if (DatabaseDescriptor.getAuthenticator() instanceof AllowAllAuthenticator)
return;
setupAuthKeyspace();
setupTable(USERS_CF, USERS_CF_SCHEMA);
DatabaseDescriptor.getAuthenticator().setup();
DatabaseDescriptor.getAuthorizer().setup();
// register a custom MigrationListener for permissions cleanup after dropped keyspaces/cfs.
MigrationManager.instance.register(new AuthMigrationListener());
// the delay is here to give the node some time to see its peers - to reduce
// "Skipped default superuser setup: some nodes were not ready" log spam.
// It's the only reason for the delay.
ScheduledExecutors.nonPeriodicTasks.schedule(new Runnable()
{
public void run()
{
setupDefaultSuperuser();
}
}, SUPERUSER_SETUP_DELAY, TimeUnit.MILLISECONDS);
try
{
String query = String.format("SELECT * FROM %s.%s WHERE name = ?", AUTH_KS, USERS_CF);
selectUserStatement = (SelectStatement) QueryProcessor.parseStatement(query).prepare().statement;
}
catch (RequestValidationException e)
{
throw new AssertionError(e); // not supposed to happen
}
}
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:39,代码来源:Auth.java
示例8: setup
import org.apache.cassandra.cql3.statements.SelectStatement; //导入依赖的package包/类
public void setup()
{
Auth.setupTable(CREDENTIALS_CF, CREDENTIALS_CF_SCHEMA);
// the delay is here to give the node some time to see its peers - to reduce
// "skipped default user setup: some nodes are were not ready" log spam.
// It's the only reason for the delay.
ScheduledExecutors.nonPeriodicTasks.schedule(new Runnable()
{
public void run()
{
setupDefaultUser();
}
}, Auth.SUPERUSER_SETUP_DELAY, TimeUnit.MILLISECONDS);
try
{
String query = String.format("SELECT %s FROM %s.%s WHERE username = ?",
SALTED_HASH,
Auth.AUTH_KS,
CREDENTIALS_CF);
authenticateStatement = (SelectStatement) QueryProcessor.parseStatement(query).prepare().statement;
}
catch (RequestValidationException e)
{
throw new AssertionError(e); // not supposed to happen
}
}
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:29,代码来源:PasswordAuthenticator.java
示例9: setup
import org.apache.cassandra.cql3.statements.SelectStatement; //导入依赖的package包/类
public void setup()
{
Auth.setupTable(PERMISSIONS_CF, PERMISSIONS_CF_SCHEMA);
try
{
String query = String.format("SELECT permissions FROM %s.%s WHERE username = ? AND resource = ?", Auth.AUTH_KS, PERMISSIONS_CF);
authorizeStatement = (SelectStatement) QueryProcessor.parseStatement(query).prepare().statement;
}
catch (RequestValidationException e)
{
throw new AssertionError(e); // not supposed to happen
}
}
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:15,代码来源:CassandraAuthorizer.java
示例10: extractResultMetadata
import org.apache.cassandra.cql3.statements.SelectStatement; //导入依赖的package包/类
private static ResultSet.Metadata extractResultMetadata(CQLStatement statement)
{
if (!(statement instanceof SelectStatement))
return ResultSet.Metadata.EMPTY;
return ((SelectStatement)statement).getResultMetadata();
}
开发者ID:vcostet,项目名称:cassandra-kmean,代码行数:8,代码来源:ResultMessage.java
示例11: setup
import org.apache.cassandra.cql3.statements.SelectStatement; //导入依赖的package包/类
public void setup()
{
setupCredentialsTable();
// the delay is here to give the node some time to see its peers - to reduce
// "skipped default user setup: some nodes are were not ready" log spam.
// It's the only reason for the delay.
if (DatabaseDescriptor.getSeeds().contains(FBUtilities.getBroadcastAddress()) || !DatabaseDescriptor.isAutoBootstrap())
{
StorageService.tasks.schedule(new Runnable()
{
public void run()
{
setupDefaultUser();
}
},
Auth.SUPERUSER_SETUP_DELAY,
TimeUnit.MILLISECONDS);
}
try
{
String query = String.format("SELECT %s FROM %s.%s WHERE username = ?",
SALTED_HASH,
Auth.AUTH_KS,
CREDENTIALS_CF);
authenticateStatement = (SelectStatement) QueryProcessor.parseStatement(query).prepare().statement;
}
catch (RequestValidationException e)
{
throw new AssertionError(e); // not supposed to happen
}
}
开发者ID:pgaref,项目名称:ACaZoo,代码行数:34,代码来源:PasswordAuthenticator.java
示例12: getExpressions
import org.apache.cassandra.cql3.statements.SelectStatement; //导入依赖的package包/类
private static IndexExpression[] getExpressions(String cqlQuery) throws Exception
{
ParsedStatement parsedStatement = QueryProcessor.parseStatement(String.format(cqlQuery, KS_NAME, CF_NAME));
SelectStatement selectStatement = (SelectStatement) parsedStatement.prepare().statement;
List<IndexExpression> expressions = selectStatement.getIndexExpressions(Collections.<ByteBuffer>emptyList());
return expressions.toArray(new IndexExpression[expressions.size()]);
}
开发者ID:xedin,项目名称:sasi,代码行数:9,代码来源:SSTableAttachedSecondaryIndexTest.java
示例13: FromPager
import org.apache.cassandra.cql3.statements.SelectStatement; //导入依赖的package包/类
private FromPager(SelectStatement select, QueryPager pager, int pageSize)
{
this.select = select;
this.pager = pager;
this.pageSize = pageSize;
this.metadata = select.getResultMetadata().requestNames();
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:8,代码来源:UntypedResultSet.java
示例14: setup
import org.apache.cassandra.cql3.statements.SelectStatement; //导入依赖的package包/类
public void setup()
{
loadRoleStatement = (SelectStatement) prepare("SELECT * from %s.%s WHERE role = ?",
AuthKeyspace.NAME,
AuthKeyspace.ROLES);
// If the old users table exists, we may need to migrate the legacy authn
// data to the new table. We also need to prepare a statement to read from
// it, so we can continue to use the old tables while the cluster is upgraded.
// Otherwise, we may need to create a default superuser role to enable others
// to be added.
if (Schema.instance.getCFMetaData(AuthKeyspace.NAME, "users") != null)
{
legacySelectUserStatement = (SelectStatement) prepare("SELECT * FROM %s.%s WHERE name = ?",
AuthKeyspace.NAME,
LEGACY_USERS_TABLE);
scheduleSetupTask(() -> {
convertLegacyData();
return null;
});
}
else
{
scheduleSetupTask(() -> {
setupDefaultRole();
return null;
});
}
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:29,代码来源:CassandraRoleManager.java
示例15: getRoleFromTable
import org.apache.cassandra.cql3.statements.SelectStatement; //导入依赖的package包/类
private Role getRoleFromTable(String name, SelectStatement statement, Function<UntypedResultSet.Row, Role> function)
throws RequestExecutionException, RequestValidationException
{
ResultMessage.Rows rows =
statement.execute(QueryState.forInternalCalls(),
QueryOptions.forInternalCalls(consistencyForRole(name),
Collections.singletonList(ByteBufferUtil.bytes(name))));
if (rows.result.isEmpty())
return NULL_ROLE;
return function.apply(UntypedResultSet.create(rows.result).one());
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:13,代码来源:CassandraRoleManager.java
示例16: doAuthenticate
import org.apache.cassandra.cql3.statements.SelectStatement; //导入依赖的package包/类
private AuthenticatedUser doAuthenticate(String username, String password, SelectStatement authenticationStatement)
throws RequestExecutionException, AuthenticationException
{
ResultMessage.Rows rows = authenticationStatement.execute(QueryState.forInternalCalls(),
QueryOptions.forInternalCalls(consistencyForRole(username),
Lists.newArrayList(ByteBufferUtil.bytes(username))));
UntypedResultSet result = UntypedResultSet.create(rows.result);
if ((result.isEmpty() || !result.one().has(SALTED_HASH)) || !BCrypt.checkpw(password, result.one().getString(SALTED_HASH)))
throw new AuthenticationException("Username and/or password are incorrect");
return new AuthenticatedUser(username);
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:14,代码来源:PasswordAuthenticator.java
示例17: prepare
import org.apache.cassandra.cql3.statements.SelectStatement; //导入依赖的package包/类
private SelectStatement prepare(String entityname, String permissionsTable)
{
String query = String.format("SELECT permissions FROM %s.%s WHERE %s = ? AND resource = ?",
AuthKeyspace.NAME,
permissionsTable,
entityname);
return (SelectStatement) QueryProcessor.getStatement(query, ClientState.forInternalCalls()).statement;
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:9,代码来源:CassandraAuthorizer.java
示例18: extractResultMetadata
import org.apache.cassandra.cql3.statements.SelectStatement; //导入依赖的package包/类
private static ResultSet.ResultMetadata extractResultMetadata(CQLStatement statement)
{
if (!(statement instanceof SelectStatement))
return ResultSet.ResultMetadata.EMPTY;
return ((SelectStatement)statement).getResultMetadata();
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:8,代码来源:ResultMessage.java
示例19: ViewDefinition
import org.apache.cassandra.cql3.statements.SelectStatement; //导入依赖的package包/类
/**
* @param viewName Name of the view
* @param baseTableId Internal ID of the table which this view is based off of
* @param includeAllColumns Whether to include all columns or not
*/
public ViewDefinition(String ksName, String viewName, UUID baseTableId, String baseTableName, boolean includeAllColumns, SelectStatement.RawStatement select, String whereClause, CFMetaData metadata)
{
this.ksName = ksName;
this.viewName = viewName;
this.baseTableId = baseTableId;
this.baseTableName = baseTableName;
this.includeAllColumns = includeAllColumns;
this.select = select;
this.whereClause = whereClause;
this.metadata = metadata;
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:17,代码来源:ViewDefinition.java
示例20: fetchView
import org.apache.cassandra.cql3.statements.SelectStatement; //导入依赖的package包/类
private static ViewDefinition fetchView(String keyspaceName, String viewName, Types types)
{
String query = String.format("SELECT * FROM %s.%s WHERE keyspace_name = ? AND view_name = ?", NAME, VIEWS);
UntypedResultSet rows = query(query, keyspaceName, viewName);
if (rows.isEmpty())
throw new RuntimeException(String.format("%s:%s not found in the schema definitions keyspace.", keyspaceName, viewName));
UntypedResultSet.Row row = rows.one();
UUID id = row.getUUID("id");
UUID baseTableId = row.getUUID("base_table_id");
String baseTableName = row.getString("base_table_name");
boolean includeAll = row.getBoolean("include_all_columns");
String whereClause = row.getString("where_clause");
List<ColumnDefinition> columns = fetchColumns(keyspaceName, viewName, types);
Map<ByteBuffer, CFMetaData.DroppedColumn> droppedColumns = fetchDroppedColumns(keyspaceName, viewName);
CFMetaData cfm = CFMetaData.create(keyspaceName,
viewName,
id,
false,
true,
false,
false,
true,
columns,
DatabaseDescriptor.getPartitioner())
.params(createTableParamsFromRow(row))
.droppedColumns(droppedColumns);
String rawSelect = View.buildSelectStatement(baseTableName, columns, whereClause);
SelectStatement.RawStatement rawStatement = (SelectStatement.RawStatement) QueryProcessor.parseStatement(rawSelect);
return new ViewDefinition(keyspaceName, viewName, baseTableId, baseTableName, includeAll, rawStatement, whereClause, cfm);
}
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:37,代码来源:SchemaKeyspace.java
注:本文中的org.apache.cassandra.cql3.statements.SelectStatement类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论