com.datastax.driver.core.exceptions.InvalidTypeException Java Examples
The following examples show how to use
com.datastax.driver.core.exceptions.InvalidTypeException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CassandraResultSet.java From cassandra-jdbc-wrapper with Apache License 2.0 | 6 votes |
@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); } }
Example #2
Source File: DateTimeCodec.java From cassandra-reaper with Apache License 2.0 | 6 votes |
@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()); }
Example #3
Source File: CassandraResultSet.java From cassandra-jdbc-wrapper with Apache License 2.0 | 6 votes |
@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); } }
Example #4
Source File: CassandraMetadataResultSet.java From cassandra-jdbc-wrapper with Apache License 2.0 | 6 votes |
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); }
Example #5
Source File: IntToLongCodec.java From cassandra-jdbc-wrapper with Apache License 2.0 | 5 votes |
@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()); }
Example #6
Source File: TimestampToLongCodec.java From cassandra-jdbc-wrapper with Apache License 2.0 | 5 votes |
@Override public ByteBuffer serialize(Long paramT, ProtocolVersion paramProtocolVersion) throws InvalidTypeException { if (paramT == null) { return null; } return ByteBufferUtil.bytes(paramT); }
Example #7
Source File: TimestampToLongCodec.java From cassandra-jdbc-wrapper with Apache License 2.0 | 5 votes |
@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()); }
Example #8
Source File: BigDecimalToBigintCodec.java From cassandra-jdbc-wrapper with Apache License 2.0 | 5 votes |
@Override public ByteBuffer serialize(BigDecimal paramT, ProtocolVersion paramProtocolVersion) throws InvalidTypeException { if (paramT == null) { return null; } return ByteBufferUtil.bytes(paramT.longValue()); }
Example #9
Source File: BigDecimalToBigintCodec.java From cassandra-jdbc-wrapper with Apache License 2.0 | 5 votes |
@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); }
Example #10
Source File: LongToIntCodec.java From cassandra-jdbc-wrapper with Apache License 2.0 | 5 votes |
@Override public ByteBuffer serialize(Integer paramT, ProtocolVersion paramProtocolVersion) throws InvalidTypeException { if (paramT == null) { return null; } return ByteBufferUtil.bytes(paramT); }
Example #11
Source File: LongToIntCodec.java From cassandra-jdbc-wrapper with Apache License 2.0 | 5 votes |
@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(); }
Example #12
Source File: DoubleToFloatCodec.java From cassandra-jdbc-wrapper with Apache License 2.0 | 5 votes |
@Override public ByteBuffer serialize(Double paramT, ProtocolVersion paramProtocolVersion) throws InvalidTypeException { if (paramT == null) { return null; } return ByteBufferUtil.bytes(paramT.floatValue()); }
Example #13
Source File: DoubleToFloatCodec.java From cassandra-jdbc-wrapper with Apache License 2.0 | 5 votes |
@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(); }
Example #14
Source File: IntToLongCodec.java From cassandra-jdbc-wrapper with Apache License 2.0 | 5 votes |
@Override public ByteBuffer serialize(Long paramT, ProtocolVersion paramProtocolVersion) throws InvalidTypeException { if (paramT == null) { return null; } return ByteBufferUtil.bytes(paramT.intValue()); }
Example #15
Source File: DateTimeCodec.java From cassandra-reaper with Apache License 2.0 | 5 votes |
@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)); } }
Example #16
Source File: DoubleToDecimalCodec.java From cassandra-jdbc-wrapper with Apache License 2.0 | 5 votes |
@Override public ByteBuffer serialize(Double paramT, ProtocolVersion paramProtocolVersion) throws InvalidTypeException { if (paramT == null) { return null; } return ByteBufferUtil.bytes(paramT); }
Example #17
Source File: DoubleToDecimalCodec.java From cassandra-jdbc-wrapper with Apache License 2.0 | 5 votes |
@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(); }
Example #18
Source File: CassandraMetadataResultSet.java From cassandra-jdbc-wrapper with Apache License 2.0 | 5 votes |
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); } }
Example #19
Source File: CassandraMetadataResultSet.java From cassandra-jdbc-wrapper with Apache License 2.0 | 5 votes |
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); } }
Example #20
Source File: CassandraMetadataResultSet.java From cassandra-jdbc-wrapper with Apache License 2.0 | 5 votes |
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); } }
Example #21
Source File: ColumnDefinitions.java From cassandra-jdbc-wrapper with Apache License 2.0 | 5 votes |
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(); }
Example #22
Source File: ColumnDefinitions.java From cassandra-jdbc-wrapper with Apache License 2.0 | 5 votes |
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(); }
Example #23
Source File: DataTypeTest.java From jmeter-cassandra with Apache License 2.0 | 5 votes |
@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 */ } }
Example #24
Source File: CassandraCqlMapState.java From storm-cassandra-cql with Apache License 2.0 | 5 votes |
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 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 || e instanceof ReadFailureException || e instanceof WriteFailureException || e instanceof FunctionExecutionException) { throw new ReportedFailedException(e); } else { throw new RuntimeException(e); } }
Example #25
Source File: CassandraResultSet.java From cassandra-jdbc-wrapper with Apache License 2.0 | 5 votes |
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); } }
Example #26
Source File: CassandraResultSet.java From cassandra-jdbc-wrapper with Apache License 2.0 | 5 votes |
@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); } }
Example #27
Source File: DateTimeCodec.java From cassandra-reaper with Apache License 2.0 | 5 votes |
@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); } }
Example #28
Source File: StringBlobCodec.java From cassandra-jdbc-driver with Apache License 2.0 | 5 votes |
@Override public String deserialize(ByteBuffer bytes, ProtocolVersion protocolVersion) throws InvalidTypeException { if (bytes == null || bytes.remaining() == 0) return null; return new String(bytes.array()); }
Example #29
Source File: StringTimeCodec.java From cassandra-jdbc-driver with Apache License 2.0 | 5 votes |
@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); }
Example #30
Source File: BytesBlobCodec.java From cassandra-jdbc-driver with Apache License 2.0 | 5 votes |
@Override public byte[] deserialize(ByteBuffer bytes, ProtocolVersion protocolVersion) throws InvalidTypeException { if (bytes == null || bytes.remaining() == 0) return null; return bytes.duplicate().array(); }