当前位置: 首页>>代码示例>>Java>>正文


Java ResultSet.one方法代码示例

本文整理汇总了Java中com.datastax.driver.core.ResultSet.one方法的典型用法代码示例。如果您正苦于以下问题:Java ResultSet.one方法的具体用法?Java ResultSet.one怎么用?Java ResultSet.one使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.datastax.driver.core.ResultSet的用法示例。


在下文中一共展示了ResultSet.one方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getUserLastGeoCoordinates

import com.datastax.driver.core.ResultSet; //导入方法依赖的package包/类
/**
 * getUserLastGeoCoordinates
 * @param userId
 * @return user's last geo coordinates and null if it doesn't exist
 * @throws Exception
 */
public static GeoCoordinates getUserLastGeoCoordinates (
  UUID userId) throws Exception {
  
  ResultSet resultSet =
    UsersInfo.i().executeSyncSelectLastLocation(userId);
  
  if (resultSet.isExhausted() == false) {
    
    Row row = resultSet.one();
    
    double latitude =
      row.getDouble(UsersInfo.kLastLatitudeColumnName);
    double longitude =
      row.getDouble(UsersInfo.kLastLongitudeColumnName);
    
    return new GeoCoordinates(latitude, longitude);
  } else {
    
    return null;
  }
}
 
开发者ID:vangav,项目名称:vos_instagram,代码行数:28,代码来源:GettersInl.java

示例2: getIdByKey

import com.datastax.driver.core.ResultSet; //导入方法依赖的package包/类
/**
 * Get entity id by entity key.
 *
 * @param key    the entity key
 * @param tenant tenant name
 * @return entity id
 */
public Long getIdByKey(String key, String tenant) {
    Select select = QueryBuilder.select(ENTITY_ID_COL).from(tenant, TABLE_KEY_ID);
    select.where(eq(ENTITY_KEY_COL, key));
    ResultSet resultSet = session.execute(select);
    Row row = resultSet.one();
    return  row == null ? null : row.getLong(ENTITY_ID_COL);
}
 
开发者ID:xm-online,项目名称:xm-ms-timeline,代码行数:15,代码来源:EntityMappingRepository.java

示例3: getKeyById

import com.datastax.driver.core.ResultSet; //导入方法依赖的package包/类
/**
 * Get entity key by entity id.
 *
 * @param entityId entity id
 * @param tenant   tenant name
 * @return entity key
 */
public String getKeyById(Long entityId, String tenant) {
    Select select = QueryBuilder.select(ENTITY_KEY_COL).from(tenant, VIEW_ID_KEY);
    select.where(eq(ENTITY_ID_COL, entityId));
    ResultSet resultSet = session.execute(select);
    Row row = resultSet.one();
    return row == null ? null : row.getString(ENTITY_KEY_COL);
}
 
开发者ID:xm-online,项目名称:xm-ms-timeline,代码行数:15,代码来源:EntityMappingRepository.java

示例4: get

import com.datastax.driver.core.ResultSet; //导入方法依赖的package包/类
/**
 * Loads a {@link DecisionTreeRuleSet} from Cassandra using the defined keyspace.
 *
 * @return {@link Result} indicating if the load succeeded, storing any exception if the load failed.
 */
@Override
public Result<DecisionTreeRuleSet> get() {
    try {
        ResultSet resultSet = this.session.execute(CQL_GET_RULESET_FROM_RULESETNAME,
                "DEFAULT", this.ruleSetName);
        EhSupport.ensure(!resultSet.isExhausted(), "RuleSet %s does not exist in %s.", this.ruleSetName,
                this.keyspace);

        final Row resultsRow = resultSet.one();
        final List<String> driverList = resultsRow.getList("drivers", String.class);
        final DriverCache driverCache = new DriverCache();

        resultSet = this.session.execute(CQL_GET_RULES_FOR_RULESET, this.ruleSetName);
        final Builder<RuleSetBuilder, DecisionTreeRuleSet> ruleSetBuilder = RuleSetBuilder.creator(driverList);
        ruleSetBuilder.with(RuleSetBuilder::setName, this.ruleSetName);
        ruleSetBuilder.with(RuleSetBuilder::groups, getValueGroupsForRuleSet(this.ruleSetName));
        ruleSetBuilder.with(RuleSetBuilder::setCache, driverCache);

        resultSet.iterator().forEachRemaining(row -> ruleSetBuilder.with(RuleSetBuilder::rule, RuleBuilder.creator()
                .with(RuleBuilder::cache, driverCache)
                .with(RuleBuilder::setId, row.get("id", UUID.class))
                .with(RuleBuilder::setCode, row.get("code", UUID.class))
                .with(RuleBuilder::start, row.get("start", Instant.class))
                .with(RuleBuilder::end, row.get("end", Instant.class))
                .with(RuleBuilder::input, row.getList("drivers", String.class))
                .with(RuleBuilder::output, row.getList("outputs", String.class))
        ));

        final DecisionTreeRuleSet loadedRuleSet = ruleSetBuilder.build();
        return Result.success(loadedRuleSet);
    } catch (final Exception exception) {
        return Result.failure(() -> exception);
    }
}
 
