TableBatchOperation Class

  • java.lang.Object
    • java.util.ArrayList<TableOperation>
      • com.microsoft.azure.storage.table.TableBatchOperation

public class TableBatchOperation

A class which represents a batch operation. A batch operation is a collection of table operations which are executed by the Storage Service REST API as a single atomic operation, by invoking an Entity Group Transaction.

A batch operation may contain up to 100 individual table operations, with the requirement that each operation entity must have same partition key. A batch with a retrieve operation cannot contain any other operations. Note that the total payload of a batch operation is limited to 4MB.

Method Summary

Modifier and Type Method and Description
void add(final int index, final TableOperation element)

Adds the table operation at the specified index in the batch operation .

boolean add(final TableOperation element)

Adds the table operation to the batch operation .

boolean addAll(final int index, final java.util.Collection<? extends TableOperation> c)

Adds the collection of table operations to the batch operation starting at the specified index.

boolean addAll(final java.util.Collection<? extends TableOperation> c)

Adds the collection of table operations to the batch operation .

void clear()

Clears all table operations from the batch operation.

void delete(final TableEntity entity)

Adds a table operation to delete the specified entity to the batch operation.

ArrayList<TableResult> execute(final CloudTableClient client, final String tableName, final TableRequestOptions options, final OperationContext opContext)

Reserved for internal use. Executes this batch operation on the specified table, using the specified TableRequestOptions and OperationContext.

This method will invoke the Storage Service REST API to execute this batch operation, using the Table service endpoint and storage account credentials in the CloudTableClient object.

void insert(final TableEntity entity)

Adds a table operation to insert the specified entity to the batch operation.

void insert(final TableEntity entity, boolean echoContent)

Adds a table operation to insert the specified entity to the batch operation.

void insertOrMerge(final TableEntity entity)

Adds a table operation to insert or merge the specified entity to the batch operation.

void insertOrReplace(final TableEntity entity)

Adds a table operation to insert or replace the specified entity to the batch operation.

void merge(final TableEntity entity)

Adds a table operation to merge the specified entity to the batch operation.

TableOperation remove(int index)

Removes the table operation at the specified index from the batch operation.

boolean remove(Object o)

Removes the specified from the batch operation.

boolean removeAll(java.util.Collection<?> c)

Removes all elements of the specified collection from the batch operation.

void removeRange(int fromIndex, int toIndex)

Reserved for internal use. Removes all the table operations at indexes in the specified range from the batch operation .

void replace(final TableEntity entity)

Adds a table operation to replace the specified entity to the batch operation.

void retrieve(final String partitionKey, final String rowKey, final Class<? extends TableEntity> clazzType)

Adds a table operation to retrieve an entity of the specified class type with the specified PartitionKey and RowKey to the batch operation.

void retrieve(final String partitionKey, final String rowKey, final EntityResolver<?> resolver)

Adds a table operation to retrieve an entity of the specified class type with the specified PartitionKey and RowKey to the batch operation.

Method Details

add

public void add(final int index, final TableOperation element)

Adds the table operation at the specified index in the batch operation .

Parameters:

index - An int which represents the index in the batch operation ArrayList to add the table operation at.
element - The TableOperation to add to the batch operation.

add

public boolean add(final TableOperation element)

Adds the table operation to the batch operation .

Parameters:

element - The TableOperation to add to the batch operation.

Returns:

true if the operation was added successfully.

addAll

public boolean addAll(final int index, final java.util.Collection c)

Adds the collection of table operations to the batch operation starting at the specified index.

Parameters:

index - An int which represents the index in the batch operation ArrayList to add the table operation at.
c - A java.util.Collection of TableOperation objects to add to the batch operation.

Returns:

true if the operations were added successfully.

addAll

public boolean addAll(final java.util.Collection c)

Adds the collection of table operations to the batch operation .

Parameters:

c - A java.util.Collection of TableOperation objects to add to the batch operation.

Returns:

true if the operations were added successfully.

clear

public void clear()

