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


Java ResultSet类代码示例

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


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

示例1: getRecordById

import com.datastax.driver.core.ResultSet; //导入依赖的package包/类
@Override
public Response getRecordById(String keyspaceName, String tableName, String identifier) {
  long startTime = System.currentTimeMillis();
  ProjectLogger.log("Cassandra Service getRecordById method started at ==" + startTime,
      LoggerEnum.PERF_LOG);
  Response response = new Response();
  try {
    Select selectQuery = QueryBuilder.select().all().from(keyspaceName, tableName);
    Where selectWhere = selectQuery.where();
    Clause clause = QueryBuilder.eq(Constants.IDENTIFIER, identifier);
    selectWhere.and(clause);
    ResultSet results = connectionManager.getSession(keyspaceName).execute(selectQuery);
    response = CassandraUtil.createResponse(results);
  } catch (Exception e) {
    ProjectLogger.log(Constants.EXCEPTION_MSG_FETCH + tableName + " : " + e.getMessage(), e);
    throw new ProjectCommonException(ResponseCode.SERVER_ERROR.getErrorCode(),
        ResponseCode.SERVER_ERROR.getErrorMessage(), ResponseCode.SERVER_ERROR.getResponseCode());
  }
  long stopTime = System.currentTimeMillis();
  long elapsedTime = stopTime - startTime;
  ProjectLogger.log("Cassandra Service getRecordById method end at ==" + stopTime
      + " ,Total time elapsed = " + elapsedTime, LoggerEnum.PERF_LOG);
  return response;
}
 
开发者ID:project-sunbird,项目名称:sunbird-utils,代码行数:25,代码来源:CassandraOperationImpl.java

示例2: getPropertiesValueById

import com.datastax.driver.core.ResultSet; //导入依赖的package包/类
@Override
public Response getPropertiesValueById(String keyspaceName, String tableName, String id,
    String... properties) {
  long startTime = System.currentTimeMillis();
  ProjectLogger.log("Cassandra Service getPropertiesValueById method started at ==" + startTime,
      LoggerEnum.PERF_LOG);
  Response response = new Response();
  try {
    String selectQuery = CassandraUtil.getSelectStatement(keyspaceName, tableName, properties);
    PreparedStatement statement = connectionManager.getSession(keyspaceName).prepare(selectQuery);
    BoundStatement boundStatement = new BoundStatement(statement);
    ResultSet results =
        connectionManager.getSession(keyspaceName).execute(boundStatement.bind(id));
    response = CassandraUtil.createResponse(results);
  } catch (Exception e) {
    ProjectLogger.log(Constants.EXCEPTION_MSG_FETCH + tableName + " : " + e.getMessage(), e);
    throw new ProjectCommonException(ResponseCode.SERVER_ERROR.getErrorCode(),
        ResponseCode.SERVER_ERROR.getErrorMessage(), ResponseCode.SERVER_ERROR.getResponseCode());
  }
  long stopTime = System.currentTimeMillis();
  long elapsedTime = stopTime - startTime;
  ProjectLogger.log("Cassandra Service getPropertiesValueById method end at ==" + stopTime
      + " ,Total time elapsed = " + elapsedTime, LoggerEnum.PERF_LOG);
  return response;
}
 
开发者ID:project-sunbird,项目名称:sunbird-utils,代码行数:26,代码来源:CassandraOperationImpl.java

示例3: selectByDeviceAndSensor

import com.datastax.driver.core.ResultSet; //导入依赖的package包/类
@Override
	public Status selectByDeviceAndSensor(TsPoint point, Double max, Double min, Date startTime, Date endTime) {
		long costTime = 0L;
		Cluster cluster = null;
		try {
			cluster = Cluster.builder().addContactPoint(CASSADRA_URL).build();
			Session session = cluster.connect(KEY_SPACE_NAME);
			String createIndexCql = "CREATE INDEX IF NOT EXISTS value_index ON " + TABLE_NAME + "(value)";
//			System.out.println(createIndexCql);
			long startTime1 = System.nanoTime();
			session.execute(createIndexCql);
			String selectCql = "SELECT * FROM point WHERE device_code='" + point.getDeviceCode() + "' and sensor_code='"
					+ point.getSensorCode() + "' and value<" + max + " and value>" + min + " and timestamp>="
					+ startTime.getTime() + " and timestamp<=" + endTime.getTime() + " ALLOW FILTERING";
//			System.out.println(selectCql);
			ResultSet rs = session.execute(selectCql);
			long endTime1 = System.nanoTime();
			costTime = endTime1 - startTime1;
		} finally {
			if (cluster != null)
				cluster.close();
		}
//		System.out.println("此次查询消耗时间[" + costTime / 1000 + "]s");
		return Status.OK(costTime);
	}
 
