Top Inners Fields Constructors Methods
org.apache.avro

public Class LogicalTypes

extends Object
Class Inheritance
Imports
java.util.Collections, .Map, .Objects, .ServiceLoader, java.util.concurrent.ConcurrentHashMap, org.slf4j.Logger, .LoggerFactory

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
LogicalTypes.Date

Date represents a date without a time

public static class
LogicalTypes.Decimal

Decimal represents arbitrary-precision fixed-scale decimal numbers

public static class
public static class
public static interface
LogicalTypes.LogicalTypeFactory

Factory interface and SPI for logical types.

public static class
LogicalTypes.TimeMicros

TimeMicros represents a time in microseconds without a date

public static class
LogicalTypes.TimeMillis

TimeMillis represents a time in milliseconds without a date

public static class
LogicalTypes.TimestampMicros

TimestampMicros represents a date and time in microseconds

public static class
LogicalTypes.TimestampMillis

TimestampMillis represents a date and time in milliseconds

Field Summary

Modifier and TypeField and Description
private static final String
private static final LogicalTypes.Date
private static final String
private static final String
private static final LogicalTypes.LocalTimestampMicros
private static final String
private static final LogicalTypes.LocalTimestampMillis
private static final Logger
private static final Map<String, LogicalTypes.LogicalTypeFactory>
private static final String
private static final LogicalTypes.TimeMicros
private static final String
private static final LogicalTypes.TimeMillis
private static final String
private static final LogicalTypes.TimestampMicros
private static final String
private static final LogicalTypes.TimestampMillis
private static final String
private static final LogicalType

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static LogicalTypes.Date
date()

public static LogicalTypes.Decimal
decimal(int precision)

Create a Decimal LogicalType with the given precision and scale 0

public static LogicalTypes.Decimal
decimal(int precision, int scale)

Create a Decimal LogicalType with the given precision and scale

public static LogicalType
fromSchema(Schema schema)

Returns the LogicalType from the schema, if one is present.

public static LogicalType
private static LogicalType
fromSchemaImpl(Schema schema, boolean throwErrors)

public static Map<String, LogicalTypes.LogicalTypeFactory>
getCustomRegisteredTypes()

Return an unmodifiable map of any registered custom LogicalType

public static LogicalTypes.LocalTimestampMicros
public static LogicalTypes.LocalTimestampMillis
public static void
register(LogicalTypes.LogicalTypeFactory
The logical type factory
factory
)

Register a logical type.

public static void
register(String
The logical type name
logicalTypeName
,
LogicalTypes.LogicalTypeFactory
The logical type factory
factory
)

Register a logical type.

public static LogicalTypes.TimeMicros
public static LogicalTypes.TimeMillis
public static LogicalTypes.TimestampMicros
public static LogicalTypes.TimestampMillis
public static LogicalType
uuid()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DATEback to summary
private static final String DATE
DATE_TYPEback to summary
private static final LogicalTypes.Date DATE_TYPE
DECIMALback to summary
private static final String DECIMAL
LOCAL_TIMESTAMP_MICROSback to summary
private static final String LOCAL_TIMESTAMP_MICROS
LOCAL_TIMESTAMP_MICROS_TYPEback to summary
private static final LogicalTypes.LocalTimestampMicros LOCAL_TIMESTAMP_MICROS_TYPE
LOCAL_TIMESTAMP_MILLISback to summary
private static final String LOCAL_TIMESTAMP_MILLIS
LOCAL_TIMESTAMP_MILLIS_TYPEback to summary
private static final LogicalTypes.LocalTimestampMillis LOCAL_TIMESTAMP_MILLIS_TYPE
LOGback to summary
private static final Logger LOG
REGISTERED_TYPESback to summary
private static final Map<String, LogicalTypes.LogicalTypeFactory> REGISTERED_TYPES
TIME_MICROSback to summary
private static final String TIME_MICROS
TIME_MICROS_TYPEback to summary
private static final LogicalTypes.TimeMicros TIME_MICROS_TYPE
TIME_MILLISback to summary
private static final String TIME_MILLIS
TIME_MILLIS_TYPEback to summary
private static final LogicalTypes.TimeMillis TIME_MILLIS_TYPE
TIMESTAMP_MICROSback to summary
private static final String TIMESTAMP_MICROS
TIMESTAMP_MICROS_TYPEback to summary
private static final LogicalTypes.TimestampMicros TIMESTAMP_MICROS_TYPE
TIMESTAMP_MILLISback to summary
private static final String TIMESTAMP_MILLIS
TIMESTAMP_MILLIS_TYPEback to summary
private static final LogicalTypes.TimestampMillis TIMESTAMP_MILLIS_TYPE
UUIDback to summary
private static final String UUID
UUID_TYPEback to summary
private static final LogicalType UUID_TYPE

