def to_pb(self): """Converts the row filter to a protobuf. First converts to a :class:`.data_pb2.ColumnRange` and then uses it in the ``column_range_filter`` field. :rtype: :class:`.data_pb2.RowFilter` :returns: The converted current object. """ column_range_kwargs = {'family_name': self.column_family_id} if self.start_column is not None: if self.inclusive_start: key = 'start_qualifier_inclusive' else: key = 'start_qualifier_exclusive' column_range_kwargs[key] = _to_bytes(self.start_column) if self.end_column is not None: if self.inclusive_end: key = 'end_qualifier_inclusive' else: key = 'end_qualifier_exclusive' column_range_kwargs[key] = _to_bytes(self.end_column) column_range = data_pb2.ColumnRange(**column_range_kwargs) return data_pb2.RowFilter(column_range_filter=column_range)
def test_to_pb(self): from gcloud.bigtable._generated import bigtable_data_pb2 as data_pb2 column_family_id = u'column-family-id' row_filter = self._makeOne(column_family_id) col_range_pb = data_pb2.ColumnRange(family_name=column_family_id) expected_pb = data_pb2.RowFilter(column_range_filter=col_range_pb) self.assertEqual(row_filter.to_pb(), expected_pb)
def test_to_pb_inclusive_end(self): from gcloud.bigtable._generated import bigtable_data_pb2 as data_pb2 column_family_id = u'column-family-id' column = b'column' row_filter = self._makeOne(column_family_id, end_column=column) col_range_pb = data_pb2.ColumnRange( family_name=column_family_id, end_qualifier_inclusive=column, ) expected_pb = data_pb2.RowFilter(column_range_filter=col_range_pb) self.assertEqual(row_filter.to_pb(), expected_pb)