statement.setDouble(paramIndex, (double) typeCodec.parse(paramValue));
@Override public QueryBinder<ENTITY> setDouble(int i, double v) { for (BoundStatement statement : statements.values()) { statement.setDouble(i, v); } return this; }
@Test(groups = "short") public void should_use_default_codecs_with_prepared_statements_2() { session() .execute( session() .prepare(insertQuery) .bind() .setInt(0, n_int) .setLong(1, n_bigint) .setFloat(2, n_float) .setDouble(3, n_double) .setVarint(4, n_varint) .setDecimal(5, n_decimal)); PreparedStatement ps = session().prepare(selectQuery); ResultSet rows = session().execute(ps.bind().setInt(0, n_int).setLong(1, n_bigint)); Row row = rows.one(); assertRow(row); }
/** * Sets the specified {@code DoubleValue} to the bound statement * * @param value a {@code DoubleValue} to be set */ @Override public void visit(DoubleValue value) { LOGGER.debug(value.get() + " is bound to " + i); bound.setDouble(i++, value.get()); }
public void setDouble(int parameterIndex, double decimal) throws SQLException { checkNotClosed(); checkIndex(parameterIndex); //bindValues.put(parameterIndex, JdbcDouble.instance.decompose(decimal)); this.statement.setDouble(parameterIndex-1, decimal); }
@Override public QueryBinder<ENTITY> setDouble(String name, double v) { for (BoundStatement statement : statements.values()) { if (statement.preparedStatement().getVariables().contains(name)) { statement.setDouble(name, v); } } return this; }
private <T> void bindValue(BoundStatement bs, MetricType<T> type, DataPoint<T> dataPoint) { switch(type.getCode()) { case 0: bs.setDouble(0, (Double) dataPoint.getValue()); break; case 1: bs.setBytes(0, getBytes((DataPoint<AvailabilityType>) dataPoint)); break; case 2: bs.setLong(0, (Long) dataPoint.getValue()); break; case 3: bs.setLong(0, (Long) dataPoint.getValue()); break; case 4: throw new IllegalArgumentException("Not implemented yet"); case 5: bs.setDouble(0, (Double) dataPoint.getValue()); break; default: throw new IllegalArgumentException("Unsupported metricType"); } }
private <T> void bindValue(BoundStatement bs, MetricType<T> type, DataPoint<T> dataPoint) { switch(type.getCode()) { case 0: bs.setDouble(0, (Double) dataPoint.getValue()); break; case 1: bs.setBytes(0, getBytes((DataPoint<AvailabilityType>) dataPoint)); break; case 2: bs.setLong(0, (Long) dataPoint.getValue()); break; case 3: bs.setLong(0, (Long) dataPoint.getValue()); break; case 4: throw new IllegalArgumentException("Not implemented yet"); case 5: bs.setDouble(0, (Double) dataPoint.getValue()); break; default: throw new IllegalArgumentException("Unsupported metricType"); } }
@Test public void visit_DoubleValueAcceptCalled_ShouldCallSetDouble() { // Arrange DoubleValue value = new DoubleValue(ANY_NAME, ANY_DOUBLE); ValueBinder binder = new ValueBinder(bound); // Act value.accept(binder); // Assert verify(bound).setDouble(0, ANY_DOUBLE); }
@Override public void insertRanges(final byte[][] ids, final double value) throws DataAccessLayerException { /* * insert in CF_RN_SP_O */ final BoundStatement nspoStatement = _insertNSPOStatement.bind(); nspoStatement.setBytesUnsafe(0, ID_SERIALIZER.serialize(ids[0])); nspoStatement.setBytesUnsafe(1, ID_SERIALIZER.serialize(ids[1])); nspoStatement.setBytesUnsafe(2, ID_SERIALIZER.serialize(ids[2])); nspoStatement.setDouble(3, value); _batchStatements.get().add(nspoStatement); /* * insert in CF_RN_P_OS */ final BoundStatement nposStatement = _insertNPOSStatement.bind(); nposStatement.setBytesUnsafe(0, ID_SERIALIZER.serialize(ids[1])); nposStatement.setBytesUnsafe(1, ID_SERIALIZER.serialize(ids[2])); nposStatement.setBytesUnsafe(2, ID_SERIALIZER.serialize(ids[0])); nposStatement.setDouble(3, value); _batchStatements.get().add(nposStatement); }
@Override public void insertRanges(final byte[][] ids, final double value) throws DataAccessLayerException { /* * insert in CF_RN_SP_O */ final BoundStatement nspoStatement = _insertNSPOStatement.bind(); nspoStatement.setBytesUnsafe(0, ID_SERIALIZER.serialize(ids[0])); nspoStatement.setBytesUnsafe(1, ID_SERIALIZER.serialize(ids[1])); nspoStatement.setBytesUnsafe(2, ID_SERIALIZER.serialize(ids[2])); nspoStatement.setDouble(3, value); _batchStatements.get().add(nspoStatement); /* * insert in CF_RN_P_OS */ final BoundStatement nposStatement = _insertNPOSStatement.bind(); nposStatement.setBytesUnsafe(0, ID_SERIALIZER.serialize(ids[1])); nposStatement.setBytesUnsafe(1, ID_SERIALIZER.serialize(ids[2])); nposStatement.setBytesUnsafe(2, ID_SERIALIZER.serialize(ids[0])); nposStatement.setDouble(3, value); _batchStatements.get().add(nposStatement); }
case DOUBLE: final double doubleValue = ((GetterDouble<Object>)getters.get(i)).get(tuple); boundStmnt.setDouble(i, doubleValue); break; case DECIMAL:
case DOUBLE: final double doubleValue = ((GetterDouble<Object>)getters.get(i)).get(tuple); boundStmnt.setDouble(i, doubleValue); break; case DECIMAL:
bstm.setDecimal(key, (BigDecimal) value); } else if (value instanceof Double) { bstm.setDouble(key, ((Double) value).doubleValue()); } else if (value instanceof Float) { bstm.setFloat(key, ((Float) value).floatValue());
@Override public Iterator<byte[][]> dateRangeQuery( final Value[] query, final long lowerBound, final boolean equalsLower, final long upperBound, final boolean equalsUpper, final boolean reverse, final int limit) throws DataAccessLayerException { final byte[] s = _dictionary.getID(query[0], false); final byte[] p = _dictionary.getID(query[1], true); final boolean subjectIsVariable = isVariable(s); final BoundStatement statement = _rangeQueries[getRangeQueryIndex(reverse, subjectIsVariable, false, !equalsUpper, !equalsLower)].bind(); int queryParameterIndex = 0; if (!subjectIsVariable) { statement.setBytesUnsafe(queryParameterIndex++, ID_SERIALIZER.serialize(s)); } statement.setBytesUnsafe(queryParameterIndex++, ID_SERIALIZER.serialize(p)); statement.setDouble(queryParameterIndex++, lowerBound); statement.setDouble(queryParameterIndex++, upperBound); statement.setInt(queryParameterIndex, limit); return new SPOCResultIterator(_session.executeAsync(statement), false); }
@Override public Iterator<byte[][]> dateRangeQuery( final Value[] query, final long lowerBound, final boolean equalsLower, final long upperBound, final boolean equalsUpper, final boolean reverse, final int limit) throws DataAccessLayerException { final byte[] s = _dictionary.getID(query[0], false); final byte[] p = _dictionary.getID(query[1], true); final boolean subjectIsVariable = isVariable(s); final BoundStatement statement = _rangeQueries[getRangeQueryIndex(reverse, subjectIsVariable, false, !equalsUpper, !equalsLower)].bind(); int queryParameterIndex = 0; if (!subjectIsVariable) { statement.setBytesUnsafe(queryParameterIndex++, ID_SERIALIZER.serialize(s)); } statement.setBytesUnsafe(queryParameterIndex++, ID_SERIALIZER.serialize(p)); statement.setDouble(queryParameterIndex++, lowerBound); statement.setDouble(queryParameterIndex++, upperBound); statement.setInt(queryParameterIndex, limit); return new SPOCResultIterator(_session.executeAsync(statement), false); }
@Override public Iterator<byte[][]> numericRangeQuery( final Value[] query, final double lowerBound, final boolean equalsLower, final double upperBound, final boolean equalsUpper, final boolean reverse, final int limit) throws DataAccessLayerException { final byte[] s = _dictionary.getID(query[0], false); final byte[] p = _dictionary.getID(query[1], true); final boolean subjectIsVariable = isVariable(s); final BoundStatement statement = _rangeQueries[getRangeQueryIndex(reverse, subjectIsVariable, true, !equalsUpper, !equalsLower)].bind(); int queryParameterIndex = 0; if (!subjectIsVariable) { statement.setBytesUnsafe(queryParameterIndex++, ID_SERIALIZER.serialize(s)); } statement.setBytesUnsafe(queryParameterIndex++, ID_SERIALIZER.serialize(p)); statement.setDouble(queryParameterIndex++, lowerBound); statement.setDouble(queryParameterIndex++, upperBound); statement.setInt(queryParameterIndex, limit); return new SPOCResultIterator(_session.executeAsync(statement), false); }
@Override public Iterator<byte[][]> numericRangeQuery( final Value[] query, final double lowerBound, final boolean equalsLower, final double upperBound, final boolean equalsUpper, final boolean reverse, final int limit) throws DataAccessLayerException { final byte[] s = _dictionary.getID(query[0], false); final byte[] p = _dictionary.getID(query[1], true); final boolean subjectIsVariable = isVariable(s); final BoundStatement statement = _rangeQueries[getRangeQueryIndex(reverse, subjectIsVariable, true, !equalsUpper, !equalsLower)].bind(); int queryParameterIndex = 0; if (!subjectIsVariable) { statement.setBytesUnsafe(queryParameterIndex++, ID_SERIALIZER.serialize(s)); } statement.setBytesUnsafe(queryParameterIndex++, ID_SERIALIZER.serialize(p)); statement.setDouble(queryParameterIndex++, lowerBound); statement.setDouble(queryParameterIndex++, upperBound); statement.setInt(queryParameterIndex, limit); return new SPOCResultIterator(_session.executeAsync(statement), false); }
bstm.setDecimal(i, (BigDecimal) value); } else if (value instanceof Double) { bstm.setDouble(i, ((Double) value).doubleValue()); } else if (value instanceof Float) { bstm.setFloat(i, ((Float) value).floatValue());
@Test(groups = "short") public void should_use_default_codecs_with_prepared_statements_2() { session() .execute( session() .prepare(insertQuery) .bind() .setInt(0, n_int) .setLong(1, n_bigint) .setFloat(2, n_float) .setDouble(3, n_double) .setVarint(4, n_varint) .setDecimal(5, n_decimal)); PreparedStatement ps = session().prepare(selectQuery); ResultSet rows = session().execute(ps.bind().setInt(0, n_int).setLong(1, n_bigint)); Row row = rows.one(); assertRow(row); }