Search in sources :

Example 1 with Column

use of org.apache.storm.cassandra.query.Column in project storm by apache.

the class BoundCQLStatementTupleMapper method map.

/**
     * {@inheritDoc}
     */
@Override
public List<Statement> map(Map config, Session session, ITuple tuple) {
    final List<Column> columns = mapper.map(tuple);
    final String query = contextQuery.resolves(config, tuple);
    PreparedStatement statement = getPreparedStatement(session, query);
    if (hasRoutingKeys()) {
        List<ByteBuffer> keys = rkGenerator.getRoutingKeys(tuple);
        if (keys.size() == 1)
            statement.setRoutingKey(keys.get(0));
        else
            statement.setRoutingKey(keys.toArray(new ByteBuffer[keys.size()]));
    }
    return Arrays.asList((Statement) this.binder.apply(statement, columns));
}
Also used : Column(org.apache.storm.cassandra.query.Column) PreparedStatement(com.datastax.driver.core.PreparedStatement) ByteBuffer(java.nio.ByteBuffer)

Example 2 with Column

use of org.apache.storm.cassandra.query.Column in project storm by apache.

the class BoundCQLStatementTupleMapper method map.

/**
 * {@inheritDoc}
 */
@Override
public List<Statement> map(Map<String, Object> config, Session session, ITuple tuple) {
    final List<Column> columns = mapper.map(tuple);
    final String query = contextQuery.resolves(config, tuple);
    PreparedStatement statement = getPreparedStatement(session, query);
    if (hasRoutingKeys()) {
        List<ByteBuffer> keys = rkGenerator.getRoutingKeys(tuple);
        if (keys.size() == 1) {
            statement.setRoutingKey(keys.get(0));
        } else {
            statement.setRoutingKey(keys.toArray(new ByteBuffer[keys.size()]));
        }
    }
    return Arrays.asList((Statement) this.binder.apply(statement, columns));
}
Also used : Column(org.apache.storm.cassandra.query.Column) PreparedStatement(com.datastax.driver.core.PreparedStatement) ByteBuffer(java.nio.ByteBuffer)

Example 3 with Column

use of org.apache.storm.cassandra.query.Column in project storm by apache.

the class SimpleCQLStatementMapper method map.

/**
 * {@inheritDoc}.
 */
@Override
public List<Statement> map(Map<String, Object> conf, Session session, ITuple tuple) {
    List<Column> columns = mapper.map(tuple);
    SimpleStatement statement = new SimpleStatement(queryString, Column.getVals(columns));
    if (hasRoutingKeys()) {
        List<ByteBuffer> keys = rkGenerator.getRoutingKeys(tuple);
        if (keys.size() == 1) {
            statement.setRoutingKey(keys.get(0));
        } else {
            statement.setRoutingKey(keys.toArray(new ByteBuffer[keys.size()]));
        }
    }
    return Arrays.asList((Statement) statement);
}
Also used : Column(org.apache.storm.cassandra.query.Column) SimpleStatement(com.datastax.driver.core.SimpleStatement) ByteBuffer(java.nio.ByteBuffer)

Example 4 with Column

use of org.apache.storm.cassandra.query.Column in project storm by apache.

the class SimpleCQLStatementMapper method map.

/**
     * {@inheritDoc}.
     */
@Override
public List<Statement> map(Map conf, Session session, ITuple tuple) {
    List<Column> columns = mapper.map(tuple);
    SimpleStatement statement = new SimpleStatement(queryString, Column.getVals(columns));
    if (hasRoutingKeys()) {
        List<ByteBuffer> keys = rkGenerator.getRoutingKeys(tuple);
        if (keys.size() == 1)
            statement.setRoutingKey(keys.get(0));
        else
            statement.setRoutingKey(keys.toArray(new ByteBuffer[keys.size()]));
    }
    return Arrays.asList((Statement) statement);
}
Also used : Column(org.apache.storm.cassandra.query.Column) SimpleStatement(com.datastax.driver.core.SimpleStatement) ByteBuffer(java.nio.ByteBuffer)

Aggregations

ByteBuffer (java.nio.ByteBuffer)4 Column (org.apache.storm.cassandra.query.Column)4 PreparedStatement (com.datastax.driver.core.PreparedStatement)2 SimpleStatement (com.datastax.driver.core.SimpleStatement)2