Skip to content

Commit

Permalink
Use existing GetFullName function
Browse files Browse the repository at this point in the history
  • Loading branch information
serejja committed Feb 1, 2016
1 parent 2f447d1 commit 0fddac4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 26 deletions.
4 changes: 2 additions & 2 deletions datum_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func (this *SpecificDatumReader) mapEnum(field Schema, dec Decoder) (reflect.Val
return reflect.ValueOf(enumIndex), err
} else {
schema := field.(*EnumSchema)
fullName := schema.FullName()
fullName := GetFullName(schema)

if enumSymbolsToIndexCache[fullName] == nil {
enumSymbolsToIndexCacheLock.Lock()
Expand Down Expand Up @@ -472,7 +472,7 @@ func (this *GenericDatumReader) mapEnum(field Schema, dec Decoder) (*GenericEnum
return nil, err
} else {
schema := field.(*EnumSchema)
fullName := schema.FullName()
fullName := GetFullName(schema)

if enumSymbolsToIndexCache[fullName] == nil {
enumSymbolsToIndexCacheLock.Lock()
Expand Down
37 changes: 13 additions & 24 deletions schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -597,14 +597,6 @@ func (this *EnumSchema) GetName() string {
return this.Name
}

func (this *EnumSchema) FullName() string {
if this.Namespace == "" {
return this.GetName()
}

return fmt.Sprintf("%s.%s", this.Namespace, this.Name)
}

// Gets a custom non-reserved string property from this schema and a bool representing if it exists.
func (this *EnumSchema) Prop(key string) (string, bool) {
if this.Properties != nil {
Expand Down Expand Up @@ -862,32 +854,29 @@ func (this *FixedSchema) MarshalJSON() ([]byte, error) {
}

func GetFullName(schema Schema) string {
switch schema.Type() {
case Record:
switch sch := schema.(type) {
case *RecordSchema:
{
recordSchema := schema.(*RecordSchema)
if recordSchema.Namespace == "" {
return recordSchema.GetName()
if sch.Namespace == "" {
return sch.GetName()
} else {
return fmt.Sprintf("%s.%s", recordSchema.Namespace, recordSchema.GetName())
return fmt.Sprintf("%s.%s", sch.Namespace, sch.GetName())
}
}
case Enum:
case *EnumSchema:
{
enumSchema := schema.(*EnumSchema)
if enumSchema.Namespace == "" {
return enumSchema.GetName()
if sch.Namespace == "" {
return sch.GetName()
} else {
return fmt.Sprintf("%s.%s", enumSchema.Namespace, enumSchema.GetName())
return fmt.Sprintf("%s.%s", sch.Namespace, sch.GetName())
}
}
case Fixed:
case *FixedSchema:
{
fixedSchema := schema.(*FixedSchema)
if fixedSchema.Namespace == "" {
return fixedSchema.GetName()
if sch.Namespace == "" {
return sch.GetName()
} else {
return fmt.Sprintf("%s.%s", fixedSchema.Namespace, fixedSchema.GetName())
return fmt.Sprintf("%s.%s", sch.Namespace, sch.GetName())
}
}
default:
Expand Down

0 comments on commit 0fddac4

Please sign in to comment.