Skip to content

Latest commit

 

History

History
227 lines (161 loc) · 4.44 KB

README_old.md

File metadata and controls

227 lines (161 loc) · 4.44 KB

Table of Contents

Using the BT Emulator

Google's bigtable emulator can be used for easy local development and testing

Installing the emulator

gcloud components update
gcloud components install beta cbt

Starting the emulator

gcloud beta emulators bigtable start & $(gcloud beta emulators bigtable env-init)
cbt createtable ride && cbt createfamily ride ride

Bigtable Operations

Read Rows

All Rows

Default Table

alias Bigtable.ReadRows

ReadRows.read()

Custom Table

alias Bigtable.ReadRows

ReadRows.read("projects/[project_id]/instances/[instance_id]/tables/[table_name]")

Single Row Key

Default Table

alias Bigtable.{ReadRows, RowSet}

RowSet.row_keys("Ride#123")
|> ReadRows.read()

Custom Table

alias Bigtable.{ReadRows, RowSet}

ReadRows.build("projects/[project_id]/instances/[instance_id]/tables/[table_name]")
|> RowSet.row_keys("Ride#123")
|> ReadRows.read()

Multiple Row Keys

Default Table

alias Bigtable.{ReadRows, RowSet}

RowSet.row_keys(["Ride#123", "Ride#124"])
|> ReadRows.read()

Custom Table

alias Bigtable.{ReadRows, RowSet}

ReadRows.build("projects/[project_id]/instances/[instance_id]/tables/[table_name]")
|> RowSet.row_keys(["Ride#123", "Ride#124"])
|> ReadRows.read()

Single Row Range

Default Table (inclusive range)

alias Bigtable.{ReadRows, RowSet}

RowSet.row_range("Ride#121", "Ride#124")
|> ReadRows.read()

Default Table (exclusive range)

alias Bigtable.{ReadRows, RowSet}

RowSet.row_range("Ride#121", "Ride#124", false)
|> ReadRows.read()

Multiple Row Ranges

Default Table (inclusive ranges)

alias Bigtable.{ReadRows, RowSet}

ranges = [
  {"Ride#121", "Ride#124"},
  {"Ride#128", "Ride#131"}
]

RowSet.row_ranges(ranges)
|> ReadRows.read()

Default Table (exclusive ranges)

alias Bigtable.{ReadRows, RowSet}

ranges = [
  {"Ride#121", "Ride#124"},
  {"Ride#128", "Ride#131"}
]

RowSet.row_ranges(ranges, false)
|> ReadRows.read()

Custom Table

alias Bigtable.{ReadRows, RowSet}

ReadRows.build("projects/[project_id]/instances/[instance_id]/tables/[table_name]")
|> RowSet.row_range("Ride#121", "Ride#124")
|> ReadRows.read()

Filtering Results

alias Bigtable.{ReadRows, RowSet}
alias ReadRows.Filter

RowSet.row_keys("Ride#123")
|> Filter.cells_per_column(5)
|> ReadRows.read()

Mutations

Single Row

SetCell

alias Bigtable.{Mutations, MutateRow}

Mutations.build("Ride#123")
|> Mutations.set_cell("ride", "foo", "bar")
|> MutateRow.mutate

DeleteFromColumn

alias Bigtable.{Mutations, MutateRow}

Mutations.build("Ride#123")
|> Mutations.delete_from_column("ride", "foo")
|> MutateRow.mutate

DeleteFromFamily

alias Bigtable.{Mutations, MutateRow}

Mutations.build("Ride#123")
|> Mutations.delete_from_family("ride")
|> MutateRow.mutate

DeleteFromRow

alias Bigtable.{Mutations, MutateRow}

Mutations.build("Ride#123")
|> Mutations.delete_from_row()
|> MutateRow.mutate