Coder Social home page Coder Social logo

solutions-spanner-sequences's Introduction

Spanner Sequence Generator example code

This repository contains example code for Sequence Generators in Google Cloud Spanner, to accompany the Sequence Generation on Google Cloud Spanner solution.

How to use this example

The example code includes performance tests of the different types of sequence generators. These tests require a Cloud Spanner database.

  1. Create a Cloud Spanner instance (if required). One node is sufficient for these tests.

  2. Create a Cloud Spanner database with the following table definition:

    CREATE TABLE sequences (
        name STRING(64) NOT NULL,
        next_value INT64 NOT NULL)
        PRIMARY KEY (name)
    )
  3. Insert the following single row into the database:

    INSERT INTO sequences (name,next_value) VALUES ('my-sequence', 0);
  4. Clone the repository from GitHub

    git clone https://github.com/GoogleCloudPlatform/solutions-spanner-sequences.git
  5. If running on a Compute Engine VM, ensure that the service account being used has access to the Cloud Spanner API and can read/write to the Cloud Spanner Database.
    If running on a development machine ensure that your Application Default Credentials are set to an account that can read/write to the Cloud Spanner database.
    See Authentication Overview in Google Cloud documentation for more information.

  6. Compile and run the performance test

    Either: compile and execute using Maven:

    mvn compile exec:java \
        -Dexec.mainClass=com.google.cloud.solutions.spanner.PerformanceTest \
        -Dexec.args="INSTANCE_NAME DATABASE_NAME MODE ITERATIONS THREADS"

    Or: build a deployable JAR containing all dependencies (for easy copying to a remote machine), and execute the JAR:

    mvn deploy
    java -jar target/sequence-generator-1.0-SNAPSHOT-jar-with-dependencies.jar \
        INSTANCE_NAME DATABASE_NAME MODE ITERATIONS THREADS

    where:

    • INSTANCE_NAME is your Cloud Spanner instance name
    • DATABASE_NAME is the name of your database
    • MODE is one of the sequence generator modes: naive, sync, async or batch. (see the solution document for the definition of these modes)
    • ITERATIONS - the number of sequence values to generate
    • THREADS - the number of simultaneous threads requesting sequence values

License

Apache Version 2.0

solutions-spanner-sequences's People

Contributors

keisukeyamashita avatar nielm avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.