Java 类com.datastax.driver.core.exceptions.InvalidTypeException 实例源码

项目:storm-cassandra-cql    文件:CassandraCqlMapState.java   
protected void checkCassandraException(Exception e) {
    _mexceptions.incr();
    if (e instanceof AlreadyExistsException ||
            e instanceof AuthenticationException ||
            e instanceof DriverException ||
            e instanceof DriverInternalError ||
            e instanceof InvalidConfigurationInQueryException ||
            e instanceof InvalidQueryException ||
            e instanceof InvalidTypeException ||
            e instanceof QueryExecutionException ||
            e instanceof QueryTimeoutException ||
            e instanceof QueryValidationException ||
            e instanceof ReadTimeoutException ||
            e instanceof SyntaxError ||
            e instanceof TraceRetrievalException ||
            e instanceof TruncateException ||
            e instanceof UnauthorizedException ||
            e instanceof UnavailableException ||
            e instanceof ReadTimeoutException ||
            e instanceof WriteTimeoutException) {
        throw new ReportedFailedException(e);
    } else {
        throw new RuntimeException(e);
    }
}
项目:cassandra-jdbc-wrapper    文件:CassandraResultSet.java   
@SuppressWarnings("cast")
public long getLong(int index) throws SQLException
   {
       checkIndex(index);
       try{
        if(currentRow.getColumnDefinitions().getType(index-1).getName().toString().equals("int")){
            return (long)currentRow.getInt(index-1);
        }else if(currentRow.getColumnDefinitions().getType(index-1).getName().toString().equals("varint")){
            return currentRow.getVarint(index-1).longValue();
        }else{
            return currentRow.getLong(index-1);
        }
       }catch(InvalidTypeException e){      
        throw new SQLNonTransientException(e);
    }

   }
项目:cassandra-jdbc-wrapper    文件:CassandraResultSet.java   
@SuppressWarnings("cast")
public long getLong(String name) throws SQLException
   {
       checkName(name);
       try{
        if(currentRow.getColumnDefinitions().getType(name).getName().toString().equals("int")){
            return (long)currentRow.getInt(name);
        }else if(currentRow.getColumnDefinitions().getType(name).getName().toString().equals("varint")){
            return currentRow.getVarint(name).longValue();
        }else{
            return currentRow.getLong(name);
        }
       }catch(InvalidTypeException e){      
        throw new SQLNonTransientException(e);
    }
   }
项目:cassandra-jdbc-wrapper    文件:CassandraMetadataResultSet.java   
public long getLong(int index) throws SQLException
{
    checkIndex(index);
    try{
        if(currentRow.getColumnDefinitions().getType(index-1).getName().toString().equals("int")){
            return currentRow.getInt(index-1);
        }else if(currentRow.getColumnDefinitions().getType(index-1).getName().toString().equals("varint")){
            return currentRow.getVarint(index-1).longValue();
        }else{
            return currentRow.getLong(index-1);
        }
    }catch(InvalidTypeException e){     
        throw new SQLNonTransientException(e);
    }



    //return currentRow.getLong(index - 1);

}
项目:Fido    文件:DatastoreService.java   
/**
 * Use the query set via a previous call to prepare to return a single Entity
 *
 * @return the entity
 */