开发者ID:jpmorganchase,项目名称:swblocks-decisiontree,代码行数:40,代码来源:CassandraLoader.java

示例5: getSingleValue

import com.datastax.driver.core.ResultSet; //导入方法依赖的package包/类
public static Object getSingleValue(ResultSet resultSet) {
    Row one = resultSet.one();
    return one != null ? one.getObject(0) : null;
}
 
开发者ID:papyrusglobal,项目名称:state-channels,代码行数:5,代码来源:CassandraUtil.java

示例6: authenticateRequest

import com.datastax.driver.core.ResultSet; //导入方法依赖的package包/类
@Override
protected void authenticateRequest (
  final Request request) throws Exception {
  
  // get request's body
  RequestLoginEmail requestLoginEmail =
    (RequestLoginEmail)request.getRequestJsonBody();
  
  // select user's password
  ResultSet resultSet =
    EmailCreds.i().executeSyncSelect(requestLoginEmail.email);
  
  // email isn't registered?
  if (resultSet.isExhausted() == true) {
    
    throw new BadRequestException(
      421,
      1,
      "Email ["
        + requestLoginEmail.email
        + "] isn't registered, request sent from device_token ["
        + requestLoginEmail.device_token
        + "]",
      ExceptionClass.AUTHENTICATION);
  }
  
  // extract password
  Row row = resultSet.one();
  
  String password = row.getString(EmailCreds.kPasswordColumnName);
  
  // wrong password?
  if (requestLoginEmail.password.compareTo(password) != 0) {
    
    throw new BadRequestException(
      421,
      2,
      "Wrong password ["
        + requestLoginEmail.password
        + "], expected password ["
        + password
        + "] for email ["
        + requestLoginEmail.email
        + "], request sent from device_token ["
        + requestLoginEmail.device_token
        + "]",
      ExceptionClass.AUTHENTICATION);
  }
}
 
开发者ID:vangav,项目名称:vos_instagram,代码行数:50,代码来源:HandlerLoginEmail.java

示例7: processRequest

import com.datastax.driver.core.ResultSet; //导入方法依赖的package包/类
@Override
protected void processRequest (final Request request) throws Exception {

  // use the following request Object to process the request and set
  //   the response to be returned
  RequestLoginEmail requestLoginEmail =
    (RequestLoginEmail)request.getRequestJsonBody();

  // select user's password and user_id
  ResultSet resultSet =
    EmailCreds.i().executeSyncSelect(requestLoginEmail.email);
  
  // email isn't registered? -- in case authentication is disabled
  if (resultSet.isExhausted() == true) {
    
    throw new BadRequestException(
      421,
      3,
      "Email ["
        + requestLoginEmail.email
        + "] isn't registered, request sent from device_token ["
        + requestLoginEmail.device_token
        + "]",
      ExceptionClass.AUTHENTICATION);
  }
  
  // extract user_id
  Row row = resultSet.one();
  
  UUID userId = row.getUUID(EmailCreds.kUserIdColumnName);
  
  // set user's id
  request.setUserId(userId);

  // generate new authentication tokens
  OAuth2Tokens oAuth2Tokens = new OAuth2Tokens();
  
  // insert into ig_auth.auth_codes
  AuthCodes.i().executeSyncInsert(
    userId,
    requestLoginEmail.device_token,
    oAuth2Tokens.getAuthorizationCode(),
    oAuth2Tokens.getAccessToken(),
    oAuth2Tokens.getRefreshToken(),
    ((int)Constants.kAuthCodeLifeTime.getAs(
      TimeUnitType.SECOND).getValue() ) );
  
  // set response
  ((ResponseLoginEmail)request.getResponseBody() ).set(
    requestLoginEmail.request_tracking_id,
    userId.toString(),
    oAuth2Tokens.getAuthorizationCode() );
}
 
开发者ID:vangav,项目名称:vos_instagram,代码行数:54,代码来源:HandlerLoginEmail.java

示例8: processRequest

