當前位置: 首頁>>代碼示例>>Java>>正文


Java BatchStatement.Type方法代碼示例

本文整理匯總了Java中com.datastax.driver.core.BatchStatement.Type方法的典型用法代碼示例。如果您正苦於以下問題:Java BatchStatement.Type方法的具體用法?Java BatchStatement.Type怎麽用?Java BatchStatement.Type使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.datastax.driver.core.BatchStatement的用法示例。


在下文中一共展示了BatchStatement.Type方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: untilApplied

import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
public static boolean untilApplied(Session session, BatchStatement.Type type, Consumer<BatchStatement> transaction) {
    for (int i = 1; i <= MAX_RETRY; i ++) {
        BatchStatement batchStatement = new BatchStatement(type);
        transaction.accept(batchStatement);
        if (batchStatement.size() == 0) return false;
        boolean applied;
        if (batchStatement.size() > 1) {
            applied = session.execute(batchStatement).wasApplied();
        } else {
            Statement statement = Iterables.getOnlyElement(batchStatement.getStatements());
            applied = session.execute(statement).wasApplied();
        }
        if (applied) return true;
        log.warn("Attempt {}/{} failed executing {}", i, MAX_RETRY, batchStatement);
        try {
            Thread.sleep(100 * i);
        } catch (InterruptedException e) {
            throw new AttemptsFailedException(e);
        }
    }
    throw new AttemptsFailedException();
}
 
開發者ID:papyrusglobal,項目名稱:state-channels,代碼行數:23,代碼來源:CassandraUtil.java

示例2: batchInsert

import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
public ResultSet batchInsert(final Class<?> targetClass, final Collection<? extends Map<String, Object>> propsList, final BatchStatement.Type type) {
    N.checkArgument(N.notNullOrEmpty(propsList), "'propsList' can't be null or empty.");

    final BatchStatement batchStatement = new BatchStatement(type == null ? BatchStatement.Type.LOGGED : type);

    if (settings != null) {
        batchStatement.setConsistencyLevel(settings.getConsistency());
        batchStatement.setSerialConsistencyLevel(settings.getSerialConsistency());
        batchStatement.setRetryPolicy(settings.getRetryPolicy());

        if (settings.traceQuery) {
            batchStatement.enableTracing();
        } else {
            batchStatement.disableTracing();
        }
    }

    CP pair = null;

    for (Map<String, Object> props : propsList) {
        pair = prepareAdd(targetClass, props);
        batchStatement.add(prepareStatement(pair.cql, pair.parameters.toArray()));
    }

    return session.execute(batchStatement);
}
 
開發者ID:landawn,項目名稱:AbacusUtil,代碼行數:27,代碼來源:CassandraExecutor.java

示例3: sendBatch

import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
public void sendBatch(BatchStatement.Type type, boolean addCounter, boolean addNonCounter)
{

    assert addCounter || addNonCounter;
    BatchStatement b = new BatchStatement(type);

    for (int i = 0; i < 10; i++)
    {
        if (addNonCounter)
            b.add(noncounter.bind(i, "foo"));

        if (addCounter)
            b.add(counter.bind((long)i, i));
    }

    session.execute(b);
}
 
開發者ID:vcostet,項目名稱:cassandra-kmean,代碼行數:18,代碼來源:BatchTests.java

示例4: FactoryData

