当前位置: 首页>>代码示例>>Java>>正文


Java SelectStatement类代码示例

本文整理汇总了Java中org.apache.cassandra.cql3.statements.SelectStatement的典型用法代码示例。如果您正苦于以下问题:Java SelectStatement类的具体用法?Java SelectStatement怎么用?Java SelectStatement使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


SelectStatement类属于org.apache.cassandra.cql3.statements包,在下文中一共展示了SelectStatement类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的org.apache.cassandra.cql3.statements.SelectStatement类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。