當前位置: 首頁>>代碼示例>>Java>>正文


Java DataType.getName方法代碼示例

本文整理匯總了Java中com.datastax.driver.core.DataType.getName方法的典型用法代碼示例。如果您正苦於以下問題:Java DataType.getName方法的具體用法?Java DataType.getName怎麽用?Java DataType.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.datastax.driver.core.DataType的用法示例。


在下文中一共展示了DataType.getName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getColValue

import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
public Object getColValue(Row row, String colName, DataType colType){	
	switch(colType.getName()){
	case VARCHAR: 
		return row.getString(colName);
	case UUID: 
		return row.getUUID(colName);
	case VARINT: 
		return row.getVarint(colName);
	case BIGINT: 
		return row.getLong(colName);
	case INT: 
		return row.getInt(colName);
	case FLOAT: 
		return row.getFloat(colName);	
	case DOUBLE: 
		return row.getDouble(colName);
	case BOOLEAN: 
		return row.getBool(colName);
	case MAP: 
		return row.getMap(colName, String.class, String.class);
	default: 
		return null;
	}
}
 
開發者ID:att,項目名稱:music,代碼行數:25,代碼來源:MusicDataStore.java

示例2: convertToCQLDataType

import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
public static String convertToCQLDataType(DataType type,Object valueObj){
	String value ="";
	switch (type.getName()) {
	case UUID:
		value = valueObj+"";
		break;
	case TEXT: case VARCHAR:
		String valueString = valueObj+"";
		valueString = valueString.replace("'", "''");
		value = "'"+valueString+"'";
		break;
	case MAP:{
		Map<String,Object> otMap = (Map<String,Object>)valueObj;
		value = "{"+jsonMaptoSqlString(otMap, ",")+"}";
		break;
	}	
	default:
		value = valueObj+"";
		break;
	}
	return value;
}
 
開發者ID:att,項目名稱:music,代碼行數:23,代碼來源:MusicCore.java

示例3: convertToActualDataType

import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
public static Object convertToActualDataType(DataType colType,Object valueObj){
	String valueObjString = valueObj+"";
	switch(colType.getName()){
	case UUID: 
		return UUID.fromString(valueObjString);
	case VARINT: 
		return BigInteger.valueOf(Long.parseLong(valueObjString));
	case BIGINT: 
		return Long.parseLong(valueObjString);
	case INT: 
		return Integer.parseInt(valueObjString);
	case FLOAT: 
		return Float.parseFloat(valueObjString);	
	case DOUBLE: 
		return Double.parseDouble(valueObjString);
	case BOOLEAN: 
		return Boolean.parseBoolean(valueObjString);
	case MAP: 
		return (Map<String,Object>)valueObj;
	default:
		return valueObjString;
	}
}
 
開發者ID:att,項目名稱:music,代碼行數:24,代碼來源:MusicDataStore.java

示例4: readRow

import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
private Object readRow(final Row row, final String name, final DataType colType) {
		switch (colType.getName()) {
		case BIGINT:
			return row.getLong(name);
		case BOOLEAN:
			return row.getBool(name);
		case DOUBLE:
			return row.getDouble(name);
		case FLOAT:
			return row.getFloat(name);
		case INT:
			return row.getInt(name);
		case MAP:
			return row.getMap(name, String.class, String.class);
		case UUID:
			return row.getUUID(name);
		case TEXT:
		case VARCHAR:
			return row.getString(name);
		case VARINT:
			return row.getVarint(name);
// These are not supported right now....
// ASCII
// BLOB
// COUNTER
// CUSTOM
// DECIMAL
// INET
// LIST
// SET
// TIMESTAMP
// TIMEUUID
// TUPLE
// UDT
		default:
			return null;
		}
	}
 
開發者ID:att,項目名稱:music,代碼行數:39,代碼來源:MusicClient.java

示例5: parseValue

