本文整理汇总了Java中com.datastax.driver.core.ResultSet.getAvailableWithoutFetching方法的典型用法代码示例。如果您正苦于以下问题:Java ResultSet.getAvailableWithoutFetching方法的具体用法?Java ResultSet.getAvailableWithoutFetching怎么用?Java ResultSet.getAvailableWithoutFetching使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.datastax.driver.core.ResultSet
的用法示例。
在下文中一共展示了ResultSet.getAvailableWithoutFetching方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPage
import com.datastax.driver.core.ResultSet; //导入方法依赖的package包/类
private TimelinePageVM getPage(Select select, String page, int limit) {
//If we have a 'next' page set we deserialise it and add it to the select
//statement
if (page != null) {
select.setPagingState(PagingState.fromString(page));
}
//Execute the query
ResultSet resultSet = session.execute(select);
//Get the next paging state
PagingState newPagingState = resultSet.getExecutionInfo().getPagingState();
//The number of rows that can be read without fetching
int remaining = resultSet.getAvailableWithoutFetching();
List<XmTimeline> timelines = new ArrayList<>(limit);
for (Row row : resultSet) {
XmTimeline timeline = TimelineMapper.createTimeline(row);
timelines.add(timeline);
//If we can't move to the next row without fetching we break
if (--remaining == 0) {
break;
}
}
//Serialise the next paging state
String serializedNewPagingState = newPagingState != null
? newPagingState.toString() :
null;
//Return an object with a list of timelines and the next paging state
return new TimelinePageVM(timelines, serializedNewPagingState);
}
示例2: executeUpdate
import com.datastax.driver.core.ResultSet; //导入方法依赖的package包/类
/**
* 描述: 数据操作(Insert|Update|Delete)
* 时间: 2017年11月15日 上午11:27:52
* @author yi.zhang
* @param cql cql语句
* @param params 参数
* @return 返回值
*/
public int executeUpdate(String cql, Object... params) {
try {
if(session!=null){
init(servers, keyspace, username, password);
}
ResultSet rs = session.execute(cql, params);
return rs.getAvailableWithoutFetching();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return -1;
}
示例3: process
import com.datastax.driver.core.ResultSet; //导入方法依赖的package包/类
@Override
protected void process(CycleLog cycleLog) throws Exception {
// get cycle's planned start calendar
Calendar plannedStartCalendar =
CalendarAndDateOperationsInl.getCalendarFromUnixTime(
cycleLog.getPlannedStartTime() );
// -1 hour -- this cycle should check for the jobs from the past hour
plannedStartCalendar.set(Calendar.HOUR_OF_DAY, -1);
// query all jobs within cycle's hour
ResultSet resultSet =
HourlyCurrentJobs.i().executeSyncSelect(
CalendarFormatterInl.concatCalendarFields(
plannedStartCalendar,
Calendar.YEAR,
Calendar.MONTH,
Calendar.DAY_OF_MONTH,
Calendar.HOUR_OF_DAY) );
// to to fetch each job
ResultSet currJobResultSet;
String currSerializedJob;
Job currJob;
// retry executing every found job (failed to execute job)
for (Row row : resultSet) {
if (resultSet.getAvailableWithoutFetching() <=
Constants.kCassandraPrefetchLimit &&
resultSet.isFullyFetched() == false) {
// this is asynchronous
resultSet.fetchMoreResults();
}
// select job
currJobResultSet =
CurrentJobs.i().executeSyncSelect(
row.getUUID(HourlyCurrentJobs.kJobIdColumnName) );
// couldn't get job?
if (currJobResultSet.isExhausted() == true) {
// may need to log an exception here depending how how this service,
// the main service and the dispense work together - in terms of sync
continue;
}
// get serialized job
currSerializedJob =
EncodingInl.decodeStringFromByteBuffer(
currJobResultSet.one().getBytes(
CurrentJobs.kJobColumnName) );
// deserialize
currJob = SerializationInl.<Job>deserializeObject(currSerializedJob);
// execute job (retry)
JobsExecutorInl.executeJobsAsync(currJob);
}
}