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


Java ResultSet.all方法代碼示例

本文整理匯總了Java中com.datastax.driver.core.ResultSet.all方法的典型用法代碼示例。如果您正苦於以下問題:Java ResultSet.all方法的具體用法?Java ResultSet.all怎麽用?Java ResultSet.all使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.datastax.driver.core.ResultSet的用法示例。


在下文中一共展示了ResultSet.all方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: testQueryPrimeSimple

import com.datastax.driver.core.ResultSet; //導入方法依賴的package包/類
@Test
public void testQueryPrimeSimple() throws Exception {
  RequestPrime prime = HttpTestUtil.createSimplePrimedQuery("Select * FROM TABLE2");
  HttpTestResponse response = server.prime(prime);
  assertNotNull(response);
  RequestPrime responseQuery = om.readValue(response.body, RequestPrime.class);
  assertThat(responseQuery).isEqualTo(prime);

  String contactPoint = HttpTestUtil.getContactPointString(server.getCluster(), 0);
  ResultSet set = HttpTestUtil.makeNativeQuery("Select * FROM TABLE2", contactPoint);
  List<Row> results = set.all();
  assertThat(1).isEqualTo(results.size());
  Row row1 = results.get(0);
  String column1 = row1.getString("column1");
  assertThat(column1).isEqualTo("column1");
  Long column2 = row1.getLong("column2");
  assertThat(column2).isEqualTo(new Long(2));
}
 
開發者ID:datastax,項目名稱:simulacron,代碼行數:19,代碼來源:HttpPrimeQueryIntegrationTest.java

示例2: testBoundStatementPositional

import com.datastax.driver.core.ResultSet; //導入方法依賴的package包/類
@Test
public void testBoundStatementPositional() throws Exception {
  HashMap<String, String> paramTypes = new HashMap<>();
  paramTypes.put("c1", "ascii");
  HashMap<String, Object> params = new HashMap<>();
  params.put("c1", "c1");
  RequestPrime prime =
      HttpTestUtil.createSimpleParameterizedQuery(
          "SELECT table FROM foo WHERE c1=?", params, paramTypes);
  HttpTestResponse response = server.prime(prime);
  assertNotNull(response);
  RequestPrime responseQuery = om.readValue(response.body, RequestPrime.class);
  assertThat(responseQuery).isEqualTo(prime);
  String contactPoint = HttpTestUtil.getContactPointString(server.getCluster(), 0);
  ResultSet set =
      HttpTestUtil.makeNativeBoundQueryWithPositionalParam(
          "SELECT table FROM foo WHERE c1=?", contactPoint, "c1");
  List<Row> results = set.all();
  assertThat(1).isEqualTo(results.size());
  Row row1 = results.get(0);
  String column1 = row1.getString("column1");
  assertThat(column1).isEqualTo("column1");
  Long column2 = row1.getLong("column2");
}
 
開發者ID:datastax,項目名稱:simulacron,代碼行數:25,代碼來源:HttpPrimeQueryIntegrationTest.java

示例3: queryTables

import com.datastax.driver.core.ResultSet; //導入方法依賴的package包/類
/**
 * 描述: 查詢數據庫表名[未實現]
 * 時間: 2017年11月15日 上午11:29:59
 * @author yi.zhang
 * @return 返回表
 */