import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
public static Object parseValue(final DataType type, final String value) {
  if (value == null) {
    return null;
  }
  switch (type.getName()) {
  case TEXT:
  case VARCHAR:
  case ASCII:
    return value;
  case INET:
    return type.parse("'" + value + "'");
  case INT:
  case VARINT:
  case BIGINT:
  case FLOAT:
  case DOUBLE:
  case DECIMAL:
  case BOOLEAN:
    return type.parse(value.replaceAll("\\s+", ""));
  default:
    return type.parse(value);
  }
}
 
開發者ID:Stratio,項目名稱:ingestion,代碼行數:24,代碼來源:CassandraUtils.java

示例6: convertDataType

import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
public static int convertDataType(DataType type) {
    switch (type.getName()) {
    	case SMALLINT: 
        case INT:
        case BIGINT:
        case COUNTER:
        case TIME:
        	return ValueMetaInterface.TYPE_INTEGER; // 5 > java.lang.Long
        case ASCII:
        case TEXT:
        case VARCHAR:
        case UUID:
        case TIMEUUID:            	
            return ValueMetaInterface.TYPE_STRING; // 2 > java.lang.String
        case INET:
        	return ValueMetaInterface.TYPE_INET; // 10 > 
        case BOOLEAN:
            return ValueMetaInterface.TYPE_BOOLEAN; // 4 > java.lang.Boolean
        case DECIMAL:
        case FLOAT:
        case DOUBLE:
            return ValueMetaInterface.TYPE_NUMBER; // 1 > java.lang.Double
        case VARINT:
            return ValueMetaInterface.TYPE_BIGNUMBER; // 6 > java.math.BigDecimal
        case TIMESTAMP:
            return ValueMetaInterface.TYPE_DATE; // 3 > java.util.Date
        case BLOB:
        	return ValueMetaInterface.TYPE_BINARY; // 8 > java.lang.byte[]
        case LIST:
        case MAP:
        case SET:
        	return ValueMetaInterface.TYPE_SERIALIZABLE; // 0
        default:
        	return ValueMetaInterface.TYPE_STRING;
    }
}
 
開發者ID:bcolas,項目名稱:pentaho-cassandra-plugin,代碼行數:37,代碼來源:Utils.java

示例7: convertToSqlDataType

import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
private String convertToSqlDataType(DataType type, Object valueObj) {
	switch (type.getName()) {
	case TEXT:
		String t = valueObj.toString();
		t = t.replaceAll("'", "''");
		return "'" + t + "'";
	case MAP:
		@SuppressWarnings("unchecked")
		Map<String,Object> otMap = (Map<String,Object>) valueObj;
		return "{" + jsonMaptoSqlString(otMap, ",") + "}";
	default:
	case UUID:
		return valueObj.toString();
	}
}
 
開發者ID:att,項目名稱:music,代碼行數:16,代碼來源:MusicClient.java

示例8: checkType

import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
DataType.Name checkType(int i, DataType.Name name1, DataType.Name name2) {
    DataType defined = getType(i);
    if (name1 != defined.getName() && name2 != defined.getName())
        throw new InvalidTypeException(String.format("Column %s is of type %s", getName(i), defined));

    return defined.getName();
}
 
開發者ID:adejanovski,項目名稱:cassandra-jdbc-wrapper,代碼行數:8,代碼來源:ColumnDefinitions.java

示例9: getCql3Type

