|
16 | 16 |
|
17 | 17 | This package is intended to emulate the HappyBase library using |
18 | 18 | Google Cloud Bigtable as the backing store. |
| 19 | +
|
| 20 | +Differences in Public API |
| 21 | +------------------------- |
| 22 | +
|
| 23 | +Some concepts from HBase/Thrift do not map directly to the Cloud |
| 24 | +Bigtable API. As a result, the following instance methods and functions |
| 25 | +could not be implemented: |
| 26 | +
|
| 27 | +* :meth:`.Connection.enable_table` - no concept of enabled/disabled |
| 28 | +* :meth:`.Connection.disable_table` - no concept of enabled/disabled |
| 29 | +* :meth:`.Connection.is_table_enabled` - no concept of enabled/disabled |
| 30 | +* :meth:`.Connection.compact_table` - table storage is opaque to user |
| 31 | +* :func:`make_row() <gcloud.bigtable.happybase.table.make_row>` - helper |
| 32 | + needed for Thrift library |
| 33 | +* :func:`make_ordered_row() <gcloud.bigtable.happybase.table.make_ordered_row>` |
| 34 | + - helper needed for Thrift library |
| 35 | +* :meth:`Table.regions() <gcloud.bigtable.happybase.table.Table.regions>` |
| 36 | + - tables in Cloud Bigtable do not expose internal storage details |
| 37 | +* :meth:`Table.counter_set() \ |
| 38 | + <gcloud.bigtable.happybase.table.Table.counter_set>` - method can't |
| 39 | + be atomic, so we disable it |
| 40 | +* The ``__version__`` value for the HappyBase package is :data:`None`. |
| 41 | + However, it's worth nothing this implementation was based off HappyBase |
| 42 | + 0.9. |
| 43 | +
|
| 44 | +In addition, many of the constants from :mod:`.connection` are specific |
| 45 | +to HBase and are defined as :data:`None` in our module: |
| 46 | +
|
| 47 | +* ``COMPAT_MODES`` |
| 48 | +* ``THRIFT_TRANSPORTS`` |
| 49 | +* ``THRIFT_PROTOCOLS`` |
| 50 | +* ``DEFAULT_HOST`` |
| 51 | +* ``DEFAULT_PORT`` |
| 52 | +* ``DEFAULT_TRANSPORT`` |
| 53 | +* ``DEFAULT_COMPAT`` |
| 54 | +* ``DEFAULT_PROTOCOL`` |
| 55 | +
|
| 56 | +Two of these ``DEFAULT_HOST`` and ``DEFAULT_PORT``, are even imported in |
| 57 | +the main :mod:`happybase <gcloud.bigtable.happybase>` package. |
| 58 | +
|
| 59 | +Finally, we do not provide the ``util`` module. Though it is public in the |
| 60 | +HappyBase library, it provides no core functionality. |
| 61 | +
|
| 62 | +API Behavior Changes |
| 63 | +-------------------- |
| 64 | +
|
| 65 | +* Since there is no concept of an enabled / disabled table, calling |
| 66 | + :meth:`.Connection.delete_table` with ``disable=True`` can't be supported. |
| 67 | + Using that argument will result in a warning. |
| 68 | +* The :class:`.Connection` constructor **disables** the use of several |
| 69 | + arguments and will print a warning if any of them are passed in as keyword |
| 70 | + arguments. The arguments are: |
| 71 | +
|
| 72 | + * ``host`` |
| 73 | + * ``port`` |
| 74 | + * ``compat`` |
| 75 | + * ``transport`` |
| 76 | + * ``protocol`` |
| 77 | +* In order to make :class:`.Connection` compatible with Cloud Bigtable, we |
| 78 | + add a ``cluster`` keyword argument to allow user's to pass in their own |
| 79 | + :class:`.Cluster` (which they can construct beforehand). |
| 80 | +
|
| 81 | + For example: |
| 82 | +
|
| 83 | + .. code:: python |
| 84 | +
|
| 85 | + from gcloud.bigtable.client import Client |
| 86 | + client = Client(project=PROJECT_ID, admin=True) |
| 87 | + cluster = client.cluster(zone, cluster_id) |
| 88 | + cluster.reload() |
| 89 | +
|
| 90 | + from gcloud.bigtable.happybase import Connection |
| 91 | + connection = Connection(cluster=cluster) |
| 92 | +
|
| 93 | +* Any uses of the ``wal`` (Write Ahead Log) argument will result in a |
| 94 | + warning as well. This includes uses in: |
| 95 | +
|
| 96 | + * :class:`.Batch` constructor |
| 97 | + * :meth:`.Batch.put` |
| 98 | + * :meth:`.Batch.delete` |
| 99 | + * :meth:`Table.put() <gcloud.bigtable.happybase.table.Table.put>` |
| 100 | + * :meth:`Table.delete() <gcloud.bigtable.happybase.table.Table.delete>` |
| 101 | + * :meth:`Table.batch() <gcloud.bigtable.happybase.table.Table.batch>` factory |
| 102 | +* When calling :meth:`.Connection.create_table`, the majority of HBase column |
| 103 | + family options cannot be used. Among |
| 104 | +
|
| 105 | + * ``max_versions`` |
| 106 | + * ``compression`` |
| 107 | + * ``in_memory`` |
| 108 | + * ``bloom_filter_type`` |
| 109 | + * ``bloom_filter_vector_size`` |
| 110 | + * ``bloom_filter_nb_hashes`` |
| 111 | + * ``block_cache_enabled`` |
| 112 | + * ``time_to_live`` |
| 113 | +
|
| 114 | + Only ``max_versions`` and ``time_to_live`` are availabe in Cloud Bigtable |
| 115 | + (as |
| 116 | + :class:`MaxVersionsGCRule <gcloud.bigtable.column_family.MaxVersionsGCRule>` |
| 117 | + and |
| 118 | + `MaxAgeGCRule <gcloud.bigtable.column_family.MaxAgeGCRule>`). |
| 119 | +
|
| 120 | + In addition to using a dictionary for specifying column family options, |
| 121 | + we also accept instances of :class:`.GarbageCollectionRule` or subclasses. |
| 122 | +* :meth:`Table.scan() <gcloud.bigtable.happybase.table.Table.scan>` no longer |
| 123 | + accepts the following arguments (which will result in a warning): |
| 124 | +
|
| 125 | + * ``batch_size`` |
| 126 | + * ``scan_batching`` |
| 127 | + * ``sorted_columns`` |
| 128 | +
|
| 129 | +* Using a HBase filter string in |
| 130 | + :meth:`Table.scan() <gcloud.bigtable.happybase.table.Table.scan>` is |
| 131 | + not possible with Cloud Bigtable and will result in a |
| 132 | + :class:`TypeError <exceptions.TypeError>`. However, the method now accepts |
| 133 | + instances of :class:`.RowFilter` and subclasses. |
| 134 | +* :meth:`.Batch.delete` (and hence |
| 135 | + :meth:`Table.delete() <gcloud.bigtable.happybase.table.Table.delete>`) |
| 136 | + will fail with a :class:`ValueError <exceptions.ValueError>` when either a |
| 137 | + row or column family delete is attempted with a ``timestamp``. This is |
| 138 | + because the Cloud Bigtable API uses the ``DeleteFromFamily`` and |
| 139 | + ``DeleteFromRow`` mutations for these deletes, and neither of these |
| 140 | + mutations support a timestamp. |
19 | 141 | """ |
| 142 | + |
| 143 | +from gcloud.bigtable.happybase.batch import Batch |
| 144 | +from gcloud.bigtable.happybase.connection import Connection |
| 145 | +from gcloud.bigtable.happybase.connection import DEFAULT_HOST |
| 146 | +from gcloud.bigtable.happybase.connection import DEFAULT_PORT |
| 147 | +from gcloud.bigtable.happybase.pool import ConnectionPool |
| 148 | +from gcloud.bigtable.happybase.pool import NoConnectionsAvailable |
| 149 | +from gcloud.bigtable.happybase.table import Table |
| 150 | + |
| 151 | + |
| 152 | +# Values from HappyBase that we don't reproduce / are not relevant. |
| 153 | +__version__ = None |
0 commit comments