Constructor Detail

LogicalTypesback to summary
public LogicalTypes()

Method Detail

dateback to summary
public static LogicalTypes.Date date()
decimalback to summary
public static LogicalTypes.Decimal decimal(int precision)

Create a Decimal LogicalType with the given precision and scale 0

decimalback to summary
public static LogicalTypes.Decimal decimal(int precision, int scale)

Create a Decimal LogicalType with the given precision and scale

fromSchemaback to summary
public static LogicalType fromSchema(Schema schema)

Returns the LogicalType from the schema, if one is present.

fromSchemaIgnoreInvalidback to summary
public static LogicalType fromSchemaIgnoreInvalid(Schema schema)
fromSchemaImplback to summary
private static LogicalType fromSchemaImpl(Schema schema, boolean throwErrors)
getCustomRegisteredTypesback to summary
public static Map<String, LogicalTypes.LogicalTypeFactory> getCustomRegisteredTypes()

Return an unmodifiable map of any registered custom LogicalType

localTimestampMicrosback to summary
public static LogicalTypes.LocalTimestampMicros localTimestampMicros()
localTimestampMillisback to summary
public static LogicalTypes.LocalTimestampMillis localTimestampMillis()
registerback to summary
public static void register(LogicalTypes.LogicalTypeFactory factory)

Register a logical type.

Parameters
factory:LogicalTypes.LogicalTypeFactory

The logical type factory

Exceptions
NullPointerException:
if factory or factory.getTypedName() is null
registerback to summary
public static void register(String logicalTypeName, LogicalTypes.LogicalTypeFactory factory)

Register a logical type.

Parameters
logicalTypeName:String

The logical type name

factory:LogicalTypes.LogicalTypeFactory

The logical type factory

Exceptions
NullPointerException:
if logicalTypeName or factory is null
timeMicrosback to summary
public static LogicalTypes.TimeMicros timeMicros()
timeMillisback to summary
public static LogicalTypes.TimeMillis timeMillis()
timestampMicrosback to summary
public static LogicalTypes.TimestampMicros timestampMicros()
timestampMillisback to summary
public static LogicalTypes.TimestampMillis timestampMillis()
uuidback to summary
public static LogicalType uuid()
org.apache.avro back to summary

public Class LogicalTypes.Date

extends LogicalType
Class Inheritance

Date represents a date without a time

Field Summary

Inherited from org.apache.avro.LogicalType:
LOGICAL_TYPE_PROP

Constructor Summary

AccessConstructor and Description
private
Date()

Method Summary

Modifier and TypeMethod and Description
public void
validate(Schema
a Schema
schema
)

Overrides org.apache.avro.LogicalType.validate.

Validate this logical type for the given Schema.
Inherited from org.apache.avro.LogicalType:
addToSchemagetName

Constructor Detail

Dateback to summary
private Date()

Method Detail

validateback to summary
public void validate(Schema schema)

Overrides org.apache.avro.LogicalType.validate.

Doc from org.apache.avro.LogicalType.validate.

Validate this logical type for the given Schema.

This will throw an exception if the Schema is incompatible with this type. For example, a date is stored as an int and is incompatible with a fixed Schema.

Parameters
schema:Schema

a Schema

Annotations
@Override
org.apache.avro back to summary

public Class LogicalTypes.Decimal

extends LogicalType
Class Inheritance

Decimal represents arbitrary-precision fixed-scale decimal numbers

Field Summary

Modifier and TypeField and Description
private final int
private static final String
private final int
private static final String
Inherited from org.apache.avro.LogicalType:
LOGICAL_TYPE_PROP

Constructor Summary

AccessConstructor and Description
private
Decimal(int precision, int scale)

private
Decimal(Schema schema)

Method Summary

