layout: docs title: Using Key-Value Storage permalink: /docs/key-value-storage/

Another method of interacting with Accumulo through Pig is through the AccumuloKVStorage class. Instead of interacting with data in terms of the rows with sparse columns as AccumuloStorage provides, AccumuloKVStorage provides more “native” key-value support as the name implies. The first N entries in a Tuple create the Accumulo Key while the final entry in the Tuple is placed into the Accumulo Value.

The same configuration options that exist for AccumuloStorage also exist for AccumuloKVStorage.

Reading

Reading data from Accumulo using the AccumuloKVStorage class is relatively simple. You will always receive a 6-Tuple in Pig which corresponds to the 5-tuple of the Accumulo Key plus the Accumulo Value. For example, the following Accumulo Key

would create the following Tuple:

All elements except the timestamp, the 5th element in the Tuple, are chararray's with the timestamp being a long.

Writing

When writing data using the AccumuloKVStorage, you can provide a Tuple which contains at least four elements. Elements one through three translate to the row, column family and column qualifier. With four elements, the fourth is the Accumulo Value. With five, the fourth element is the column visibility and the fifth is the Accumulo Value, and with six elements, fourth is the column visibility, fifth is the timestamp and the sixth is the Accumulo Value. For Tuples greater than six elements in size, the extra elements are ignored.

A 4-Tuple

translates to

A 5-Tuple

translates to

And a 6-Tuple

translates to

Overall, this provides a much lower-level support that may be of use in specific applications which already have data stored in Accumulo tables. An end-to-end example can provide some basic insight to what is currently possible.