Skip to content
This repository was archived by the owner on Jan 27, 2018. It is now read-only.

Latest commit

 

History

History
 
 

README.md

Bigtable Samples.

Build Status Build status

These samples demonstrate how to call the Google Cloud Bigtable API using C++.

Build and Run

  1. Create a project in the Google Cloud Console. If you haven't already created a project, create one now. Projects enable you to manage all Google Cloud Platform resources for your app, including deployment, access control, billing, and services.

    1. Open the Google Cloud Console.
    2. In the drop-down menu at the top, select Create a project.
    3. Click Show advanced options. Under App Engine location, select a United States location.
    4. Give your project a name.
    5. Make a note of the project ID, which might be different from the project name. The project ID is used in commands and in configurations.
  2. Enable billing for your project. If you haven't already enabled billing for your project, enable billing now. Enabling billing allows the application to consume billable resources such as Cloud Bigtable API calls. See Google Cloud Console Help for more information about billing settings.

  3. Enable the Cloud Bigtable Admin APIs for your project. Click here to visit Google Cloud Console and enable the Bigtable Admin API.

  4. Enable the Cloud Bigtable APIs for your project. Click here to visit Google Cloud Console and enable the Bigtable Admin API.

  5. Download service account credentials. These samples use service accounts for authentication.

    1. Visit the Google Cloud Console, and navigate to: API Manager > Credentials > Create credentials > Service account key
    2. Under Service account, select New service account.
    3. Under Service account name, enter a service account name of your choosing. For example, transcriber.
    4. Under Role, select Project > Service Account Actor.
    5. Under Key type, leave JSON selected.
    6. Click Create to create a new service account, and download the json credentials file.
    7. Set the GOOGLE_APPLICATION_CREDENTIALS environment variable to point to your downloaded service account credentials:
      export GOOGLE_APPLICATION_CREDENTIALS=/path/to/your/credentials-key.json
      

    See the Cloud Platform Auth Guide for more information.

  6. Install gRPC.

    1. Visit the gRPC github repo and follow the instructions to install gRPC.
    2. Then, follow the instructions in the Pre-requisites section to install protoc.
  7. Download or close this repo with

    git clone https://github.com/GoogleCloudPlatform/cpp-docs-samples
    cd cpp-docs-samples
    git submodule update --init
  8. Generate googleapis gRPC source code.

    cd bigtable/api
    env -u LANGUAGE make -C googleapis OUTPUT=$PWD/googleapis-gens
  9. Compile the examples

    cmake .
    make -j 2
  10. Run the examples

    # This should be the name of the project you enabled billing and the APIs for.
    PROJECT=<your project here>
    
    # ... outside GCE you may need to set:
    # export GOOGLE_APPLICATION_CREDENTIALS=<path to service account private key file>
    
    ./list_instances $PROJECT
    
    ./create_instance $PROJECT bt-test-instance cluster-00 us-east1-c
    
    ./list_instances $PROJECT
    
    ./create_table $PROJECT bt-test-instance my-table
    
    ./list_tables $PROJECT bt-test-instance
    
    ./delete_table $PROJECT bt-test-instance my-table
    
    ./create_table $PROJECT bt-test-instance daily
    ./create_table $PROJECT bt-test-instance quote-per-row
    
    ./resources/download_taq.sh
    
    ./upload_taq $PROJECT bt-test-instance quote-per-row NBBO.txt
    
    ./upload_taq_batch $PROJECT bt-test-instance quote-per-row 20161024 NBBO.txt
    
    ./read_row $PROJECT bt-test-instance quote-per-row 20161024
    
    ./delete_instance $PROJECT bt-test-instance
    
    ./list_instances $PROJECT