本文整理汇总了Java中com.datastax.driver.core.ColumnDefinitions.toString方法的典型用法代码示例。如果您正苦于以下问题:Java ColumnDefinitions.toString方法的具体用法?Java ColumnDefinitions.toString怎么用?Java ColumnDefinitions.toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.datastax.driver.core.ColumnDefinitions
的用法示例。
在下文中一共展示了ColumnDefinitions.toString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: convertResultSet
import com.datastax.driver.core.ColumnDefinitions; //导入方法依赖的package包/类
private String convertResultSet(ResultSet rs) {
// TODO Auto-generated method stub
String colStr = "";
String rowStr = "";
JsonObject response = new JsonObject();
List<Row> rows = rs.all();
if (!rows.isEmpty() && rows.size() == 1) {
rowStr = rows.get(0).toString();
}
ColumnDefinitions colDefs = rs.getColumnDefinitions();
colStr = colDefs.toString();
response.putString("columns", colStr.substring(8, colStr.length() - 1));
response.putString("values", rowStr.substring(4, rowStr.length() - 1));
return response.toString();
}
示例2: convertResultSet
import com.datastax.driver.core.ColumnDefinitions; //导入方法依赖的package包/类
private String convertResultSet(ResultSet rs) {
// TODO Auto-generated method stub
String colStr = "";
String rowStr = "";
JsonObject response = new JsonObject();
List<Row> rows = rs.all();
if (!rows.isEmpty() && rows.size() == 1) {
rowStr = rows.get(0).toString();
}
ColumnDefinitions colDefs = rs.getColumnDefinitions();
colStr = colDefs.toString();
response.putString("columns", colStr.substring(8, colStr.length() - 1));
response.putString("values", rowStr.substring(4, rowStr.length() - 1));
return response.toString();
}
示例3: formatQueryResult
import com.datastax.driver.core.ColumnDefinitions; //导入方法依赖的package包/类
public static String formatQueryResult(com.datastax.driver.core.ResultSet rs) {
// TODO Auto-generated method stub
String colStr = "";
String rowStr = "";
JsonObject response = new JsonObject();
List<Row> rows = rs.all();
if (!rows.isEmpty() && rows.size() == 1) {
rowStr = rows.get(0).toString();
}
ColumnDefinitions colDefs = rs.getColumnDefinitions();
colStr = colDefs.toString();
response.putString("columns", colStr.substring(8, colStr.length() - 1));
response.putString("values", rowStr.substring(4, rowStr.length() - 1));
return response.toString();
}
示例4: convertResultSet
import com.datastax.driver.core.ColumnDefinitions; //导入方法依赖的package包/类
private String convertResultSet(ResultSet rs) {
// TODO Auto-generated method stub
String colStr = "";
String rowStr = "";
JsonObject response = new JsonObject();
List<Row> rows = rs.all();
if (!rows.isEmpty() && rows.size()==1) {
rowStr = rows.get(0).toString();
}
ColumnDefinitions colDefs = rs.getColumnDefinitions();
colStr = colDefs.toString();
response.putString("columns", colStr.substring(8,colStr.length()-1));
response.putString("values", rowStr.substring(4,rowStr.length()-1));
return response.toString();
// for (Row ro:rows) {
// Print(ro.toString());
//// ro.getColumnDefinitions()
// }
// return null;
// if (rm.kind == ResultMessage.Kind.ROWS) {
// //ToDo maybe processInternal
// boolean bSwitch = true;
// if (bSwitch) {
// ResultMessage.Rows cqlRows = (ResultMessage.Rows) rm;
// List<ColumnSpecification> columnSpecs = cqlRows.result.metadata.names;
//
// for (List<ByteBuffer> row : cqlRows.result.rows) {
// Map<String,Object> map = new HashMap<String,Object>();
// int i = 0;
// for (ByteBuffer bytes : row) {
// ColumnSpecification specs = columnSpecs.get(i++);
// if (specs.name!=null && specs.type!=null && bytes!=null && bytes.hasRemaining()) {
// System.out.println("name = "+specs.name.toString()+" ,type= "+specs.type.compose(bytes));
// map.put(specs.name.toString(), specs.type.compose(bytes));
// }
// }
// returnRows.add(map);
// }
// } else {
// boolean convert = true;;
// CqlResult result = rm.toThriftResult();
// List<CqlRow> rows = result.getRows();
// for (CqlRow row: rows) {
// List<org.apache.cassandra.thrift.Column> columns = row.getColumns();
// for (org.apache.cassandra.thrift.Column c: columns){
// HashMap<String,Object> m = new HashMap<String,Object>();
// if (convert) {
// m.put("name" , TypeHelper.getCqlTyped(result.schema.name_types.get(c.name), c.name) );
// m.put("value" , TypeHelper.getCqlTyped(result.schema.name_types.get(c.name), c.value) );
// } else {
// m.put("value", TypeHelper.getBytes(c.value));
// m.put("name", TypeHelper.getBytes(c.name));
// }
// returnRows.add(m);
// }
// }
// }
// }
// JsonObject response = new JsonObject();
// JsonArray array = new JsonArray();
// for (Map<String,Object> m : returnRows) {
// array.add(new JsonObject(m));
// }
// response.putString(Long.toString(counter.incrementAndGet()), "OK");
// response.putArray(Long.toString(counter.incrementAndGet()), array);
// String testQry = "CREATE KEYSPACE testdb WITH REPLICATION = {'class' : 'SimpleStrategy', 'replication_factor': 1};";
//// create("testdb",1);
// return response.toString();
// return null;
// }
}