本文整理汇总了Java中com.datastax.driver.core.ColumnDefinitions.Definition.getName方法的典型用法代码示例。如果您正苦于以下问题:Java Definition.getName方法的具体用法?Java Definition.getName怎么用?Java Definition.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.datastax.driver.core.ColumnDefinitions.Definition
的用法示例。
在下文中一共展示了Definition.getName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: select
import com.datastax.driver.core.ColumnDefinitions.Definition; //导入方法依赖的package包/类
@Override
public DbRecordValuesList[] select(
DbQuery dbQuery,
DbReturnModes dbReturnMode ) throws DbException {
connect();
ArrayList<DbRecordValuesList> dbRecords = new ArrayList<DbRecordValuesList>();
String sqlQuery = dbQuery.getQuery();
if (allowFiltering) {
sqlQuery += " ALLOW FILTERING";
}
if (log.isDebugEnabled()) {
log.debug(sqlQuery);
}
ResultSet results = session.execute(sqlQuery);
int currentRow = 0;
Iterator<Row> it = results.iterator();
while (it.hasNext()) {
Row row = it.next();
currentRow++;
if (log.isDebugEnabled()) {
log.debug("Result row number: " + currentRow);
}
DbRecordValuesList recordList = new DbRecordValuesList();
for (Definition columnDefinition : row.getColumnDefinitions()) {
DbColumn dbColumn = new DbColumn(columnDefinition.getTable(), columnDefinition.getName());
dbColumn.setColumnType(columnDefinition.getType().getName().toString());
Object value = extractObjectFromResultSet(row, columnDefinition);
DbRecordValue recordValue = new DbRecordValue(dbColumn, value);
recordList.add(recordValue);
}
dbRecords.add(recordList);
}
return dbRecords.toArray(new DbRecordValuesList[]{});
}
示例2: syncQuorum
import com.datastax.driver.core.ColumnDefinitions.Definition; //导入方法依赖的package包/类
private static void syncQuorum(String key){
logger.info("Performing sync operation---");
String[] splitString = key.split("\\.");
String keyspaceName = splitString[0];
String tableName = splitString[1];
String primaryKeyValue = splitString[2];
//get the primary key d
TableMetadata tableInfo = returnColumnMetadata(keyspaceName, tableName);
String primaryKeyName = tableInfo.getPrimaryKey().get(0).getName();//we only support single primary key
DataType primaryKeyType = tableInfo.getPrimaryKey().get(0).getType();
String cqlFormattedPrimaryKeyValue = convertToCQLDataType(primaryKeyType, primaryKeyValue);
//get the row of data from a quorum
String selectQuery = "SELECT * FROM "+keyspaceName+"."+tableName+ " WHERE "+primaryKeyName+"="+cqlFormattedPrimaryKeyValue+";";
ResultSet results = getDSHandle().executeCriticalGet(selectQuery);
//write it back to a quorum
Row row = results.one();
ColumnDefinitions colInfo = row.getColumnDefinitions();
int totalColumns = colInfo.size();
int counter =1;
String fieldValueString="";
for (Definition definition : colInfo){
String colName = definition.getName();
if(colName.equals(primaryKeyName))
continue;
DataType colType = definition.getType();
Object valueObj = getDSHandle().getColValue(row, colName, colType);
String valueString = convertToCQLDataType(colType,valueObj);
fieldValueString = fieldValueString+ colName+"="+valueString;
if(counter!=(totalColumns-1))
fieldValueString = fieldValueString+",";
counter = counter +1;
}
String updateQuery = "UPDATE "+keyspaceName+"."+tableName+" SET "+fieldValueString+" WHERE "+primaryKeyName+"="+cqlFormattedPrimaryKeyValue+";";
getDSHandle().executePut(updateQuery, "critical");
}
示例3: CassandraResultSet
import com.datastax.driver.core.ColumnDefinitions.Definition; //导入方法依赖的package包/类
protected CassandraResultSet(BaseCassandraStatement statement, CassandraCqlStatement parsedStmt, ResultSet rs) {
super(statement, parsedStmt);
if (rs != null) {
for (Definition def : rs.getColumnDefinitions()) {
CassandraColumnDefinition d = new CassandraColumnDefinition(
def.getKeyspace(), def.getTable(), def.getName(), def
.getType().getName().toString(), false);
metadata.addColumnDefinition(d);
}
}
_resultSet = rs;
}
示例4: get
import com.datastax.driver.core.ColumnDefinitions.Definition; //导入方法依赖的package包/类
@Override
public Hit get(Entity entity) throws Exception {
String cql = "SELECT * FROM "+entity.getName()+"_"+entity.getMappingHash()+" WHERE rendezvous_id = '" + entity.getId() + "'";
logger.info(cql);
ResultSet result = session.execute(cql);
List<Value> values = new ArrayList<Value>();
for(Row row : result.all()){
for(Definition definition : row.getColumnDefinitions().asList()){
String field = definition.getName();
if(!field.equals("rendezvous_id")){
values.add(new Value(entity.getName(),field,row.getString(field),new Type(DataType.STRING.toString()), this));
logger.info("Added a value for the field "+field);
}
}
}
Hit hit = new Hit();
hit.setRelevance(1);
hit.setValues(values);
return hit;
}
示例5: query
import com.datastax.driver.core.ColumnDefinitions.Definition; //导入方法依赖的package包/类
@Override
public List<Hit> query(Entity entity, Set<Value> queryValues) throws Exception {
logger.debug("Searching from Cassandra");
if(queryValues==null || queryValues.isEmpty() || queryValues.size() == 0) throw new Exception("No parameter for the query");
int index = 0;
String cql = "SELECT * FROM "+entity.getName()+"_"+entity.getMappingHash()+" WHERE ";
for(Value value:queryValues){
++index;
cql+=value.getField().getFieldName()+"='"+value.getValue()+"'";
if(index<queryValues.size()) cql+=" AND ";
else cql+=" ALLOW FILTERING;";
}
logger.info(cql);
ResultSet result = session.execute(cql);
List<Hit> hits = new ArrayList<Hit>();
for(Row row : result.all()){
Hit hit = new Hit();
hit.setRelevance(1);
List<Value> values = new ArrayList<Value>();
for(Definition definition : row.getColumnDefinitions().asList()){
String field = definition.getName();
if(!field.equals("rendezvous_id")){
values.add(new Value(entity.getName(),field,row.getString(field),new Type(DataType.STRING.toString()), this));
}
}
hit.setValues(values);
hits.add(hit);
}
logger.info("<"+hits.size()+"> hits where found in Cassandra");
return hits;
}