开发者ID:dbiir,项目名称:ts-benchmark,代码行数:26,代码来源:CassandraDB.java

示例4: selectMaxByDeviceAndSensor

import com.datastax.driver.core.ResultSet; //导入依赖的package包/类
@Override
	public Status selectMaxByDeviceAndSensor(String deviceCode, String sensorCode, Date startTime, Date endTime) {
		long costTime = 0L;
		Cluster cluster = null;
		try {
//			cluster = Cluster.builder().addContactPoint(CASSADRA_URL).build();
//			Session session = cluster.connect(KEY_SPACE_NAME);
			Session session = SessionManager.getSession();
			String selectCql = "SELECT MAX(value) FROM point WHERE device_code='" + deviceCode + "' and sensor_code='"
					+ sensorCode + "' and timestamp>=" + startTime.getTime() + " and timestamp<=" + endTime.getTime()
					+ " ALLOW FILTERING";
			long startTime1 = System.nanoTime();
//			System.out.println("aaa");
			ResultSet rs = session.execute(selectCql);
//			System.out.println("bbb");
			long endTime1 = System.nanoTime();
			costTime = endTime1 - startTime1;
		} finally {
			if (cluster != null)
				cluster.close();
		}
//		System.out.println("此次查询消耗时间[" + costTime / 1000 + "]s");
		return Status.OK(costTime);
	}
 
开发者ID:dbiir,项目名称:ts-benchmark,代码行数:25,代码来源:CassandraDB.java

示例5: selectAvgByDeviceAndSensor

import com.datastax.driver.core.ResultSet; //导入依赖的package包/类
@Override
	public Status selectAvgByDeviceAndSensor(String deviceCode, String sensorCode, Date startTime, Date endTime) {
		long costTime = 0L;
		Cluster cluster = null;
		try {
			cluster = Cluster.builder().addContactPoint(CASSADRA_URL).build();
			Session session = cluster.connect(KEY_SPACE_NAME);
			String selectCql = "SELECT AVG(value) FROM point WHERE device_code='" + deviceCode + "' and sensor_code='"
					+ sensorCode + "' and timestamp>=" + startTime.getTime() + " and timestamp<=" + endTime.getTime()
					+ " ALLOW FILTERING";
//			System.out.println(selectCql);
			long startTime1 = System.nanoTime();
			ResultSet rs = session.execute(selectCql);
			long endTime1 = System.nanoTime();
			costTime = endTime1 - startTime1;
		} finally {
			if (cluster != null)
				cluster.close();
		}
//		System.out.println("此次查询消耗时间[" + costTime / 1000 + "]s");
		return Status.OK(costTime);
	}
 
开发者ID:dbiir,项目名称:ts-benchmark,代码行数:23,代码来源:CassandraDB.java

示例6: selectCountByDeviceAndSensor

import com.datastax.driver.core.ResultSet; //导入依赖的package包/类
@Override
	public Status selectCountByDeviceAndSensor(String deviceCode, String sensorCode, Date startTime, Date endTime) {
		long costTime = 0L;
		Cluster cluster = null;
		try {
			cluster = Cluster.builder().addContactPoint(CASSADRA_URL).build();
			Session session = cluster.connect(KEY_SPACE_NAME);
			String selectCql = "SELECT COUNT(*) FROM point WHERE device_code='" + deviceCode + "' and sensor_code='"
					+ sensorCode + "' and timestamp>=" + startTime.getTime() + " and timestamp<=" + endTime.getTime()
					+ " ALLOW FILTERING";
//			System.out.println(selectCql);
			long startTime1 = System.nanoTime();
			ResultSet rs = session.execute(selectCql);
			long endTime1 = System.nanoTime();
			costTime = endTime1 - startTime1;
		} finally {
			if (cluster != null)
				cluster.close();
		}
//		System.out.println("此次查询消耗时间[" + costTime / 1000 + "]s");
		return Status.OK(costTime);
	}
 