import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
private static CQL3Type.Raw getCql3Type(DataType dt) throws Exception {
    CQL3Type.Raw type;
    switch (dt.getName()) {
    case LIST:
        type = CQL3Type.Raw.list(getCql3Type(dt.getTypeArguments().get(0)));
        break;
    case MAP:
        type = CQL3Type.Raw.map(getCql3Type(dt.getTypeArguments().get(0)),
                getCql3Type(dt.getTypeArguments().get(1)));
        break;
    case SET:
        type = CQL3Type.Raw.set(getCql3Type(dt.getTypeArguments().get(0)));
        break;
    case TUPLE:
        ArrayList<CQL3Type.Raw> tupleTypes = new ArrayList<CQL3Type.Raw>();
        for (DataType arg : ((TupleType) dt).getComponentTypes()) {
            tupleTypes.add(getCql3Type(arg));
        }
        type = CQL3Type.Raw.tuple(tupleTypes);
        break;
    case UDT: // Requires this UDT to already be loaded
        UserType udt = (UserType) dt;
        type = CQL3Type.Raw.userType(new UTName(new ColumnIdentifier(udt.getKeyspace(), true),
                new ColumnIdentifier(udt.getTypeName(), true)));
        break;
    default:
        type = CQL3Type.Raw.from(
                Enum.<CQL3Type.Native> valueOf(CQL3Type.Native.class, dt.getName().toString().toUpperCase()));
        break;
    }
    if (dt.isFrozen()) {
        type = CQL3Type.Raw.frozen(type);
    }
    return type;
}
 
開發者ID:scylladb,項目名稱:scylla-tools-java,代碼行數:36,代碼來源:BulkLoader.java

示例10: validateName

import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
private DataType.Name validateName(DataType dataType) {

        final DataType.Name name = dataType.getName();
        if (DataTypeHelper.isNumber(name)) {
            return name;
        }
        throw new IllegalArgumentException("Datatype " + dataType + " not a number");
    }
 
開發者ID:arnaudroger,項目名稱:SimpleFlatMapper,代碼行數:9,代碼來源:DatastaxGenericByteGetter.java

示例11: validateName

import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
private DataType.Name validateName(DataType dataType) {

        final DataType.Name name = dataType.getName();
        if (DataTypeHelper.isNumber(name)) {
            return name;
        }

        throw new IllegalArgumentException("Datatype " + dataType + " not a number");
    }
 
開發者ID:arnaudroger,項目名稱:SimpleFlatMapper,代碼行數:10,代碼來源:DatastaxGenericIntegerGetter.java

示例12: CellValidator

import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
/**
 * private constructor.
 *
 * @param type a {@link com.datastax.driver.core.DataType} coming from the underlying Java driver.
 */
private CellValidator(DataType type) {
    if (type == null) {
        throw new DeepInstantiationException("input DataType cannot be null");
    }

    cqlTypeName = type.getName();

    if (!type.isCollection()) {
        validatorClassName = MAP_JAVA_TYPE_TO_ABSTRACT_TYPE.get(type.asJavaClass()).getClass()
                .getName();
    } else {
        validatorTypes = new ArrayList<>();

        for (DataType dataType : type.getTypeArguments()) {
            validatorTypes.add(dataType.toString());
        }

        switch (type.getName()) {
        case SET:
            validatorKind = Kind.SET;
            validatorClassName = SetType.class.getName();
            break;
        case LIST:
            validatorKind = Kind.LIST;
            validatorClassName = ListType.class.getName();
            break;
        case MAP:
            validatorKind = Kind.MAP;
            validatorClassName = MapType.class.getName();
            break;
        default:
            throw new DeepGenericException("Cannot determine collection type for " + type.getName());
        }

        validatorTypes = unmodifiableCollection(validatorTypes);
    }
}
 
開發者ID:Stratio,項目名稱:deep-spark,代碼行數:43,代碼來源:CellValidator.java

示例13: activate

