Package com.datastax.driver.core

Examples of com.datastax.driver.core.BatchStatement


    private volatile boolean submitted;
    private final List<BatchPartFutureImpl> futures = new ArrayList<BatchPartFutureImpl>();

    public BatchImpl(PersistenceSessionImpl persistenceSession, BatchStatement.Type type) {
        this.persistenceSession = persistenceSession;
        batchStatement = new BatchStatement(type);
        persistenceSession.statementOptions.applyWrite(batchStatement, null, null);
    }
View Full Code Here


        super.casResultListener = Optional.<CASResultListener>fromNullable(this.compositeCASResultListener);
        this.batchStatement = createBatchStatement(batchType, statementWrappers);
    }

    private BatchStatement createBatchStatement(BatchStatement.Type batchType, List<AbstractStatementWrapper> statementWrappers) {
        BatchStatement batch = new BatchStatement(batchType);
        boolean tracingEnabled = false;
        for (AbstractStatementWrapper statementWrapper : statementWrappers) {
            statementWrapper.activateQueryTracing();
            tracingEnabled |= statementWrapper.isTracingEnabled();

            if (statementWrapper.casResultListener.isPresent()) {
                this.compositeCASResultListener.addCASResultListener(statementWrapper.casResultListener.get());
            }

            if (statementWrapper instanceof NativeStatementWrapper) {
                batch.add(((NativeStatementWrapper) statementWrapper).buildParameterizedStatement());
            } else {
                batch.add(statementWrapper.getStatement());
            }
        }
        if (tracingEnabled) {
            batch.enableTracing();
        }
        if (consistencyLevelO.isPresent()) {
            batch.setConsistencyLevel(getCQLLevel(consistencyLevelO.get()));
        }
        // TODO Serial Consistency not supported for batch. Wait for C* 2.1
        if (serialConsistencyLevelO.isPresent()) {
           // batch.setSerialConsistencyLevel(serialConsistencyLevelO.get());
        }
View Full Code Here

  private BatchStatement getCachedPreparedStatement() {
   
    final List<CqlColumnListMutationImpl<?, ?>> colListMutations = getColumnMutations();

    if (colListMutations == null || colListMutations.size() == 0) {
      return new BatchStatement(Type.UNLOGGED);
    }
   
    ColListMutationType mutationType = colListMutations.get(0).getType();

    BatchStatement batch = new BatchStatement(Type.UNLOGGED);
    if (mutationType == ColListMutationType.CounterColumnsUpdate) {
      batch = new BatchStatement(Type.COUNTER);
    } else if (useAtomicBatch()) {
      batch = new BatchStatement(Type.LOGGED);
    }
   
    for (CqlColumnListMutationImpl<?, ?> colListMutation : colListMutations) {
     
      CFMutationQueryGen queryGen = colListMutation.getMutationQueryGen();
      queryGen.addColumnListMutationToBatch(batch, colListMutation, useCaching);
    }
   
    batch.setConsistencyLevel(ConsistencyLevelMapping.getCL(this.getConsistencyLevel()));
   
    return batch;
  }
View Full Code Here

TOP

Related Classes of com.datastax.driver.core.BatchStatement

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.