Code Monkey home page Code Monkey logo

amazon-keyspaces-compression-example's Introduction

Amazon Keyspaces (for Apache Cassandra) Snappy compression demo.

This Repository contains the source-code for the blog post Compress and Conquer with Amazon Keyspaces.

Prerequisites

JDK 1.7.0u71 or better
Maven 3.3.9 or better
Snappy for java 1.1.7.3 or better
DataStax java driver 4.9.0 or better
Authentication Plugin for the DataStax Java Driver 4.0.3 or better
json-simple 1.1.1 or better

If you want to build everything at once, from the top directory run

````mvn install````

Let's first create one keyspace and two tables

    CREATE KEYSPACE compression WITH replication = {'class':
    'com.amazonaws.cassandra.DefaultReplication'} AND durable_writes = true;
    CREATE TABLE table_with_compressed_json (
    id timeuuid PRIMARY KEY,
    data blob)
    CREATE TABLE table_with_uncompressed_json (
    id timeuuid PRIMARY KEY,
    data blob

Configure the performance test in resources/config.properties

    contactPoint=cassandra.us-east-1.amazonaws.com
    port=9124
    input_jsons=/path/to/json
    output_partitions_compressed=/path/to/compressed_data/partition_keys
    output_partitions_uncompressed=/path/to/uncompressed_data/partition_keys

Run write performance test

    java -cp SnappyKeyspaces-1.0-SNAPSHOT-jar-with-dependencies.jar PerformanceTestWriteRunner

Run read performance test

    java -cp SnappyKeyspaces-1.0-SNAPSHOT-jar-with-dependencies.jar PerformanceTestReadRunner

Reading data stored in BLOB columns

To help you access and read data stored in a BLOB column by using the console (https://docs.aws.amazon.com/keyspaces/latest/devguide/console_keyspaces.html) or cqlsh (https://docs.aws.amazon.com/keyspaces/latest/devguide/programmatic.cqlsh.html), I’ve created a helper wrapper cqlsh-experimental.sh

  1. Clone Amazon Keyspaces (for Apache Cassandra) developer toolkit
    git clone https://github.com/aws-samples/amazon-keyspaces-toolkit.git
  1. Modify the Dockerfile
    #Install jq
    RUN yum install -y jq && \
        yum install -y python-pip && \
        yum install -y gcc-c++ && \
        yum install -y snappy-devel && \
        yum install -y python-devel && \
        pip install --no-cache-dir --user python-snappy && \
        yum clean all
        
        .....
        
    #toolkit helpers
    COPY bin/ $AWS_KEYSPACES_WORKING_DIR/bin/
    RUN chmod +x $AWS_KEYSPACES_WORKING_DIR/bin/cqlsh-experimental.sh    
  1. Copy cqlsh-experimental.sh under /bin folder

  2. Build your Docker Image

    docker build --tag amazon/keyspaces-toolkit --build-arg CLI_VERSION=latest .

  1. Run cqlsh from the amazon/keyspaces-toolkit image
   docker run --rm -ti --entrypoint cqlsh-experimental.sh \
   amazon/keyspaces-toolkit cassandra.us-east-1.amazonaws.com 9142 \
   -u "USERNAME" -p "PASSWORD" -d snappy --ssl

Enjoy! Feedback and PR's welcome!

License

This library is licensed under the MIT-0 License. See the LICENSE file.

amazon-keyspaces-compression-example's People

Contributors

dependabot[bot] avatar nwheeler81 avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

jamierobert

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.