本文整理匯總了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;
}