@Deprecated
public List<String> queryTables(){
	try {
		List<String> tables = new ArrayList<String>();
		String useQuery = "describe tables";
		ResultSet rs = session.execute(useQuery);
		for (Row row : rs.all()) {
			String table = row.getString(1);
			tables.add(table);
		}
		return tables;
	} catch (Exception e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return null;
}
 
開發者ID:dev-share,項目名稱:database-transform-tool,代碼行數:24,代碼來源:CassandraFactory.java

示例4: createResponse

import com.datastax.driver.core.ResultSet; //導入方法依賴的package包/類
/**
 * @desc This method is used for creating response from the resultset i.e return map
 *       <String,Object> or map<columnName,columnValue>
 * @param results ResultSet
 * @return Response Response
 */
public static Response createResponse(ResultSet results) {
  Response response = new Response();
  List<Row> rows = results.all();
  Map<String, Object> map = null;
  List<Map<String, Object>> responseList = new ArrayList<>();
  String str = results.getColumnDefinitions().toString().substring(8,
      results.getColumnDefinitions().toString().length() - 1);
  String[] keyArray = str.split("\\), ");
  for (Row row : rows) {
    map = new HashMap<>();
    for (int i = 0; i < keyArray.length; i++) {
      int pos = keyArray[i].indexOf(Constants.OPEN_BRACE);
      String column = instance.getProperty(keyArray[i].substring(0, pos).trim());
      map.put(column, row.getObject(column));
    }
    responseList.add(map);
  }
  ProjectLogger.log(responseList.toString());
  response.put(Constants.RESPONSE, responseList);
  return response;
}
 
開發者ID:project-sunbird,項目名稱:sunbird-utils,代碼行數:28,代碼來源:CassandraUtil.java

示例5: testVerifyQueryParticularCluster

import com.datastax.driver.core.ResultSet; //導入方法依賴的package包/類
private void testVerifyQueryParticularCluster(Function<ClusterSpec, String> f) {
  HttpClient client = vertx.createHttpClient();
  ClusterSpec clusterQueried = this.createMultiNodeCluster(client, "3,3");
  ClusterSpec clusterUnused = this.createMultiNodeCluster(client, "3,3");

  String query = "Select * FROM TABLE2_" + clusterQueried.getName();

  RequestPrime prime = createSimplePrimedQuery(query);
  HttpTestResponse response =
      this.primeSimpleRequest(client, prime, "/prime" + "/" + f.apply(clusterQueried));

  Iterator<NodeSpec> nodeIteratorQueried = clusterQueried.getNodes().iterator();
  Iterator<NodeSpec> nodeIteratorUnused = clusterUnused.getNodes().iterator();

  while (nodeIteratorQueried.hasNext()) {
    NodeSpec node = nodeIteratorQueried.next();

    String contactPoint = HttpTestUtil.getContactPointStringByNodeID(node);
    ResultSet set = HttpTestUtil.makeNativeQuery(query, contactPoint);
    List<Row> results = set.all();
    assertThat(1).isEqualTo(results.size());
  }

  while (nodeIteratorUnused.hasNext()) {
    String contactPointUnused =
        HttpTestUtil.getContactPointStringByNodeID(nodeIteratorUnused.next());
    ResultSet setUnused = HttpTestUtil.makeNativeQuery(query, contactPointUnused);
    List<Row> resultsUnused = setUnused.all();
    assertThat(0).isEqualTo(resultsUnused.size());
  }
}
 
開發者ID:datastax,項目名稱:simulacron,代碼行數:32,代碼來源:HttpContainerIntegrationTest.java

示例6: testVerifyQueryParticularDatacenter

import com.datastax.driver.core.ResultSet; //導入方法依賴的package包/類
private void testVerifyQueryParticularDatacenter(
    Function<ClusterSpec, String> fc, Function<DataCenterSpec, String> fd) {
  HttpClient client = vertx.createHttpClient();
  ClusterSpec clusterQueried = this.createMultiNodeCluster(client, "3,3");
  ClusterSpec clusterUnused = this.createMultiNodeCluster(client, "3,3");

  String query = "Select * FROM TABLE2_" + clusterQueried.getName();

  RequestPrime prime = createSimplePrimedQuery(query);
  List<DataCenterSpec> datacenters = (List<DataCenterSpec>) clusterQueried.getDataCenters();
  DataCenterSpec datacenterQueried = datacenters.get(0);

  this.primeSimpleRequest(client, prime, fc.apply(clusterQueried), fd.apply(datacenterQueried));

  Iterator<NodeSpec> nodeIteratorQueried = clusterQueried.getNodes().iterator();
  Iterator<NodeSpec> nodeIteratorUnused = clusterUnused.getNodes().iterator();

  while (nodeIteratorQueried.hasNext()) {
    NodeSpec node = nodeIteratorQueried.next();

    String contactPoint = HttpTestUtil.getContactPointStringByNodeID(node);
    ResultSet set = HttpTestUtil.makeNativeQuery(query, contactPoint);
    List<Row> results = set.all();
    if (node.getDataCenter().equals(datacenterQueried)) {
      assertThat(1).isEqualTo(results.size());
    } else {
      assertThat(0).isEqualTo(results.size());
    }
  }

  while (nodeIteratorUnused.hasNext()) {
    String contactPointUnused =
        HttpTestUtil.getContactPointStringByNodeID(nodeIteratorUnused.next());
    ResultSet setUnused = HttpTestUtil.makeNativeQuery(query, contactPointUnused);
    List<Row> resultsUnused = setUnused.all();
    assertThat(0).isEqualTo(resultsUnused.size());
  }
}
 
開發者ID:datastax,項目名稱:simulacron,代碼行數:39,代碼來源:HttpContainerIntegrationTest.java

示例7: testQueryPositionalParamSimple

import com.datastax.driver.core.ResultSet; //導入方法依賴的package包/類
@Test
public void testQueryPositionalParamSimple() throws Exception {
  HashMap<String, String> paramTypes = new HashMap<>();
  paramTypes.put("c1", "ascii");
  HashMap<String, Object> params = new HashMap<>();
  params.put("c1", "c1");
  RequestPrime prime =
      HttpTestUtil.createSimpleParameterizedQuery(
          "SELECT table FROM foo WHERE c1=?", params, paramTypes);
  HttpTestResponse response = server.prime(prime);
  assertNotNull(response);
  RequestPrime responseQuery = om.readValue(response.body, RequestPrime.class);
  assertThat(responseQuery).isEqualTo(prime);
  String contactPoint = HttpTestUtil.getContactPointString(server.getCluster(), 0);
  ResultSet set =
      HttpTestUtil.makeNativeQueryWithPositionalParams(
          "SELECT table FROM foo WHERE c1=?", contactPoint, "c1");
  List<Row> results = set.all();
  assertThat(1).isEqualTo(results.size());
  Row row1 = results.get(0);
  String column1 = row1.getString("column1");
  assertThat(column1).isEqualTo("column1");
  Long column2 = row1.getLong("column2");
  // Extra Param
  set =
      HttpTestUtil.makeNativeQueryWithPositionalParams(
          "SELECT table FROM foo WHERE c1=?", contactPoint, "c1", "extraParam");
  assertThat(set.all().size()).isEqualTo(0);
  // Wrong Param
  set =
      HttpTestUtil.makeNativeQueryWithPositionalParams(
          "SELECT table FROM foo WHERE ci1=?", contactPoint, "d1");
  assertThat(set.all().size()).isEqualTo(0);
}
 
開發者ID:datastax,項目名稱:simulacron,代碼行數:35,代碼來源:HttpPrimeQueryIntegrationTest.java

示例8: testBoundStatementNamed

import com.datastax.driver.core.ResultSet; //導入方法依賴的package包/類
@Test
public void testBoundStatementNamed() throws Exception {
  HashMap<String, String> paramTypes = new HashMap<>();
  paramTypes.put("id", "bigint");
  paramTypes.put("id2", "bigint");
  HashMap<String, Object> params = new HashMap<>();
  params.put("id", new Long(1));
  params.put("id2", new Long(2));
  RequestPrime prime =
      HttpTestUtil.createSimpleParameterizedQuery(
          "SELECT * FROM users WHERE id = :id and id2 = :id2", params, paramTypes);

  HttpTestResponse response = server.prime(prime);
  assertNotNull(response);
  RequestPrime responseQuery = (RequestPrime) om.readValue(response.body, RequestPrime.class);
  assertThat(responseQuery).isEqualTo(prime);
  Map<String, Long> values = ImmutableMap.<String, Long>of("id", new Long(1), "id2", new Long(2));
  String contactPoint = HttpTestUtil.getContactPointString(server.getCluster(), 0);
  ResultSet set =
      HttpTestUtil.makeNativeBoundQueryWithNameParams(
          "SELECT * FROM users WHERE id = :id and id2 = :id2", contactPoint, values);
  List<Row> results = set.all();
  assertThat(1).isEqualTo(results.size());
  Row row1 = results.get(0);
  String column1 = row1.getString("column1");
  assertThat(column1).isEqualTo("column1");
  Long column2 = row1.getLong("column2");
  assertThat(column2).isEqualTo(new Long(2));
  Map<String, String> values2 = ImmutableMap.<String, String>of("id", "1", "id2", "2");
}
 
開發者ID:datastax,項目名稱:simulacron,代碼行數:31,代碼來源:HttpPrimeQueryIntegrationTest.java

示例9: assertResult

import com.datastax.driver.core.ResultSet; //導入方法依賴的package包/類
private void assertResult(ResultSet set) {
  List<Row> results = set.all();
  assertThat(1).isEqualTo(results.size());
  Row row1 = results.get(0);
  boolean column1 = row1.getBool("applied");
  assertThat(column1).isTrue();
}
 
開發者ID:datastax,項目名稱:simulacron,代碼行數:8,代碼來源:HttpPrimeBatchIntegrationTest.java

示例10: getEntityRelations

import com.datastax.driver.core.ResultSet; //導入方法依賴的package包/類
private List<EntityRelation> getEntityRelations(ResultSet rs) {
    List<Row> rows = rs.all();
    List<EntityRelation> entries = new ArrayList<>(rows.size());
    if (!rows.isEmpty()) {
        rows.forEach(row -> {
            entries.add(getEntityRelation(row));
        });
    }
    return entries;
}
 
開發者ID:osswangxining,項目名稱:iotplatform,代碼行數:11,代碼來源:BaseRelationDao.java

示例11: convertResultToAttributesKvEntryList

import com.datastax.driver.core.ResultSet; //導入方法依賴的package包/類
private List<AttributeKvEntry> convertResultToAttributesKvEntryList(ResultSet resultSet) {
    List<Row> rows = resultSet.all();
    List<AttributeKvEntry> entries = new ArrayList<>(rows.size());
    if (!rows.isEmpty()) {
        rows.forEach(row -> {
            String key = row.getString(ModelConstants.ATTRIBUTE_KEY_COLUMN);
            AttributeKvEntry kvEntry = convertResultToAttributesKvEntry(key, row);
            if (kvEntry != null) {
                entries.add(kvEntry);
            }
        });
    }
    return entries;
}
 
開發者ID:osswangxining,項目名稱:iotplatform,代碼行數:15,代碼來源:CassandraBaseAttributesDao.java

示例12: testVerifyQueryParticularNode

import com.datastax.driver.core.ResultSet; //導入方法依賴的package包/類
private void testVerifyQueryParticularNode(
    Function<ClusterSpec, String> fc,
    Function<DataCenterSpec, String> fd,
    Function<NodeSpec, String> fn) {
  HttpClient client = vertx.createHttpClient();
  ClusterSpec clusterQueried = this.createMultiNodeCluster(client, "3,3");
  ClusterSpec clusterUnused = this.createMultiNodeCluster(client, "3,3");

  String query = "Select * FROM TABLE2_" + clusterQueried.getName();

  RequestPrime prime = createSimplePrimedQuery(query);

  List<DataCenterSpec> datacenters = (List<DataCenterSpec>) clusterQueried.getDataCenters();
  DataCenterSpec datacenterQueried = datacenters.get(0);
  Iterator<NodeSpec> datacenterIterator = datacenterQueried.getNodes().iterator();

  NodeSpec nodeQueried = datacenterIterator.next();

  this.primeSimpleRequest(
      client,
      prime,
      fc.apply(clusterQueried),
      fd.apply(datacenterQueried),
      fn.apply(nodeQueried));

  Iterator<NodeSpec> nodeIteratorQueried = clusterQueried.getNodes().iterator();
  Iterator<NodeSpec> nodeIteratorUnused = clusterUnused.getNodes().iterator();

  while (nodeIteratorQueried.hasNext()) {
    NodeSpec node = nodeIteratorQueried.next();

    String contactPoint = HttpTestUtil.getContactPointStringByNodeID(node);
    ResultSet set = HttpTestUtil.makeNativeQuery(query, contactPoint);
    List<Row> results = set.all();
    if (node.equals(nodeQueried)) {
      assertThat(1).isEqualTo(results.size());
    } else {
      assertThat(0).isEqualTo(results.size());
    }
  }

  while (nodeIteratorUnused.hasNext()) {
    String contactPointUnused =
        HttpTestUtil.getContactPointStringByNodeID(nodeIteratorUnused.next());
    ResultSet setUnused = HttpTestUtil.makeNativeQuery(query, contactPointUnused);
    List<Row> resultsUnused = setUnused.all();
    assertThat(0).isEqualTo(resultsUnused.size());
  }
}
 
開發者ID:datastax,項目名稱:simulacron,代碼行數:50,代碼來源:HttpContainerIntegrationTest.java

示例13: testQueryPrimeNamedParamSimple

import com.datastax.driver.core.ResultSet; //導入方法依賴的package包/類
@Test
public void testQueryPrimeNamedParamSimple() throws Exception {
  HashMap<String, String> paramTypes = new HashMap<>();
  paramTypes.put("id", "bigint");
  paramTypes.put("id2", "bigint");
  HashMap<String, Object> params = new HashMap<>();
  params.put("id", new Long(1));
  params.put("id2", new Long(2));
  RequestPrime prime =
      HttpTestUtil.createSimpleParameterizedQuery(
          "SELECT * FROM users WHERE id = :id and id2 = :id2", params, paramTypes);

  HttpTestResponse response = server.prime(prime);
  assertNotNull(response);
  RequestPrime responseQuery = om.readValue(response.body, RequestPrime.class);
  assertThat(responseQuery).isEqualTo(prime);
  Map<String, Object> values =
      ImmutableMap.<String, Object>of("id", new Long(1), "id2", new Long(2));
  String contactPoint = HttpTestUtil.getContactPointString(server.getCluster(), 0);
  ResultSet set =
      HttpTestUtil.makeNativeQueryWithNameParams(
          "SELECT * FROM users WHERE id = :id and id2 = :id2", contactPoint, values);
  List<Row> results = set.all();
  assertThat(1).isEqualTo(results.size());
  Row row1 = results.get(0);
  String column1 = row1.getString("column1");
  assertThat(column1).isEqualTo("column1");
  Long column2 = row1.getLong("column2");
  assertThat(column2).isEqualTo(new Long(2));

  // Try with the wrong values
  values = ImmutableMap.<String, Object>of("id", new Long(2), "id2", new Long(2));
  set =
      HttpTestUtil.makeNativeQueryWithNameParams(
          "SELECT * FROM users WHERE id = :id and id2 = :id2", contactPoint, values);
  assertThat(set.all().size()).isEqualTo(0);
  // Try with the wrong number of values
  values = ImmutableMap.<String, Object>of("id", new Long(2));
  set =
      HttpTestUtil.makeNativeQueryWithNameParams(
          "SELECT * FROM users WHERE id = :id and id2 = :id2", contactPoint, values);
  assertThat(set.all().size()).isEqualTo(0);
  // No values
  values = ImmutableMap.<String, Object>of();
  set =
      HttpTestUtil.makeNativeQueryWithNameParams(
          "SELECT * FROM users WHERE id = :id and id2 = :id2", contactPoint, values);
  assertThat(set.all().size()).isEqualTo(0);
}
 
開發者ID:datastax,項目名稱:simulacron,代碼行數:50,代碼來源:HttpPrimeQueryIntegrationTest.java


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