當前位置: 首頁>>代碼示例>>Java>>正文


Java ResultSet.getAvailableWithoutFetching方法代碼示例

本文整理匯總了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);
}
 
開發者ID:xm-online,項目名稱:xm-ms-timeline,代碼行數:37,代碼來源:TimelineRepository.java

示例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;
}
 
開發者ID:dev-share,項目名稱:database-transform-tool,代碼行數:22,代碼來源:CassandraFactory.java

示例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);
  }
}
 
開發者ID:vangav,項目名稱:vos_instagram_jobs,代碼行數:65,代碼來源:RestJobs.java


注:本文中的com.datastax.driver.core.ResultSet.getAvailableWithoutFetching方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。