import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
@Override
public void activate(Context.OperatorContext context)
{
  com.datastax.driver.core.ResultSet rs
      = store.getSession().execute("select * from " + store.keyspace + "." + tablename);
  final ColumnDefinitions rsMetaData = rs.getColumnDefinitions();

  if (fieldInfos == null) {
    populateFieldInfosFromPojo(rsMetaData);
  }

  for (FieldInfo fieldInfo : getFieldInfos()) {
    // get the designated column's data type.
    final DataType type = rsMetaData.getType(fieldInfo.getColumnName());
    columnDataTypes.add(type);
    final Object getter;
    final String getterExpr = fieldInfo.getPojoFieldExpression();
    switch (type.getName()) {
      case ASCII:
      case TEXT:
      case VARCHAR:
        getter = PojoUtils.createGetter(pojoClass, getterExpr, String.class);
        break;
      case BOOLEAN:
        getter = PojoUtils.createGetterBoolean(pojoClass, getterExpr);
        break;
      case INT:
        getter = PojoUtils.createGetterInt(pojoClass, getterExpr);
        break;
      case BIGINT:
      case COUNTER:
        getter = PojoUtils.createGetterLong(pojoClass, getterExpr);
        break;
      case FLOAT:
        getter = PojoUtils.createGetterFloat(pojoClass, getterExpr);
        break;
      case DOUBLE:
        getter = PojoUtils.createGetterDouble(pojoClass, getterExpr);
        break;
      case DECIMAL:
        getter = PojoUtils.createGetter(pojoClass, getterExpr, BigDecimal.class);
        break;
      case SET:
        getter = PojoUtils.createGetter(pojoClass, getterExpr, Set.class);
        break;
      case MAP:
        getter = PojoUtils.createGetter(pojoClass, getterExpr, Map.class);
        break;
      case LIST:
        getter = PojoUtils.createGetter(pojoClass, getterExpr, List.class);
        break;
      case TIMESTAMP:
        getter = PojoUtils.createGetter(pojoClass, getterExpr, Date.class);
        break;
      case UUID:
        getter = PojoUtils.createGetter(pojoClass, getterExpr, UUID.class);
        break;
      default:
        getter = PojoUtils.createGetter(pojoClass, getterExpr, Object.class);
        break;
    }
    getters.add(getter);
  }
  super.activate(context);
}
 
開發者ID:apache,項目名稱:apex-malhar,代碼行數:66,代碼來源:CassandraPOJOOutputOperator.java

示例14: setStatementParameters

import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
@Override
@SuppressWarnings("unchecked")
protected Statement setStatementParameters(PreparedStatement updateCommand, Object tuple) throws DriverException
{
  final BoundStatement boundStmnt = new BoundStatement(updateCommand);
  final int size = columnDataTypes.size();
  for (int i = 0; i < size; i++) {
    final DataType type = columnDataTypes.get(i);
    switch (type.getName()) {
      case UUID:
        final UUID id = ((Getter<Object, UUID>)getters.get(i)).get(tuple);
        boundStmnt.setUUID(i, id);
        break;
      case ASCII:
      case VARCHAR:
      case TEXT:
        final String ascii = ((Getter<Object, String>)getters.get(i)).get(tuple);
        boundStmnt.setString(i, ascii);
        break;
      case BOOLEAN:
        final boolean bool = ((GetterBoolean<Object>)getters.get(i)).get(tuple);
        boundStmnt.setBool(i, bool);
        break;
      case INT:
        final int intValue = ((GetterInt<Object>)getters.get(i)).get(tuple);
        boundStmnt.setInt(i, intValue);
        break;
      case BIGINT:
      case COUNTER:
        final long longValue = ((GetterLong<Object>)getters.get(i)).get(tuple);
        boundStmnt.setLong(i, longValue);
        break;
      case FLOAT:
        final float floatValue = ((GetterFloat<Object>)getters.get(i)).get(tuple);
        boundStmnt.setFloat(i, floatValue);
        break;
      case DOUBLE:
        final double doubleValue = ((GetterDouble<Object>)getters.get(i)).get(tuple);
        boundStmnt.setDouble(i, doubleValue);
        break;
      case DECIMAL:
        final BigDecimal decimal = ((Getter<Object, BigDecimal>)getters.get(i)).get(tuple);
        boundStmnt.setDecimal(i, decimal);
        break;
      case SET:
        Set<?> set = ((Getter<Object, Set<?>>)getters.get(i)).get(tuple);
        boundStmnt.setSet(i, set);
        break;
      case MAP:
        final Map<?,?> map = ((Getter<Object, Map<?,?>>)getters.get(i)).get(tuple);
        boundStmnt.setMap(i, map);
        break;
      case LIST:
        final List<?> list = ((Getter<Object, List<?>>)getters.get(i)).get(tuple);
        boundStmnt.setList(i, list);
        break;
      case TIMESTAMP:
        final Date date = ((Getter<Object, Date>)getters.get(i)).get(tuple);
        boundStmnt.setDate(i, LocalDate.fromMillisSinceEpoch(date.getTime()));
        break;
      default:
        throw new RuntimeException("unsupported data type " + type.getName());
    }
  }
  return boundStmnt;
}
 
