Skip to content

Commit

Permalink
chore: use more verbose paths in hello snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-sanche committed Nov 25, 2024
1 parent 7ea3c23 commit fcc93f3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
12 changes: 4 additions & 8 deletions samples/hello/async_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@

# [START bigtable_async_hw_imports]
from google.cloud import bigtable
from google.cloud.bigtable.data import row_filters
from google.cloud.bigtable.data import RowMutationEntry
from google.cloud.bigtable.data import SetCell
from google.cloud.bigtable.data import ReadRowsQuery
# [END bigtable_async_hw_imports]


Expand Down Expand Up @@ -85,8 +81,8 @@ async def main(project_id, instance_id, table_id):
#
# https://cloud.google.com/bigtable/docs/schema-design
row_key = "greeting{}".format(i).encode()
row_mutation = RowMutationEntry(
row_key, SetCell(column_family_id, column, value)
row_mutation = bigtable.data.RowMutationEntry(
row_key, bigtable.data.SetCell(column_family_id, column, value)
)
mutations.append(row_mutation)
await table.bulk_mutate_rows(mutations)
Expand All @@ -95,7 +91,7 @@ async def main(project_id, instance_id, table_id):
# [START bigtable_async_hw_create_filter]
# Create a filter to only retrieve the most recent version of the cell
# for each column across entire row.
row_filter = row_filters.CellsColumnLimitFilter(1)
row_filter = bigtable.data.row_filters.CellsColumnLimitFilter(1)
# [END bigtable_async_hw_create_filter]

# [START bigtable_async_hw_get_with_filter]
Expand All @@ -112,7 +108,7 @@ async def main(project_id, instance_id, table_id):
# [START bigtable_async_hw_scan_with_filter]
# [START bigtable_async_hw_scan_all]
print("Scanning for all greetings:")
query = ReadRowsQuery(row_filter=row_filter)
query = bigtable.data.ReadRowsQuery(row_filter=row_filter)
async for row in await table.read_rows_stream(query):
cell = row.cells[0]
print(cell.value.decode("utf-8"))
Expand Down
6 changes: 2 additions & 4 deletions samples/hello/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
import datetime

from google.cloud import bigtable
from google.cloud.bigtable import column_family
from google.cloud.bigtable import row_filters

# [END bigtable_hw_imports]

Expand All @@ -52,7 +50,7 @@ def main(project_id, instance_id, table_id):
print("Creating column family cf1 with Max Version GC rule...")
# Create a column family with GC policy : most recent N versions
# Define the GC policy to retain only the most recent 2 versions
max_versions_rule = column_family.MaxVersionsGCRule(2)
max_versions_rule = bigtable.column_family.MaxVersionsGCRule(2)
column_family_id = "cf1"
column_families = {column_family_id: max_versions_rule}
if not table.exists():
Expand Down Expand Up @@ -93,7 +91,7 @@ def main(project_id, instance_id, table_id):
# [START bigtable_hw_create_filter]
# Create a filter to only retrieve the most recent version of the cell
# for each column across entire row.
row_filter = row_filters.CellsColumnLimitFilter(1)
row_filter = bigtable.row_filters.CellsColumnLimitFilter(1)
# [END bigtable_hw_create_filter]

# [START bigtable_hw_get_with_filter]
Expand Down

0 comments on commit fcc93f3

Please sign in to comment.