Java Code Examples for com.datastax.driver.core.ColumnDefinitions#Definition

The following examples show how to use com.datastax.driver.core.ColumnDefinitions#Definition . 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: SchemaStatement.java    From stratio-cassandra with Apache License 2.0 6 votes vote down vote up
public SchemaStatement(Timer timer, StressSettings settings, DataSpec spec,
                       PreparedStatement statement, Integer thriftId, ConsistencyLevel cl, ValidationType validationType)
{
    super(timer, settings, spec);
    this.statement = statement;
    this.thriftId = thriftId;
    this.cl = cl;
    this.validationType = validationType;
    argumentIndex = new int[statement.getVariables().size()];
    bindBuffer = new Object[argumentIndex.length];
    int i = 0;
    for (ColumnDefinitions.Definition definition : statement.getVariables())
        argumentIndex[i++] = spec.partitionGenerator.indexOf(definition.getName());

    statement.setConsistencyLevel(JavaDriverClient.from(cl));
}
 
Example 2
Source File: CassandraWriteMetrics.java    From glowroot with Apache License 2.0 5 votes vote down vote up
private @Nullable String getTransactionType(
        List<ColumnDefinitions.Definition> columnDefinitions, BoundStatement boundStatement) {
    if (columnDefinitions.size() < 2) {
        return currTransactionType.get();
    }
    ColumnDefinitions.Definition columnDefinition = columnDefinitions.get(1);
    String columnDefinitionName = columnDefinition.getName();
    if (columnDefinitionName.equals("transaction_type")) {
        return boundStatement.getString(1);
    } else {
        return currTransactionType.get();
    }
}
 
Example 3
Source File: CassandraWriteMetrics.java    From glowroot with Apache License 2.0 5 votes vote down vote up
private @Nullable String getTransactionName(
        List<ColumnDefinitions.Definition> columnDefinitions, BoundStatement boundStatement) {
    if (columnDefinitions.size() < 3) {
        return currTransactionName.get();
    }
    ColumnDefinitions.Definition columnDefinition = columnDefinitions.get(2);
    String columnDefinitionName = columnDefinition.getName();
    if (columnDefinitionName.equals("transaction_name")) {
        return boundStatement.getString(2);
    } else {
        return currTransactionName.get();
    }
}
 
Example 4
Source File: CassandraWriteMetrics.java    From glowroot with Apache License 2.0 5 votes vote down vote up
private static @Nullable String getAgentRollupId(
        List<ColumnDefinitions.Definition> columnDefinitions, BoundStatement boundStatement) {
    ColumnDefinitions.Definition columnDefinition = columnDefinitions.get(0);
    String columnDefinitionName = columnDefinition.getName();
    if (columnDefinitionName.equals("agent_rollup_id")
            || columnDefinitionName.equals("agent_id")
            || columnDefinitionName.equals("agent_rollup")) {
        return boundStatement.getString(0);
    } else {
        return null;
    }
}
 
Example 5
Source File: DefinitionToNameFunction.java    From Explorer with Apache License 2.0 5 votes vote down vote up
/**
 * Extract name of columndefinions
 * @param definition Definition Objetc
 * @return name of definition
 */
@Override
public String transform(ColumnDefinitions.Definition definition) {
    String name = definition.getName();
    if (name==null)
        name="";
    return name;
}
 
Example 6
Source File: DoubleSession.java    From Explorer with Apache License 2.0 5 votes vote down vote up
private ResultSet mockResultSet(List<Row> rows,ColumnDefinitions columDefiniton){
    ResultSet resultSet = mock(ResultSet.class);
    ColumnDefinitions.Definition mockDefinition = new DoubleDefinition().buildDefinitionWithName("");
    expect(resultSet.getColumnDefinitions()).andStubReturn(columDefiniton);
    expect(resultSet.all()).andStubReturn(rows);
    replay(resultSet);
    return resultSet;
}
 
Example 7
Source File: DoubleSession.java    From Explorer with Apache License 2.0 5 votes vote down vote up
private ColumnDefinitions mockColumnDefinions(){
    ColumnDefinitions columnDefinions = mock(ColumnDefinitions.class);
    List<ColumnDefinitions.Definition> columnDefinitions = new ArrayList<>();
    columnDefinitions.add(new DoubleDefinition().buildDefinitionWithName(""));
    expect(columnDefinions.asList()).andStubReturn(columnDefinitions);
    replay(columnDefinions);
    return columnDefinions;
}
 
Example 8
Source File: DoubleSession.java    From Explorer with Apache License 2.0 5 votes vote down vote up
private ColumnDefinitions mockColumnDefinionsWithoutData(){
    ColumnDefinitions columnDefinions = mock(ColumnDefinitions.class);
    List<ColumnDefinitions.Definition> columnDefinitions = new ArrayList<>();
    expect(columnDefinions.asList()).andStubReturn(columnDefinitions);
    replay(columnDefinions);
    return columnDefinions;
}
 
Example 9
Source File: DoubleDefinition.java    From Explorer with Apache License 2.0 4 votes vote down vote up
public  ColumnDefinitions.Definition buildDefinitionWithName(String nameHeader) {
    ColumnDefinitions.Definition definition = mock(ColumnDefinitions.Definition.class);
    return definition;
}