Oracle NoSQL Database
version 11gR2.2.0.26

oracle.kv.avro
Interface AvroBinding<T>

Type Parameters:
T - is the type of the deserialized object that is passed to toValue and returned by toObject. The specific type depends on the particular binding that is used. It may be an Avro-generated specific class that implements SpecificRecord, a GenericRecord, a JsonRecord, or a RawRecord.
All Superinterfaces:
ValueBinding<T>
All Known Subinterfaces:
GenericAvroBinding, JsonAvroBinding, RawAvroBinding, SpecificAvroBinding<T>

public interface AvroBinding<T>
extends ValueBinding<T>

The AvroBinding interface has the same methods as ValueBinding, but adds semantics and exceptions that are specific to the Avro data format.

All AvroBinding subtypes -- SpecificAvroBinding, GenericAvroBinding, JsonAvroBinding and RawAvroBinding -- operate on the built-in Avro data format. The serialized data used and produced by the binding -- the byte array of the Value -- is serialized Avro data, packaged in an internal format that includes a reference to the Avro schema. The toValue method of each Avro binding returns this serialized format, and the toObject method is passed this serialized format.

See AvroCatalog for a comparison of the different types of Avro bindings and the trade-offs in using them.

Since:
2.0

Method Summary
 T toObject(Value value)
          After doing a read operation using a KVStore method, the user calls toObject with the Value obtained from the read operation.
 Value toValue(T object)
          Before doing a write operation, the user calls toValue passing an object she wishes to store.
 

Method Detail

toObject

T toObject(Value value)
           throws SchemaNotAllowedException,
                  IllegalArgumentException
After doing a read operation using a KVStore method, the user calls toObject with the Value obtained from the read operation.

Specified by:
toObject in interface ValueBinding<T>
Parameters:
value - the Value obtained from a KVStore read operation method.. The byte array of the Value is serialized Avro data, packaged in an internal format that includes a reference to the Avro schema
Returns:
the deserialized object.
Throws:
SchemaNotAllowedException - if the schema associated with the value parameter is not allowed with this binding.
IllegalArgumentException - if the value format is not Value.Format.AVRO, the schema identifier embedded in the value parameter is invalid, or the serialized data cannot be parsed.

toValue

Value toValue(T object)
              throws SchemaNotAllowedException,
                     UndefinedSchemaException,
                     IllegalArgumentException
Before doing a write operation, the user calls toValue passing an object she wishes to store. The resulting Value is then passed to the write operation method in KVStore.

Specified by:
toValue in interface ValueBinding<T>
Parameters:
object - the object the user wishes to store, or at least serialize.
Returns:
the serialized object.. The byte array of the Value is serialized Avro data, packaged in an internal format that includes a reference to the Avro schema
Throws:
SchemaNotAllowedException - if the schema associated with the object parameter is not allowed with this binding.
UndefinedSchemaException - if the schema associated with the object parameter has not been defined using the NoSQL Database administration interface. Note that when the allowed schemas for a binding are specified (and validate) at the time the binding is created, this exception is extremely unlikely and is only possible if a schema is mistakenly disabled after the binding is created.
IllegalArgumentException - if the object parameter is invalid according to its schema, and cannot be serialized.

Oracle NoSQL Database
version 11gR2.2.0.26

Copyright (c) 2011, 2013 Oracle and/or its affiliates. All rights reserved.