Clears all table operations from the batch operation.

delete

public void delete(final TableEntity entity)

Adds a table operation to delete the specified entity to the batch operation.

Parameters:

entity - The TableEntity to delete.

execute

protected ArrayList execute(final CloudTableClient client, final String tableName, final TableRequestOptions options, final OperationContext opContext)

Reserved for internal use. Executes this batch operation on the specified table, using the specified TableRequestOptions and OperationContext.

This method will invoke the Storage Service REST API to execute this batch operation, using the Table service endpoint and storage account credentials in the CloudTableClient object.

Parameters:

client - A CloudTableClient instance specifying the Table service endpoint and storage account credentials to use.
tableName - A String containing the name of the table.
options - A TableRequestOptions object that specifies execution options such as retry policy and timeout settings for the operation.
opContext - An OperationContext object for tracking the current operation.

Returns:

An ArrayList of TableResult containing the results of executing the operation.

Throws:

StorageException - if an error occurs in the storage operation.

insert

public void insert(final TableEntity entity)

Adds a table operation to insert the specified entity to the batch operation.

Parameters:

entity - The TableEntity to insert.

insert

public void insert(final TableEntity entity, boolean echoContent)

Adds a table operation to insert the specified entity to the batch operation.

Parameters:

entity - The TableEntity to insert.
echoContent - The boolean representing whether the message payload should be returned in the response.

insertOrMerge

public void insertOrMerge(final TableEntity entity)

Adds a table operation to insert or merge the specified entity to the batch operation.

Parameters:

entity - The TableEntity to insert if not found or to merge if it exists.

insertOrReplace

public void insertOrReplace(final TableEntity entity)

Adds a table operation to insert or replace the specified entity to the batch operation.

Parameters:

entity - The TableEntity to insert if not found or to replace if it exists.

merge

public void merge(final TableEntity entity)

Adds a table operation to merge the specified entity to the batch operation.

Parameters:

entity - The TableEntity to merge.

remove

public TableOperation remove(int index)

Removes the table operation at the specified index from the batch operation.

Parameters:

index - An int which represents the index in the ArrayList of the table operation to remove from the batch operation.

remove

public boolean remove(Object o)

Removes the specified from the batch operation.

Parameters:

o - The Object to remove from the batch operation.

Returns:

true if the object was removed successfully.

removeAll

public boolean removeAll(java.util.Collection c)

Removes all elements of the specified collection from the batch operation.

Parameters:

c - The collection of elements to remove from the batch operation.

Returns:

true if the objects in the collection were removed successfully.

removeRange

protected void removeRange(int fromIndex, int toIndex)

Reserved for internal use. Removes all the table operations at indexes in the specified range from the batch operation .

Parameters:

fromIndex - An int which represents the inclusive lower bound of the range of TableOperation objects to remove from the batch operation ArrayList.
toIndex - An int which represents the exclusive upper bound of the range of TableOperation objects to remove from the batch operation ArrayList.

replace

public void replace(final TableEntity entity)

Adds a table operation to replace the specified entity to the batch operation.

Parameters:

entity - The TableEntity to replace.

retrieve

public void retrieve(final String partitionKey, final String rowKey, final Class clazzType)

Adds a table operation to retrieve an entity of the specified class type with the specified PartitionKey and RowKey to the batch operation.

Parameters:

partitionKey - A String containing the PartitionKey of the entity to retrieve.
rowKey - A String containing the RowKey of the entity to retrieve.
clazzType - The class of the TableEntity type for the entity to retrieve.

retrieve

public void retrieve(final String partitionKey, final String rowKey, final EntityResolver resolver)

Adds a table operation to retrieve an entity of the specified class type with the specified PartitionKey and RowKey to the batch operation.

Parameters:

partitionKey - A String containing the PartitionKey of the entity to retrieve.
rowKey - A String containing the RowKey of the entity to retrieve.
resolver - The EntityResolver<T> implementation to project the entity to retrieve as a particular type in the result.

Applies to