HappyBase Package#
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 package.
This package is intended to emulate the HappyBase library using Google Cloud Bigtable as the backing store.
Differences in Public API#
Some concepts from HBase/Thrift do not map directly to the Cloud Bigtable API. As a result, the following instance methods and functions could not be implemented:
Connection.enable_table()- no concept of enabled/disabledConnection.disable_table()- no concept of enabled/disabledConnection.is_table_enabled()- no concept of enabled/disabledConnection.compact_table()- table storage is opaque to userTable.regions()- tables in Cloud Bigtable do not expose internal storage detailsTable.counter_set()- method can’t be atomic, so we disable it- The
__version__value for the HappyBase package isNone. However, it’s worth nothing this implementation was based off HappyBase 0.9.
In addition, many of the constants from
connection
are specific to HBase and are defined as None in our module:
COMPAT_MODESTHRIFT_TRANSPORTSTHRIFT_PROTOCOLSDEFAULT_HOSTDEFAULT_PORTDEFAULT_TRANSPORTDEFAULT_COMPATDEFAULT_PROTOCOL
Two of these DEFAULT_HOST and DEFAULT_PORT, are even imported in
the main happybase package.
Finally, we do not provide the util module. Though it is public in the
HappyBase library, it provides no core functionality.
API Behavior Changes#
Since there is no concept of an enabled / disabled table, calling
Connection.delete_table()withdisable=Truecan’t be supported. Using that argument will result in a warning.The
Connectionconstructor disables the use of several arguments and will print a warning if any of them are passed in as keyword arguments. The arguments are:hostportcompattransportprotocol
In order to make
Connectioncompatible with Cloud Bigtable, we add ainstancekeyword argument to allow users to pass in their ownInstance(which they can construct beforehand).For example:
from gcloud.bigtable.client import Client client = Client(project=PROJECT_ID, admin=True) instance = client.instance(instance_id, location_id) instance.reload() from gcloud.bigtable.happybase import Connection connection = Connection(instance=instance)
Any uses of the
wal(Write Ahead Log) argument will result in a warning as well. This includes uses in:When calling
Connection.create_table(), the majority of HBase column family options cannot be used. Amongmax_versionscompressionin_memorybloom_filter_typebloom_filter_vector_sizebloom_filter_nb_hashesblock_cache_enabledtime_to_live
Only
max_versionsandtime_to_liveare availabe in Cloud Bigtable (asMaxVersionsGCRuleandMaxAgeGCRule).In addition to using a dictionary for specifying column family options, we also accept instances of
GarbageCollectionRuleor subclasses.Table.scan()no longer accepts the following arguments (which will result in a warning):batch_sizescan_batchingsorted_columns
Using a HBase filter string in
Table.scan()is not possible with Cloud Bigtable and will result in aTypeError. However, the method now accepts instances ofRowFilterand subclasses.Batch.delete()(and henceTable.delete()) will fail with aValueErrorwhen either a row or column family delete is attempted with atimestamp. This is because the Cloud Bigtable API uses theDeleteFromFamilyandDeleteFromRowmutations for these deletes, and neither of these mutations support a timestamp.