HappyBase Batch#
Warning
gRPC is required for using the Cloud Bigtable API. As of May 2016,
grpcio is only supported in Python 2.7, so importing
gcloud.bigtable in other versions of Python will fail.
Google Cloud Bigtable HappyBase batch module.
-
class
gcloud.bigtable.happybase.batch.Batch(table, timestamp=None, batch_size=None, transaction=False, wal=<object object>)[source]# Bases:
objectBatch class for accumulating mutations.
Note
When using a batch with
transaction=Falseas a context manager (i.e. in awithstatement), mutations will still be sent as row mutations even if the context manager exits with an error. This behavior is in place to match the behavior in the HappyBase HBase / Thrift implementation.Parameters: - table (
Table) – The table where mutations will be applied. - timestamp (int) – (Optional) Timestamp (in milliseconds since the epoch) that all mutations will be applied at.
- batch_size (int) – (Optional) The maximum number of mutations to allow to accumulate before committing them.
- transaction (bool) – Flag indicating if the mutations should be sent
transactionally or not. If
transaction=Trueand an error occurs while aBatchis active, then none of the accumulated mutations will be committed. Ifbatch_sizeis set, the mutation can’t be transactional. - wal (object) – Unused parameter (Boolean for using the HBase Write Ahead Log). Provided for compatibility with HappyBase, but irrelevant for Cloud Bigtable since it does not have a Write Ahead Log.
Raises: TypeErrorifbatch_sizeis set andtransaction=True.ValueErrorifbatch_sizeis not positive.-
delete(row, columns=None, wal=<object object>)[source]# Delete data from a row in the table owned by this batch.
Parameters: - row (str) – The row key where the delete will occur.
- columns (list) –
(Optional) Iterable containing column names (as strings). Each column name can be either
- an entire column family:
famorfam: - a single column:
fam:col
If not used, will delete the entire row.
- an entire column family:
- wal (object) – Unused parameter (to over-ride the default on the instance). Provided for compatibility with HappyBase, but irrelevant for Cloud Bigtable since it does not have a Write Ahead Log.
Raises: If the delete timestamp range is set on the current batch, but a full row delete is attempted.
-
put(row, data, wal=<object object>)[source]# Insert data into a row in the table owned by this batch.
Parameters: - row (str) – The row key where the mutation will be “put”.
- data (dict) – Dictionary containing the data to be inserted. The keys
are columns names (of the form
fam:col) and the values are strings (bytes) to be stored in those columns. - wal (object) – Unused parameter (to over-ride the default on the instance). Provided for compatibility with HappyBase, but irrelevant for Cloud Bigtable since it does not have a Write Ahead Log.
- table (