org.apache.avro.thrift

## Class ThriftData

- java.lang.Object
- - org.apache.avro.generic.GenericData
  - - org.apache.avro.thrift.ThriftData

-     public class ThriftData
      extends GenericData

  Utilities for serializing Thrift data in Avro format.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.apache.avro.generic.GenericData

      `GenericData.Array<T>, GenericData.EnumSymbol, GenericData.Fixed, GenericData.InstanceSupplier, GenericData.Record, GenericData.StringType`

  - ### Field Summary

    - ### Fields inherited from class org.apache.avro.generic.GenericData

      `FAST_READER_PROP, STRING_PROP, STRING_TYPE_STRING`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `ThriftData()`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `DatumReader` | `createDatumReader(Schema schema)` Returns a `DatumReader` for this kind of data.
    `DatumWriter` | `createDatumWriter(Schema schema)` Returns a `DatumWriter` for this kind of data.
    `static ThriftData` | `get()` Return the singleton instance.
    `protected Schema` | `getEnumSchema(Object datum)` Called to obtain the schema of a enum.
    `Object` | `getField(Object r, String name, int pos)` Called by `GenericDatumReader.readRecord(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder)` to retrieve a record field value from a reused instance.
    `protected Object` | `getField(Object record, String name, int pos, Object state)` Version of `GenericData.getField(java.lang.Object, java.lang.String, int)` that has state.
    `protected Schema` | `getRecordSchema(Object record)` Called to obtain the schema of a record.
    `protected Object` | `getRecordState(Object r, Schema s)` Produce state for repeated calls to `GenericData.getField(Object,String,int,Object)` and `GenericData.setField(Object,String,int,Object,Object)` on the same record.
    `Schema` | `getSchema(Class c)` Return a record schema given a thrift generated class.
    `protected String` | `getSchemaName(Object datum)` Return the schema full name for a datum.
    `protected boolean` | `isBytes(Object datum)` Called by the default implementation of `GenericData.instanceOf(org.apache.avro.Schema, java.lang.Object)`.
    `protected boolean` | `isEnum(Object datum)` Called by the default implementation of `GenericData.instanceOf(org.apache.avro.Schema, java.lang.Object)`.
    `protected boolean` | `isRecord(Object datum)` Called by the default implementation of `GenericData.instanceOf(org.apache.avro.Schema, java.lang.Object)`.
    `Object` | `newRecord(Object old, Schema schema)` Called to create new record instances.
    `void` | `setField(Object r, String n, int pos, Object value)` Called by `GenericDatumReader.readRecord(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder)` to set a record fields value to a record instance.
    `protected void` | `setField(Object record, String name, int position, Object value, Object state)` Version of `GenericData.setField(java.lang.Object, java.lang.String, int, java.lang.Object)` that has state.

    - ### Methods inherited from class org.apache.avro.generic.GenericData

      `addLogicalTypeConversion, compare, compare, compareMaps, createDatumReader, createEnum, createFixed, createFixed, createString, deepCopy, getArrayAsCollection, getClassLoader, getConversionByClass, getConversionByClass, getConversionFor, getConversions, getDefaultValue, getFastReaderBuilder, getFixedSchema, getNewRecordSupplier, getPrimitiveTypeCache, hashCode, hashCodeAdd, induce, instanceOf, isArray, isBoolean, isDouble, isFastReaderEnabled, isFixed, isFloat, isInteger, isLong, isMap, isString, newArray, newMap, resolveUnion, setFastReaderEnabled, setStringType, toString, toString, validate`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ThriftData

          protected ThriftData()

  - ### Method Detail

    - #### get

          public static ThriftData get()

      Return the singleton instance.

    - #### createDatumReader

          public DatumReader createDatumReader(Schema schema)

      Description copied from class: `GenericData`
      Returns a `DatumReader` for this kind of data.
      Overrides:
        `createDatumReader` in class `GenericData`

    - #### createDatumWriter

          public DatumWriter createDatumWriter(Schema schema)

      Description copied from class: `GenericData`
      Returns a `DatumWriter` for this kind of data.
      Overrides:
        `createDatumWriter` in class `GenericData`

    - #### setField

          public void setField(Object r,
                               String n,
                               int pos,
                               Object value)

      Description copied from class: `GenericData`
      Called by `GenericDatumReader.readRecord(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder)` to set a record fields value to a record instance. The default implementation is for `IndexedRecord`.
      Overrides:
        `setField` in class `GenericData`

    - #### getField

          public Object getField(Object r,
                                 String name,
                                 int pos)

      Description copied from class: `GenericData`
      Called by `GenericDatumReader.readRecord(java.lang.Object, org.apache.avro.Schema, org.apache.avro.io.ResolvingDecoder)` to retrieve a record field value from a reused instance. The default implementation is for `IndexedRecord`.
      Overrides:
        `getField` in class `GenericData`

    - #### setField

          protected void setField(Object record,
                                  String name,
                                  int position,
                                  Object value,
                                  Object state)

      Description copied from class: `GenericData`
      Version of `GenericData.setField(java.lang.Object, java.lang.String, int, java.lang.Object)` that has state.
      Overrides:
        `setField` in class `GenericData`

    - #### getField

          protected Object getField(Object record,
                                    String name,
                                    int pos,
                                    Object state)

      Description copied from class: `GenericData`
      Version of `GenericData.getField(java.lang.Object, java.lang.String, int)` that has state.
      Overrides:
        `getField` in class `GenericData`

    - #### getRecordState

          protected Object getRecordState(Object r,
                                          Schema s)

      Description copied from class: `GenericData`
      Produce state for repeated calls to `GenericData.getField(Object,String,int,Object)` and `GenericData.setField(Object,String,int,Object,Object)` on the same record.
      Overrides:
        `getRecordState` in class `GenericData`

    - #### getSchemaName

          protected String getSchemaName(Object datum)

      Description copied from class: `GenericData`
      Return the schema full name for a datum. Called by `GenericData.resolveUnion(Schema,Object)`.
      Overrides:
        `getSchemaName` in class `GenericData`

    - #### isRecord

          protected boolean isRecord(Object datum)

      Description copied from class: `GenericData`
      Called by the default implementation of `GenericData.instanceOf(org.apache.avro.Schema, java.lang.Object)`.
      Overrides:
        `isRecord` in class `GenericData`

    - #### isEnum

          protected boolean isEnum(Object datum)

      Description copied from class: `GenericData`
      Called by the default implementation of `GenericData.instanceOf(org.apache.avro.Schema, java.lang.Object)`.
      Overrides:
        `isEnum` in class `GenericData`

    - #### getEnumSchema

          protected Schema getEnumSchema(Object datum)

      Description copied from class: `GenericData`
      Called to obtain the schema of a enum. By default calls {GenericContainer#getSchema(). May be overridden for alternate enum representations.
      Overrides:
        `getEnumSchema` in class `GenericData`

    - #### isBytes

          protected boolean isBytes(Object datum)

      Description copied from class: `GenericData`
      Called by the default implementation of `GenericData.instanceOf(org.apache.avro.Schema, java.lang.Object)`.
      Overrides:
        `isBytes` in class `GenericData`

    - #### newRecord

          public Object newRecord(Object old,
                                  Schema schema)

      Description copied from class: `GenericData`
      Called to create new record instances. Subclasses may override to use a different record implementation. The returned instance must conform to the schema provided. If the old object contains fields not present in the schema, they should either be removed from the old object, or it should create a new instance that conforms to the schema. By default, this returns a `GenericData.Record`.
      Overrides:
        `newRecord` in class `GenericData`

    - #### getRecordSchema

          protected Schema getRecordSchema(Object record)

      Description copied from class: `GenericData`
      Called to obtain the schema of a record. By default calls {GenericContainer#getSchema(). May be overridden for alternate record representations.
      Overrides:
        `getRecordSchema` in class `GenericData`

    - #### getSchema

          public Schema getSchema(Class c)

      Return a record schema given a thrift generated class.

Copyright © 2009–2024 The Apache Software Foundation. All rights reserved.