Documentation ¶
Index ¶
Examples ¶
Constants ¶
View Source
const ( // CompressionNull - The "null" codec simply passes through data uncompressed. CompressionNull = "null" // CompressionDeflate - The "deflate" codec writes the data block using the deflate algorithm as specified in RFC 1951, // and typically implemented using the zlib library. // Note that this format (unlike the "zlib format" in RFC 1950) does not have a checksum. CompressionDeflate = "deflate" // CompressionSnappy - The "snappy" codec uses Google's Snappy compression library. // Each compressed block is followed by the 4-byte, big-endian CRC32 checksum of the uncompressed data in the block. CompressionSnappy = "snappy" )
Variables ¶
View Source
var ( // ErrUnsupportedType - Avro doesn't support the given type ErrUnsupportedType = errors.New("ErrUnsupportedType - AVRO doesn't support the given type") // ErrInvalidSchema - Avro doesn't support the given type ErrInvalidSchema = errors.New("ErrInvalidSchema - Given schema is not AVRO") // ErrUnsupportedCompression - avro doesn't supprot this compression ErrUnsupportedCompression = errors.New("ErrUnsupportedCompression") )
Functions ¶
This section is empty.
Types ¶
type AnySchema ¶
type AnySchema struct {
// contains filtered or unexported fields
}
AnySchema -
func (*AnySchema) UnmarshalJSON ¶
UnmarshalJSON -
type ArraySchema ¶
ArraySchema -
type DerivedPrimitiveSchema ¶
type DerivedPrimitiveSchema struct { Type Type `json:"type"` Documentation string `json:"doc,omitempty"` LogicalType LogicalType `json:"logicalType"` Precision *int `json:"precision,omitempty"` Scale *int `json:"scale,omitempty"` }
DerivedPrimitiveSchema -
func (*DerivedPrimitiveSchema) TypeName ¶
func (t *DerivedPrimitiveSchema) TypeName() Type
TypeName -
type EnumSchema ¶
type EnumSchema struct { Type Type `json:"type"` Name string `json:"name"` Namespace string `json:"namespace,omitempty"` Aliases []string `json:"aliases,omitempty"` Documentation string `json:"doc,omitempty"` Symbols []string `json:"symbols"` }
EnumSchema -
type FixedSchema ¶
type FixedSchema struct { Type Type `json:"type"` LogicalType LogicalType `json:"logicalType,omitempty"` Name string `json:"name"` Namespace string `json:"namespace,omitempty"` Aliases []string `json:"aliases,omitempty"` Documentation string `json:"doc,omitempty"` Size int `json:"size"` }
FixedSchema -
type LogicalType ¶
type LogicalType Type
LogicalType decorates primitive and complex types to represent a derived type
const ( // LogicalTypeDecimal - LogicalTypeDecimal LogicalType = "decimal" // LogicalTypeDate - LogicalTypeDate LogicalType = "date" // LogicalTypeTime - LogicalTypeTime LogicalType = "time" // LogicalTypeTimestamp - LogicalTypeTimestamp LogicalType = "timestamp" // LogialTypeDuration - LogialTypeDuration LogicalType = "duration" )
type Order ¶
type Order string
Order - specifies how this field impacts sort ordering of this record (optional). Valid values are "ascending" (the default), "descending", or "ignore".
type RecordFieldSchema ¶
type RecordFieldSchema struct { Name string `json:"name"` Aliases []string `json:"aliases,omitempty"` Documentation string `json:"doc,omitempty"` Type Schema `json:"type"` Default *json.RawMessage `json:"default,omitempty"` Order Order `json:"order,omitempty"` }
RecordFieldSchema -
type RecordSchema ¶
type RecordSchema struct { Type Type `json:"type"` Namespace string `json:"namespace,omitempty"` Name string `json:"name"` Aliases []string `json:"aliases,omitempty"` Documentation string `json:"doc,omitempty"` Fields []RecordFieldSchema `json:"fields"` }
RecordSchema has fields
type Schema ¶
type Schema interface {
TypeName() Type
}
Schema -
Example ¶
package main import ( "encoding/json" "fmt" "github.com/khezen/avro" ) func main() { schemaBytes := []byte( `{ "type": "record", "namespace": "test", "name": "LongList", "aliases": [ "LinkedLongs" ], "doc": "linked list of 64 bits integers", "fields": [ { "name": "value", "type": "long" }, { "name": "next", "type": [ "null", "LongList" ] } ] }`, ) // Unmarshal JSON bytes to Schema interface var anySchema avro.AnySchema err := json.Unmarshal(schemaBytes, &anySchema) if err != nil { panic(err) } schema := anySchema.Schema() // Marshal Schema interface to JSON bytes schemaBytes, err = json.Marshal(schema) if err != nil { panic(err) } fmt.Println(string(schemaBytes)) }
Output:
type Type ¶
type Type string
Type - primitive or derived type name as defined below
const ( // TypeNull - TypeNull Type = "null" // TypeBoolean - TypeBoolean Type = "boolean" // TypeInt32 - TypeInt32 Type = "int" // TypeInt64 - TypeInt64 Type = "long" // TypeFloat32 - TypeFloat32 Type = "float" // TypeFloat64 - TypeFloat64 Type = "double" // TypeBytes - TypeBytes Type = "bytes" // TypeString - TypeString Type = "string" // TypeUnion - TypeUnion Type = "union" // TypeRecord - TypeRecord Type = "record" // TypeArray - TypeArray Type = "array" // TypeMap - TypeMap Type = "map" // TypeEnum - TypeEnum Type = "enum" // TypeFixed - TypeFixed Type = "fixed" )
type UnionSchema ¶
type UnionSchema []Schema
UnionSchema - A JSON array, representing a union of embedded types.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.