本文整理汇总了Java中org.apache.cassandra.service.StorageProxy.read方法的典型用法代码示例。如果您正苦于以下问题:Java StorageProxy.read方法的具体用法?Java StorageProxy.read怎么用?Java StorageProxy.read使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.cassandra.service.StorageProxy
的用法示例。
在下文中一共展示了StorageProxy.read方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.apache.cassandra.service.StorageProxy; //导入方法依赖的package包/类
private ResultMessage.Rows execute(Pageable command, QueryOptions options, int limit, long now, QueryState state) 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, options.getConsistency(), state.getClientState())
: StorageProxy.getRangeSlice((RangeSliceCommand)command, options.getConsistency());
}
return processResults(rows, options, limit, now);
}
示例2: queryNextPage
import org.apache.cassandra.service.StorageProxy; //导入方法依赖的package包/类
protected List<Row> queryNextPage(int pageSize, ConsistencyLevel consistencyLevel, boolean localQuery)
throws RequestValidationException, RequestExecutionException
{
// For some queries, such as a DISTINCT query on static columns, the limit for slice queries will be lower
// than the page size (in the static example, it will be 1). We use the min here to ensure we don't fetch
// more rows than we're supposed to. See CASSANDRA-8108 for more details.
SliceQueryFilter filter = command.filter.withUpdatedCount(Math.min(command.filter.count, pageSize));
if (lastReturned != null)
filter = filter.withUpdatedStart(lastReturned, cfm.comparator);
logger.debug("Querying next page of slice query; new filter: {}", filter);
ReadCommand pageCmd = command.withUpdatedFilter(filter);
return localQuery
? Collections.singletonList(pageCmd.getRow(Keyspace.open(command.ksName)))
: StorageProxy.read(Collections.singletonList(pageCmd), consistencyLevel, cstate);
}
示例3: execute
import org.apache.cassandra.service.StorageProxy; //导入方法依赖的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);
}
示例4: retryDummyRead
import org.apache.cassandra.service.StorageProxy; //导入方法依赖的package包/类
private void retryDummyRead(String ks, String cf) throws PermanentBackendException {
final long limit = System.currentTimeMillis() + (60L * 1000L);
while (System.currentTimeMillis() < limit) {
try {
SortedSet<ByteBuffer> ss = new TreeSet<ByteBuffer>();
ss.add(ByteBufferUtil.zeroByteBuffer(1));
NamesQueryFilter nqf = new NamesQueryFilter(ss);
SliceByNamesReadCommand cmd = new SliceByNamesReadCommand(ks, ByteBufferUtil.zeroByteBuffer(1), cf, 1L, nqf);
StorageProxy.read(ImmutableList.<ReadCommand> of(cmd), ConsistencyLevel.QUORUM);
log.info("Read on CF {} in KS {} succeeded", cf, ks);
return;
} catch (Throwable t) {
log.warn("Failed to read CF {} in KS {} following creation", cf, ks, t);
}
try {
Thread.sleep(1000L);
} catch (InterruptedException e) {
throw new PermanentBackendException(e);
}
}
throw new PermanentBackendException("Timed out while attempting to read CF " + cf + " in KS " + ks + " following creation");
}
示例5: execute
import org.apache.cassandra.service.StorageProxy; //导入方法依赖的package包/类
private ResultMessage.Rows execute(Pageable command, QueryOptions options, int limit, long now) throws RequestValidationException, RequestExecutionException
{
List<Row> rows;
if (command == null)
{
rows = Collections.<Row>emptyList();
}
else
{
//@daidong we shall fall into the first category: calling StorageProxy.read().
//StorageProxy.read() still use the List<ReadCommand> as parameter instead of Pageable.ReadCommands
rows = command instanceof Pageable.ReadCommands
? StorageProxy.read(((Pageable.ReadCommands)command).commands, options.getConsistency())
: StorageProxy.getRangeSlice((RangeSliceCommand)command, options.getConsistency());
}
//@daidong still need to process the outputs before returning. From List<Row> to ResultMessage.Rows.
//basically, the processing is to encode the Rows into a formation we can send to client.
return processResults(rows, options, limit, now);
}
示例6: execute
import org.apache.cassandra.service.StorageProxy; //导入方法依赖的package包/类
public ResultMessage.Rows execute(ConsistencyLevel cl, QueryState state, List<ByteBuffer> variables) throws RequestExecutionException, RequestValidationException
{
if (cl == null)
throw new InvalidRequestException("Invalid empty consistency level");
cl.validateForRead(keyspace());
List<Row> rows;
if (isKeyRange)
{
RangeSliceCommand command = getRangeCommand(variables);
rows = command == null ? Collections.<Row>emptyList() : StorageProxy.getRangeSlice(command, cl);
}
else
{
List<ReadCommand> commands = getSliceCommands(variables);
rows = commands == null ? Collections.<Row>emptyList() : StorageProxy.read(commands, cl);
}
return processResults(rows, variables);
}
示例7: remoteStorageQuery
import org.apache.cassandra.service.StorageProxy; //导入方法依赖的package包/类
public static ColumnFamily remoteStorageQuery(String target, String dataTag){
try {
List<ReadCommand> command = new ArrayList<ReadCommand>();
command.add(new SliceFromReadCommand(
Metadata.MetaData_KS,
ByteBufferUtil.bytes(target),
new QueryPath(Metadata.MetadataLog_CF),
Column.decomposeName(String.valueOf(0) , "", dataTag, "value"),
Column.decomposeName(String.valueOf(Long.MAX_VALUE) , "", dataTag, "value"),
false,
Integer.MAX_VALUE));
List<Row> rows = StorageProxy.read(command, ConsistencyLevel.ANY);
return rows.get(0).cf;
} catch (Exception e) {
return null;
}
}
示例8: remoteStorageQuery
import org.apache.cassandra.service.StorageProxy; //导入方法依赖的package包/类
private ColumnFamily remoteStorageQuery(String target, String dataTag){
try {
List<ReadCommand> command = new ArrayList<ReadCommand>();
command.add(new SliceFromReadCommand(
Metadata.MetaData_KS,
ByteBufferUtil.bytes(target),
new QueryPath(Metadata.MetadataRegistry_CF),
Column.decomposeName(dataTag, "admin_tag"),
Column.decomposeName(dataTag, "admin_tag"),
false,
Integer.MAX_VALUE));
List<Row> rows = StorageProxy.read(command, ConsistencyLevel.ANY);
return rows.get(0).cf;
} catch (Exception e) {
return null;
}
}
示例9: execute
import org.apache.cassandra.service.StorageProxy; //导入方法依赖的package包/类
private ResultMessage.Rows execute(Pageable command, ConsistencyLevel cl, List<ByteBuffer> variables, int limit, long now) throws RequestValidationException, RequestExecutionException
{
logger.info(">>> STRATIO >>> SelectStatement.execute(...5)");
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);
}
示例10: retryDummyRead
import org.apache.cassandra.service.StorageProxy; //导入方法依赖的package包/类
private void retryDummyRead(String ks, String cf) throws PermanentBackendException {
final long limit = System.currentTimeMillis() + (60L * 1000L);
while (System.currentTimeMillis() < limit) {
try {
SortedSet<CellName> names = new TreeSet<>(new Comparator<CellName>() {
// This is a singleton set. We need to define a comparator because SimpleDenseCellName is not
// comparable, but it doesn't have to be a useful comparator
@Override
public int compare(CellName o1, CellName o2)
{
return 0;
}
});
names.add(CellNames.simpleDense(ByteBufferUtil.zeroByteBuffer(1)));
NamesQueryFilter nqf = new NamesQueryFilter(names);
SliceByNamesReadCommand cmd = new SliceByNamesReadCommand(ks, ByteBufferUtil.zeroByteBuffer(1), cf, 1L, nqf);
StorageProxy.read(ImmutableList.<ReadCommand> of(cmd), ConsistencyLevel.QUORUM);
log.info("Read on CF {} in KS {} succeeded", cf, ks);
return;
} catch (Throwable t) {
log.warn("Failed to read CF {} in KS {} following creation", cf, ks, t);
}
try {
Thread.sleep(1000L);
} catch (InterruptedException e) {
throw new PermanentBackendException(e);
}
}
throw new PermanentBackendException("Timed out while attempting to read CF " + cf + " in KS " + ks + " following creation");
}
示例11: readColumnFamily
import org.apache.cassandra.service.StorageProxy; //导入方法依赖的package包/类
protected Map<DecoratedKey, ColumnFamily> readColumnFamily(List<ReadCommand> commands, org.apache.cassandra.db.ConsistencyLevel consistency_level, ClientState cState)
throws org.apache.cassandra.exceptions.InvalidRequestException, UnavailableException, TimedOutException
{
// TODO - Support multiple column families per row, right now row only contains 1 column family
Map<DecoratedKey, ColumnFamily> columnFamilyKeyMap = new HashMap<DecoratedKey, ColumnFamily>();
List<Row> rows = null;
try
{
schedule(DatabaseDescriptor.getReadRpcTimeout());
try
{
rows = StorageProxy.read(commands, consistency_level, cState);
}
finally
{
release();
}
}
catch (RequestExecutionException e)
{
ThriftConversion.rethrow(e);
}
for (Row row: rows)
{
columnFamilyKeyMap.put(row.key, row.cf);
}
return columnFamilyKeyMap;
}
示例12: queryNextPage
import org.apache.cassandra.service.StorageProxy; //导入方法依赖的package包/类
protected List<Row> queryNextPage(int pageSize, ConsistencyLevel consistencyLevel, boolean localQuery)
throws RequestValidationException, RequestExecutionException
{
SliceQueryFilter filter = command.filter.withUpdatedCount(pageSize);
if (lastReturned != null)
filter = filter.withUpdatedStart(lastReturned, cfm.comparator);
ReadCommand pageCmd = command.withUpdatedFilter(filter);
return localQuery
? Collections.singletonList(pageCmd.getRow(Keyspace.open(command.ksName)))
: StorageProxy.read(Collections.singletonList(pageCmd), consistencyLevel);
}
示例13: readColumnFamily
import org.apache.cassandra.service.StorageProxy; //导入方法依赖的package包/类
protected Map<DecoratedKey, ColumnFamily> readColumnFamily(List<ReadCommand> commands, org.apache.cassandra.db.ConsistencyLevel consistency_level)
throws org.apache.cassandra.exceptions.InvalidRequestException, UnavailableException, TimedOutException
{
// TODO - Support multiple column families per row, right now row only contains 1 column family
Map<DecoratedKey, ColumnFamily> columnFamilyKeyMap = new HashMap<DecoratedKey, ColumnFamily>();
List<Row> rows = null;
try
{
schedule(DatabaseDescriptor.getReadRpcTimeout());
try
{
rows = StorageProxy.read(commands, consistency_level);
}
finally
{
release();
}
}
catch (RequestExecutionException e)
{
ThriftConversion.rethrow(e);
}
for (Row row: rows)
{
columnFamilyKeyMap.put(row.key, row.cf);
}
return columnFamilyKeyMap;
}
示例14: queryNextPage
import org.apache.cassandra.service.StorageProxy; //导入方法依赖的package包/类
protected List<Row> queryNextPage(int pageSize, ConsistencyLevel consistencyLevel, boolean localQuery)
throws RequestValidationException, RequestExecutionException
{
SliceQueryFilter filter = command.filter.withUpdatedCount(pageSize);
if (lastReturned != null)
filter = filter.withUpdatedStart(lastReturned, cfm.comparator);
logger.debug("Querying next page of slice query; new filter: {}", filter);
ReadCommand pageCmd = command.withUpdatedFilter(filter);
return localQuery
? Collections.singletonList(pageCmd.getRow(Keyspace.open(command.ksName)))
: StorageProxy.read(Collections.singletonList(pageCmd), consistencyLevel);
}
示例15: execute
import org.apache.cassandra.service.StorageProxy; //导入方法依赖的package包/类
public PartitionIterator execute(ConsistencyLevel consistency, ClientState clientState) throws RequestExecutionException
{
return StorageProxy.read(Group.one(this), consistency, clientState);
}