Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
spec
Gemfile
Gemfile.lock
README.md
hello_world.rb
instanceadmin.rb
quickstart.rb
tableadmin.rb

README.md

Google Cloud Platform logo

Cloud Bigtable: RubySamples

Open in Cloud Shell

Cloud Bigtable is Google's NoSQL Big Data database service. It's the same database that powers many core Google services, including Search, Analytics, Maps, and Gmail.

Table of Contents

Before you begin

Before running the samples, make sure you've followed the steps in the Before you begin section of the client library's README.

Samples

Quickstart

The Quick start sample shows a basic usage of the Cloud Bigtable client library: reading rows from a table.

Follow the cbt tutorial to install the cbt command line tool. Here are the cbt commands to create a table, column family and add some data:

   cbt createtable my-table
   cbt createfamily my-table cf
   cbt set my-table "row-1" cf:field1=test-value

Run the quick start to read the row you just wrote using cbt:

   bundle exec ruby quickstart.rb

Expected output similar to:

  #<Google::Cloud::Bigtable::Row:0x007fc2fbc8ba70
   @cells=
    {"cf"=>
      [#<Google::Cloud::Bigtable::Row::Cell:0x007fc2fbc2f1f8
        @family="cf",
        @labels=[],
        @qualifier="field1",
        @timestamp=1527522606344000,
        @value="test-value">
      ]}
   @key="row-1">

Hello World

View the Hello World sample to see a basic usage of the Cloud Bigtable client library.

Instance Admin

View the source code.

Open in Cloud Shell

Usage: bundle exec ruby instanceadmin.rb --help

bundle exec ruby instanceadmin.rb <command> <instance_id> <cluster_id>

COMMANDS:

  run          <instance_id> <cluster_id>   Creates an Instance(type: PRODUCTION) and run basic instance-operations
  add-cluster  <instance_id> <cluster_id>   Add Cluster
  del-cluster  <instance_id> <cluster_id>   Delete the Cluster
  del-instance <instance_id>                Delete the Instance
  dev-instance <instance_id>                Create Development Instance

Examples:
  bundle exec ruby instanceadmin.rb run <instance_id> <cluster_id>            Run instance operations
  bundle exec ruby instanceadmin.rb dev-instance <instance_id> <cluster_id>   Create Development Instance
  bundle exec ruby instanceadmin.rb del-instance <instance_id> <cluster_id>   Delete the Instance.
  bundle exec ruby instanceadmin.rb add-cluster <instance_id> <cluster_id>    Add Cluster
  bundle exec ruby instanceadmin.rb del-cluster <instance_id> <cluster_id>    Delete the Cluster

For more information, see https://cloud.google.com/bigtable/docs

Table and column family management

View the source code. This sample showcases the basic table / column family operations:

  1. Create a table (if does not exist)
  2. List tables in the current project
  3. Retrieve table metadata
  4. Create column families with supported garbage collection(GC) rules
  5. List table column families and GC rules
  6. Update a column family GC rule
  7. Delete a column family
  8. Delete a table

Open in Cloud Shell

Usage: bundle exec ruby tableadmin.rb --help

Commands:
  run    <instance_id> <table_id>   Create a table (if does not exist) and run basic table operations
  delete <instance_id> <table_id>   Delete table

Examples:
  bundle exec ruby tableadmin.rb run <instance_id> <table_id>     Create a table (if does not exist) and run basic table operations.
  bundle exec ruby tableadmin.rb delete <instance_id> <table_id>  Delete a table.

For more information, see https://cloud.google.com/bigtable/docs
You can’t perform that action at this time.