本文整理汇总了Java中com.datastax.driver.core.Statement.setPagingState方法的典型用法代码示例。如果您正苦于以下问题:Java Statement.setPagingState方法的具体用法?Java Statement.setPagingState怎么用?Java Statement.setPagingState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.datastax.driver.core.Statement
的用法示例。
在下文中一共展示了Statement.setPagingState方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reduceFetchSize
import com.datastax.driver.core.Statement; //导入方法依赖的package包/类
/**
* Reduces the fetch size and retries the query. Returns true if the query succeeded, false if the root cause
* of the exception does not indicate a frame size issue, if the frame size cannot be adjusted down any further,
* or if the retried query fails for an unrelated reason.
*/
private boolean reduceFetchSize(Throwable reason) {
if (!isAdaptiveException(reason) || --_remainingAdaptations == 0) {
return false;
}
ExecutionInfo executionInfo = _delegate.getExecutionInfo();
Statement statement = executionInfo.getStatement();
PagingState pagingState = executionInfo.getPagingState();
int fetchSize = statement.getFetchSize();
while (fetchSize > MIN_FETCH_SIZE) {
fetchSize = Math.max(fetchSize / 2, MIN_FETCH_SIZE);
_log.debug("Retrying query at next page with fetch size {} due to {}", fetchSize, reason.getMessage());
statement.setFetchSize(fetchSize);
statement.setPagingState(pagingState);
try {
_delegate = _session.execute(statement);
return true;
} catch (Throwable t) {
// Exit the adaptation loop if the exception isn't one where adapting further may help
if (!isAdaptiveException(t) || --_remainingAdaptations == 0) {
return false;
}
}
}
return false;
}
示例2: run
import com.datastax.driver.core.Statement; //导入方法依赖的package包/类
public boolean run() throws Exception
{
State state = currentState.get();
if (state == null)
{ // start processing a new token range
TokenRange range = tokenRangeIterator.next();
if (range == null)
return true; // no more token ranges to process
state = new State(range, buildQuery(range));
currentState.set(state);
}
ResultSet results;
Statement statement = new SimpleStatement(state.query);
statement.setFetchSize(pageSize);
if (state.pagingState != null)
statement.setPagingState(state.pagingState);
results = client.getSession().execute(statement);
state.pagingState = results.getExecutionInfo().getPagingState();
int remaining = results.getAvailableWithoutFetching();
rowCount += remaining;
for (Row row : results)
{
// this call will only succeed if we've added token(partition keys) to the query
Token partition = row.getPartitionKeyToken();
if (!state.partitions.contains(partition))
{
partitionCount += 1;
state.partitions.add(partition);
}
if (--remaining == 0)
break;
}
if (results.isExhausted() || isWarmup)
{ // no more pages to fetch or just warming up, ready to move on to another token range
currentState.set(null);
}
return true;
}