Giter Site home page Giter Site logo

pig-dynamodb's Introduction

pig-dynamodb

An Apache Pig storage function for DynamoDB, by Mortar Data.

Build Status

Features

  • Automatic write throttling: Writes are automatically throttled and balanced across Hadoop tasks to match your DynamoDB table's write throughput.
  • Automatic schema conversion: Whatever you pass to the storage function gets converted and stored.
  • Retries, retries, retries: Automatic retries and logging when DynamoDB write limits are hit.

Building

Use maven to build the package:

mvn clean package

...and then upload the JAR in the target directory to S3, where you can register it from your pigscripts.

Storing Data to DynamoDB

For full instructions, see Storing Data into DynamoDB on the Mortar help site.

Here's a quick sample of how it works:

-- register the jar
REGISTER 's3://my-bucket/my-folder/pig-dynamodb-0.2-SNAPSHOT.jar'

-- Percentage of the table's write throughput to use
SET dynamodb.throughput.write.percent 1.0;

-- Disable Pig's MultiQuery optimization when using DynamoDBStorage
SET opt.multiquery false;

-- Load up some input data
input_data = LOAD '$INPUT_PATH'
    USING PigStorage()
    AS (...);

-- Select exactly the fields you want to store to dynamodb.
-- MUST include your DynamoDB table's primary key.
exact_fields_to_store = FOREACH input_data
    GENERATE my_field AS name_in_dynamodb_1,
             my_field_2 AS name_in_dynamodb_2,
             my_field_3 AS name_in_dynamodb_3;

-- Store the data to DynamoDB
STORE exact_fields_to_store
 INTO 's3://ignored-output-bucket/ignored'
USING com.mortardata.pig.storage.DynamoDBStorage(
	'my_dynamo_db_table', 
	'my_aws_access_key_id', 
	'my_aws_secret_access_key');

Options

  • dynamodb.throughput.write.percent: Percentage of total write throughput on the table to use for this STORE. Range: [0.1 - 1.5]. Default: 0.5.
  • dynamodb.retry.max_per_batch_write: Number of times to retry a failed write (due to throttling) before throwing an Exception. Default: 100.
  • dynamodb.retry.wait.max: Maximum time, in milliseconds, to wait (during exponential backoff) between retries on a failed write. Default: 120000.

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.