本文整理汇总了Java中com.datastax.driver.core.ColumnMetadata.getName方法的典型用法代码示例。如果您正苦于以下问题:Java ColumnMetadata.getName方法的具体用法?Java ColumnMetadata.getName怎么用?Java ColumnMetadata.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.datastax.driver.core.ColumnMetadata
的用法示例。
在下文中一共展示了ColumnMetadata.getName方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildColumnHandle
import com.datastax.driver.core.ColumnMetadata; //导入方法依赖的package包/类
private CassandraColumnHandle buildColumnHandle(ColumnMetadata columnMeta, boolean partitionKey, boolean clusteringKey, int ordinalPosition, boolean hidden)
{
CassandraType cassandraType = CassandraType.getCassandraType(columnMeta.getType().getName());
List<CassandraType> typeArguments = null;
if (cassandraType != null && cassandraType.getTypeArgumentSize() > 0) {
List<DataType> typeArgs = columnMeta.getType().getTypeArguments();
switch (cassandraType.getTypeArgumentSize()) {
case 1:
typeArguments = ImmutableList.of(CassandraType.getCassandraType(typeArgs.get(0).getName()));
break;
case 2:
typeArguments = ImmutableList.of(CassandraType.getCassandraType(typeArgs.get(0).getName()), CassandraType.getCassandraType(typeArgs.get(1).getName()));
break;
default:
throw new IllegalArgumentException("Invalid type arguments: " + typeArgs);
}
}
boolean indexed = columnMeta.getIndex() != null;
return new CassandraColumnHandle(connectorId, columnMeta.getName(), ordinalPosition, cassandraType, typeArguments, partitionKey, clusteringKey, indexed, hidden);
}
示例2: generateSpecificGet
import com.datastax.driver.core.ColumnMetadata; //导入方法依赖的package包/类
private static MethodSpec generateSpecificGet(TableMetadata table, ClassName entityTable, int desiredColumns) {
String query = getBaseQuery(table) + " WHERE ";
MethodSpec.Builder builder = MethodSpec.methodBuilder("getAll");
List<ColumnMetadata> columns = table.getPrimaryKey();
for(int i = 0; i < desiredColumns; i++) {
ColumnMetadata column = columns.get(i);
String name = column.getName();
String newClause = name + "=:" + name;
if(i != 0) {
newClause = " AND " + newClause;
}
query += newClause;
builder.addParameter(getSpec(column, true));
}
return builder.addModifiers(Modifier.ABSTRACT).addModifiers(Modifier.PUBLIC)
.returns(ParameterizedTypeName.get(ClassName.get(ListenableFuture.class),
ParameterizedTypeName.get(ClassName.get(Result.class), entityTable)))
.addAnnotation(AnnotationSpec.builder(Query.class).addMember("value", "$S", query).build())
.build();
}
示例3: getSpec
import com.datastax.driver.core.ColumnMetadata; //导入方法依赖的package包/类
private static ParameterSpec getSpec(ColumnMetadata column, boolean addAnnotation) {
String name = column.getName();
String paramName = CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name);
ParameterSpec.Builder param;
if (Udt.instance.isUdt(column.getType())) {
throw new IllegalArgumentException("We don't currently support UDT primary keys in the query string, field: "
+ column.getName());
} else {
param = ParameterSpec.builder(EntityGeneratorHelper.getRawType(column.getType()), paramName);
}
if(addAnnotation) {
param.addAnnotation(AnnotationSpec.builder(Param.class).addMember("value", "$S", name).build());
}
return param.addModifiers(Modifier.FINAL).build();
}
示例4: validateAdditionalFilters
import com.datastax.driver.core.ColumnMetadata; //导入方法依赖的package包/类
private void validateAdditionalFilters(TableMetadata tableMetadata) {
for (Map.Entry<String, Serializable> entry : additionalFilters.entrySet()) {
/* check if there's an index specified on the provided column */
ColumnMetadata columnMetadata = tableMetadata.getColumn(entry.getKey());
if (columnMetadata == null) {
throw new DeepNoSuchFieldException("No column with name " + entry.getKey() + " has been found on " +
"table " + this.catalog + "." + this.table);
}
if (columnMetadata.getIndex() == null) {
throw new DeepIndexNotFoundException("No index has been found on column " + columnMetadata.getName()
+ " on table " + this.catalog + "." + this.table);
}
}
}
示例5: generateMetaData
import com.datastax.driver.core.ColumnMetadata; //导入方法依赖的package包/类
private Map<String, Map<String, DataColumn>> generateMetaData() {
Map<String, Map<String, DataColumn>> metadata = new HashMap<>();
for (String tableName : this.tableList) {
Map<String, DataColumn> dataColumnMap = new HashMap<>();
for (ColumnMetadata columnMetadata : this.session.getCluster().getMetadata().getKeyspace(this.keyspace)
.getTable(tableName).getColumns()) {
DataColumn dataColumn;
if (this.primaryKeys.get(tableName).contains(columnMetadata.getName())) {
dataColumn = new DataColumn(columnMetadata.getName(),
getDataType(columnMetadata.getType().getName()), false);
} else {
dataColumn = new DataColumn(columnMetadata.getName(),
getDataType(columnMetadata.getType().getName()), true);
}
dataColumnMap.put(dataColumn.getColumnName(), dataColumn);
}
metadata.put(tableName, dataColumnMap);
}
return metadata;
}
示例6: parse
import com.datastax.driver.core.ColumnMetadata; //导入方法依赖的package包/类
public Map<String, Object> parse(final Event event) {
// translate to lowercase for ignorecase option
final Map<String, String> headers = ignoreCase ? processHeadersIgnoreCase(event.getHeaders())
: event.getHeaders();
final int maxValues = Math.min(headers.size(), totalColumns);
final Map<String, Object> result = new HashMap<String, Object>(maxValues);
for (final ColumnMetadata column : columns) {
final String columnName = ignoreCase ? column.getName().toLowerCase() : column.getName();
if (headers.containsKey(columnName) && !columnName.equals(bodyColumn)) {
result.put(columnName, parseValue(column.getType(), headers.get(columnName)));
} else if (columnName.equals(bodyColumn)) {
result.put(columnName, parseValue(column.getType(), new String(event.getBody(), Charsets.UTF_8)));
}
}
return result;
}
示例7: addFields
import com.datastax.driver.core.ColumnMetadata; //导入方法依赖的package包/类
/**
* Add fields to the class spec.
*/
private static void addFields(TypeSpec.Builder builder, TableMetadata tableMetadata, String className) {
Map<String, Integer> partitionKeys = getMapOfKeys(tableMetadata.getPartitionKey());
Map<String, Integer> clusteringKeys = getMapOfKeys(tableMetadata.getClusteringColumns());
List<String> fields = new ArrayList<>();
for (ColumnMetadata column : tableMetadata.getColumns()) {
DataType type = column.getType();
String name = column.getName();
List<AnnotationSpec> extraAnnotations = new ArrayList<>();
if(partitionKeys.containsKey(name)) {
extraAnnotations.add(EntityGeneratorHelper.getPartitionKeyAnnotation(partitionKeys.get(name)));
}
if(clusteringKeys.containsKey(name)) {
extraAnnotations.add(EntityGeneratorHelper.getClusteringAnnotation(clusteringKeys.get(name)));
}
builder.addField(EntityGeneratorHelper.getFieldSpec(name, type, false, extraAnnotations));
builder.addMethod(EntityGeneratorHelper.getSetter(name, type));
builder.addMethod(EntityGeneratorHelper.getGetter(name, type));
fields.add(CaseFormat.LOWER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, name));
}
builder.addMethod(EntityGeneratorHelper.getToString(fields, className));
}
示例8: getQueryConverter
import com.datastax.driver.core.ColumnMetadata; //导入方法依赖的package包/类
private static MethodSpec getQueryConverter(TableMetadata table) {
List<ColumnMetadata> keys = table.getPrimaryKey();
int numKeys = keys.size();
TypeMap typeToConverters = TypeMap.create();
MethodSpec.Builder builder = MethodSpec.methodBuilder("convertQueryString")
.addJavadoc("Convert query params to their Cassandra type.\n")
.addParameter(RoutingContext.class, "context", Modifier.FINAL)
.addModifiers(Modifier.PUBLIC)
.returns(Object[].class)
.addStatement("$T request = context.request()", HttpServerRequest.class)
.addCode("// if query params aren't valid a HttpResponseStatus.BAD_REQUEST will be sent with the missing field\n")
.addStatement("$T values = new Object[$L]", Object[].class, keys.size());
builder.beginControlFlow("try");
for(int i = 0; i < numKeys; i++) {
ColumnMetadata column = keys.get(i);
if(column.getType().equals(DataType.text())) {
builder.addStatement("values[$L] = request.getParam($S)", i, column.getName());
} else if (Udt.instance.isUdt(column.getType())) {
throw new IllegalArgumentException("We don't currently support UDT primary keys in the query string, field: "
+ column.getName());
} else {
String type = EntityGeneratorHelper.getRawType(column.getType()).simpleName();
builder.addCode("values[$L] = ", i)
.addCode(typeToConverters.getTypeConverter(type,
CodeBlock.builder().add("request.getParam($S)", column.getName()).build()))
.addStatement("");
}
}
return builder.nextControlFlow("catch (Exception ex)")
.addStatement("$T.processErrorResponse(ex.getMessage(), context.response(), $T.BAD_REQUEST.code())",
HttpHelper.class, HttpResponseStatus.class)
.addStatement("return null")
.endControlFlow()
.addStatement("return values").build();
}
示例9: getLuceneIndex
import com.datastax.driver.core.ColumnMetadata; //导入方法依赖的package包/类
/**
* Retrieve the column name for the lucene indexes. Null if there is no lucene index.
*
* @return Lucene index; null, if doesn't exist.
*/
private String getLuceneIndex() {
String indexName = "";
TableMetadata tableMetadata = config.fetchTableMetadata();
List<ColumnMetadata> columns = tableMetadata.getColumns();
for (ColumnMetadata column : columns) {
if (column.getIndex() != null) {
if (column.getIndex().isCustomIndex()) {
indexName = column.getName();
}
}
}
return indexName;
}
示例10: detectTable
import com.datastax.driver.core.ColumnMetadata; //导入方法依赖的package包/类
/**
* Performs an analysis of an available table in Cassandra.
*
* @param tableMetaData
* the table meta data
* @return a table definition for cassandra.
*/
public static SimpleTableDef detectTable(TableMetadata tableMetaData) {
final List<ColumnMetadata> columns = tableMetaData.getColumns();
final String[] columnNames = new String[columns.size()];
final ColumnType[] columnTypes = new ColumnType[columns.size()];
int i = 0;
for (final ColumnMetadata column : columns) {
columnNames[i] = column.getName();
columnTypes[i] = getColumnTypeFromMetaDataField(column.getType().getName());
i++;
}
return new SimpleTableDef(tableMetaData.getName(), columnNames, columnTypes);
}
示例11: of
import com.datastax.driver.core.ColumnMetadata; //导入方法依赖的package包/类
public static DatastaxColumnKey of(ColumnMetadata metaData, int column) {
return new DatastaxColumnKey(metaData.getName(), column , metaData.getType());
}
示例12: getRelDataType
import com.datastax.driver.core.ColumnMetadata; //导入方法依赖的package包/类
RelProtoDataType getRelDataType(String columnFamily, boolean view) {
List<ColumnMetadata> columns;
if (view) {
columns = getKeyspace().getMaterializedView(columnFamily).getColumns();
} else {
columns = getKeyspace().getTable(columnFamily).getColumns();
}
// Temporary type factory, just for the duration of this method. Allowable
// because we're creating a proto-type, not a type; before being used, the
// proto-type will be copied into a real type factory.
final RelDataTypeFactory typeFactory =
new SqlTypeFactoryImpl(RelDataTypeSystem.DEFAULT);
final RelDataTypeFactory.Builder fieldInfo = typeFactory.builder();
for (ColumnMetadata column : columns) {
final String columnName = column.getName();
final DataType type = column.getType();
// TODO: This mapping of types can be done much better
SqlTypeName typeName = SqlTypeName.ANY;
if (type == DataType.uuid() || type == DataType.timeuuid()) {
// We currently rely on this in CassandraFilter to detect UUID columns.
// That is, these fixed length literals should be unquoted in CQL.
typeName = SqlTypeName.CHAR;
} else if (type == DataType.ascii() || type == DataType.text()
|| type == DataType.varchar()) {
typeName = SqlTypeName.VARCHAR;
} else if (type == DataType.cint() || type == DataType.varint()) {
typeName = SqlTypeName.INTEGER;
} else if (type == DataType.bigint()) {
typeName = SqlTypeName.BIGINT;
} else if (type == DataType.cdouble() || type == DataType.cfloat()
|| type == DataType.decimal()) {
typeName = SqlTypeName.DOUBLE;
}
fieldInfo.add(columnName, typeFactory.createSqlType(typeName)).nullable(true);
}
return RelDataTypeImpl.proto(fieldInfo.build());
}