public class Binding extends Object
The class is used by IndexViewService to parse the Value part of KV pairs. It also supplies some general conversion methods for user records with different schemas. The example defines a BillInfo as its primary DB record schema which is defined in the resource file "billinfo-schema.avsc".
Constructor and Description |
---|
Binding(AvroCatalog avroCatalog) |
Modifier and Type | Method and Description |
---|---|
Schema |
getSchema(String schemaName)
Returns the Schema object for the given schema name.
|
String |
getSchemaName(Value value)
Returns the schema name of value.
|
List<Object> |
toFields(Value value,
List<String> fieldNames)
Given a list of Avro field names, extracts the field values from the
value parameter. |
GenericRecord |
toObject(Value value)
Returns the deserialized
GenericRecord instance. |
Value |
toValue(GenericRecord record)
Returns the Value that conforms to the schema of the given
GenericRecord . |
public Binding(AvroCatalog avroCatalog)
public Value toValue(GenericRecord record)
GenericRecord
.record
- public GenericRecord toObject(Value value)
GenericRecord
instance. If the given
Value is not in Avro format then null will be returned.value
- public List<Object> toFields(Value value, List<String> fieldNames)
value
parameter. null is returned if the given Value is not
valid Avro data.value
- fieldNames
- the Avro field names to extract from value. The fields
must be contained in the value's schema definition.public String getSchemaName(Value value)
value
- Copyright (c) 2011, 2015 Oracle and/or its affiliates. All rights reserved.