public void addDataPoint(DataPointsRowKey rowKey, int columnTime, DataPoint dataPoint, int ttl) throws IOException { KDataOutput kDataOutput = new KDataOutput(); dataPoint.writeValueToBuffer(kDataOutput); BoundStatement boundStatement = new BoundStatement(m_clusterConnection.psDataPointsInsert); boundStatement.setBytesUnsafe(0, DATA_POINTS_ROW_KEY_SERIALIZER.toByteBuffer(rowKey)); ByteBuffer b = ByteBuffer.allocate(4); b.putInt(columnTime); b.rewind(); boundStatement.setBytesUnsafe(1, b); boundStatement.setBytesUnsafe(2, ByteBuffer.wrap(kDataOutput.getBytes())); boundStatement.setInt(3, ttl); boundStatement.setLong(4, m_now); boundStatement.setConsistencyLevel(m_consistencyLevel); boundStatement.setIdempotent(true); addBoundStatement(boundStatement); }
statement.setLong(paramIndex, (long) typeCodec.parse(paramValue));
@Override int apply(BoundStatement bs, int currentIndex) { bs.setLong(currentIndex, this.tsValue); return currentIndex + 1; }
@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); }
@Test(groups = "short") public void should_use_default_codecs_with_prepared_statements_3() { session() .execute( session() .prepare(insertQuery) .bind() .set(0, n_int, Integer.class) .set(1, n_bigint, Long.class) .set(2, n_float, Float.class) .set(3, n_double, Double.class) .set(4, n_varint, BigInteger.class) .set(5, n_decimal, BigDecimal.class)); 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); }
public void setLong(int parameterIndex, long bigint) throws SQLException { checkNotClosed(); checkIndex(parameterIndex); //bindValues.put(parameterIndex, JdbcLong.instance.decompose(bigint)); this.statement.setLong(parameterIndex-1, bigint); }
public BoundStatement saveQueryWithTimestamp(T value, long timestamp) { BoundStatement boundStatement = insertQueryWithTimestamp.bind(); insertSetter.mapTo(value, boundStatement); boundStatement.setLong(numberOfColumns, timestamp); return boundStatement; }
public void delete() { FlareBot.instance().getFutureActions().remove(this); if (delete == null) delete = CassandraController.prepare("DELETE FROM flarebot.future_tasks WHERE guild_id = ? " + "AND channel_id = ? AND created_at = ?"); CassandraController.executeAsync(delete.bind().setLong(0, guildId).setLong(1, channelId) .setTimestamp(2, created.toDate())); Scheduler.cancelTask("FutureTask-" + action.name() + "-" + expires.toString()); }
private CompletableFuture<ResultSet> retrieveDeletedBetween(CassandraId cassandraId, MessageUid from, MessageUid to) { return cassandraAsyncExecutor.execute( selectBetweenUidStatement.bind() .setUUID(MAILBOX_ID, cassandraId.asUuid()) .setLong(UID_FROM, from.asLong()) .setLong(UID_TO, to.asLong())); }
private void executeTableRowDeleteAsynchronously(String key, PreparedStatement deleteRowPrepState, List<ResultSetFuture> futureList) { BoundStatement boundState = deleteRowPrepState.bind(); boundState.setLong(0, m_timestamp); boundState.setString(1, key); futureList.add(CQLService.instance().getSession().executeAsync(boundState)); } // executeTableRowDeleteAsynchronously
@Override public void set(final K key, final V value) { BoundStatement insertStatement = _insertStatement.bind(); insertStatement.setBytesUnsafe(0, _keySerializer.serialize(key)); insertStatement.setLong(1, getValueHash(value)); insertStatement.setBytesUnsafe(2, _valueSerializer.serialize(value)); _session.execute(insertStatement); }
private CompletableFuture<ResultSet> selectFrom(CassandraId mailboxId, MessageUid uid) { return cassandraAsyncExecutor.execute(selectUidGte.bind() .setUUID(MAILBOX_ID, mailboxId.asUuid()) .setLong(IMAP_UID, uid.asLong())); }
private CompletableFuture<ResultSet> retrieveOneDeleted(CassandraId cassandraId, MessageUid uid) { return cassandraAsyncExecutor.execute( selectOneUidStatement.bind() .setUUID(MAILBOX_ID, cassandraId.asUuid()) .setLong(UID, uid.asLong())); }
private CompletableFuture<ResultSet> selectOneRow(CassandraId mailboxId, MessageUid uid) { return cassandraAsyncExecutor.execute(select.bind() .setUUID(MAILBOX_ID, mailboxId.asUuid()) .setLong(IMAP_UID, uid.asLong())); }
Statement deleteColumn(final StaticBuffer key, final StaticBuffer column, final long timestamp) { return this.deleteColumn.bind() .setBytes(KEY_BINDING, key.asByteBuffer()) .setBytes(COLUMN_BINDING, column.asByteBuffer()) .setLong(TIMESTAMP_BINDING, timestamp); }
public CompletableFuture<Void> addUnread(CassandraId cassandraId, MessageUid uid) { return cassandraAsyncExecutor.executeVoid( addStatement.bind() .setUUID(MAILBOX_ID, cassandraId.asUuid()) .setLong(UID, uid.asLong())); }
public CompletableFuture<Void> addToRecent(CassandraId mailboxId, MessageUid messageUid) { return cassandraAsyncExecutor.executeVoid(addStatement.bind() .setUUID(CassandraMailboxRecentsTable.MAILBOX_ID, mailboxId.asUuid()) .setLong(CassandraMailboxRecentsTable.RECENT_MESSAGE_UID, messageUid.asLong())); } }
public CompletableFuture<Void> save(Mailbox mailbox) { CassandraId cassandraId = (CassandraId) mailbox.getMailboxId(); return executor.executeVoid(insertStatement.bind() .setUUID(ID, cassandraId.asUuid()) .setString(NAME, mailbox.getName()) .setLong(UIDVALIDITY, mailbox.getUidValidity()) .setUDTValue(MAILBOX_BASE, mailboxBaseTupleUtil.createMailboxBaseUDT(mailbox.getNamespace(), mailbox.getUser()))); }
public CompletableFuture<Void> storeAttachment(DAOAttachment attachment) { return cassandraAsyncExecutor.executeVoid( insertStatement.bind() .setUUID(ID_AS_UUID, attachment.getAttachmentId().asUUID()) .setString(ID, attachment.getAttachmentId().getId()) .setLong(SIZE, attachment.getSize()) .setString(TYPE, attachment.getType()) .setString(BLOB_ID, attachment.getBlobId().asString())); }