public Entity asSingleEntity() {
    if (null == this.preparedQuery) {
        throw new DatastoreServiceException(messages.NO_QUERY_SET_ERROR);
    }   
    try {
        List<DataStoreRow> rows = this.getClient().select(this.preparedQuery);
        if (rows.size() > 0) {
            Entity e = rows.get(0).getEntity();
            return e;
        }
    } catch (DatastoreServiceException dse) {
        if (InvalidTypeException.class != dse.getInner().getClass()) {
            Log.e(LOG_TAG, dse);
            throw dse;
        }           
    } catch(EntityNotFoundException enfe) {
        Log.v(LOG_TAG, enfe.toString());
    }
    return null;            
}
项目:cassandra-reaper    文件:DateTimeCodec.java   
@Override
public DateTime parse(String value) {
  if (value == null || value.equals("NULL")) {
    return null;
  }

  try {
    return DateTime.parse(value);
  } catch (IllegalArgumentException iae) {
    throw new InvalidTypeException("Could not parse format: " + value, iae);
  }
}
项目:cassandra-reaper    文件:DateTimeCodec.java   
@Override
public Long parse(String value) {
  try {
    return value == null || value.isEmpty() || value.equalsIgnoreCase("NULL") ? null : Long.parseLong(value);
  } catch (NumberFormatException e) {
    throw new InvalidTypeException(String.format("Cannot parse 64-bits long value from \"%s\"", value));
  }
}
项目:cassandra-reaper    文件:DateTimeCodec.java   
@Override
public long deserializeNoBoxing(ByteBuffer bytes, ProtocolVersion protocolVersion) {
  if (bytes == null || bytes.remaining() == 0) {
    return 0;
  }
  if (bytes.remaining() != 8) {
    throw new InvalidTypeException("Invalid 64-bits long value, expecting 8 bytes but got " + bytes.remaining());
  }

  return bytes.getLong(bytes.position());
}
项目:cassandra-jdbc-driver    文件:StringBlobCodec.java   
@Override
public String deserialize(ByteBuffer bytes, ProtocolVersion protocolVersion) throws InvalidTypeException {
    if (bytes == null || bytes.remaining() == 0)
        return null;

    return new String(bytes.array());
}
项目:cassandra-jdbc-driver    文件:BytesBlobCodec.java   
@Override
public byte[] deserialize(ByteBuffer bytes, ProtocolVersion protocolVersion) throws InvalidTypeException {
    if (bytes == null || bytes.remaining() == 0)
        return null;

    return bytes.duplicate().array();
}
项目:cassandra-jdbc-driver    文件:JavaSqlTimeCodec.java   
@Override
public Time deserialize(ByteBuffer bytes, ProtocolVersion protocolVersion) throws InvalidTypeException {
    if (bytes == null || bytes.remaining() == 0)
        return null;
    long nanosOfDay = bigint().deserializeNoBoxing(bytes, protocolVersion);
    return new Time(LocalTime.fromMillisOfDay(nanosOfDay / 1000000L).toDateTimeToday().getMillis());
}
项目:cassandra-jdbc-driver    文件:StringTimeCodec.java   
@Override
public String deserialize(ByteBuffer bytes, ProtocolVersion protocolVersion) throws InvalidTypeException {
    if (bytes == null || bytes.remaining() == 0)
        return null;
    long nanosOfDay = bigint().deserializeNoBoxing(bytes, protocolVersion);
    return LocalTime.fromMillisOfDay(nanosOfDay / 1000000).toString();
}
项目:cassandra-jdbc-driver    文件:StringTimeCodec.java   
@Override
public String parse(String value) {
    if (value == null || value.isEmpty() || value.equalsIgnoreCase("NULL"))
        return null;

    // enclosing single quotes required, even for long literals
    if (!ParseUtils.isQuoted(value))
        throw new InvalidTypeException("time values must be enclosed by single quotes");

    return value.substring(1, value.length() - 1);
}
项目:cassandra-loader    文件:DelimParser.java   
public String format(Row row) throws IndexOutOfBoundsException, InvalidTypeException {
    StringBuilder retVal = new StringBuilder();
    String[] stringVals = stringVals(row);
    retVal.append(stringVals[0]);
    for (int i = 1; i < parsersSize; i++) {
        retVal.append(delimiter).append(stringVals[i]);
    }
    return retVal.toString();
}
项目:cassandra-loader    文件:CqlDelimParser.java   
public String formatJson(Row row) throws IndexOutOfBoundsException, InvalidTypeException {
    String[] stringVals = delimParser.stringVals(row);
    Map<String,String> pairs = new HashMap<String,String>();
    for (int i = 0; i < sbl.size(); i++)
        pairs.put(sbl.get(i).name, stringVals[i]);
    return JSONObject.toJSONString(pairs);
}
项目:cassandra-jdbc-wrapper    文件:CassandraResultSet.java   
public double getDouble(int index) throws SQLException
 {
     checkIndex(index);

     try{
        if(currentRow.getColumnDefinitions().getType(index-1).getName().toString().equals("float")){
            return currentRow.getFloat(index-1);
        }
return currentRow.getDouble(index-1);
     }catch(InvalidTypeException e){
        throw new SQLNonTransientException(e);
    }       
 }
项目:cassandra-jdbc-wrapper    文件:CassandraResultSet.java   
@SuppressWarnings("cast")
public double getDouble(String name) throws SQLException
   {
       checkName(name);
       try{
        if(currentRow.getColumnDefinitions().getType(name).getName().toString().equals("float")){
            return (double)currentRow.getFloat(name);
        }
        return currentRow.getDouble(name);
       }catch(InvalidTypeException e){      
        throw new SQLNonTransientException(e);
    }
   }