import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
private FactoryData(final SocketAddress[] contactPoints, final ColumnMapping[] columns, final boolean useTls,
                    final String clusterName, final String keyspace, final String table, final String username,
                    final String password, final boolean useClockForTimestampGenerator, final int bufferSize,
                    final boolean batched, final BatchStatement.Type batchType) {
    super(bufferSize, null);
    this.contactPoints = convertAndAddDefaultPorts(contactPoints);
    this.columns = columns;
    this.useTls = useTls;
    this.clusterName = clusterName;
    this.keyspace = keyspace;
    this.table = table;
    this.username = username;
    this.password = password;
    this.useClockForTimestampGenerator = useClockForTimestampGenerator;
    this.batched = batched;
    this.batchType = batchType;
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:18,代碼來源:CassandraManager.java

示例5: batch

import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
public static ResultSet batch(Session session, BatchStatement.Type type, Consumer<BatchStatement> transaction) {
    BatchStatement batchStatement = new BatchStatement(type);
    transaction.accept(batchStatement);
    if (batchStatement.size() == 0) return null;
    if (batchStatement.size() > 1) {
        return session.execute(batchStatement);
    } else {
        Statement statement = Iterables.getOnlyElement(batchStatement.getStatements());
        return session.execute(statement);
    }
}
 
開發者ID:papyrusglobal,項目名稱:state-channels,代碼行數:12,代碼來源:CassandraUtil.java

示例6: batchUpdate

import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
public ResultSet batchUpdate(final Collection<?> entities, final BatchStatement.Type type) {
    N.checkArgument(N.notNullOrEmpty(entities), "'entities' can't be null or empty.");

    final Class<?> targetClass = Seq.of(entities).first().get().getClass();
    final Set<String> keyNameSet = Maps.getOrDefault(entityKeyNamesMap, targetClass, ID_SET);
    return batchUpdate(entities, keyNameSet, type);
}
 
開發者ID:landawn,項目名稱:AbacusUtil,代碼行數:8,代碼來源:CassandraExecutor.java

示例7: asyncBatchInsert

import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
public CompletableFuture<ResultSet> asyncBatchInsert(final Collection<?> entities, final BatchStatement.Type type) {
    return asyncExecutor.execute(new Callable<ResultSet>() {
        @Override
        public ResultSet call() {
            return batchInsert(entities, type);
        }
    });
}
 
開發者ID:landawn,項目名稱:AbacusUtil,代碼行數:9,代碼來源:CassandraExecutor.java

示例8: asyncBatchUpdate

import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
public CompletableFuture<ResultSet> asyncBatchUpdate(final Collection<?> entities, final BatchStatement.Type type) {
    return asyncExecutor.execute(new Callable<ResultSet>() {
        @Override
        public ResultSet call() {
            return batchUpdate(entities, type);
        }
    });
}
 
開發者ID:landawn,項目名稱:AbacusUtil,代碼行數:9,代碼來源:CassandraExecutor.java

示例9: getBatchType

import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
protected BatchStatement.Type getBatchType() {
  BatchStatement.Type type = BatchStatement.Type.LOGGED;
  if (batchType != null && BatchStatement.Type.UNLOGGED.name().equalsIgnoreCase(batchType)) {
    type = BatchStatement.Type.UNLOGGED;
  }
  return type;
}
 
開發者ID:kaaproject,項目名稱:kaa,代碼行數:8,代碼來源:AbstractCassandraDao.java

示例10: SaveToCassandraActionExecutionFunction

import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
public SaveToCassandraActionExecutionFunction(String cassandraQuorum, int cassandraPort, int maxBatchSize,
        BatchStatement.Type batchType) {
    this.cassandraQuorum = cassandraQuorum;
    this.cassandraPort = cassandraPort;
    this.maxBatchSize = maxBatchSize;
    this.batchType = batchType;
}
 
開發者ID:Stratio,項目名稱:Decision,代碼行數:8,代碼來源:SaveToCassandraActionExecutionFunction.java

示例11: getManager

import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
public static CassandraManager getManager(final String name, final SocketAddress[] contactPoints,
                                          final ColumnMapping[] columns, final boolean useTls,
                                          final String clusterName, final String keyspace, final String table,
                                          final String username, final String password,
                                          final boolean useClockForTimestampGenerator, final int bufferSize,
                                          final boolean batched, final BatchStatement.Type batchType) {
    return getManager(name,
        new FactoryData(contactPoints, columns, useTls, clusterName, keyspace, table, username, password,
            useClockForTimestampGenerator, bufferSize, batched, batchType), CassandraManagerFactory.INSTANCE);
}
 
開發者ID:apache,項目名稱:logging-log4j2,代碼行數:11,代碼來源:CassandraManager.java

示例12: SchemaInsert

import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
public SchemaInsert(Timer timer, StressSettings settings, PartitionGenerator generator, SeedManager seedManager, Distribution batchSize, RatioDistribution useRatio, Integer thriftId, PreparedStatement statement, ConsistencyLevel cl, BatchStatement.Type batchType)
{
    super(timer, settings, new DataSpec(generator, seedManager, batchSize, useRatio), statement, thriftId, cl, ValidationType.NOT_FAIL);
    this.batchType = batchType;
}
 
開發者ID:vcostet,項目名稱:cassandra-kmean,代碼行數:6,代碼來源:SchemaInsert.java

示例13: SchemaInsert

import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
public SchemaInsert(Timer timer, StressSettings settings, PartitionGenerator generator, SeedManager seedManager, Distribution batchSize, RatioDistribution useRatio, RatioDistribution rowPopulation, Integer thriftId, PreparedStatement statement, ConsistencyLevel cl, BatchStatement.Type batchType)
{
    super(timer, settings, new DataSpec(generator, seedManager, batchSize, useRatio, rowPopulation), statement, thriftId, cl);
    this.batchType = batchType;
}
 
開發者ID:scylladb,項目名稱:scylla-tools-java,代碼行數:6,代碼來源:SchemaInsert.java

示例14: SchemaInsert

import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
public SchemaInsert(Timer timer, PartitionGenerator generator, StressSettings settings, Distribution batchSize, RatioDistribution selectChance, Integer thriftId, PreparedStatement statement, ConsistencyLevel cl, BatchStatement.Type batchType)
{
    super(timer, generator, settings, batchSize, statement, thriftId, cl, ValidationType.NOT_FAIL);
    this.batchType = batchType;
    this.selectChance = selectChance;
}
 
開發者ID:daidong,項目名稱:GraphTrek,代碼行數:7,代碼來源:SchemaInsert.java

示例15: getCassandraBatchType

import com.datastax.driver.core.BatchStatement; //導入方法依賴的package包/類
public BatchStatement.Type getCassandraBatchType() {
    return cassandraBatchType;
}
 
開發者ID:Stratio,項目名稱:Decision,代碼行數:4,代碼來源:ConfigurationContext.java


注:本文中的com.datastax.driver.core.BatchStatement.Type方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。