Modifier and TypeMethod and Description
public Schema
addToSchema(Schema
a Schema
schema
)

Overrides org.apache.avro.LogicalType.addToSchema.

Add this logical type to the given Schema.
public boolean
equals(Object
the reference object with which to compare.
o
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
private int
getInt(Schema schema, String name)

public int
public int
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
private boolean
hasProperty(Schema schema, String name)

private long
public void
validate(Schema
a Schema
schema
)

Overrides org.apache.avro.LogicalType.validate.

Validate this logical type for the given Schema.
Inherited from org.apache.avro.LogicalType:
getName

Field Detail

precisionback to summary
private final int precision
PRECISION_PROPback to summary
private static final String PRECISION_PROP
scaleback to summary
private final int scale
SCALE_PROPback to summary
private static final String SCALE_PROP

Constructor Detail

Decimalback to summary
private Decimal(int precision, int scale)
Decimalback to summary
private Decimal(Schema schema)

Method Detail

addToSchemaback to summary
public Schema addToSchema(Schema schema)

Overrides org.apache.avro.LogicalType.addToSchema.

Doc from org.apache.avro.LogicalType.addToSchema.

Add this logical type to the given Schema.

The "logicalType" property will be set to this type's name, and other type-specific properties may be added. The Schema is first validated to ensure it is compatible.

Parameters
schema:Schema

a Schema

Returns:Schema

the modified Schema

Annotations
@Override
equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
getIntback to summary
private int getInt(Schema schema, String name)
getPrecisionback to summary
public int getPrecision()
getScaleback to summary
public int getScale()
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
hasPropertyback to summary
private boolean hasProperty(Schema schema, String name)
maxPrecisionback to summary
private long maxPrecision(Schema schema)
validateback to summary
public void validate(Schema schema)

Overrides org.apache.avro.LogicalType.validate.

Doc from org.apache.avro.LogicalType.validate.

Validate this logical type for the given Schema.

This will throw an exception if the Schema is incompatible with this type. For example, a date is stored as an int and is incompatible with a fixed Schema.

Parameters
schema:Schema

a Schema

Annotations
@Override
org.apache.avro back to summary

public Class LogicalTypes.LocalTimestampMicros

extends LogicalType
Class Inheritance

Field Summary

Inherited from org.apache.avro.LogicalType:
LOGICAL_TYPE_PROP

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
validate(Schema
a Schema
schema
)

Overrides org.apache.avro.LogicalType.validate.

Validate this logical type for the given Schema.
Inherited from org.apache.avro.LogicalType:
addToSchemagetName

Constructor Detail

LocalTimestampMicrosback to summary
private LocalTimestampMicros()

Method Detail

validateback to summary
public void validate(Schema schema)

Overrides org.apache.avro.LogicalType.validate.

Doc from org.apache.avro.LogicalType.validate.

Validate this logical type for the given Schema.

This will throw an exception if the Schema is incompatible with this type. For example, a date is stored as an int and is incompatible with a fixed Schema.

Parameters
schema:Schema

a Schema

Annotations
@Override
org.apache.avro back to summary

public Class LogicalTypes.LocalTimestampMillis

extends LogicalType
Class Inheritance

Field Summary

Inherited from org.apache.avro.LogicalType:
LOGICAL_TYPE_PROP

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
validate(Schema
a Schema
schema
)

Overrides org.apache.avro.LogicalType.validate.

Validate this logical type for the given Schema.
Inherited from org.apache.avro.LogicalType:
addToSchemagetName

Constructor Detail

LocalTimestampMillisback to summary
private LocalTimestampMillis()

Method Detail

validateback to summary
public void validate(Schema schema)

Overrides org.apache.avro.LogicalType.validate.

Doc from org.apache.avro.LogicalType.validate.

Validate this logical type for the given Schema.

This will throw an exception if the Schema is incompatible with this type. For example, a date is stored as an int and is incompatible with a fixed Schema.

Parameters
schema:Schema

a Schema

Annotations
@Override
org.apache.avro back to summary

public Interface LogicalTypes.LogicalTypeFactory


Factory interface and SPI for logical types. A LogicalTypeFactory can be registered in two ways:
  1. Manually, via register(LogicalTypeFactory) or register(String, LogicalTypeFactory)
  2. Automatically, when the LogicalTypeFactory implementation is a public class with a public no-arg constructor, is named in a file called /META-INF/services/org.apache.avro.LogicalTypes$LogicalTypeFactory, and both are available in the classpath
See Also
ServiceLoader

Method Summary

Modifier and TypeMethod and Description
public LogicalType
public default String

Method Detail

fromSchemaback to summary
public LogicalType fromSchema(Schema schema)
getTypeNameback to summary
public default String getTypeName()
org.apache.avro back to summary

public Class LogicalTypes.TimeMicros

extends LogicalType
Class Inheritance

TimeMicros represents a time in microseconds without a date

Field Summary

Inherited from org.apache.avro.LogicalType:
LOGICAL_TYPE_PROP

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
validate(Schema
a Schema
schema
)

Overrides org.apache.avro.LogicalType.validate.

Validate this logical type for the given Schema.
Inherited from org.apache.avro.LogicalType:
addToSchemagetName

Constructor Detail

TimeMicrosback to summary
private TimeMicros()

Method Detail

validateback to summary
public void validate(Schema schema)

Overrides org.apache.avro.LogicalType.validate.

Doc from org.apache.avro.LogicalType.validate.

Validate this logical type for the given Schema.

This will throw an exception if the Schema is incompatible with this type. For example, a date is stored as an int and is incompatible with a fixed Schema.

Parameters
schema:Schema

a Schema

Annotations
@Override
org.apache.avro back to summary

public Class LogicalTypes.TimeMillis

extends LogicalType
Class Inheritance

TimeMillis represents a time in milliseconds without a date

Field Summary

Inherited from org.apache.avro.LogicalType:
LOGICAL_TYPE_PROP

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
validate(Schema
a Schema
schema
)

Overrides org.apache.avro.LogicalType.validate.

Validate this logical type for the given Schema.
Inherited from org.apache.avro.LogicalType:
addToSchemagetName

Constructor Detail

TimeMillisback to summary
private TimeMillis()

Method Detail

validateback to summary
public void validate(Schema schema)

Overrides org.apache.avro.LogicalType.validate.

Doc from org.apache.avro.LogicalType.validate.

Validate this logical type for the given Schema.

This will throw an exception if the Schema is incompatible with this type. For example, a date is stored as an int and is incompatible with a fixed Schema.

Parameters
schema:Schema

a Schema

Annotations
@Override
org.apache.avro back to summary

public Class LogicalTypes.TimestampMicros

extends LogicalType
Class Inheritance

TimestampMicros represents a date and time in microseconds

Field Summary

Inherited from org.apache.avro.LogicalType:
LOGICAL_TYPE_PROP

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
validate(Schema
a Schema
schema
)

Overrides org.apache.avro.LogicalType.validate.

Validate this logical type for the given Schema.
Inherited from org.apache.avro.LogicalType:
addToSchemagetName

Constructor Detail

TimestampMicrosback to summary
private TimestampMicros()

Method Detail

validateback to summary
public void validate(Schema schema)

Overrides org.apache.avro.LogicalType.validate.

Doc from org.apache.avro.LogicalType.validate.

Validate this logical type for the given Schema.

This will throw an exception if the Schema is incompatible with this type. For example, a date is stored as an int and is incompatible with a fixed Schema.

Parameters
schema:Schema

a Schema

Annotations
@Override
org.apache.avro back to summary

public Class LogicalTypes.TimestampMillis

extends LogicalType
Class Inheritance

TimestampMillis represents a date and time in milliseconds

Field Summary

Inherited from org.apache.avro.LogicalType:
LOGICAL_TYPE_PROP

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
validate(Schema
a Schema
schema
)

Overrides org.apache.avro.LogicalType.validate.

Validate this logical type for the given Schema.
Inherited from org.apache.avro.LogicalType:
addToSchemagetName

Constructor Detail

TimestampMillisback to summary
private TimestampMillis()

Method Detail

validateback to summary
public void validate(Schema schema)

Overrides org.apache.avro.LogicalType.validate.

Doc from org.apache.avro.LogicalType.validate.

Validate this logical type for the given Schema.

This will throw an exception if the Schema is incompatible with this type. For example, a date is stored as an int and is incompatible with a fixed Schema.

Parameters
schema:Schema

a Schema

Annotations
@Override