项目:cassandra-jdbc-wrapper    文件:TimestampToLongCodec.java   
@Override
public ByteBuffer serialize(Long paramT, ProtocolVersion paramProtocolVersion) throws InvalidTypeException {
    if (paramT == null) {
        return null;
    }
    return ByteBufferUtil.bytes(paramT);
}
项目:cassandra-jdbc-wrapper    文件:TimestampToLongCodec.java   
@Override
public Long deserialize(ByteBuffer paramByteBuffer, ProtocolVersion paramProtocolVersion) throws InvalidTypeException {
    if (paramByteBuffer == null) {
        return null;

    }
    // always duplicate the ByteBuffer instance before consuming it!
    return ByteBufferUtil.toLong(paramByteBuffer.duplicate());
}
项目:cassandra-jdbc-wrapper    文件:BigDecimalToBigintCodec.java   
@Override
public ByteBuffer serialize(BigDecimal paramT, ProtocolVersion paramProtocolVersion) throws InvalidTypeException {
    if (paramT == null) {
        return null;
    }
    return ByteBufferUtil.bytes(paramT.longValue());
}
项目:cassandra-jdbc-wrapper    文件:BigDecimalToBigintCodec.java   
@Override
public BigDecimal deserialize(ByteBuffer paramByteBuffer, ProtocolVersion paramProtocolVersion) throws InvalidTypeException {
    if (paramByteBuffer == null) {
        return null;

    }
    // always duplicate the ByteBuffer instance before consuming it!
    Long value = ByteBufferUtil.toLong(paramByteBuffer.duplicate());
    return new BigDecimal(value);
}
项目:cassandra-jdbc-wrapper    文件:LongToIntCodec.java   
@Override
public ByteBuffer serialize(Integer paramT, ProtocolVersion paramProtocolVersion) throws InvalidTypeException {
    if (paramT == null) {
        return null;
    }
    return ByteBufferUtil.bytes(paramT);
}
项目:cassandra-jdbc-wrapper    文件:LongToIntCodec.java   
@Override
public Integer deserialize(ByteBuffer paramByteBuffer, ProtocolVersion paramProtocolVersion) throws InvalidTypeException {
    if (paramByteBuffer == null) {
        return null;

    }
    // always duplicate the ByteBuffer instance before consuming it!
    Long value = ByteBufferUtil.toLong(paramByteBuffer.duplicate());
    return value.intValue();
}
项目:cassandra-jdbc-wrapper    文件:DoubleToFloatCodec.java   
@Override
public ByteBuffer serialize(Double paramT, ProtocolVersion paramProtocolVersion) throws InvalidTypeException {
    if (paramT == null) {
        return null;
    }
    return ByteBufferUtil.bytes(paramT.floatValue());
}
项目:cassandra-jdbc-wrapper    文件:DoubleToFloatCodec.java   
@Override
public Double deserialize(ByteBuffer paramByteBuffer, ProtocolVersion paramProtocolVersion) throws InvalidTypeException {
    if (paramByteBuffer == null) {
        return null;

    }
    // always duplicate the ByteBuffer instance before consuming it!
    Float value = ByteBufferUtil.toFloat(paramByteBuffer.duplicate());      
    return value.doubleValue();
}
项目:cassandra-jdbc-wrapper    文件:IntToLongCodec.java   
@Override
public ByteBuffer serialize(Long paramT, ProtocolVersion paramProtocolVersion) throws InvalidTypeException {
    if (paramT == null) {
        return null;
    }
    return ByteBufferUtil.bytes(paramT.intValue());
}
项目:cassandra-jdbc-wrapper    文件:IntToLongCodec.java   
@Override
public Long deserialize(ByteBuffer paramByteBuffer, ProtocolVersion paramProtocolVersion) throws InvalidTypeException {
    if (paramByteBuffer == null) {
        return null;

    }
    // always duplicate the ByteBuffer instance before consuming it!
    return ByteBufferUtil.toLong(paramByteBuffer.duplicate());
}
项目:cassandra-jdbc-wrapper    文件:DoubleToDecimalCodec.java   
@Override
public ByteBuffer serialize(Double paramT, ProtocolVersion paramProtocolVersion) throws InvalidTypeException {
    if (paramT == null) {
        return null;
    }
    return ByteBufferUtil.bytes(paramT);
}
项目:cassandra-jdbc-wrapper    文件:DoubleToDecimalCodec.java   
@Override
public Double deserialize(ByteBuffer paramByteBuffer, ProtocolVersion paramProtocolVersion) throws InvalidTypeException {
    if (paramByteBuffer == null) {
        return null;

    }
    // always duplicate the ByteBuffer instance before consuming it!
    Float value = ByteBufferUtil.toFloat(paramByteBuffer.duplicate());      
    return value.doubleValue();
}
项目:cassandra-jdbc-wrapper    文件:CassandraMetadataResultSet.java   
public double getDouble(int index) throws SQLException
 {
     checkIndex(index);

     try{
        if(currentRow.getColumnDefinitions().getType(index-1).getName().toString().equals("float")){
            return currentRow.getFloat(index-1);
        }
return currentRow.getDouble(index-1);
     }catch(InvalidTypeException e){
        throw new SQLNonTransientException(e);
    }       
 }
