Writing Records to the Store

Creating a new record in the store and updating an existing
record are usually identical operations (although methods exist
that work only if the record is being updated, or only if it is
being created — these are described a little later in this
section). In both cases, you simply write a record to the store
that uses the appropriate key. If a record with that key does
not currently exist in the store, then the record is created for
you. If a record exists that does use the specified key, then
that record is updated with the information that you are writing
to the store.

In order to put an ordinary record into the store:

Construct a key, making sure to specify all of the key's
major and minor path components. For information on major
and minor path components, see
Record Design Considerations.

Construct a value. This is the actual data that you want
to put into the store. Normally you want to use the Avro
data format for this, which is described in
Avro Schemas
and
Avro Bindings.

Use one of the KVStore
class's put methods to put the record to the store.

The following is a trivial example of writing a record to the
store. It assumes that the KVStore handle
has already been created. For the sake of simplicity, this
example trivially serializes a string to use as the value for the
put operation. This is not what you should
do in your code. Rather, you should use the Avro data format,
even for this trivial case.