开发者ID:dbiir,项目名称:ts-benchmark,代码行数:23,代码来源:CassandraDB.java

示例7: findListByStatementAsync

import com.datastax.driver.core.ResultSet; //导入依赖的package包/类
protected ListenableFuture<List<D>> findListByStatementAsync(Statement statement) {
    if (statement != null) {
        statement.setConsistencyLevel(cluster.getDefaultReadConsistencyLevel());
        ResultSetFuture resultSetFuture = getSession().executeAsync(statement);
        return Futures.transform(resultSetFuture, new Function<ResultSet, List<D>>() {
            @Nullable
            @Override
            public List<D> apply(@Nullable ResultSet resultSet) {
                Result<E> result = getMapper().map(resultSet);
                if (result != null) {
                    List<E> entities = result.all();
                    return DaoUtil.convertDataList(entities);
                } else {
                    return Collections.emptyList();
                }
            }
        });
    }
    return Futures.immediateFuture(Collections.emptyList());
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:21,代码来源:CassandraAbstractModelDao.java

示例8: saveIfNotExist

import com.datastax.driver.core.ResultSet; //导入依赖的package包/类
private Optional<ComponentDescriptor> saveIfNotExist(ComponentDescriptorEntity entity) {
    if (entity.getId() == null) {
        entity.setId(UUIDs.timeBased());
    }

    ResultSet rs = executeRead(QueryBuilder.insertInto(getColumnFamilyName())
            .value(ModelConstants.ID_PROPERTY, entity.getId())
            .value(ModelConstants.COMPONENT_DESCRIPTOR_NAME_PROPERTY, entity.getName())
            .value(ModelConstants.COMPONENT_DESCRIPTOR_CLASS_PROPERTY, entity.getClazz())
            .value(ModelConstants.COMPONENT_DESCRIPTOR_TYPE_PROPERTY, entity.getType())
            .value(ModelConstants.COMPONENT_DESCRIPTOR_SCOPE_PROPERTY, entity.getScope())
            .value(ModelConstants.COMPONENT_DESCRIPTOR_CONFIGURATION_DESCRIPTOR_PROPERTY, entity.getConfigurationDescriptor())
            .value(ModelConstants.COMPONENT_DESCRIPTOR_ACTIONS_PROPERTY, entity.getActions())
            .value(ModelConstants.SEARCH_TEXT_PROPERTY, entity.getSearchText())
            .ifNotExists()
    );
    if (rs.wasApplied()) {
        return Optional.of(DaoUtil.getData(entity));
    } else {
        return Optional.empty();
    }
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:23,代码来源:CassandraBaseComponentDescriptorDao.java

示例9: userLikedPost

import com.datastax.driver.core.ResultSet; //导入依赖的package包/类
/**
 * userLikedPost
 * @param postId
 * @param userId
 * @return true if param userId liked param postId and false otherwise
 * @throws Exception
 */
public static boolean userLikedPost (
  UUID postId,
  UUID userId) throws Exception {
  
  ResultSet resultSet =
    PostLikesTime.i().executeSyncSelect(
      postId,
      userId);
  
  if (resultSet.isExhausted() == true) {
    
    return false;
  }
  
  return true;
}
 
开发者ID:vangav,项目名称:vos_instagram,代码行数:24,代码来源:CheckersInl.java

示例10: executeSyncInsert

import com.datastax.driver.core.ResultSet; //导入依赖的package包/类
/**
 * executeSyncInsert
 * BLOCKING-METHOD: blocks till the ResultSet is ready
 * executes Insert Query synchronously
 * @param userid
 * @param devicetoken
 * @param authcode
 * @param accesstoken
 * @param refreshtoken
 * @param ttl
 * @return ResultSet
 * @throws Exception
 */
public ResultSet executeSyncInsert (
  Object userid,
  Object devicetoken,
  Object authcode,
  Object accesstoken,
  Object refreshtoken,
  Object ttl) throws Exception {

  return
    this.getQuery(kInsertName).executeSync(
      userid,
      devicetoken,
      authcode,
      accesstoken,
      refreshtoken,
      ttl);
}
 
开发者ID:vangav,项目名称:vos_instagram,代码行数:31,代码来源:AuthCodes.java

示例11: queryColumns

import com.datastax.driver.core.ResultSet; //导入依赖的package包/类
/**
 * 描述: 查询数据表字段名(key:字段名,value:字段类型名)
 * 时间: 2017年11月15日 上午11:29:32
 * @author yi.zhang
 * @param table	表名
 * @return
 */
public Map<String,String> queryColumns(String table){
	try {
		String sql = "select * from "+table;
		ResultSet rs = session.execute(sql);
		ColumnDefinitions rscd = rs.getColumnDefinitions();
		int count = rscd.size();
		Map<String,String> reflect = new HashMap<String,String>();
		for (int i = 0; i < count; i++) {
			String column = rscd.getName(i);
			String type = rscd.getType(i).getName().name().toLowerCase();
			reflect.put(column, type);
		}
		return reflect;
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return null;
}
 
开发者ID:dev-share,项目名称:database-transform-tool,代码行数:27,代码来源:CassandraFactory.java

示例12: executeSyncInsert

import com.datastax.driver.core.ResultSet; //导入依赖的package包/类
/**
 * executeSyncInsert
 * BLOCKING-METHOD: blocks till the ResultSet is ready
 * executes Insert Query synchronously
 * @param yearweek
 * @param rank
 * @param userid
 * @return ResultSet
 * @throws Exception
 */
public ResultSet executeSyncInsert (
  Object yearweek,
  Object rank,
  Object userid) throws Exception {

  return
    this.getQuery(kInsertName).executeSync(
      yearweek,
      rank,
      userid);
}
 
开发者ID:vangav,项目名称:vos_instagram_jobs,代码行数:22,代码来源:UsersRankWorld.java

示例13: executeSyncSelectTopSmallerThanLimit

import com.datastax.driver.core.ResultSet; //导入依赖的package包/类
/**
 * executeSyncSelectTopSmallerThanLimit
 * BLOCKING-METHOD: blocks till the ResultSet is ready
 * executes SelectTopSmallerThanLimit Query synchronously
 * @param yearweekgridid
 * @param rank
 * @return ResultSet
 * @throws Exception
 */
public ResultSet executeSyncSelectTopSmallerThanLimit (
  Object yearweekgridid,
  Object rank) throws Exception {

  return
    this.getQuery(kSelectTopSmallerThanLimitName).executeSync(
      yearweekgridid,
      rank);
}
 
开发者ID:vangav,项目名称:vos_instagram,代码行数:19,代码来源:UsersRankGrid.java

示例14: find

import com.datastax.driver.core.ResultSet; //导入依赖的package包/类
@Override
public ListenableFuture<Optional<AttributeKvEntry>> find(EntityId entityId, String attributeType, String attributeKey) {
    Select.Where select = select().from(ATTRIBUTES_KV_CF)
            .where(eq(ENTITY_TYPE_COLUMN, entityId.getEntityType()))
            .and(eq(ENTITY_ID_COLUMN, entityId.getId()))
            .and(eq(ATTRIBUTE_TYPE_COLUMN, attributeType))
            .and(eq(ATTRIBUTE_KEY_COLUMN, attributeKey));
    log.trace("Generated query [{}] for entityId {} and key {}", select, entityId, attributeKey);
    return Futures.transform(executeAsyncRead(select), (Function<? super ResultSet, ? extends Optional<AttributeKvEntry>>) input ->
                    Optional.ofNullable(convertResultToAttributesKvEntry(attributeKey, input.one()))
            , readResultsProcessingExecutor);
}
 
开发者ID:osswangxining,项目名称:iotplatform,代码行数:13,代码来源:CassandraBaseAttributesDao.java

示例15: executeSyncInsert

import com.datastax.driver.core.ResultSet; //导入依赖的package包/类
/**
 * executeSyncInsert
 * BLOCKING-METHOD: blocks till the ResultSet is ready
 * executes Insert Query synchronously
 * @param yearweekcountrycode
 * @param rank
 * @param userid
 * @return ResultSet
 * @throws Exception
 */
public ResultSet executeSyncInsert (
  Object yearweekcountrycode,
  Object rank,
  Object userid) throws Exception {

  return
    this.getQuery(kInsertName).executeSync(
      yearweekcountrycode,
      rank,
      userid);
}
 
开发者ID:vangav,项目名称:vos_instagram_jobs,代码行数:22,代码来源:UsersRankCountry.java


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