開發者ID:apache,項目名稱:apex-malhar,代碼行數:67,代碼來源:CassandraPOJOOutputOperator.java

示例15: activate

import com.datastax.driver.core.DataType; //導入方法依賴的package包/類
@Override
public void activate(OperatorContext context)
{
  Long keyToken;
  if (startRow != null) {
    if ((keyToken = fetchKeyTokenFromDB(startRow)) != null) {
      startRowToken = keyToken;
    }
  }

  com.datastax.driver.core.ResultSet rs = store.getSession().execute("select * from " + store.keyspace + "." + tablename + " LIMIT " + 1);
  ColumnDefinitions rsMetaData = rs.getColumnDefinitions();

  if (query.contains("%t")) {
    query = query.replace("%t", tablename);
  }
  if (query.contains("%p")) {
    query = query.replace("%p", primaryKeyColumn);
  }
  if (query.contains("%l")) {
    query = query.replace("%l", limit + "");
  }

  LOG.debug("query is {}", query);

  for (FieldInfo fieldInfo : fieldInfos) {
    // Get the designated column's data type.
    DataType type = rsMetaData.getType(fieldInfo.getColumnName());
    columnDataTypes.add(type);
    Object setter;
    final String setterExpr = fieldInfo.getPojoFieldExpression();
    switch (type.getName()) {
      case ASCII:
      case TEXT:
      case VARCHAR:
        setter = PojoUtils.createSetter(pojoClass, setterExpr, String.class);
        break;
      case BOOLEAN:
        setter = PojoUtils.createSetterBoolean(pojoClass, setterExpr);
        break;
      case INT:
        setter = PojoUtils.createSetterInt(pojoClass, setterExpr);
        break;
      case BIGINT:
      case COUNTER:
        setter = PojoUtils.createSetterLong(pojoClass, setterExpr);
        break;
      case FLOAT:
        setter = PojoUtils.createSetterFloat(pojoClass, setterExpr);
        break;
      case DOUBLE:
        setter = PojoUtils.createSetterDouble(pojoClass, setterExpr);
        break;
      case DECIMAL:
        setter = PojoUtils.createSetter(pojoClass, setterExpr, BigDecimal.class);
        break;
      case SET:
        setter = PojoUtils.createSetter(pojoClass, setterExpr, Set.class);
        break;
      case MAP:
        setter = PojoUtils.createSetter(pojoClass, setterExpr, Map.class);
        break;
      case LIST:
        setter = PojoUtils.createSetter(pojoClass, setterExpr, List.class);
        break;
      case TIMESTAMP:
        setter = PojoUtils.createSetter(pojoClass, setterExpr, Date.class);
        break;
      case UUID:
        setter = PojoUtils.createSetter(pojoClass, setterExpr, UUID.class);
        break;
      default:
        setter = PojoUtils.createSetter(pojoClass, setterExpr, Object.class);
        break;
    }
    setters.add(setter);
  }
}
 
開發者ID:apache,項目名稱:apex-malhar,代碼行數:79,代碼來源:CassandraPOJOInputOperator.java


注:本文中的com.datastax.driver.core.DataType.getName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。