本文整理匯總了Java中com.datastax.driver.core.DataType.text方法的典型用法代碼示例。如果您正苦於以下問題:Java DataType.text方法的具體用法?Java DataType.text怎麽用?Java DataType.text使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.datastax.driver.core.DataType
的用法示例。
在下文中一共展示了DataType.text方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: cqlType
import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
private static DataType cqlType(FieldInfo info) {
if (String.class.equals(info.type())) {
return DataType.text();
} else if (Boolean.class.equals(info.type()) || Boolean.TYPE.equals(info.type())) {
return DataType.cboolean();
} else if (Long.class.equals(info.type()) || Long.TYPE.equals(info.type())) {
return DataType.cint();
} else if (Double.class.equals(info.type()) || Double.TYPE.equals(info.type())) {
return DataType.cint();
} else if (Float.class.equals(info.type()) || Float.TYPE.equals(info.type())) {
return DataType.cint();
} else if (Integer.class.equals(info.type()) || Integer.TYPE.equals(info.type())) {
return DataType.cint();
} else if (LocalDate.class.equals(info.type())) {
return DataType.date();
} else if (Enum.class.isAssignableFrom(info.type())) {
return DataType.set(DataType.text());
} else if (Collection.class.isAssignableFrom(info.type())) {
return DataType.set(DataType.text());
}
throw new IllegalArgumentException("unknown type " + info.type() + " for " + info.id());
}
示例2: currentRowField
import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
/** Get a field for the current row from the underlying object.
*
* @param index Index of the field within the Row object
* @param typeName Type of the field in this row
*/
private Object currentRowField(int index, SqlTypeName typeName) {
DataType type = current.getColumnDefinitions().getType(index);
if (type == DataType.ascii() || type == DataType.text() || type == DataType.varchar()) {
return current.getString(index);
} else if (type == DataType.cint() || type == DataType.varint()) {
return current.getInt(index);
} else if (type == DataType.bigint()) {
return current.getLong(index);
} else if (type == DataType.cdouble()) {
return current.getDouble(index);
} else if (type == DataType.cfloat()) {
return current.getFloat(index);
} else if (type == DataType.uuid() || type == DataType.timeuuid()) {
return current.getUUID(index).toString();
} else {
return null;
}
}
示例3: getHecubaClientManagerWithStringKeys
import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
public HecubaClientManager<String> getHecubaClientManagerWithStringKeys(CassandraParamsBean parameters,
HecubaConstants.CassandraClientImplementation cassandraManagerType) {
switch (cassandraManagerType) {
case ASTYANAX:
return new AstyanaxBasedHecubaClientManager<String>(parameters,
com.netflix.astyanax.serializers.StringSerializer.get());
case HECTOR:
return new HectorBasedHecubaClientManager<String>(parameters,
me.prettyprint.cassandra.serializers.StringSerializer.get());
case DATASTAX:
return new DataStaxBasedHecubaClientManager<>(parameters, DataType.text());
case DATASTAX_SHARED:
return new DataStaxBasedSharedHecubaClientManager<>(parameters, DataType.text());
default:
throw new RuntimeException("Unhandled CassandraManagerType: " + cassandraManagerType);
}
}
示例4: getRelDataType
import com.datastax.driver.core.DataType; //導入方法依賴的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());
}