本文整理汇总了Java中com.datastax.driver.core.PreparedStatement.setConsistencyLevel方法的典型用法代码示例。如果您正苦于以下问题:Java PreparedStatement.setConsistencyLevel方法的具体用法?Java PreparedStatement.setConsistencyLevel怎么用?Java PreparedStatement.setConsistencyLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.datastax.driver.core.PreparedStatement
的用法示例。
在下文中一共展示了PreparedStatement.setConsistencyLevel方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepare
import com.datastax.driver.core.PreparedStatement; //导入方法依赖的package包/类
/**
* prepare
* prepares param workerQuery if it's not already prepared
* @param workerQuery
* @throws Exception
*/
private void prepare (
WorkerQuery workerQuery) throws Exception {
if (this.preparedStatements.containsKey(
workerQuery.getPreparedStatementString() ) == true) {
return;
}
PreparedStatement preparedStatement =
Cassandra.i().makePreparedStatementSync(
workerQuery.getPreparedStatementString() );
preparedStatement.setConsistencyLevel(workerQuery.getConsistencyLevel() );
this.preparedStatements.put(
workerQuery.getPreparedStatementString(),
preparedStatement);
}
示例2: prepare
import com.datastax.driver.core.PreparedStatement; //导入方法依赖的package包/类
private PreparedStatement prepare(final String query) {
PreparedStatement preStat = session.prepare(query);
if (settings != null) {
if (settings.getConsistency() != null) {
preStat.setConsistencyLevel(settings.getConsistency());
}
if (settings.getSerialConsistency() != null) {
preStat.setSerialConsistencyLevel(settings.getSerialConsistency());
}
if (settings.getRetryPolicy() != null) {
preStat.setRetryPolicy(settings.getRetryPolicy());
}
if (settings.isTraceQuery()) {
preStat.enableTracing();
} else {
preStat.disableTracing();
}
}
return preStat;
}
示例3: SchemaStatement
import com.datastax.driver.core.PreparedStatement; //导入方法依赖的package包/类
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));
}
示例4: SchemaStatement
import com.datastax.driver.core.PreparedStatement; //导入方法依赖的package包/类
public SchemaStatement(Timer timer, StressSettings settings, DataSpec spec,
PreparedStatement statement, Integer thriftId, ConsistencyLevel cl)
{
super(timer, settings, spec);
this.statement = statement;
this.thriftId = thriftId;
this.cl = cl;
argumentIndex = new int[statement.getVariables().size()];
bindBuffer = new Object[argumentIndex.length];
definitions = statement.getVariables();
int i = 0;
for (ColumnDefinitions.Definition definition : definitions)
argumentIndex[i++] = spec.partitionGenerator.indexOf(definition.getName());
statement.setConsistencyLevel(JavaDriverClient.from(cl));
}
示例5: prepareStatement
import com.datastax.driver.core.PreparedStatement; //导入方法依赖的package包/类
/**
* Create and configure a Prepared CQL statement
*/
protected PreparedStatement prepareStatement(String cql) {
PreparedStatement preparedStatement = getSessionHolder().getSession().prepare(cql);
if (consistencyLevel != null) {
preparedStatement.setConsistencyLevel(consistencyLevel);
}
return preparedStatement;
}
示例6: setConsistencyLevel
import com.datastax.driver.core.PreparedStatement; //导入方法依赖的package包/类
public ReadyStatements setConsistencyLevel(ConsistencyLevel defaultConsistencyLevel) {
for (ReadyStatement readyStatment: readyStatements) {
PreparedStatement preparedStatement = readyStatment.getPreparedStatement();
preparedStatement.setConsistencyLevel(defaultConsistencyLevel);
}
return this;
}
示例7: load
import com.datastax.driver.core.PreparedStatement; //导入方法依赖的package包/类
@Override
public PreparedStatement load(String query) throws Exception {
PreparedStatement stmt = session.prepare(query);
stmt.setConsistencyLevel(readConsistencyLevel);
if (tracingEnabled) {
stmt.enableTracing();
}
return stmt;
}
示例8: visaOfferData
import com.datastax.driver.core.PreparedStatement; //导入方法依赖的package包/类
public void visaOfferData(List<VisaOffers> list,int batchsize){
PreparedStatement ps = session.prepare(
"INSERT INTO emmd.visatable " +
"(org_id, alrt_id, alrt_bid_id,acct_fundg_src_cd,acct_fundg_src_subtyp_cd) " +
"VALUES (?, ?, ?,?,?);");
ps.setConsistencyLevel(ConsistencyLevel.ONE);
BatchStatement batch = new BatchStatement();
StringBuilder sb = new StringBuilder("BEGIN BATCH \n");
// Profiler profiler = new Profiler();
long count=list.size();
int i =0;
for (VisaOffers visa : list){
i++;
batch.add(ps.bind(visa.getAccountId(),visa.getAlertId(),visa.getMaxUpcId(),visa.getAcct_fundg_src_cd(),visa.getAcct_fundg_src_subtyp_cd()));
if(i%100000 ==0 )
{
System.out.println("Number of rows inserted so far..."+ i);
}
if(i%batchsize ==0 ){
//System.out.println("Iteration"+ i);
//session.executeAsync(batch);
ResultSet results = session.execute(batch);
ExecutionInfo executionInfo = results.getExecutionInfo();
// QueryTrace queryTrace = executionInfo.getQueryTrace();
// System.out.println("Trace id: %s\n\n"+ "hosts"+ executionInfo.getQueriedHost()+"consistency"+ executionInfo.getAchievedConsistencyLevel());
batch.clear();
}
}
if (i%batchsize >0 ){
session.execute(batch);
//session.executeAsync(batch);
batch.clear();
sb=null;
}
}