public class BatchImpl extends StatementImpl<Void,VoidFuture,Void> implements Batch, ParentStatementImpl
BatchImpl class extends the functionality of Cassandra's
Batch class to provide
support for POJOs.| Modifier and Type | Class and Description |
|---|---|
static class |
BatchImpl.OptionsImpl
The
OptionsImpl class defines the options of a BATCH statement. |
Batch.Optionsbridge, CI_PREFIX, idempotent, isCounterOp, mgr, MK_PREFIX, resultClass, simpleSize, UDT_C_PREFIXRECOMMENDED_MAX| Constructor and Description |
|---|
BatchImpl(Optional<Recorder> recorder,
BatchableStatement<?,?>[] statements,
boolean logged,
StatementManagerImpl mgr,
StatementBridge bridge)
Instantiates a new
BatchImpl object. |
BatchImpl(Optional<Recorder> recorder,
Iterable<BatchableStatement<?,?>> statements,
boolean logged,
StatementManagerImpl mgr,
StatementBridge bridge)
Instantiates a new
BatchImpl object. |
| Modifier and Type | Method and Description |
|---|---|
<R,F extends com.google.common.util.concurrent.ListenableFuture<R>> |
add(BatchableStatement<R,F> statement) |
Batch |
add(com.datastax.driver.core.RegularStatement statement) |
Batch |
addErrorHandler(ERunnable<?> run) |
protected void |
appendGroupSubType(StringBuilder builder)
Appends the sub-type of group this is; used when building a query string.
|
protected void |
appendGroupType(StringBuilder builder)
Appends the type of group this is; used when building a query string.
|
protected void |
appendOptions(StringBuilder builder)
Called to append options to the query string when building a batch.
|
protected StringBuilder[] |
buildQueryStrings()
Builds the query strings (one per underlying statement) to be collected if
the statement represents some a batch, sequence, or a group statement.
|
protected List<StatementImpl<?,?,?>> |
buildStatements()
Gets all underlying statements or this statement if none contained within.
|
void |
clear() |
Batch |
duplicate() |
Batch |
duplicate(Recorder recorder) |
String |
getKeyspace() |
Optional<Recorder> |
getRecorder() |
<U> Optional<Using<U>> |
getUsing(String name) |
boolean |
hasReachedRecommendedSize() |
boolean |
hasReachedRecommendedSizeFor(Class<?> clazz) |
boolean |
hasReachedRecommendedSizeFor(ClassInfo<?> cinfo) |
boolean |
isEmpty() |
java.util.stream.Stream<ObjectStatement<?>> |
objectStatements()
Gets all object statements contained recursively in this parent statement.
|
void |
recorded(ObjectStatement<?> statement,
ParentStatement pstatement)
Notifies the registered recorder and parent of the specified object statement.
|
void |
runErrorHandlers() |
protected void |
setDirty()
Sets the dirty bit for the cached query string and clear the number of
statements.
|
protected void |
setDirty(boolean recurse)
Sets the dirty bit for the cached query string and clear the number of
statements potentially recursively for all contained statement.
|
void |
setParent(ParentStatementImpl parent)
Sets the parent for this statement.
|
protected int |
simpleSize()
Gets the number of simple statements in this statement.
|
int |
size() |
java.util.stream.Stream<GenericStatement<?,?>> |
statements()
Gets all statements contained recursively in this parent statement including
parent statements (and this one).
|
Batch.Options |
using(Using<?> using)
Adds a new options for this BATCH statement.
|
java.util.stream.Stream<Using<?>> |
usings() |
buildQueryString, clearKeyspace, disable, disableErrorTracing, disableTracing, enable, enableErrorTracing, enableErrorTracing, enableTracing, enableTracing, execute, executeAsync, executeAsync0, executeAsyncRaw, executeAsyncRaw0, executeRaw, getClassInfo, getClassInfoImpl, getConsistencyLevel, getContext, getDefaultTimestamp, getFetchSize, getObject, getObjectClass, getPOJOContext, getQueryString, getReadTimeoutMillis, getRetryPolicy, getSerialConsistencyLevel, getUserData, init, init, isCounterOp, isDirty, isEnabled, isErrorTracing, isIdempotent, isTracing, setConsistencyLevel, setCounterOp, setDefaultTimestamp, setFetchSize, setIdempotent, setReadTimeoutMillis, setRetryPolicy, setSerialConsistencyLevel, setUserData, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitdisable, disableErrorTracing, disableTracing, enable, enableErrorTracing, enableErrorTracing, enableTracing, enableTracing, execute, executeAsync, executeAsyncRaw, executeRaw, getConsistencyLevel, getDefaultTimestamp, getFetchSize, getQueryString, getReadTimeoutMillis, getRetryPolicy, getSerialConsistencyLevel, getUserData, isEnabled, isErrorTracing, isIdempotent, isTracing, setConsistencyLevel, setDefaultTimestamp, setFetchSize, setIdempotent, setReadTimeoutMillis, setRetryPolicy, setSerialConsistencyLevel, setUserDataresetIfErrors, setAndResetIfErrorspublic BatchImpl(Optional<Recorder> recorder, BatchableStatement<?,?>[] statements, boolean logged, StatementManagerImpl mgr, StatementBridge bridge)
BatchImpl object.recorder - the optional recorder to register with this batchstatements - the statements to batchlogged - true if the batch should be logged; false
if it should be unloggedmgr - the non-null statement managerbridge - the non-null statement bridgeNullPointerException - if statement or any of the
statements are nullIllegalArgumentException - if counter and non-counter operations
are mixedpublic BatchImpl(Optional<Recorder> recorder, Iterable<BatchableStatement<?,?>> statements, boolean logged, StatementManagerImpl mgr, StatementBridge bridge)
BatchImpl object.recorder - the optional recorder to register with this batchstatements - the statements to batchlogged - true if the batch should be logged; false
if it should be unloggedmgr - the non-null statement managerbridge - the non-null statement bridgeNullPointerException - if statement or any of the
statements are nullIllegalArgumentException - if counter and non-counter operations
are mixedprotected void appendGroupType(StringBuilder builder)
appendGroupType in class StatementImpl<Void,VoidFuture,Void>builder - the builder to which to append the type of groupStatementImpl.appendGroupType(java.lang.StringBuilder)protected void appendGroupSubType(StringBuilder builder)
appendGroupSubType in class StatementImpl<Void,VoidFuture,Void>builder - the builder to which to append the sub-type of groupStatementImpl.appendGroupSubType(java.lang.StringBuilder)protected final List<StatementImpl<?,?,?>> buildStatements()
Note: Any statements that contains other statements should be flattened out based on its type. For example, a batch will flattened out all included batches recursively. A sequence will do the same with contained sequences but not with contained groups or batches. A group will do the same with contained groups but not with contained sequences or batches.
buildStatements in class StatementImpl<Void,VoidFuture,Void>null list of all underlying statements from this
statementStatementImpl.buildStatements()protected int simpleSize()
simpleSize in class StatementImpl<Void,VoidFuture,Void>StatementImpl.simpleSize()protected StringBuilder[] buildQueryStrings()
buildQueryStrings in class StatementImpl<Void,VoidFuture,Void>null if nothing to batchStatementImpl.buildQueryStrings()protected void setDirty()
setDirty in class StatementImpl<Void,VoidFuture,Void>StatementImpl.setDirty()protected void setDirty(boolean recurse)
setDirty in class StatementImpl<Void,VoidFuture,Void>recurse - true to recursively set the dirty bit;
false to simply set this statement dirty bitStatementImpl.setDirty(boolean)protected void appendOptions(StringBuilder builder)
appendOptions in class StatementImpl<Void,VoidFuture,Void>builder - the builder to which to append optionsStatementImpl.appendOptions(java.lang.StringBuilder)public void setParent(ParentStatementImpl parent)
setParent in interface ParentStatementImplparent - the parent for this statementParentStatementImpl.setParent(org.helenus.driver.impl.ParentStatementImpl)public void recorded(ObjectStatement<?> statement, ParentStatement pstatement)
recorded in interface ParentStatementImplstatement - the non-null object statement that was recordedpstatement - the non-null parent where the statement was definedParentStatementImpl.recorded(org.helenus.driver.ObjectStatement, org.helenus.driver.ParentStatement)public java.util.stream.Stream<ObjectStatement<?>> objectStatements()
objectStatements in interface ParentStatementImplParentStatementImpl.objectStatements()public java.util.stream.Stream<GenericStatement<?,?>> statements()
statements in interface ParentStatementImplParentStatementImpl.statements()public String getKeyspace()
Gets the keyspace of the first statement in this batch.
getKeyspace in interface BatchgetKeyspace in interface GenericStatement<Void,VoidFuture>getKeyspace in class StatementImpl<Void,VoidFuture,Void>null if the batch is emptyStatementImpl.getKeyspace()public Optional<Recorder> getRecorder()
getRecorder in interface ParentStatementImplgetRecorder in interface ParentStatementParentStatement.getRecorder()public boolean isEmpty()
isEmpty in interface ParentStatementParentStatement.isEmpty()public boolean hasReachedRecommendedSize()
hasReachedRecommendedSize in interface BatchBatch.hasReachedRecommendedSize()public boolean hasReachedRecommendedSizeFor(Class<?> clazz)
hasReachedRecommendedSizeFor in interface BatchBatch.hasReachedRecommendedSizeFor(java.lang.Class)public boolean hasReachedRecommendedSizeFor(ClassInfo<?> cinfo)
hasReachedRecommendedSizeFor in interface BatchBatch.hasReachedRecommendedSizeFor(org.helenus.driver.info.ClassInfo)public int size()
size in interface ParentStatementParentStatement.size()public void clear()
clear in interface ParentStatementParentStatement.clear()public <R,F extends com.google.common.util.concurrent.ListenableFuture<R>> Batch add(BatchableStatement<R,F> statement)
add in interface Batchadd in interface ParentStatementBatch.add(org.helenus.driver.BatchableStatement)public Batch add(com.datastax.driver.core.RegularStatement statement)
add in interface Batchadd in interface ParentStatementBatch.add(com.datastax.driver.core.RegularStatement)public Batch addErrorHandler(ERunnable<?> run)
addErrorHandler in interface BatchaddErrorHandler in interface ParentStatementBatch.addErrorHandler(org.helenus.util.function.ERunnable)public void runErrorHandlers()
runErrorHandlers in interface ParentStatementParentStatement.runErrorHandlers()public Batch.Options using(Using<?> using)
public java.util.stream.Stream<Using<?>> usings()
usings in interface BatchInsert.usings()public <U> Optional<Using<U>> getUsing(String name)
getUsing in interface BatchInsert.getUsing(java.lang.String)public Batch duplicate()
duplicate in interface BatchBatch.duplicate()public Batch duplicate(Recorder recorder)
duplicate in interface BatchBatch.duplicate(org.helenus.driver.Recorder)Copyright (C) 2015-2017 The Helenus Driver Project Authors.