import com.datastax.driver.core.ResultSet; //导入方法依赖的package包/类
@Override
protected void processRequest (final Request request) throws Exception {

  // use the following request Object to process the request and set
  //   the response to be returned
  RequestUpdateLocation requestUpdateLocation =
    (RequestUpdateLocation)request.getRequestJsonBody();
  
  // get last user's location
  ResultSet resultSet =
    UsersInfo.i().executeSyncSelectLastLocation(
      requestUpdateLocation.getUserId() );
    
  Row row = resultSet.one();
  
  // extract location's coordinates
  double lastLatitude = row.getDouble(UsersInfo.kLastLatitudeColumnName);
  double lastLongitude = row.getDouble(UsersInfo.kLastLongitudeColumnName);
  
  // first time to update location?
  if (lastLatitude == 0.0 && lastLongitude == 0.0) {
    
    // get location's continent code
    ReverseGeoCode reverseGeoCode =
      ReverseGeoCoding.i().getReverseGeoCode(lastLatitude, lastLongitude);
    
    // get user's registration time
    
    resultSet =
      UsersInfo.i().executeSyncSelectRegistrationTime(
        requestUpdateLocation.getUserId() );
    
    long registrationTime =
      resultSet.one().getLong(UsersInfo.kRegistrationTimeColumnName);
    
    Calendar registrationCalendar =
      CalendarAndDateOperationsInl.getCalendarFromUnixTime(
        registrationTime);
    
    // dispatch analytics
    
    // ig_analytics.annual_regional_counters.increment_new_users
    request.getDispatcher().addDispatchMessage(
      AnnualRegionalCounters.i().getQueryDispatchableIncrementNewUsers(
        CalendarFormatterInl.concatCalendarFields(
          registrationCalendar,
          Calendar.YEAR)
          + Constants.kCassandraIdConcat
          + reverseGeoCode.getContinentCode() ) );
    
    // ig_analytics.daily_regional_counters.increment_new_users
    request.getDispatcher().addDispatchMessage(
      DailyRegionalCounters.i().getQueryDispatchableIncrementNewUsers(
        CalendarFormatterInl.concatCalendarFields(
          registrationCalendar,
          Calendar.YEAR,
          Calendar.MONTH,
          Calendar.DAY_OF_MONTH)
          + Constants.kCassandraIdConcat
          + reverseGeoCode.getContinentCode() ) );
  }
  
  // update last_latitude and last_longitude
  UsersInfo.i().executeSyncSetLastLocation(
    requestUpdateLocation.latitude,
    requestUpdateLocation.longitude,
    requestUpdateLocation.getUserId() );
  
  // set response
  ((ResponseUpdateLocation)request.getResponseBody() ).set(
    requestUpdateLocation.request_tracking_id,
    request.getStartTime() );
}
 
开发者ID:vangav,项目名称:vos_instagram,代码行数:74,代码来源:HandlerUpdateLocation.java

示例9: processRequest

import com.datastax.driver.core.ResultSet; //导入方法依赖的package包/类
@Override
  protected void processRequest (final Request request) throws Exception {

    // use the following request Object to process the request and set
    //   the response to be returned
    RequestGetFeedPosts requestGetFeedPosts =
      (RequestGetFeedPosts)request.getRequestJsonBody();
    
    // set count limit
    
    // CURRENTLY DISABLED - set to 30
//    int countLimit;
//    
//    if (requestGetFeedPosts.isValidParam(
//          RequestGetFeedPosts.kCountLimitName) == true) {
//      
//      countLimit =
//        NumbersInl.trim(
//          requestGetFeedPosts.count_limit,
//          Constants.kMinGettersCountLimit,
//          Constants.kMaxGettersCountLimit);
//    } else {
//      
//      countLimit = Constants.kDefaultGettersCountLimit;
//    }
    
    // select feed posts from the database
    
    ResultSet resultSet;
    
    if (requestGetFeedPosts.isValidParam(
          RequestGetFeedPosts.kAtOrBeforeTimeName) == true) {
      
      resultSet =
        UserFeedPosts.i().executeSyncSelectAtOrBeforeTimeLimit(
          requestGetFeedPosts.getUserId(),
          requestGetFeedPosts.at_or_before_time);
    } else {
      
      resultSet =
        UserFeedPosts.i().executeSyncSelectRecentLimit(
          requestGetFeedPosts.getUserId() );
    }
    
    // extract response data
    
    Row row;
    ArrayList<ResponseFeedPost> feedPosts = new ArrayList<ResponseFeedPost>();
    
    while (resultSet.isExhausted() == false) {
      
      row = resultSet.one();
      
      feedPosts.add(
        new ResponseFeedPost(
          row.getUUID(UserFeedPosts.kPostIdColumnName).toString(),
          row.getLong(UserFeedPosts.kPostTimeColumnName) ) );
    }
    
    // set response
    ((ResponseGetFeedPosts)request.getResponseBody() ).set(
      requestGetFeedPosts.request_tracking_id,
      feedPosts.toArray(new ResponseFeedPost[0] ) );
  }
 
开发者ID:vangav,项目名称:vos_instagram,代码行数:65,代码来源:HandlerGetFeedPosts.java

示例10: getReleaseVersion

import com.datastax.driver.core.ResultSet; //导入方法依赖的package包/类
/**
 * Retrieve the Cassandra release version.
 *
 * @param session must not be {@literal null}.
 * @return the release {@link Version}.
 */
public static Version getReleaseVersion(Session session) {

	Assert.notNull(session, "Session must not be null");

	ResultSet resultSet = session.execute("SELECT release_version FROM system.local;");
	Row row = resultSet.one();

	return Version.parse(row.getString(0));
}
 
开发者ID:Just-Fun,项目名称:spring-data-examples,代码行数:16,代码来源:CassandraVersion.java


注:本文中的com.datastax.driver.core.ResultSet.one方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。