项目:cassandra-jdbc-wrapper    文件:CassandraMetadataResultSet.java   
public double getDouble(String name) throws SQLException
 {
     checkName(name);
     try{
        if(currentRow.getColumnDefinitions().getType(name).getName().toString().equals("float")){
            return currentRow.getFloat(name);
        }
return currentRow.getDouble(name);
     }catch(InvalidTypeException e){        
        throw new SQLNonTransientException(e);
    }
 }
项目:cassandra-jdbc-wrapper    文件:CassandraMetadataResultSet.java   
public long getLong(String name) throws SQLException
{
    checkName(name);
    try{
        if(currentRow.getColumnDefinitions().getType(name).getName().toString().equals("int")){
            return currentRow.getInt(name);
        }else if(currentRow.getColumnDefinitions().getType(name).getName().toString().equals("varint")){
            return currentRow.getVarint(name).longValue();
        }else{
            return currentRow.getLong(name);
        }
    }catch(InvalidTypeException e){     
        throw new SQLNonTransientException(e);
    }
}
项目:cassandra-jdbc-wrapper    文件:ColumnDefinitions.java   
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();
}
项目:cassandra-jdbc-wrapper    文件:ColumnDefinitions.java   
DataType.Name checkType(int i, DataType.Name name1, DataType.Name name2, DataType.Name name3) {
    DataType defined = getType(i);
    if (name1 != defined.getName() && name2 != defined.getName() && name3 != defined.getName())
        throw new InvalidTypeException(String.format("Column %s is of type %s", getName(i), defined));

    return defined.getName();
}
项目:scylla-tools-java    文件:UDHelper.java   
public static ByteBuffer serialize(TypeCodec<?> codec, int protocolVersion, Object value)
{
    if (!codec.getJavaType().getRawType().isAssignableFrom(value.getClass()))
        throw new InvalidTypeException("Invalid value for CQL type " + codec.getCqlType().getName().toString());

    return ((TypeCodec)codec).serialize(value, ProtocolVersion.fromInt(protocolVersion));
}
项目:jmeter-cassandra    文件:DataTypeTest.java   
@Test(groups = "long")
public void serializeDeserializeCollectionsTest() {

    List<String> l = Arrays.asList("foo", "bar");

    DataType dt = DataType.list(DataType.text());
    assertEquals(dt.deserialize(dt.serialize(l, ProtocolVersion.V3)), l);

    try {
        DataType.list(DataType.bigint()).serialize(l, ProtocolVersion.V3);
        fail("This should not have worked");
    } catch (InvalidTypeException e) { /* That's what we want */ }
}
项目:act-platform    文件:CassandraEnumCodec.java   
@Override
public ByteBuffer serialize(E value, ProtocolVersion protocolVersion) throws InvalidTypeException {
  return innerCodec.serialize(value == null ? null : value.value(), protocolVersion);
}
项目:act-platform    文件:CassandraEnumCodec.java   
@Override
public E deserialize(ByteBuffer bytes, ProtocolVersion protocolVersion) throws InvalidTypeException {
  Integer value = innerCodec.deserialize(bytes, protocolVersion);
  return value == null ? null : enumValueMap.get(value);
}
项目:act-platform    文件:CassandraEnumCodec.java   
@Override
public E parse(String value) throws InvalidTypeException {
  return value == null || value.isEmpty() || value.equalsIgnoreCase("NULL") ? null : enumValueMap.get(Integer.parseInt(value));
}
项目:act-platform    文件:CassandraEnumCodec.java   
@Override
public String format(E value) throws InvalidTypeException {
  return value == null ? "NULL" : Integer.toString(value.value());
}