本文整理汇总了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));
}
示例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");
}
示例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;
}
示例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;
}
示例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());
}
}
示例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());
}
}
示例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);
}
示例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");
}
示例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();
}
示例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;
}
示例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;
}
示例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());
}
}
示例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);
}