本文整理汇总了Java中org.apache.cassandra.transport.messages.ResultMessage.Rows方法的典型用法代码示例。如果您正苦于以下问题:Java ResultMessage.Rows方法的具体用法?Java ResultMessage.Rows怎么用?Java ResultMessage.Rows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.transport.messages.ResultMessage
的用法示例。
在下文中一共展示了ResultMessage.Rows方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeWithCondition
import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的package包/类
public ResultMessage executeWithCondition(QueryState queryState, QueryOptions options)
throws RequestExecutionException, RequestValidationException
{
List<ByteBuffer> keys = buildPartitionKeyNames(options);
// We don't support IN for CAS operation so far
if (keys.size() > 1)
throw new InvalidRequestException("IN on the partition key is not supported with conditional updates");
ByteBuffer key = keys.get(0);
long now = options.getTimestamp(queryState);
Composite prefix = createClusteringPrefix(options);
CQL3CasRequest request = new CQL3CasRequest(cfm, key, false);
addConditions(prefix, request, options);
request.addRowUpdate(prefix, this, options, now);
ColumnFamily result = StorageProxy.cas(keyspace(),
columnFamily(),
key,
request,
options.getSerialConsistency(),
options.getConsistency(),
queryState.getClientState());
return new ResultMessage.Rows(buildCasResultSet(key, result, options));
}
示例2: addPermissionsForRole
import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的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));
}
}
}
示例3: executeInternal
import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的package包/类
public ResultMessage.Rows executeInternal(QueryState state, QueryOptions options, int nowInSec) throws RequestExecutionException, RequestValidationException
{
int userLimit = getLimit(options);
ReadQuery query = getQuery(options, nowInSec, userLimit);
int pageSize = getPageSize(options);
try (ReadOrderGroup orderGroup = query.startOrderGroup())
{
if (pageSize <= 0 || query.limits().count() <= pageSize)
{
try (PartitionIterator data = query.executeInternal(orderGroup))
{
return processResults(data, options, nowInSec, userLimit);
}
}
else
{
QueryPager pager = query.getPager(options.getPagingState(), options.getProtocolVersion());
return execute(Pager.forInternalQuery(pager, orderGroup), options, pageSize, nowInSec, userLimit);
}
}
}
示例4: executeCQL
import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的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;
}
示例5: thriftHandler
import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的package包/类
@Override
public Function<ResultMessage, byte[][]> thriftHandler()
{
return new Function<ResultMessage, byte[][]>()
{
@Override
public byte[][] apply(ResultMessage result)
{
if (result instanceof ResultMessage.Rows)
{
ResultMessage.Rows rows = ((ResultMessage.Rows) result);
byte[][] r = new byte[rows.result.size()][];
for (int i = 0 ; i < r.length ; i++)
r[i] = rows.result.rows.get(i).get(0).array();
return r;
}
return null;
}
};
}
示例6: executeWithCondition
import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的package包/类
public ResultMessage executeWithCondition(QueryState queryState, QueryOptions options)
throws RequestExecutionException, RequestValidationException
{
CQL3CasRequest request = makeCasRequest(queryState, options);
try (RowIterator result = StorageProxy.cas(keyspace(),
columnFamily(),
request.key,
request,
options.getSerialConsistency(),
options.getConsistency(),
queryState.getClientState()))
{
return new ResultMessage.Rows(buildCasResultSet(result, options));
}
}
示例7: execute
import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的package包/类
private ResultMessage.Rows execute(Pageable command, ConsistencyLevel cl, List<ByteBuffer> variables, int limit, long now) throws RequestValidationException, RequestExecutionException
{
List<Row> rows;
if (command == null)
{
rows = Collections.<Row>emptyList();
}
else
{
rows = command instanceof Pageable.ReadCommands
? StorageProxy.read(((Pageable.ReadCommands)command).commands, cl)
: StorageProxy.getRangeSlice((RangeSliceCommand)command, cl);
}
return processResults(rows, variables, limit, now);
}
示例8: execute
import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的package包/类
public ResultMessage.Rows execute(QueryState state, QueryOptions options) throws RequestExecutionException, RequestValidationException
{
ConsistencyLevel cl = options.getConsistency();
checkNotNull(cl, "Invalid empty consistency level");
cl.validateForRead(keyspace());
int nowInSec = FBUtilities.nowInSeconds();
int userLimit = getLimit(options);
ReadQuery query = getQuery(options, nowInSec, userLimit);
int pageSize = getPageSize(options);
if (pageSize <= 0 || query.limits().count() <= pageSize)
return execute(query, options, state, nowInSec, userLimit);
QueryPager pager = query.getPager(options.getPagingState(), options.getProtocolVersion());
return execute(Pager.forDistributedQuery(pager, cl, state.getClientState()), options, pageSize, nowInSec, userLimit);
}
示例9: executeWithConditions
import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的package包/类
private ResultMessage executeWithConditions(BatchQueryOptions options, QueryState state)
throws RequestExecutionException, RequestValidationException
{
Pair<CQL3CasRequest, Set<ColumnDefinition>> p = makeCasRequest(options, state);
CQL3CasRequest casRequest = p.left;
Set<ColumnDefinition> columnsWithConditions = p.right;
String ksName = casRequest.cfm.ksName;
String tableName = casRequest.cfm.cfName;
try (RowIterator result = StorageProxy.cas(ksName,
tableName,
casRequest.key,
casRequest,
options.getSerialConsistency(),
options.getConsistency(),
state.getClientState()))
{
return new ResultMessage.Rows(ModificationStatement.buildCasResultSet(ksName, tableName, result, columnsWithConditions, true, options.forStatement(0)));
}
}
示例10: doAuthenticate
import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的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);
}
示例11: executeInternalWithConditions
import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的package包/类
private ResultMessage executeInternalWithConditions(BatchQueryOptions options, QueryState state) throws RequestExecutionException, RequestValidationException
{
Pair<CQL3CasRequest, Set<ColumnDefinition>> p = makeCasRequest(options, state);
CQL3CasRequest request = p.left;
Set<ColumnDefinition> columnsWithConditions = p.right;
String ksName = request.cfm.ksName;
String tableName = request.cfm.cfName;
try (RowIterator result = ModificationStatement.casInternal(request, state))
{
return new ResultMessage.Rows(ModificationStatement.buildCasResultSet(ksName, tableName, result, columnsWithConditions, true, options.forStatement(0)));
}
}
示例12: resultMessage
import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的package包/类
private ResultMessage resultMessage(List<PermissionDetails> details)
{
if (details.isEmpty())
return new ResultMessage.Void();
ResultSet result = new ResultSet(metadata);
for (PermissionDetails pd : details)
{
result.addColumnValue(UTF8Type.instance.decompose(pd.username));
result.addColumnValue(UTF8Type.instance.decompose(pd.resource.toString()));
result.addColumnValue(UTF8Type.instance.decompose(pd.permission.toString()));
}
return new ResultMessage.Rows(result);
}
示例13: processResults
import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的package包/类
private ResultMessage.Rows processResults(PartitionIterator partitions,
QueryOptions options,
int nowInSec,
int userLimit) throws RequestValidationException
{
ResultSet rset = process(partitions, options, nowInSec, userLimit);
return new ResultMessage.Rows(rset);
}
示例14: executeInternal
import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的package包/类
public ResultMessage.Rows executeInternal(QueryState state, QueryOptions options) throws RequestExecutionException, RequestValidationException
{
int limit = getLimit(options);
long now = System.currentTimeMillis();
Pageable command = getPageableCommand(options, limit, now);
List<Row> rows = command == null
? Collections.<Row>emptyList()
: (command instanceof Pageable.ReadCommands
? readLocally(keyspace(), ((Pageable.ReadCommands)command).commands)
: ((RangeSliceCommand)command).executeLocally());
return processResults(rows, options, limit, now);
}
示例15: process
import org.apache.cassandra.transport.messages.ResultMessage; //导入方法依赖的package包/类
public static UntypedResultSet process(String query, ConsistencyLevel cl, List<ByteBuffer> values) throws RequestExecutionException
{
ResultMessage result = instance.process(query, QueryState.forInternalCalls(), QueryOptions.forInternalCalls(cl, values));
if (result instanceof ResultMessage.Rows)
return UntypedResultSet.create(((ResultMessage.Rows)result).result);
else
return null;
}