public void deleteDataPoint(DataPointsRowKey rowKey, int columnTime) throws IOException { BoundStatement boundStatement = new BoundStatement(m_clusterConnection.psDataPointsDelete); 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.setConsistencyLevel(m_consistencyLevel); boundStatement.setIdempotent(true); addBoundStatement(boundStatement); }
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); }
public void addRowKey(String metricName, DataPointsRowKey rowKey, int rowKeyTtl) { m_newRowKeys.add(rowKey); ByteBuffer bb = ByteBuffer.allocate(8); bb.putLong(0, rowKey.getTimestamp()); Statement bs = m_clusterConnection.psRowKeyTimeInsert.bind() .setString(0, metricName) .setTimestamp(1, new Date(rowKey.getTimestamp())) //.setBytesUnsafe(1, bb) //Setting timestamp in a more optimal way .setInt(2, rowKeyTtl) .setIdempotent(true); bs.setConsistencyLevel(m_consistencyLevel); rowKeyBatch.add(bs); bs = m_clusterConnection.psRowKeyInsert.bind() .setString(0, metricName) .setTimestamp(1, new Date(rowKey.getTimestamp())) //.setBytesUnsafe(1, bb) //Setting timestamp in a more optimal way .setString(2, rowKey.getDataType()) .setMap(3, rowKey.getTags()) .setInt(4, rowKeyTtl) .setIdempotent(true); bs.setConsistencyLevel(m_consistencyLevel); rowKeyBatch.add(bs); }
/** * Creates a new {@code BoundStatement} from the provided prepared statement. * * @param statement the prepared statement from which to create a {@code BoundStatement}. */ public BoundStatement(PreparedStatement statement) { this.statement = statement; this.wrapper = new DataWrapper(this, statement.getVariables().size()); for (int i = 0; i < wrapper.values.length; i++) { wrapper.values[i] = UNSET; } if (statement.getConsistencyLevel() != null) this.setConsistencyLevel(statement.getConsistencyLevel()); if (statement.getSerialConsistencyLevel() != null) this.setSerialConsistencyLevel(statement.getSerialConsistencyLevel()); if (statement.isTracing()) this.enableTracing(); if (statement.getRetryPolicy() != null) this.setRetryPolicy(statement.getRetryPolicy()); if (statement.getOutgoingPayload() != null) this.setOutgoingPayload(statement.getOutgoingPayload()); else // propagate incoming payload as outgoing payload, if no outgoing payload has been explicitly // set this.setOutgoingPayload(statement.getIncomingPayload()); this.codecRegistry = statement.getCodecRegistry(); if (statement.isIdempotent() != null) { this.setIdempotent(statement.isIdempotent()); } }
Object invoke(Object[] args) { BoundStatement bs = statement.bind(); for (int i = 0; i < args.length; i++) { paramMappers[i].setValue(bs, args[i]); } if (consistency != null) bs.setConsistencyLevel(consistency); if (fetchSize > 0) bs.setFetchSize(fetchSize); if (tracing) bs.enableTracing(); if (idempotent != null) bs.setIdempotent(idempotent); if (returnStatement) return bs; if (async) { ListenableFuture<ResultSet> future = session.executeAsync(bs); if (returnMapper == null) return future; return mapOne ? Futures.transform(future, returnMapper.mapOneFunctionWithoutAliases) : Futures.transform(future, returnMapper.mapAllFunctionWithoutAliases); } else { ResultSet rs = session.execute(bs); if (returnMapper == null) return rs; Result<?> result = returnMapper.map(rs); return mapOne ? result.one() : result; } }
/** * Creates a new {@code BoundStatement} from the provided prepared * statement. * * @param statement the prepared statement from which to create a {@code BoundStatement}. */ public BoundStatement(PreparedStatement statement) { this.statement = statement; this.wrapper = new DataWrapper(this, statement.getVariables().size()); for (int i = 0; i < wrapper.values.length; i++) { wrapper.values[i] = UNSET; } if (statement.getConsistencyLevel() != null) this.setConsistencyLevel(statement.getConsistencyLevel()); if (statement.getSerialConsistencyLevel() != null) this.setSerialConsistencyLevel(statement.getSerialConsistencyLevel()); if (statement.isTracing()) this.enableTracing(); if (statement.getRetryPolicy() != null) this.setRetryPolicy(statement.getRetryPolicy()); if (statement.getOutgoingPayload() != null) this.setOutgoingPayload(statement.getOutgoingPayload()); else // propagate incoming payload as outgoing payload, if no outgoing payload has been explicitly set this.setOutgoingPayload(statement.getIncomingPayload()); this.codecRegistry = statement.getCodecRegistry(); if (statement.isIdempotent() != null) { this.setIdempotent(statement.isIdempotent()); } }
/** * Creates a new {@code BoundStatement} from the provided prepared * statement. * * @param statement the prepared statement from which to create a {@code BoundStatement}. */ public BoundStatement(PreparedStatement statement) { this.statement = statement; this.wrapper = new DataWrapper(this, statement.getVariables().size()); for (int i = 0; i < wrapper.values.length; i++) { wrapper.values[i] = UNSET; } if (statement.getConsistencyLevel() != null) this.setConsistencyLevel(statement.getConsistencyLevel()); if (statement.getSerialConsistencyLevel() != null) this.setSerialConsistencyLevel(statement.getSerialConsistencyLevel()); if (statement.isTracing()) this.enableTracing(); if (statement.getRetryPolicy() != null) this.setRetryPolicy(statement.getRetryPolicy()); if (statement.getOutgoingPayload() != null) this.setOutgoingPayload(statement.getOutgoingPayload()); else // propagate incoming payload as outgoing payload, if no outgoing payload has been explicitly set this.setOutgoingPayload(statement.getIncomingPayload()); this.codecRegistry = statement.getCodecRegistry(); if (statement.isIdempotent() != null) { this.setIdempotent(statement.isIdempotent()); } }
/** * Creates a new {@code BoundStatement} from the provided prepared * statement. * * @param statement the prepared statement from which to create a {@code BoundStatement}. */ public BoundStatement(PreparedStatement statement) { this.statement = statement; this.wrapper = new DataWrapper(this, statement.getVariables().size()); for (int i = 0; i < wrapper.values.length; i++) { wrapper.values[i] = UNSET; } if (statement.getConsistencyLevel() != null) this.setConsistencyLevel(statement.getConsistencyLevel()); if (statement.getSerialConsistencyLevel() != null) this.setSerialConsistencyLevel(statement.getSerialConsistencyLevel()); if (statement.isTracing()) this.enableTracing(); if (statement.getRetryPolicy() != null) this.setRetryPolicy(statement.getRetryPolicy()); if (statement.getOutgoingPayload() != null) this.setOutgoingPayload(statement.getOutgoingPayload()); else // propagate incoming payload as outgoing payload, if no outgoing payload has been explicitly set this.setOutgoingPayload(statement.getIncomingPayload()); this.codecRegistry = statement.getCodecRegistry(); if (statement.isIdempotent() != null) { this.setIdempotent(statement.isIdempotent()); } }